1 | <?php |
||
27 | class ProxyLookup { |
||
28 | |||
29 | /** |
||
30 | * @var string[] |
||
31 | */ |
||
32 | private $proxyServers; |
||
33 | |||
34 | /** |
||
35 | * @var string[] |
||
36 | */ |
||
37 | private $proxyServersComplex; |
||
38 | |||
39 | /** |
||
40 | * @var IPSet|null |
||
41 | */ |
||
42 | private $proxyIPSet; |
||
43 | |||
44 | /** |
||
45 | * @param string[] $proxyServers Simple list of IPs |
||
46 | * @param string[] $proxyServersComplex Complex list of IPs/ranges |
||
47 | */ |
||
48 | public function __construct( $proxyServers, $proxyServersComplex ) { |
||
52 | |||
53 | /** |
||
54 | * Checks if an IP matches a proxy we've configured |
||
55 | * |
||
56 | * @param string $ip |
||
57 | * @return bool |
||
58 | */ |
||
59 | public function isConfiguredProxy( $ip ) { |
||
71 | |||
72 | /** |
||
73 | * Checks if an IP is a trusted proxy provider. |
||
74 | * Useful to tell if X-Forwarded-For data is possibly bogus. |
||
75 | * CDN cache servers for the site are whitelisted. |
||
76 | * |
||
77 | * @param string $ip |
||
78 | * @return bool |
||
79 | */ |
||
80 | public function isTrustedProxy( $ip ) { |
||
85 | } |
||
86 |
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: