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,56 @@
<?php

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

final class NewArrayReplace
{
public function getImagePaths($identifier = 'detail', $size = null)
{
$imagePaths = [];

if ($size) {
$imagePaths = $this->getFilePaths('/' . $identifier . '_' . $size . '.jpg/');
} else {
$imagePaths = $this->getFilePaths('/' . $identifier . '.jpg/');
}

return $imagePaths;
}

private function getFilePaths(): array
{
return [];
}
}

?>
-----
<?php

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

final class NewArrayReplace
{
/**
* @return mixed[]
*/
public function getImagePaths($identifier = 'detail', $size = null): array
{
$imagePaths = [];

if ($size) {
$imagePaths = $this->getFilePaths('/' . $identifier . '_' . $size . '.jpg/');
} else {
$imagePaths = $this->getFilePaths('/' . $identifier . '.jpg/');
}

return $imagePaths;
}

private function getFilePaths(): array
{
return [];
}
}

?>
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,12 @@ private function isVariableOverriddenWithNonArray(
continue;
}

if (! $assign->expr instanceof Array_) {
if ($assign->expr instanceof Array_) {
continue;
}

$nativeType = $this->nodeTypeResolver->getNativeType($assign->expr);
if (! $nativeType->isArray()->yes()) {
return true;
}
}
Expand Down