Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\StrictArrayParamDimFetchRector\Fixture;

final class SkipIsBool
{
private function getLabelsForIds($ids)
{
if (is_bool($ids)) {
$ids = explode(',', $ids);
}
if (! isset($ids[0])) {
return '';
}

if ('alle' === $ids[0]) {
return $ids[0];
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\StrictArrayParamDimFetchRector\Fixture;

final class SkipIsFloat
{
private function getLabelsForIds($ids)
{
if (is_float($ids)) {
$ids = explode(',', $ids);
}
if (! isset($ids[0])) {
return '';
}

if ('alle' === $ids[0]) {
return $ids[0];
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\StrictArrayParamDimFetchRector\Fixture;

final class SkipIsInt
{
private function getLabelsForIds($ids)
{
if (is_int($ids)) {
$ids = explode(',', $ids);
}
if (! isset($ids[0])) {
return '';
}

if ('alle' === $ids[0]) {
return $ids[0];
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\StrictArrayParamDimFetchRector\Fixture;

final class SkipIsString
{
private function getLabelsForIds($ids)
{
if (is_string($ids)) {
$ids = explode(',', $ids);
}
if (! isset($ids[0])) {
return '';
}

if ('alle' === $ids[0]) {
return $ids[0];
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ private function isParamAccessedArrayDimFetch(Param $param, ClassMethod|Function
$paramName,
&$isParamAccessedArrayDimFetch
): int|null {
if ($node instanceof FuncCall && $this->isName($node, 'is_array')) {
if ($node instanceof FuncCall && $this->isNames($node, ['is_array', 'is_string', 'is_int', 'is_bool', 'is_float'])) {
$firstArg = $node->getArgs()[0];
if ($this->isName($firstArg->value, $paramName)) {
return NodeTraverser::STOP_TRAVERSAL;
Expand Down