Skip to content
Open
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

require __DIR__ . '/../Source/src/SomeClass.php';

$someClass = new \App\SomeClass();

?>
-----
<?php

$someClass = new \App\SomeClass();

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

$result = require __DIR__ . '/../Source/src/SomeClass.php';

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

require __DIR__ . '/../Source/src/ClassWithFunction.php';

$classWithFunction = new \App\ClassWithFunction();

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

require __DIR__ . '/../Source/src/ClassWithInit.php';

$classWithInit = new \App\ClassWithInit();

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

require __DIR__ . '/../Source/src/TwoClasses.php';

$twoClasses = new \App\TwoClasses();

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

require __DIR__ . '/../Source/outside/LooseClass.php';

$looseClass = new \Outside\LooseClass();

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

declare(strict_types=1);

namespace Rector\Tests\DeadCode\Rector\Expression\RemovePsr4AutoloadedIncludeRector;

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

final class RemovePsr4AutoloadedIncludeRectorTest extends AbstractRectorTestCase
{
#[DataProvider('provideData')]
public function test(string $filePath): void
{
$this->doTestFile($filePath);
}

public static function provideData(): Iterator
{
return self::yieldFilesFromDirectory(__DIR__ . '/Fixture');
}

public function provideConfigFilePath(): string
{
return __DIR__ . '/config/configured_rule.php';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"autoload": {
"psr-4": {
"App\\": "src"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

declare(strict_types=1);

namespace Outside;

final class LooseClass
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

declare(strict_types=1);

namespace App;

final class ClassWithFunction
{
}

function some_helper(): void
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

namespace App;

final class ClassWithInit
{
public static function init(): void
{
}
}

ClassWithInit::init();
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

declare(strict_types=1);

namespace App;

final class SomeClass
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

declare(strict_types=1);

namespace App;

final class TwoClasses
{
}

final class SecondClass
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\DeadCode\Rector\Expression\RemovePsr4AutoloadedIncludeRector;

return RectorConfig::configure()
->withConfiguredRule(RemovePsr4AutoloadedIncludeRector::class, [
RemovePsr4AutoloadedIncludeRector::COMPOSER_JSON_PATH => __DIR__ . '/../Source/composer.json',
]);
Loading