Skip to content

Commit 49ab61e

Browse files
authored
Merge pull request #99 from laminas/renovate/vimeo-psalm-5.x
Update dependency vimeo/psalm to v5, improved type inference around `HydratingIteratorInterface`
2 parents 035e6d2 + 02b2516 commit 49ab61e

File tree

8 files changed

+91
-116
lines changed

8 files changed

+91
-116
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"phpbench/phpbench": "^1.2.7",
4545
"phpunit/phpunit": "^9.5.26",
4646
"psalm/plugin-phpunit": "^0.18.0",
47-
"vimeo/psalm": "^4.29"
47+
"vimeo/psalm": "^5.0"
4848
},
4949
"suggest": {
5050
"laminas/laminas-eventmanager": "^3.2, to support aggregate hydrator usage",

composer.lock

Lines changed: 29 additions & 84 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

psalm-baseline.xml

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<files psalm-version="4.29.0@7ec5ffbd5f68ae03782d7fd33fff0c45a69f95b3">
2+
<files psalm-version="5.0.0@4e177bf0c9f03c17d2fbfd83b7cc9c47605274d8">
33
<file src="src/Aggregate/AggregateHydrator.php">
44
<DocblockTypeContradiction occurrences="1">
55
<code>null === $this-&gt;eventManager</code>
@@ -39,7 +39,8 @@
3939
<MixedInferredReturnType occurrences="1">
4040
<code>array</code>
4141
</MixedInferredReturnType>
42-
<MixedReturnStatement occurrences="1">
42+
<MixedReturnStatement occurrences="2">
43+
<code>$data</code>
4344
<code>$data</code>
4445
</MixedReturnStatement>
4546
</file>
@@ -112,12 +113,9 @@
112113
</MixedArgument>
113114
</file>
114115
<file src="src/Iterator/HydratingIteratorIterator.php">
115-
<MixedArgument occurrences="1">
116-
<code>$currentValue</code>
117-
</MixedArgument>
118-
<MixedAssignment occurrences="1">
119-
<code>$currentValue</code>
120-
</MixedAssignment>
116+
<InvalidArgument occurrences="1">
117+
<code>$data</code>
118+
</InvalidArgument>
121119
<MixedMethodCall occurrences="1">
122120
<code>new $prototype()</code>
123121
</MixedMethodCall>
@@ -198,6 +196,9 @@
198196
<code>$value</code>
199197
<code>$value</code>
200198
</MixedAssignment>
199+
<UnsupportedReferenceUsage occurrences="1">
200+
<code>$properties = &amp;self::$skippedPropertiesCache[$object::class]</code>
201+
</UnsupportedReferenceUsage>
201202
</file>
202203
<file src="src/Reflection.php">
203204
<DeprecatedClass occurrences="1">
@@ -232,18 +233,11 @@
232233
<MixedReturnStatement occurrences="1">
233234
<code>$this-&gt;enumClass::from($value)</code>
234235
</MixedReturnStatement>
235-
<PropertyNotSetInConstructor occurrences="1">
236-
<code>$enumClass</code>
237-
</PropertyNotSetInConstructor>
238-
<UndefinedClass occurrences="1">
236+
<UndefinedClass occurrences="3">
239237
<code>$this-&gt;enumClass</code>
240-
</UndefinedClass>
241-
<UndefinedDocblockClass occurrences="4">
242238
<code>$value-&gt;value</code>
243-
<code>T</code>
244-
<code>class-string&lt;T&gt;</code>
245239
<code>string</code>
246-
</UndefinedDocblockClass>
240+
</UndefinedClass>
247241
</file>
248242
<file src="src/Strategy/BooleanStrategy.php">
249243
<DocblockTypeContradiction occurrences="4">
@@ -386,6 +380,10 @@
386380
</MixedAssignment>
387381
</file>
388382
<file src="test/HydratorAwareTraitTest.php">
383+
<InvalidArgument occurrences="2">
384+
<code>HydratorAwareTrait::class</code>
385+
<code>HydratorAwareTrait::class</code>
386+
</InvalidArgument>
389387
<MixedMethodCall occurrences="6">
390388
<code>getHydrator</code>
391389
<code>getHydrator</code>
@@ -436,6 +434,9 @@
436434
<code>$property</code>
437435
</MissingClosureParamType>
438436
</file>
437+
<file src="test/HydratorPluginManagerFactoryTest.php">
438+
<InvalidArgument occurrences="1"/>
439+
</file>
439440
<file src="test/HydratorStrategyTest.php">
440441
<MixedArgument occurrences="2">
441442
<code>$attributes['entities']</code>
@@ -475,6 +476,16 @@
475476
<code>$property</code>
476477
</MixedArgument>
477478
</file>
479+
<file src="test/Iterator/HydratingArrayIteratorTest.php">
480+
<ArgumentTypeCoercion occurrences="1">
481+
<code>'not a real class'</code>
482+
</ArgumentTypeCoercion>
483+
</file>
484+
<file src="test/Iterator/HydratingIteratorIteratorTest.php">
485+
<ArgumentTypeCoercion occurrences="1">
486+
<code>'not a real class'</code>
487+
</ArgumentTypeCoercion>
488+
</file>
478489
<file src="test/NamingStrategy/UnderscoreNamingStrategy/CamelCaseToUnderscoreFilterTest.php">
479490
<InternalClass occurrences="3">
480491
<code>new CamelCaseToUnderscoreFilter()</code>
@@ -584,13 +595,11 @@
584595
</UndefinedClass>
585596
</file>
586597
<file src="test/Strategy/BooleanStrategyTest.php">
587-
<InvalidArgument occurrences="1">
588-
<code>false</code>
589-
</InvalidArgument>
590-
<InvalidScalarArgument occurrences="2">
598+
<InvalidArgument occurrences="3">
591599
<code>5</code>
600+
<code>false</code>
592601
<code>true</code>
593-
</InvalidScalarArgument>
602+
</InvalidArgument>
594603
</file>
595604
<file src="test/Strategy/CollectionStrategyTest.php">
596605
<MissingClosureParamType occurrences="1">

src/HydratorPluginManagerFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function __invoke(ContainerInterface $container, string $name, ?array $op
4545
));
4646
}
4747

48-
$pluginManager = new HydratorPluginManager($container, $options ?: []);
48+
$pluginManager = new HydratorPluginManager($container, $options ?? []);
4949

5050
// If this is in a laminas-mvc application, the ServiceListener will inject
5151
// merged configuration during bootstrap.

src/Iterator/HydratingArrayIterator.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,18 @@
77
use ArrayIterator;
88
use Laminas\Hydrator\HydratorInterface;
99

10+
/**
11+
* @template TKey of array-key
12+
* @template TPrototype of object
13+
* @template TInputData of array
14+
* @template TIterator of ArrayIterator<TKey, TInputData>
15+
* @template-extends HydratingIteratorIterator<TKey, TPrototype, TInputData, TIterator>
16+
*/
1017
class HydratingArrayIterator extends HydratingIteratorIterator
1118
{
1219
/**
13-
* @param mixed[] $data Data being used to hydrate the $prototype
14-
* @param string|object $prototype Object, or class name to use for prototype.
20+
* @param array<TKey, TInputData> $data Data being used to hydrate the $prototype
21+
* @param class-string<TPrototype>|TPrototype $prototype
1522
*/
1623
public function __construct(HydratorInterface $hydrator, array $data, $prototype)
1724
{

src/Iterator/HydratingIteratorInterface.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
use Iterator;
88
use Laminas\Hydrator\HydratorInterface;
99

10+
/**
11+
* @template TKey
12+
* @template TPrototype of object
13+
* @template-extends Iterator<TKey, TPrototype>
14+
*/
1015
interface HydratingIteratorInterface extends Iterator
1116
{
1217
/**
@@ -15,7 +20,7 @@ interface HydratingIteratorInterface extends Iterator
1520
* This prototype can be the name of the class or the object itself;
1621
* iteration will clone the object.
1722
*
18-
* @param string|object $prototype
23+
* @param class-string<TPrototype>|TPrototype $prototype
1924
*/
2025
public function setPrototype($prototype): void;
2126

0 commit comments

Comments
 (0)