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
4 changes: 2 additions & 2 deletions config/set/php81.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Rector\CodingStyle\Rector\FuncCall\FunctionFirstClassCallableRector;
use Rector\CodingStyle\Rector\FunctionLike\FunctionLikeToFirstClassCallableRector;
use Rector\Config\RectorConfig;
use Rector\Php81\Rector\Array_\FirstClassCallableRector;
use Rector\Php81\Rector\Array_\ArrayToFirstClassCallableRector;
use Rector\Php81\Rector\Class_\MyCLabsClassToEnumRector;
use Rector\Php81\Rector\Class_\SpatieEnumClassToEnumRector;
use Rector\Php81\Rector\ClassMethod\NewInInitializerRector;
Expand All @@ -31,7 +31,7 @@
NullToStrictStringFuncCallArgRector::class,
NullToStrictIntPregSlitFuncCallLimitArgRector::class,
// array of local method call
FirstClassCallableRector::class,
ArrayToFirstClassCallableRector::class,
// closure/arrow function
FunctionLikeToFirstClassCallableRector::class,
ClosureFromCallableToFirstClassCallableRector::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

declare(strict_types=1);

namespace Rector\Tests\Php81\Rector\Array_\FirstClassCallableRector;
namespace Rector\Tests\Php81\Rector\Array_\ArrayToFirstClassCallableRector;

use Iterator;
use PHPUnit\Framework\Attributes\DataProvider;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;

final class FirstClassCallableRectorTest extends AbstractRectorTestCase
final class ArrayToFirstClassCallableRectorTest extends AbstractRectorTestCase
{
#[DataProvider('provideData')]
public function test(string $filePath): void
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

namespace Rector\Tests\Php81\Rector\Array_\FirstClassCallableRector\Fixture;
namespace Rector\Tests\Php81\Rector\Array_\ArrayToFirstClassCallableRector\Fixture;

use Rector\Tests\CodeQuality\Rector\Identical\FlipTypeControlToUseExclusiveTypeRector\Source\stdClass;
use Rector\Tests\Php81\Rector\Array_\FirstClassCallableRector\Source\SomeExternalObject;
use Rector\Tests\Php81\Rector\Array_\ArrayToFirstClassCallableRector\Source\SomeExternalObject;

return static function (stdClass $container): void {
$container->services()
Expand All @@ -14,10 +14,10 @@ return static function (stdClass $container): void {
-----
<?php

namespace Rector\Tests\Php81\Rector\Array_\FirstClassCallableRector\Fixture;
namespace Rector\Tests\Php81\Rector\Array_\ArrayToFirstClassCallableRector\Fixture;

use Rector\Tests\CodeQuality\Rector\Identical\FlipTypeControlToUseExclusiveTypeRector\Source\stdClass;
use Rector\Tests\Php81\Rector\Array_\FirstClassCallableRector\Source\SomeExternalObject;
use Rector\Tests\Php81\Rector\Array_\ArrayToFirstClassCallableRector\Source\SomeExternalObject;

return static function (stdClass $container): void {
$container->services()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Rector\Tests\Php81\Rector\Array_\FirstClassCallableRector\Fixture;
namespace Rector\Tests\Php81\Rector\Array_\ArrayToFirstClassCallableRector\Fixture;

$variableName = 'x';
$index = 1;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Rector\Tests\Php81\Rector\Array_\FirstClassCallableRector\Fixture;
namespace Rector\Tests\Php81\Rector\Array_\ArrayToFirstClassCallableRector\Fixture;

enum SkipEnumData: int {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Rector\Tests\Php81\Rector\Array_\FirstClassCallableRector\Fixture;
namespace Rector\Tests\Php81\Rector\Array_\ArrayToFirstClassCallableRector\Fixture;

final class SkipFunctionReference
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Rector\Tests\Php81\Rector\Array_\FirstClassCallableRector\Fixture;
namespace Rector\Tests\Php81\Rector\Array_\ArrayToFirstClassCallableRector\Fixture;

function run(\Closure $closure): void
{
Expand All @@ -9,4 +9,4 @@ function run(\Closure $closure): void
run(
#[SomeAttribute(['array-argument'])]
fn(): null => null,
);
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace Rector\Tests\Php81\Rector\Array_\ArrayToFirstClassCallableRector\Fixture;

#[SomeAttribute(['array-argument'])]
class SkipInAttributeClass
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace Rector\Tests\Php81\Rector\Array_\ArrayToFirstClassCallableRector\Fixture;

use Rector\Tests\Php81\Rector\Array_\ArrayToFirstClassCallableRector\Source\SomeExternalObject;

Route::get('verify-email', [SomeExternalObject::class, '__invoke'])
->name('verification.notice');
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Rector\Tests\Php81\Rector\Array_\FirstClassCallableRector\Fixture;
namespace Rector\Tests\Php81\Rector\Array_\ArrayToFirstClassCallableRector\Fixture;

final class SkipNonExistingMethod
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace Rector\Tests\Php81\Rector\Array_\FirstClassCallableRector\Fixture;
namespace Rector\Tests\Php81\Rector\Array_\ArrayToFirstClassCallableRector\Fixture;

use Rector\Tests\Php81\Rector\Array_\FirstClassCallableRector\Source\SomeExternalObject;
use Rector\Tests\Php81\Rector\Array_\ArrayToFirstClassCallableRector\Source\SomeExternalObject;

final class SkipNonStaticPrivateMethodWithOtherObjectConstFetch
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace Rector\Tests\Php81\Rector\Array_\FirstClassCallableRector\Fixture;
namespace Rector\Tests\Php81\Rector\Array_\ArrayToFirstClassCallableRector\Fixture;

use Rector\Tests\Php81\Rector\Array_\FirstClassCallableRector\Source\SomeExternalObject;
use Rector\Tests\Php81\Rector\Array_\ArrayToFirstClassCallableRector\Source\SomeExternalObject;

final class SkipNonStaticWithOtherObjectConstFetch
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Rector\Tests\Php81\Rector\Array_\FirstClassCallableRector\Fixture;
namespace Rector\Tests\Php81\Rector\Array_\ArrayToFirstClassCallableRector\Fixture;

final class SkipOnClassConst
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Rector\Tests\Php81\Rector\Array_\FirstClassCallableRector\Fixture;
namespace Rector\Tests\Php81\Rector\Array_\ArrayToFirstClassCallableRector\Fixture;

final class SkipOnProperty
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace Rector\Tests\Php81\Rector\Array_\FirstClassCallableRector\Fixture;
namespace Rector\Tests\Php81\Rector\Array_\ArrayToFirstClassCallableRector\Fixture;

use Rector\Tests\Php81\Rector\Array_\FirstClassCallableRector\Source\WithPrivateMethod;
use Rector\Tests\Php81\Rector\Array_\ArrayToFirstClassCallableRector\Source\WithPrivateMethod;

final class SkipPrivateMethodByInstantiation
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace Rector\Tests\Php81\Rector\Array_\FirstClassCallableRector\Fixture;
namespace Rector\Tests\Php81\Rector\Array_\ArrayToFirstClassCallableRector\Fixture;

use Rector\Tests\Php81\Rector\Array_\FirstClassCallableRector\Source\WithPrivateMethod;
use Rector\Tests\Php81\Rector\Array_\ArrayToFirstClassCallableRector\Source\WithPrivateMethod;

final class SkipPrivateMethodByPropertyFetch
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Rector\Tests\Php81\Rector\Array_\FirstClassCallableRector\Fixture;
namespace Rector\Tests\Php81\Rector\Array_\ArrayToFirstClassCallableRector\Fixture;

use PHPStan\Type\ArrayType;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace Rector\Tests\Php81\Rector\Array_\FirstClassCallableRector\Fixture;
namespace Rector\Tests\Php81\Rector\Array_\ArrayToFirstClassCallableRector\Fixture;

use Rector\Tests\Php81\Rector\Array_\FirstClassCallableRector\Source\SomeExternalObject;
use Rector\Tests\Php81\Rector\Array_\ArrayToFirstClassCallableRector\Source\SomeExternalObject;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return static function (ContainerConfigurator $container): void {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Rector\Tests\Php81\Rector\Array_\FirstClassCallableRector\Fixture;
namespace Rector\Tests\Php81\Rector\Array_\ArrayToFirstClassCallableRector\Fixture;

final class SomeClass
{
Expand All @@ -18,7 +18,7 @@ final class SomeClass
-----
<?php

namespace Rector\Tests\Php81\Rector\Array_\FirstClassCallableRector\Fixture;
namespace Rector\Tests\Php81\Rector\Array_\ArrayToFirstClassCallableRector\Fixture;

final class SomeClass
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Rector\Tests\Php81\Rector\Array_\FirstClassCallableRector\Fixture;
namespace Rector\Tests\Php81\Rector\Array_\ArrayToFirstClassCallableRector\Fixture;

final class SomeStaticCall
{
Expand All @@ -18,7 +18,7 @@ final class SomeStaticCall
-----
<?php

namespace Rector\Tests\Php81\Rector\Array_\FirstClassCallableRector\Fixture;
namespace Rector\Tests\Php81\Rector\Array_\ArrayToFirstClassCallableRector\Fixture;

final class SomeStaticCall
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace Rector\Tests\Php81\Rector\Array_\FirstClassCallableRector\Fixture;
namespace Rector\Tests\Php81\Rector\Array_\ArrayToFirstClassCallableRector\Fixture;

use Rector\Tests\Php81\Rector\Array_\FirstClassCallableRector\Source\SomeExternalObject;
use Rector\Tests\Php81\Rector\Array_\ArrayToFirstClassCallableRector\Source\SomeExternalObject;

final class StaticWithOtherObjectConstFetch
{
Expand All @@ -16,9 +16,9 @@ final class StaticWithOtherObjectConstFetch
-----
<?php

namespace Rector\Tests\Php81\Rector\Array_\FirstClassCallableRector\Fixture;
namespace Rector\Tests\Php81\Rector\Array_\ArrayToFirstClassCallableRector\Fixture;

use Rector\Tests\Php81\Rector\Array_\FirstClassCallableRector\Source\SomeExternalObject;
use Rector\Tests\Php81\Rector\Array_\ArrayToFirstClassCallableRector\Source\SomeExternalObject;

final class StaticWithOtherObjectConstFetch
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace Rector\Tests\Php81\Rector\Array_\FirstClassCallableRector\Fixture;
namespace Rector\Tests\Php81\Rector\Array_\ArrayToFirstClassCallableRector\Fixture;

use Rector\Tests\Php81\Rector\Array_\FirstClassCallableRector\Source\SomeExternalObject;
use Rector\Tests\Php81\Rector\Array_\ArrayToFirstClassCallableRector\Source\SomeExternalObject;

final class WithPropertyFetch
{
Expand All @@ -23,9 +23,9 @@ final class WithPropertyFetch
-----
<?php

namespace Rector\Tests\Php81\Rector\Array_\FirstClassCallableRector\Fixture;
namespace Rector\Tests\Php81\Rector\Array_\ArrayToFirstClassCallableRector\Fixture;

use Rector\Tests\Php81\Rector\Array_\FirstClassCallableRector\Source\SomeExternalObject;
use Rector\Tests\Php81\Rector\Array_\ArrayToFirstClassCallableRector\Source\SomeExternalObject;

final class WithPropertyFetch
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
declare(strict_types=1);

namespace Rector\Tests\Php81\Rector\Array_\FirstClassCallableRector\Source;
namespace Rector\Tests\Php81\Rector\Array_\ArrayToFirstClassCallableRector\Source;

final class SomeExternalObject
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Rector\Tests\Php81\Rector\Array_\FirstClassCallableRector\Source;
namespace Rector\Tests\Php81\Rector\Array_\ArrayToFirstClassCallableRector\Source;

class WithPrivateMethod {
/** @var callable */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\Php81\Rector\Array_\FirstClassCallableRector;
use Rector\Php81\Rector\Array_\ArrayToFirstClassCallableRector;
use Rector\ValueObject\PhpVersion;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->rule(FirstClassCallableRector::class);
$rectorConfig->rule(ArrayToFirstClassCallableRector::class);

$rectorConfig->phpVersion(PhpVersion::PHP_81);
};

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@

/**
* @see RFC https://wiki.php.net/rfc/first_class_callable_syntax
* @see \Rector\Tests\Php81\Rector\Array_\FirstClassCallableRector\FirstClassCallableRectorTest
* @see \Rector\Tests\Php81\Rector\Array_\ArrayToFirstClassCallableRector\ArrayToFirstClassCallableRectorTest
*/
final class FirstClassCallableRector extends AbstractRector implements MinPhpVersionInterface
final class ArrayToFirstClassCallableRector extends AbstractRector implements MinPhpVersionInterface
{
public function __construct(
private readonly ArrayCallableMethodMatcher $arrayCallableMethodMatcher,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
use Rector\Config\RectorConfig;
use Rector\Php80\Rector\Class_\AnnotationToAttributeRector;
use Rector\Php80\ValueObject\AnnotationToAttribute;
use Rector\Php81\Rector\Array_\FirstClassCallableRector;
use Rector\Php81\Rector\Array_\ArrayToFirstClassCallableRector;

return RectorConfig::configure()
->withConfiguredRule(AnnotationToAttributeRector::class, [
new AnnotationToAttribute('Symfony\Component\Serializer\Annotation\Context'),
])
->withRules([FirstClassCallableRector::class]);
->withRules([ArrayToFirstClassCallableRector::class]);
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\Php81\Rector\Array_\FirstClassCallableRector;
use Rector\Php81\Rector\Array_\ArrayToFirstClassCallableRector;
use Rector\Tests\Issues\AttributeAndArgValueRefresh\Source\SetArrayArgValueRector;
use Rector\Tests\Issues\AttributeAndArgValueRefresh\Source\SetArrayAttributeValueRector;

return RectorConfig::configure()
->withRules([
SetArrayArgValueRector::class,
SetArrayAttributeValueRector::class,
FirstClassCallableRector::class,
ArrayToFirstClassCallableRector::class,
]);