Skip to content

Commit 752e8d9

Browse files
staabmondrejmirtes
authored andcommitted
Forbid _HumbugBox prefixed classes
1 parent 3233155 commit 752e8d9

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

src/Rules/ClassForbiddenNameCheck.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class ClassForbiddenNameCheck
2020
'Rector' => 'RectorPrefix',
2121
'PHP-Scoper' => '_PhpScoper',
2222
'PHPUnit' => 'PHPUnitPHAR',
23+
'Box' => '_HumbugBox',
2324
];
2425

2526
public function __construct(private Container $container)

tests/PHPStan/Rules/Classes/ExistingClassInClassExtendsRuleTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@ public function testPhpstanInternalClass(): void
121121
62,
122122
'This is most likely unintentional. Did you mean to type \SebastianBergmann\Diff\Exception?',
123123
],
124+
[
125+
'Referencing prefixed Box class: _HumbugBox02f3b3909847\AClass.',
126+
73,
127+
$tip,
128+
],
124129
]);
125130
}
126131

tests/PHPStan/Rules/Classes/data/phpstan-internal-class.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,13 @@ class Baz extends \_PhpScoper19ae93be897e\AClass
6262
class BazBar extends \PHPUnitPHAR\SebastianBergmann\Diff\Exception
6363
{}
6464

65+
namespace _HumbugBox02f3b3909847; // mimicks a prefixed class, as generated by Box
66+
67+
class AClass {
68+
const Test = 1;
69+
}
70+
71+
namespace TestHumbugInternalClass;
72+
73+
class FooBar extends \_HumbugBox02f3b3909847\AClass
74+
{}

0 commit comments

Comments
 (0)