Skip to content

Commit

Permalink
Merge pull request #99 from laminas/renovate/vimeo-psalm-5.x
Browse files Browse the repository at this point in the history
Update dependency vimeo/psalm to v5, improved type inference around `HydratingIteratorInterface`
  • Loading branch information
Ocramius committed Dec 3, 2022
2 parents 035e6d2 + 02b2516 commit 49ab61e
Show file tree
Hide file tree
Showing 8 changed files with 91 additions and 116 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"phpbench/phpbench": "^1.2.7",
"phpunit/phpunit": "^9.5.26",
"psalm/plugin-phpunit": "^0.18.0",
"vimeo/psalm": "^4.29"
"vimeo/psalm": "^5.0"
},
"suggest": {
"laminas/laminas-eventmanager": "^3.2, to support aggregate hydrator usage",
Expand Down
113 changes: 29 additions & 84 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 31 additions & 22 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.29.0@7ec5ffbd5f68ae03782d7fd33fff0c45a69f95b3">
<files psalm-version="5.0.0@4e177bf0c9f03c17d2fbfd83b7cc9c47605274d8">
<file src="src/Aggregate/AggregateHydrator.php">
<DocblockTypeContradiction occurrences="1">
<code>null === $this-&gt;eventManager</code>
Expand Down Expand Up @@ -39,7 +39,8 @@
<MixedInferredReturnType occurrences="1">
<code>array</code>
</MixedInferredReturnType>
<MixedReturnStatement occurrences="1">
<MixedReturnStatement occurrences="2">
<code>$data</code>
<code>$data</code>
</MixedReturnStatement>
</file>
Expand Down Expand Up @@ -112,12 +113,9 @@
</MixedArgument>
</file>
<file src="src/Iterator/HydratingIteratorIterator.php">
<MixedArgument occurrences="1">
<code>$currentValue</code>
</MixedArgument>
<MixedAssignment occurrences="1">
<code>$currentValue</code>
</MixedAssignment>
<InvalidArgument occurrences="1">
<code>$data</code>
</InvalidArgument>
<MixedMethodCall occurrences="1">
<code>new $prototype()</code>
</MixedMethodCall>
Expand Down Expand Up @@ -198,6 +196,9 @@
<code>$value</code>
<code>$value</code>
</MixedAssignment>
<UnsupportedReferenceUsage occurrences="1">
<code>$properties = &amp;self::$skippedPropertiesCache[$object::class]</code>
</UnsupportedReferenceUsage>
</file>
<file src="src/Reflection.php">
<DeprecatedClass occurrences="1">
Expand Down Expand Up @@ -232,18 +233,11 @@
<MixedReturnStatement occurrences="1">
<code>$this-&gt;enumClass::from($value)</code>
</MixedReturnStatement>
<PropertyNotSetInConstructor occurrences="1">
<code>$enumClass</code>
</PropertyNotSetInConstructor>
<UndefinedClass occurrences="1">
<UndefinedClass occurrences="3">
<code>$this-&gt;enumClass</code>
</UndefinedClass>
<UndefinedDocblockClass occurrences="4">
<code>$value-&gt;value</code>
<code>T</code>
<code>class-string&lt;T&gt;</code>
<code>string</code>
</UndefinedDocblockClass>
</UndefinedClass>
</file>
<file src="src/Strategy/BooleanStrategy.php">
<DocblockTypeContradiction occurrences="4">
Expand Down Expand Up @@ -386,6 +380,10 @@
</MixedAssignment>
</file>
<file src="test/HydratorAwareTraitTest.php">
<InvalidArgument occurrences="2">
<code>HydratorAwareTrait::class</code>
<code>HydratorAwareTrait::class</code>
</InvalidArgument>
<MixedMethodCall occurrences="6">
<code>getHydrator</code>
<code>getHydrator</code>
Expand Down Expand Up @@ -436,6 +434,9 @@
<code>$property</code>
</MissingClosureParamType>
</file>
<file src="test/HydratorPluginManagerFactoryTest.php">
<InvalidArgument occurrences="1"/>
</file>
<file src="test/HydratorStrategyTest.php">
<MixedArgument occurrences="2">
<code>$attributes['entities']</code>
Expand Down Expand Up @@ -475,6 +476,16 @@
<code>$property</code>
</MixedArgument>
</file>
<file src="test/Iterator/HydratingArrayIteratorTest.php">
<ArgumentTypeCoercion occurrences="1">
<code>'not a real class'</code>
</ArgumentTypeCoercion>
</file>
<file src="test/Iterator/HydratingIteratorIteratorTest.php">
<ArgumentTypeCoercion occurrences="1">
<code>'not a real class'</code>
</ArgumentTypeCoercion>
</file>
<file src="test/NamingStrategy/UnderscoreNamingStrategy/CamelCaseToUnderscoreFilterTest.php">
<InternalClass occurrences="3">
<code>new CamelCaseToUnderscoreFilter()</code>
Expand Down Expand Up @@ -584,13 +595,11 @@
</UndefinedClass>
</file>
<file src="test/Strategy/BooleanStrategyTest.php">
<InvalidArgument occurrences="1">
<code>false</code>
</InvalidArgument>
<InvalidScalarArgument occurrences="2">
<InvalidArgument occurrences="3">
<code>5</code>
<code>false</code>
<code>true</code>
</InvalidScalarArgument>
</InvalidArgument>
</file>
<file src="test/Strategy/CollectionStrategyTest.php">
<MissingClosureParamType occurrences="1">
Expand Down
2 changes: 1 addition & 1 deletion src/HydratorPluginManagerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function __invoke(ContainerInterface $container, string $name, ?array $op
));
}

$pluginManager = new HydratorPluginManager($container, $options ?: []);
$pluginManager = new HydratorPluginManager($container, $options ?? []);

// If this is in a laminas-mvc application, the ServiceListener will inject
// merged configuration during bootstrap.
Expand Down
11 changes: 9 additions & 2 deletions src/Iterator/HydratingArrayIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,18 @@
use ArrayIterator;
use Laminas\Hydrator\HydratorInterface;

/**
* @template TKey of array-key
* @template TPrototype of object
* @template TInputData of array
* @template TIterator of ArrayIterator<TKey, TInputData>
* @template-extends HydratingIteratorIterator<TKey, TPrototype, TInputData, TIterator>
*/
class HydratingArrayIterator extends HydratingIteratorIterator
{
/**
* @param mixed[] $data Data being used to hydrate the $prototype
* @param string|object $prototype Object, or class name to use for prototype.
* @param array<TKey, TInputData> $data Data being used to hydrate the $prototype
* @param class-string<TPrototype>|TPrototype $prototype
*/
public function __construct(HydratorInterface $hydrator, array $data, $prototype)
{
Expand Down
7 changes: 6 additions & 1 deletion src/Iterator/HydratingIteratorInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
use Iterator;
use Laminas\Hydrator\HydratorInterface;

/**
* @template TKey
* @template TPrototype of object
* @template-extends Iterator<TKey, TPrototype>
*/
interface HydratingIteratorInterface extends Iterator
{
/**
Expand All @@ -15,7 +20,7 @@ interface HydratingIteratorInterface extends Iterator
* This prototype can be the name of the class or the object itself;
* iteration will clone the object.
*
* @param string|object $prototype
* @param class-string<TPrototype>|TPrototype $prototype
*/
public function setPrototype($prototype): void;

Expand Down
Loading

0 comments on commit 49ab61e

Please sign in to comment.