Skip to content

Commit

Permalink
Forbid _HumbugBox prefixed classes
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm authored and ondrejmirtes committed Jun 25, 2024
1 parent 3233155 commit 752e8d9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
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
{}

0 comments on commit 752e8d9

Please sign in to comment.