Skip to content

Commit

Permalink
[CodeQuality] Skip static class const fetch on InlineConstructorDefau…
Browse files Browse the repository at this point in the history
…ltToPropertyRector (#3510)

* [CodeQuality] Skip static class const fetch on InlineConstructorDefaultToPropertyRector

* [ci-review] Rector Rectify

* Fixed 🎉

---------

Co-authored-by: GitHub Action <actions@github.com>
  • Loading branch information
samsonasik and actions-user committed Mar 23, 2023
1 parent 697479f commit d7e8477
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions packages/NodeNameResolver/NodeNameResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ final class NodeNameResolver
* @see https://regex101.com/r/ImTV1W/1
*/
private const CONTAINS_WILDCARD_CHARS_REGEX = '/[\*\#\~\/]/';

/**
* @var array<string, NodeNameResolverInterface|null>
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace Rector\Tests\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector\Fixture;

final class SkipStaticClassConstFetch2
{
private $name;

private const NUMBER = 1;

public function __construct()
{
$this->name = static::NUMBER;
}
}
4 changes: 0 additions & 4 deletions src/NodeAnalyzer/ExprAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,6 @@ private function isAllowedConstFetchOrClassConstFetch(Expr $expr): bool
return false;
}

if ($expr->name->toString() !== 'class') {
return true;
}

// static::class cannot be used for compile-time class name resolution
return $expr->class->toString() !== ObjectReference::STATIC;
}
Expand Down

0 comments on commit d7e8477

Please sign in to comment.