Skip to content

Commit

Permalink
Upgrade psalm to 5.21.x
Browse files Browse the repository at this point in the history
Fixes various `RiskyTruthyFalsyComparison` issues

Signed-off-by: George Steel <[email protected]>
  • Loading branch information
gsteel committed Feb 1, 2024
1 parent 5b66374 commit 6f92812
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 64 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@
"require-dev": {
"ext-json": "*",
"laminas/laminas-coding-standard": "~2.5.0",
"phpunit/phpunit": "^10.5.5",
"phpunit/phpunit": "^10.5.9",
"psalm/plugin-phpunit": "^0.18.4",
"psr/http-message": "^2.0",
"vimeo/psalm": "^5.18",
"vimeo/psalm": "^5.21.1",
"webmozart/assert": "^1.11"
},
"suggest": {
Expand Down
100 changes: 50 additions & 50 deletions composer.lock

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

2 changes: 1 addition & 1 deletion 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="5.18.0@b113f3ed0259fd6e212d87c3df80eec95a6abf19">
<files psalm-version="5.21.1@8c473e2437be8b6a8fd8f630f0f11a16b114c494">
<file src="src/ArrayInput.php">
<DocblockTypeContradiction>
<code>is_array($value)</code>
Expand Down
8 changes: 4 additions & 4 deletions src/BaseInputFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function add($input, $name = null)
));
}

if ($input instanceof InputInterface && (empty($name) || is_int($name))) {
if ($input instanceof InputInterface && ($name === null || $name === '' || is_int($name))) {
$name = $input->getName();
}

Expand Down Expand Up @@ -233,7 +233,7 @@ public function isValid($context = null)
));
}

$inputs = $this->validationGroup ?: array_keys($this->inputs);
$inputs = $this->validationGroup ?? array_keys($this->inputs);
return $this->validateInputs($inputs, $this->data, $context);
}

Expand All @@ -247,7 +247,7 @@ public function isValid($context = null)
*/
protected function validateInputs(array $inputs, array $data = [], $context = null)
{
$inputContext = $context ?: array_merge($this->getRawValues(), $data);
$inputContext = $context ?? array_merge($this->getRawValues(), $data);

$this->validInputs = [];
$this->invalidInputs = [];
Expand Down Expand Up @@ -413,7 +413,7 @@ public function getValue($name)
*/
public function getValues()
{
$inputs = $this->validationGroup ?: array_keys($this->inputs);
$inputs = $this->validationGroup ?? array_keys($this->inputs);
$values = [];
foreach ($inputs as $name) {
$input = $this->inputs[$name];
Expand Down
4 changes: 2 additions & 2 deletions src/CollectionInputFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public function isValid($context = null)
$valid = false;
}

if (! $this->data) {
if ($this->data === null) {
$this->clearValues();
$this->clearRawValues();

Expand Down Expand Up @@ -316,7 +316,7 @@ public function getMessages()
*/
public function getUnknown()
{
if (! $this->data) {
if ($this->data === null) {
throw new Exception\RuntimeException(sprintf(
'%s: no data present!',
__METHOD__
Expand Down
4 changes: 2 additions & 2 deletions src/InputFilterPluginManagerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class InputFilterPluginManagerFactory implements FactoryInterface
*/
public function __invoke(ContainerInterface $container, $name = null, ?array $options = null)
{
$pluginManager = new InputFilterPluginManager($container, $options ?: []);
$pluginManager = new InputFilterPluginManager($container, $options ?? []);

// If this is in a laminas-mvc application, the ServiceListener will inject
// merged configuration during bootstrap.
Expand Down Expand Up @@ -75,7 +75,7 @@ public function __invoke(ContainerInterface $container, $name = null, ?array $op
*/
public function createService(ServiceLocatorInterface $container, $name = null, $requestedName = null)
{
return $this($container, $requestedName ?: InputFilterPluginManager::class, $this->creationOptions);
return $this($container, $requestedName ?? InputFilterPluginManager::class, $this->creationOptions);
}

/**
Expand Down
Loading

0 comments on commit 6f92812

Please sign in to comment.