1 | <?php |
||
2 | include_once __DIR__ . '/bootstrap.php'; |
||
3 | use OAuth\Helper\Example; |
||
0 ignored issues
–
show
|
|||
4 | |||
5 | $helper = new Example(); |
||
6 | $requirements = [ |
||
7 | 'PHP 7.2.0' => version_compare(PHP_VERSION, '7.2.0', '>='), |
||
8 | 'PHP extension dom' => extension_loaded('dom'), |
||
9 | 'PHP extension curl' => extension_loaded('curl'), |
||
10 | 'PHP extension json' => extension_loaded('json'), |
||
11 | ]; |
||
12 | require_once 'header.php'; |
||
13 | |||
14 | if (!$helper->isCli()) { |
||
15 | ?> |
||
16 | <div class="jumbotron"> |
||
17 | <p>Welcome to OAuthLib</p> |
||
18 | <p> </p> |
||
19 | <p> |
||
20 | <a class="btn btn-lg btn-primary" href="https://github.com/Lusitanian/PHPoAuthLib" role="button"> |
||
21 | <i class="fa fa-github fa-lg" title="GitHub"></i> Fork us on Github!</a> |
||
22 | </p> |
||
23 | </div> |
||
24 | <?php |
||
25 | echo '<h3>Requirement check</h3>'; |
||
26 | echo '<ul>'; |
||
27 | foreach ($requirements as $label => $result) { |
||
28 | $status = $result ? 'passed' : 'failed'; |
||
29 | echo "<li>{$label} ... <span class='{$status}'>{$status}</span></li>"; |
||
30 | } |
||
31 | echo '</ul>'; ?> |
||
32 | <h2>Select provider for check</h2> |
||
33 | <ul> |
||
34 | <?php |
||
35 | /** @var SplFileInfo $files */ |
||
36 | foreach ($helper->getFinder() as $files) { |
||
37 | $basename = $files->getBasename(); |
||
38 | echo '<li><a href="/provider/' . $basename . '">' . $basename . '</a></li>'; |
||
39 | } ?> |
||
40 | </ul> |
||
41 | |||
42 | <?php |
||
43 | } else { |
||
44 | echo 'Requirement check:' . PHP_EOL; |
||
45 | foreach ($requirements as $label => $result) { |
||
46 | $status = $result ? '32m passed' : '31m failed'; |
||
47 | echo "{$label} ... \033[{$status}\033[0m" . PHP_EOL; |
||
48 | } |
||
49 | } |
||
50 | ?> |
||
51 |
Let?s assume that you have a directory layout like this:
and let?s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: