Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forbid _HumbugBox prefixed classes #3186

Merged
merged 1 commit into from
Jun 25, 2024
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
1 change: 1 addition & 0 deletions src/Rules/ClassForbiddenNameCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class ClassForbiddenNameCheck
'Rector' => 'RectorPrefix',
'PHP-Scoper' => '_PhpScoper',
'PHPUnit' => 'PHPUnitPHAR',
'Box' => '_HumbugBox',
];

public function __construct(private Container $container)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ public function testPhpstanInternalClass(): void
62,
'This is most likely unintentional. Did you mean to type \SebastianBergmann\Diff\Exception?',
],
[
'Referencing prefixed Box class: _HumbugBox02f3b3909847\AClass.',
73,
$tip,
],
]);
}

Expand Down
10 changes: 10 additions & 0 deletions tests/PHPStan/Rules/Classes/data/phpstan-internal-class.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,13 @@ class Baz extends \_PhpScoper19ae93be897e\AClass
class BazBar extends \PHPUnitPHAR\SebastianBergmann\Diff\Exception
{}

namespace _HumbugBox02f3b3909847; // mimicks a prefixed class, as generated by Box

class AClass {
const Test = 1;
}

namespace TestHumbugInternalClass;

class FooBar extends \_HumbugBox02f3b3909847\AClass
{}
Loading