Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Nov 24, 2024
1 parent 19431d5 commit ea73380
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use Rector\Tests\CodeQuality\Rector\Class_\DynamicDocBlockPropertyToNativeProper

final class AliasedClass
{
private ?\Rector\Tests\CodeQuality\Rector\Class_\DynamicDocBlockPropertyToNativePropertyRector\Source\SomeDependency $someDependency;
private ?SomeSource\SomeDependency $someDependency;
public function run(): void
{
$this->someDependency = new SomeSource\SomeDependency();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use Rector\Tests\CodeQuality\Rector\Class_\DynamicDocBlockPropertyToNativeProper

final class BareClass
{
private ?\Rector\Tests\CodeQuality\Rector\Class_\DynamicDocBlockPropertyToNativePropertyRector\Source\SomeDependency $someDependency;
private ?SomeDependency $someDependency;
public function run(): void
{
$this->someDependency = new SomeDependency();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use Rector\Tests\CodeQuality\Rector\Class_\DynamicDocBlockPropertyToNativeProper

final class ImproveExistingPropertyType extends TestCase
{
private \Rector\Tests\CodeQuality\Rector\Class_\DynamicDocBlockPropertyToNativePropertyRector\Source\SomeDependency $someDependency;
private SomeDependency $someDependency;
protected function setUp(): void
{
parent::setUp();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use Rector\Tests\CodeQuality\Rector\Class_\DynamicDocBlockPropertyToNativeProper

final class IncludeNull
{
protected ?\Rector\Tests\CodeQuality\Rector\Class_\DynamicDocBlockPropertyToNativePropertyRector\Source\SomeDependency $someDependency = null;
protected ?SomeDependency $someDependency = null;
}

?>
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use Rector\Tests\CodeQuality\Rector\Class_\DynamicDocBlockPropertyToNativeProper

final class SomeTest extends TestCase
{
private ?\Rector\Tests\CodeQuality\Rector\Class_\DynamicDocBlockPropertyToNativePropertyRector\Source\SomeDependency $someDependency;
private ?SomeDependency $someDependency;
protected function setUp(): void
{
parent::setUp();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use Rector\Tests\CodeQuality\Rector\Class_\DynamicDocBlockPropertyToNativeProper
#[\OtherAttribute]
final class WithOtherExistingAttribute
{
private ?\Rector\Tests\CodeQuality\Rector\Class_\DynamicDocBlockPropertyToNativePropertyRector\Source\SomeDependency $someDependency;
private ?SomeDependency $someDependency;
public function run(): void
{
$this->someDependency = new SomeDependency();
Expand Down
6 changes: 3 additions & 3 deletions rules/TypeDeclaration/PHPStan/ObjectTypeSpecifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,16 +153,16 @@ private function processAliasedObject(
): ?AliasedObjectType {
// A. is alias in use statement matching this class alias
if ($alias === $className) {
return new AliasedObjectType($alias, $fullyQualifiedName);
return new AliasedObjectType($className, $fullyQualifiedName);
}

// B. is aliased classes matching the class name
if ($useName === $className) {
return new AliasedObjectType($alias, $fullyQualifiedName);
return new AliasedObjectType($className, $fullyQualifiedName);
}

if (str_starts_with($className, $alias . '\\')) {
return new AliasedObjectType($alias, $fullyQualifiedName . ltrim($className, $alias));
return new AliasedObjectType($className, $fullyQualifiedName . ltrim($className, $alias));
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function mapToPhpParserNode(Type $type, string $typeKind): ?Node
}

if ($type instanceof ShortenedObjectType || $type instanceof AliasedObjectType) {
return new FullyQualified($type->getFullyQualifiedName());
return new Name($type->getClassName());
}

if ($type instanceof FullyQualifiedObjectType) {
Expand Down

0 comments on commit ea73380

Please sign in to comment.