File tree Expand file tree Collapse file tree 5 files changed +17
-12
lines changed Expand file tree Collapse file tree 5 files changed +17
-12
lines changed Original file line number Diff line number Diff line change @@ -288,6 +288,9 @@ The class aliasing mechanism is done like follows:
288288 which will ensure the ` class_alias() ` statement is executed
289289
290290It is done this way to ensure prefixed and whitelisted classes can co-exist together without breaking the autoloading.
291+ The ` class_exists() ` statements are dumped in ` vendor/scoper-autoload.php ` , do not forget to include this file in favour
292+ of ` vendor/autoload.php ` . This part is however sorted out by [ Box] [ box ] if you are using it with the
293+ [ ` PhpScoper ` compactor] [ php-scoper-integration ] .
291294
292295The constant aliasing mechanism is done by transforming the constant declaration into a ` define() ` statement when this
293296is not already the case. Note that there is a difference here since ` define() ` defines a constant at runtime whereas
Original file line number Diff line number Diff line change 1414
1515namespace Humbug \PhpScoper \Autoload ;
1616
17+ use Humbug \PhpScoper \Whitelist ;
1718use function array_map ;
1819
1920final class ScoperAutoloadGenerator
2021{
2122 private $ whitelist ;
2223
23- /**
24- * @param string[] $whitelist
25- */
26- public function __construct (array $ whitelist )
24+ public function __construct (Whitelist $ whitelist )
2725 {
2826 $ this ->whitelist = $ whitelist ;
2927 }
@@ -61,7 +59,7 @@ function (string $whitelistedElement) use ($prefix): string {
6159 $ whitelistedElement
6260 );
6361 },
64- $ this ->whitelist
62+ $ this ->whitelist -> getClassWhitelistArray ()
6563 );
6664 }
6765}
Original file line number Diff line number Diff line change @@ -79,6 +79,14 @@ public function isClassWhitelisted(string $name): bool
7979 return in_array ($ name , $ this ->classes , true );
8080 }
8181
82+ /**
83+ * @return string[]
84+ */
85+ public function getClassWhitelistArray (): array
86+ {
87+ return $ this ->classes ;
88+ }
89+
8290 public function isNamespaceWhitelisted (string $ name ): bool
8391 {
8492 foreach ($ this ->namespaces as $ namespace ) {
Original file line number Diff line number Diff line change 1414
1515namespace Humbug \PhpScoper \Autoload ;
1616
17+ use Humbug \PhpScoper \Whitelist ;
1718use PHPUnit \Framework \TestCase ;
1819
1920class ScoperAutoloadGeneratorTest extends TestCase
2021{
2122 public function test_generate_the_autoload ()
2223 {
23- $ whitelist = [
24- 'A\Foo ' ,
25- 'B\Bar ' ,
26- ];
24+ $ whitelist = Whitelist::create ('A\Foo ' , 'B\Bar ' );
2725
2826 $ prefix = 'Humbug ' ;
2927
Original file line number Diff line number Diff line change @@ -34,9 +34,7 @@ public function test_it_can_be_created_from_a_list_of_strings(
3434
3535 $ whitelistReflection = new ReflectionClass (Whitelist::class);
3636
37- $ whitelistClassReflection = $ whitelistReflection ->getProperty ('classes ' );
38- $ whitelistClassReflection ->setAccessible (true );
39- $ actualClasses = $ whitelistClassReflection ->getValue ($ whitelistObject );
37+ $ actualClasses = $ whitelistObject ->getClassWhitelistArray ();
4038
4139 $ whitelistNamespaceReflection = $ whitelistReflection ->getProperty ('namespaces ' );
4240 $ whitelistNamespaceReflection ->setAccessible (true );
You can’t perform that action at this time.
0 commit comments