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

namespace Rector\Tests\TypeDeclarationDocblocks\Rector\ClassMethod\DocblockReturnArrayFromDirectArrayInstanceRector\Fixture;

class ComplexArray
{
public function run(): array
{
return [
'id' => new \stdClass(),
'context' => [
'id' => 1,
'data' => [
'foo' => 'bar',
'baz' => 'qux',
],
],
'values' => [
'name' => '111',
],
];
}
}

?>
-----
<?php

namespace Rector\Tests\TypeDeclarationDocblocks\Rector\ClassMethod\DocblockReturnArrayFromDirectArrayInstanceRector\Fixture;

class ComplexArray
{
/**
* @return array<string, mixed>
*/
public function run(): array
{
return [
'id' => new \stdClass(),
'context' => [
'id' => 1,
'data' => [
'foo' => 'bar',
'baz' => 'qux',
],
],
'values' => [
'name' => '111',
],
];
}
}

?>
Original file line number Diff line number Diff line change
Expand Up @@ -128,19 +128,19 @@ public function refactor(Node $node): ?Node
*/
private function constantToGenericType(Type $type): Type
{
if ($type instanceof StringType) {
if ($type->isString()->yes()) {
return new StringType();
}

if ($type instanceof IntegerType) {
if ($type->isInteger()->yes()) {
return new IntegerType();
}

if ($type instanceof BooleanType) {
if ($type->isBoolean()->yes()) {
return new BooleanType();
}

if ($type instanceof FloatType) {
if ($type->isFloat()->yes()) {
return new FloatType();
}

Expand Down
Loading