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
13 changes: 6 additions & 7 deletions packages/NodeTypeResolver/src/Php/AbstractTypeInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,15 +257,14 @@ private function normalizeNullable(string $type): string

private function normalizeCasing(string $type): string
{
if ($this->typeAnalyzer->isPhpReservedType($type)) {
return strtolower($type);
}

if (strtolower($type) === '$this') {
return strtolower($type);
$types = explode('|', $type);
foreach ($types as $key => $singleType) {
if ($this->typeAnalyzer->isPhpReservedType($singleType) || strtolower($singleType) === '$this') {
$types[$key] = strtolower($singleType);
}
}

return $type;
return implode($types, '|');
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ final class AddArrayReturnDocTypeRectorTest extends AbstractRectorTestCase
{
public function test(): void
{
$this->doTestFiles([__DIR__ . '/Fixture/fixture.php.inc', __DIR__ . '/Fixture/setter_based.php.inc']);
$this->doTestFiles([
__DIR__ . '/Fixture/fixture.php.inc',
__DIR__ . '/Fixture/setter_based.php.inc',
__DIR__ . '/Fixture/fully_qualified_name.php.inc',
]);
}

protected function getRectorClass(): string
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

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

use Rector\TypeDeclaration\Tests\Rector\ClassMethod\AddArrayReturnDocTypeRector\Source\ValidationResult;

final class FullyQualifiedName
{
public function isValidDataProvider(): array
{
return [
new ValidationResult(), true,
];
}

public function getValidationErrorMessagesAsStringDataProvider(): array
{
return [
'no_errors' => [new ValidationResult(), 'ha_ja'],
];
}
}

?>
-----
<?php

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

use Rector\TypeDeclaration\Tests\Rector\ClassMethod\AddArrayReturnDocTypeRector\Source\ValidationResult;

final class FullyQualifiedName
{
/**
* @return \Rector\TypeDeclaration\Tests\Rector\ClassMethod\AddArrayReturnDocTypeRector\Source\ValidationResult[]|bool[]
*/
public function isValidDataProvider(): array
{
return [
new ValidationResult(), true,
];
}

/**
* @return string[][]|\Rector\TypeDeclaration\Tests\Rector\ClassMethod\AddArrayReturnDocTypeRector\Source\ValidationResult[][]
*/
public function getValidationErrorMessagesAsStringDataProvider(): array
{
return [
'no_errors' => [new ValidationResult(), 'ha_ja'],
];
}
}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php declare(strict_types=1);

namespace Rector\TypeDeclaration\Tests\Rector\ClassMethod\AddArrayReturnDocTypeRector\Source;

final class ValidationResult
{

}