File tree Expand file tree Collapse file tree 5 files changed +43
-11
lines changed
rules/Php81/Rector/Array_
src/Skipper/SkipCriteriaResolver Expand file tree Collapse file tree 5 files changed +43
-11
lines changed Original file line number Diff line number Diff line change @@ -433,3 +433,12 @@ parameters:
433433 - rules/Php55/Rector/String_/StringClassNameToClassConstantRector.php
434434 - rules/Php81/Enum/AttributeName.php
435435
436+ # deprecated rule
437+ - ' #Rule Rector\\Php81\\Rector\\Array_\\FirstClassCallableRector must implements Rector\\VersionBonding\\Contract\\MinPhpVersionInterface #'
438+ - ' #Register "Rector\\Php81\\Rector\\Array_\\FirstClassCallableRector" service to "php81\.php" config set #'
439+ - ' #Access to constant on deprecated class Rector\\Php81\\Rector\\Array_\\FirstClassCallableRector #'
440+ -
441+ message : ' #Only abstract classes can be extended#'
442+ path : rules/Php81/Rector/Array_/FirstClassCallableRector.php
443+
444+
Original file line number Diff line number Diff line change 22
33declare (strict_types=1 );
44
5- use Rector \CodingStyle \Rector \FunctionLike \FunctionLikeToFirstClassCallableRector ;
65use Rector \CodingStyle \Rector \String_ \UseClassKeywordForClassNameResolutionRector ;
76use Rector \Config \RectorConfig ;
87use Rector \DeadCode \Rector \ConstFetch \RemovePhpVersionIdCheckRector ;
4241 ->withImportNames (removeUnusedImports: true )
4342 ->withRules ([RemoveRefactorDuplicatedNodeInstanceCheckRector::class, AddSeeTestAnnotationRector::class])
4443 ->withSkip ([
45- // testing skip of deprecated class
46- FunctionLikeToFirstClassCallableRector::class,
47-
4844 StringClassNameToClassConstantRector::class,
4945 // tests
5046 '*/Fixture* ' ,
Original file line number Diff line number Diff line change 3131 * @see RFC https://wiki.php.net/rfc/first_class_callable_syntax
3232 * @see \Rector\Tests\Php81\Rector\Array_\ArrayToFirstClassCallableRector\ArrayToFirstClassCallableRectorTest
3333 */
34- final class ArrayToFirstClassCallableRector extends AbstractRector implements MinPhpVersionInterface
34+ class ArrayToFirstClassCallableRector extends AbstractRector implements MinPhpVersionInterface
3535{
3636 public function __construct (
3737 private readonly ArrayCallableMethodMatcher $ arrayCallableMethodMatcher ,
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Rector \Php81 \Rector \Array_ ;
6+
7+ use PhpParser \Node ;
8+ use PhpParser \Node \Expr \MethodCall ;
9+ use PhpParser \Node \Expr \StaticCall ;
10+ use Rector \Configuration \Deprecation \Contract \DeprecatedInterface ;
11+ use Rector \Exception \ShouldNotHappenException ;
12+
13+ /**
14+ * @deprecated Renamed to \Rector\Php81\Rector\Array_\ArrayToFirstClassCallableRector
15+ */
16+ final class FirstClassCallableRector extends ArrayToFirstClassCallableRector implements DeprecatedInterface
17+ {
18+ public function refactor (Node $ node ): StaticCall |MethodCall |null
19+ {
20+ throw new ShouldNotHappenException (sprintf (
21+ '%s is deprecated and renamed to "%s". Use it instead. ' ,
22+ self ::class,
23+ ArrayToFirstClassCallableRector::class
24+ ));
25+ }
26+ }
Original file line number Diff line number Diff line change 1515final class SkippedClassResolver
1616{
1717 /**
18- * @var null|array<string, string[]|null>
18+ * @var null|array<class- string, string[]|null>
1919 */
2020 private null |array $ skippedClassesToFiles = null ;
2121
2222 /**
23- * @return array<DeprecatedInterface>
23+ * @return array<class-string< DeprecatedInterface> >
2424 */
2525 public function resolveDeprecatedSkippedClasses (): array
2626 {
2727 $ skippedClassNames = array_keys ($ this ->resolve ());
2828
29- return array_filter ($ skippedClassNames , function (string $ class ): bool {
30- return is_a ($ class , DeprecatedInterface::class, true );
31- });
29+ return array_filter (
30+ $ skippedClassNames ,
31+ fn (string $ class ): bool => is_a ($ class , DeprecatedInterface::class, true )
32+ );
3233 }
3334
3435 /**
35- * @return array<string, string[]|null>
36+ * @return array<class- string, string[]|null>
3637 */
3738 public function resolve (): array
3839 {
You can’t perform that action at this time.
0 commit comments