Skip to content

Commit

Permalink
Applying type improvements brought in by newer psalm version
Browse files Browse the repository at this point in the history
  • Loading branch information
Ocramius committed Jul 7, 2022
1 parent b1fecc0 commit 1d38f00
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 25 deletions.
30 changes: 9 additions & 21 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="4.9.3@4c262932602b9bbab5020863d1eb22d49de0dbf4">
<files psalm-version="4.24.0@06dd975cb55d36af80f242561738f16c5f58264f">
<file src="src/AbstractOptions.php">
<DocblockTypeContradiction occurrences="1">
<code>! is_array($options) &amp;&amp; ! $options instanceof Traversable</code>
Expand Down Expand Up @@ -61,35 +61,17 @@
</RedundantConditionGivenDocblockType>
</file>
<file src="src/ArrayUtils.php">
<DocblockTypeContradiction occurrences="1">
<code>! is_array($iterator) &amp;&amp; ! $iterator instanceof Traversable</code>
</DocblockTypeContradiction>
<MixedArgumentTypeCoercion occurrences="1">
<code>$callback</code>
</MixedArgumentTypeCoercion>
<MixedArrayOffset occurrences="4">
<code>$array[$key]</code>
<code>$array[$key]</code>
<code>$array[$key]</code>
<code>$array[$key]</code>
</MixedArrayOffset>
<MixedAssignment occurrences="9">
<MixedAssignment occurrences="6">
<code>$a[$key]</code>
<code>$a[$key]</code>
<code>$a[$key]</code>
<code>$a[]</code>
<code>$array[$key]</code>
<code>$h</code>
<code>$key</code>
<code>$value</code>
<code>$value</code>
</MixedAssignment>
<MixedInferredReturnType occurrences="1">
<code>array</code>
</MixedInferredReturnType>
<MixedReturnStatement occurrences="1">
<code>$iterator-&gt;toArray()</code>
</MixedReturnStatement>
</file>
<file src="src/ErrorHandler.php">
<InvalidArgument occurrences="1">
Expand Down Expand Up @@ -174,7 +156,7 @@
</file>
<file src="src/Message.php">
<DocblockTypeContradiction occurrences="2">
<code>! is_array($spec) &amp;&amp; ! $spec instanceof Traversable</code>
<code>gettype($spec)</code>
<code>is_scalar($key)</code>
</DocblockTypeContradiction>
<MixedArrayOffset occurrences="1">
Expand All @@ -192,6 +174,9 @@
<ParamNameMismatch occurrences="1">
<code>$value</code>
</ParamNameMismatch>
<RedundantConditionGivenDocblockType occurrences="1">
<code>is_object($spec)</code>
</RedundantConditionGivenDocblockType>
</file>
<file src="src/MessageInterface.php">
<MissingReturnType occurrences="1">
Expand Down Expand Up @@ -568,6 +553,9 @@
</MixedAssignment>
</file>
<file src="test/SplStackTest.php">
<InvalidDocblock occurrences="1">
<code>assertSame</code>
</InvalidDocblock>
<MixedArgument occurrences="2">
<code>$unserialized</code>
<code>$unserialized</code>
Expand Down
2 changes: 1 addition & 1 deletion psalm.xml.dist
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<psalm
totallyTyped="true"
errorLevel="1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
Expand Down
2 changes: 1 addition & 1 deletion src/StringWrapper/AbstractStringWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ public function strPad($input, $padLength, $padString = ' ', $padType = STR_PAD_
$repeatCount = (int) floor($lengthOfPadding / $padStringLength);

if ($padType === STR_PAD_BOTH) {
$repeatCountLeft = $repeatCountRight = (int) ($repeatCount - $repeatCount % 2) / 2;
$repeatCountLeft = $repeatCountRight = ($repeatCount - $repeatCount % 2) / 2;

$lastStringLength = $lengthOfPadding - 2 * $repeatCountLeft * $padStringLength;
$lastStringLeftLength = $lastStringRightLength = (int) floor($lastStringLength / 2);
Expand Down
6 changes: 4 additions & 2 deletions test/SplQueueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@

class SplQueueTest extends TestCase
{
/** @var SplQueue */
/** @var SplQueue<int, non-empty-string> */
protected $queue;

protected function setUp(): void
{
$this->queue = new SplQueue();
/** @var SplQueue<int, non-empty-string> $splQueue */
$splQueue = new SplQueue();
$this->queue = $splQueue;
$this->queue->push('foo');
$this->queue->push('bar');
$this->queue->push('baz');
Expand Down

0 comments on commit 1d38f00

Please sign in to comment.