Skip to content

Commit

Permalink
Merge pull request #199 from laminas/renovate/vimeo-psalm-5.x
Browse files Browse the repository at this point in the history
Update dependency vimeo/psalm to v5
  • Loading branch information
Ocramius authored Dec 5, 2022
2 parents fc7b09f + dc79345 commit 976dfc8
Show file tree
Hide file tree
Showing 9 changed files with 278 additions and 210 deletions.
26 changes: 13 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,23 @@
"require-dev": {
"ext-intl": "*",
"doctrine/annotations": "^1.13.3",
"laminas/laminas-captcha": "^2.13",
"laminas/laminas-captcha": "^2.15",
"laminas/laminas-coding-standard": "^2.4",
"laminas/laminas-db": "^2.15",
"laminas/laminas-db": "^2.16",
"laminas/laminas-escaper": "^2.12",
"laminas/laminas-eventmanager": "^3.6",
"laminas/laminas-filter": "^2.23",
"laminas/laminas-i18n": "^2.19",
"laminas/laminas-eventmanager": "^3.8",
"laminas/laminas-filter": "^2.29",
"laminas/laminas-i18n": "^2.21",
"laminas/laminas-modulemanager": "^2.14.0",
"laminas/laminas-recaptcha": "^3.4.0",
"laminas/laminas-servicemanager": "^3.19",
"laminas/laminas-session": "^2.13",
"laminas/laminas-recaptcha": "^3.5",
"laminas/laminas-servicemanager": "^3.20",
"laminas/laminas-session": "^2.16",
"laminas/laminas-text": "^2.9.0",
"laminas/laminas-validator": "^2.26",
"laminas/laminas-view": "^2.24",
"phpunit/phpunit": "^9.5.25",
"psalm/plugin-phpunit": "^0.18.0",
"vimeo/psalm": "^4.29"
"laminas/laminas-validator": "^2.28",
"laminas/laminas-view": "^2.25",
"phpunit/phpunit": "^9.5.26",
"psalm/plugin-phpunit": "^0.18.4",
"vimeo/psalm": "^5.1"
},
"suggest": {
"doctrine/annotations": "^1.12, required to use laminas-form annotations support",
Expand Down
314 changes: 161 additions & 153 deletions composer.lock

Large diffs are not rendered by default.

99 changes: 61 additions & 38 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.30.0@d0bc6e25d89f649e4f36a534f330f8bb4643dd69">
<files psalm-version="5.1.0@4defa177c89397c5e14737a80fe4896584130674">
<file src="src/Annotation/AbstractBuilder.php">
<DocblockTypeContradiction occurrences="1">
<code>! is_string($entity)</code>
Expand Down Expand Up @@ -56,7 +56,23 @@
</DeprecatedClass>
</file>
<file src="src/Element.php">
<LessSpecificReturnStatement occurrences="8">
<LessSpecificReturnStatement occurrences="24">
<code>$this</code>
<code>$this</code>
<code>$this</code>
<code>$this</code>
<code>$this</code>
<code>$this</code>
<code>$this</code>
<code>$this</code>
<code>$this</code>
<code>$this</code>
<code>$this</code>
<code>$this</code>
<code>$this</code>
<code>$this</code>
<code>$this</code>
<code>$this</code>
<code>$this</code>
<code>$this</code>
<code>$this</code>
Expand Down Expand Up @@ -121,6 +137,9 @@
<DocblockTypeContradiction occurrences="1">
<code>gettype($spec)</code>
</DocblockTypeContradiction>
<InvalidArgument occurrences="1">
<code>$spec</code>
</InvalidArgument>
<LessSpecificReturnStatement occurrences="2">
<code>$this-&gt;create($spec)</code>
<code>$this-&gt;create($spec)</code>
Expand All @@ -142,7 +161,11 @@
<code>gettype($elementOrFieldset)</code>
<code>is_object($object)</code>
</DocblockTypeContradiction>
<LessSpecificReturnStatement occurrences="2">
<LessSpecificReturnStatement occurrences="6">
<code>$this</code>
<code>$this</code>
<code>$this</code>
<code>$this</code>
<code>$this</code>
<code>$this</code>
</LessSpecificReturnStatement>
Expand All @@ -155,25 +178,39 @@
<RedundantConditionGivenDocblockType occurrences="1">
<code>is_object($elementOrFieldset)</code>
</RedundantConditionGivenDocblockType>
<TooManyArguments occurrences="1">
<code>bindValues</code>
</TooManyArguments>
</file>
<file src="src/FieldsetInterface.php">
<MissingTemplateParam occurrences="1">
<code>IteratorAggregate</code>
</MissingTemplateParam>
</file>
<file src="src/Form.php">
<ArgumentTypeCoercion occurrences="2">
<code>$childFieldset</code>
<code>$filter</code>
</ArgumentTypeCoercion>
<LessSpecificReturnStatement occurrences="3">
<InvalidArgument occurrences="1">
<code>$spec</code>
</InvalidArgument>
<InvalidArrayOffset occurrences="1">
<code>$values[$cKey]</code>
</InvalidArrayOffset>
<LessSpecificReturnStatement occurrences="6">
<code>$this</code>
<code>$this</code>
<code>$this</code>
<code>$this</code>
<code>$this</code>
<code>$this</code>
</LessSpecificReturnStatement>
<NoValue occurrences="1">
<code>$cKey</code>
</NoValue>
<PossiblyInvalidArgument occurrences="4">
<code>$collectionInputFilter-&gt;get($name)</code>
<code>$input</code>
<code>$inputFilter</code>
<code>$spec</code>
<code>$inputFilter-&gt;get($name)</code>
</PossiblyInvalidArgument>
<PossiblyNullArgument occurrences="1">
<code>$this-&gt;data</code>
Expand All @@ -182,20 +219,7 @@
<code>$data</code>
<code>$validationGroup</code>
</PossiblyNullArrayOffset>
<PossiblyUndefinedMethod occurrences="15">
<code>add</code>
<code>add</code>
<code>add</code>
<code>add</code>
<code>add</code>
<code>add</code>
<code>get</code>
<code>get</code>
<code>has</code>
<code>has</code>
<code>has</code>
<code>has</code>
<code>has</code>
<PossiblyUndefinedMethod occurrences="2">
<code>merge</code>
<code>merge</code>
</PossiblyUndefinedMethod>
Expand All @@ -221,20 +245,12 @@
<code>$factories</code>
<code>$instanceOf</code>
</NonInvariantDocblockPropertyType>
<RedundantConditionGivenDocblockType occurrences="6">
<code>$services</code>
<code>$services</code>
<code>$services</code>
<RedundantConditionGivenDocblockType occurrences="3">
<code>$services</code>
<code>$services</code>
<code>$services</code>
</RedundantConditionGivenDocblockType>
</file>
<file src="src/FormElementManagerFactory.php">
<MissingParamType occurrences="1">
<code>$name</code>
</MissingParamType>
</file>
<file src="src/FormFactoryAwareInterface.php">
<MissingReturnType occurrences="1">
<code>setFormFactory</code>
Expand Down Expand Up @@ -294,6 +310,12 @@
<DeprecatedMethod occurrences="1">
<code>getView</code>
</DeprecatedMethod>
<InvalidFunctionCall occurrences="4">
<code>$elementHelper($elementOrFieldset)</code>
<code>$elementHelper($elementOrFieldset)</code>
<code>$fieldsetHelper($elementOrFieldset, $this-&gt;shouldWrap())</code>
<code>$fieldsetHelper($elementOrFieldset, $this-&gt;shouldWrap())</code>
</InvalidFunctionCall>
<TypeDoesNotContainType occurrences="4">
<code>assert(is_callable($elementHelper))</code>
<code>assert(is_callable($elementHelper))</code>
Expand Down Expand Up @@ -324,16 +346,9 @@
</PossiblyNullArgument>
</file>
<file src="src/View/Helper/FormRow.php">
<InvalidArgument occurrences="1">
<code>$element</code>
</InvalidArgument>
<PossiblyNullReference occurrences="1">
<code>render</code>
</PossiblyNullReference>
<PossiblyUndefinedMethod occurrences="2">
<code>hasAttribute</code>
<code>hasAttribute</code>
</PossiblyUndefinedMethod>
</file>
<file src="src/View/Helper/FormSelect.php">
<PossiblyInvalidArgument occurrences="1">
Expand Down Expand Up @@ -376,6 +391,14 @@
</UndefinedInterfaceMethod>
</file>
<file src="test/Element/CollectionTest.php">
<InvalidArgument occurrences="2">
<code>$obj2</code>
<code>$obj3</code>
</InvalidArgument>
<InvalidArrayOffset occurrences="2">
<code>$data[$index]</code>
<code>$names[$i]</code>
</InvalidArrayOffset>
<NullArgument occurrences="1">
<code>null</code>
</NullArgument>
Expand Down
12 changes: 9 additions & 3 deletions src/ConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,20 @@
namespace Laminas\Form;

use Laminas\Form\View\Helper\Factory\FormElementErrorsFactory;
use Laminas\ServiceManager\ConfigInterface;
use Laminas\ServiceManager\Factory\InvokableFactory;

/** @psalm-import-type ServiceManagerConfigurationType from ConfigInterface */
final class ConfigProvider
{
/**
* Return general-purpose laminas-i18n configuration.
*
* @return array
* @return array{
* dependencies: ServiceManagerConfigurationType,
* view_helpers: ServiceManagerConfigurationType,
* ...
* }
*/
public function __invoke(): array
{
Expand All @@ -25,7 +31,7 @@ public function __invoke(): array
/**
* Return application-level dependency configuration.
*
* @return array
* @return ServiceManagerConfigurationType
*/
public function getDependencyConfig(): array
{
Expand All @@ -51,7 +57,7 @@ public function getDependencyConfig(): array
*
* Obsoletes View\HelperConfig.
*
* @return array
* @return ServiceManagerConfigurationType
*/
public function getViewHelperConfig(): array
{
Expand Down
17 changes: 14 additions & 3 deletions src/FormElementManagerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,28 @@
use Laminas\ServiceManager\AbstractPluginManager;
use Laminas\ServiceManager\Config;
use Laminas\ServiceManager\Factory\FactoryInterface;
use Laminas\ServiceManager\ServiceManager;
use Psr\Container\ContainerInterface;

use function is_array;

/** @psalm-import-type ServiceManagerConfiguration from ServiceManager */
final class FormElementManagerFactory implements FactoryInterface
{
/**
* @inheritDoc
* @param string|null $requestedName
* @param ServiceManagerConfiguration|null $options
* @return AbstractPluginManager
*/
public function __invoke(ContainerInterface $container, $name, ?array $options = null): AbstractPluginManager
{
$pluginManager = new FormElementManager($container, $options ?: []);
public function __invoke(
ContainerInterface $container,
$requestedName,
?array $options = null
): AbstractPluginManager {
/** @psalm-var ServiceManagerConfiguration $options */
$options = is_array($options) ? $options : [];
$pluginManager = new FormElementManager($container, $options);

// If this is in a laminas-mvc application, the ServiceListener will inject
// merged configuration during bootstrap.
Expand All @@ -39,6 +48,8 @@ public function __invoke(ContainerInterface $container, $name, ?array $options =
return $pluginManager;
}

/** @psalm-var ServiceManagerConfiguration $config['form_elements'] */

// Wire service configuration for forms and elements
(new Config($config['form_elements']))->configureServiceManager($pluginManager);

Expand Down
6 changes: 6 additions & 0 deletions test/TestAsset/CustomCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@

use Laminas\Stdlib\ArrayObject;

/**
* @template TKey of array-key
* @template TValue
* @extends ArrayObject<TKey, TValue>
*/
class CustomCollection extends ArrayObject
{
/** @return array<TKey, TValue> */
public function toArray(): array
{
$ret = [];
Expand Down
6 changes: 6 additions & 0 deletions test/TestAsset/CustomTraversable.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,14 @@
use function next;
use function reset;

/**
* @template TKey
* @template TValue
* @implements Iterator<TKey, TValue>
*/
class CustomTraversable implements Iterator
{
/** @param array<TKey, TValue> $data */
public function __construct(private array $data)
{
}
Expand Down
5 changes: 5 additions & 0 deletions test/TestAsset/IteratorAggregate.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
use IteratorAggregate as IteratorAggregateInterface;
use Traversable;

/**
* @template TKey
* @template TValue
* @implements IteratorAggregateInterface<TKey, TValue>
*/
class IteratorAggregate implements IteratorAggregateInterface
{
public function __construct(protected Traversable $iterator)
Expand Down
3 changes: 3 additions & 0 deletions test/TestAsset/StringToArrayFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
use function explode;
use function is_array;

/**
* @extends AbstractFilter<array{}>
*/
class StringToArrayFilter extends AbstractFilter
{
/**
Expand Down

0 comments on commit 976dfc8

Please sign in to comment.