File tree Expand file tree Collapse file tree 6 files changed +26
-25
lines changed Expand file tree Collapse file tree 6 files changed +26
-25
lines changed Original file line number Diff line number Diff line change @@ -88,15 +88,15 @@ e2e_013: bin/php-scoper.phar
8888 diff src/scoper.inc.php.tpl build/set013/scoper.inc.php
8989
9090.PHONY : e2e_014
91- e2e_014 : # # Run end-to-end tests for the fixture set 014: source code case with psr -0
91+ e2e_014 : # # Run end-to-end tests for the fixture set 014: source code case with PSR -0
9292e2e_014 : bin/php-scoper.phar
9393 $(PHPNOGC ) $(BOX ) compile --working-dir fixtures/set014
9494
9595 php build/set014/bin/greet.phar > build/set014/output
9696 diff fixtures/set014/expected-output build/set014/output
9797
9898.PHONY : e2e_015
99- e2e_015 : # # Run end-to-end tests for the fixture set 015: third-party code case with psr -0
99+ e2e_015 : # # Run end-to-end tests for the fixture set 015: third-party code case with PSR -0
100100e2e_015 : bin/php-scoper.phar fixtures/set015/vendor
101101 $(PHPNOGC ) $(BOX ) compile --working-dir fixtures/set015
102102
Original file line number Diff line number Diff line change 1212 * file that was distributed with this source code.
1313 */
1414
15- use Isolated \Symfony \Component \Finder \Finder ;
16-
1715return [
18- 'finders ' => [
19- (new Finder ())
20- ->files ()
21- ->in (__DIR__ )
22- ->exclude ('tests ' )
23- ->notPath ('scoper.inc.php ' )
24- ],
2516 'whitelist ' => [
2617 \Set011 \Dictionary::class,
2718 ],
Original file line number Diff line number Diff line change 44
55namespace Set011 ;
66
7- abstract class Dictionary
7+ interface Dictionary
88{
99 /**
1010 * @return string[]
1111 */
12- abstract public function provideWords (): array ;
12+ public function provideWords (): array ;
1313}
Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ function ($filePath): bool {
4848 function (array $ dictionaries , string $ className ): array {
4949 $ class = new ReflectionClass ($ className );
5050
51- if (false === $ class ->isAbstract () && $ class ->isSubclassOf (Dictionary::class)) {
51+ if (false === $ class ->isAbstract () && $ class ->implementsInterface (Dictionary::class)) {
5252 $ dictionaries [] = $ class ->newInstanceWithoutConstructor ();
5353 }
5454
Original file line number Diff line number Diff line change 44
55namespace Set011 ;
66
7- final class SalutationDictionary extends Dictionary
7+ final class SalutationDictionary implements Dictionary
88{
99 /**
1010 * @inheritdoc
Original file line number Diff line number Diff line change 1414
1515namespace Humbug \PhpScoper \Autoload ;
1616
17+ use function array_map ;
18+
1719final class ScoperAutoloadGenerator
1820{
1921 private $ whitelist ;
@@ -28,16 +30,7 @@ public function __construct(array $whitelist)
2830
2931 public function dump (string $ prefix ): string
3032 {
31- $ statements = array_map (
32- function (string $ whitelist ) use ($ prefix ): string {
33- return sprintf (
34- 'class_exists( \'%s\%s \'); ' ,
35- $ prefix ,
36- $ whitelist
37- );
38- },
39- $ this ->whitelist
40- );
33+ $ statements = $ this ->createStatements ($ prefix );
4134
4235 $ statements = implode (PHP_EOL , $ statements );
4336
@@ -54,4 +47,21 @@ function (string $whitelist) use ($prefix): string {
5447
5548PHP ;
5649 }
50+
51+ /**
52+ * @return string[]
53+ */
54+ public function createStatements (string $ prefix ): array
55+ {
56+ return array_map (
57+ function (string $ whitelistedElement ) use ($ prefix ): string {
58+ return sprintf (
59+ 'class_exists( \'%s\%s \'); ' ,
60+ $ prefix ,
61+ $ whitelistedElement
62+ );
63+ },
64+ $ this ->whitelist
65+ );
66+ }
5767}
You can’t perform that action at this time.
0 commit comments