1 | <?php |
||
10 | class SitemapIndex implements Responsable |
||
11 | { |
||
12 | /** @var array */ |
||
13 | protected $tags = []; |
||
14 | |||
15 | /** |
||
16 | * @return static |
||
17 | */ |
||
18 | public static function create() |
||
22 | |||
23 | /** |
||
24 | * @param string|\Spatie\Sitemap\Tags\Tag $tag |
||
25 | * |
||
26 | * @return $this |
||
27 | */ |
||
28 | public function add($tag) |
||
38 | |||
39 | /** |
||
40 | * Get sitemap tag. |
||
41 | * |
||
42 | * @param string $url |
||
43 | * |
||
44 | * @return \Spatie\Sitemap\Tags\Sitemap|null |
||
45 | */ |
||
46 | public function getSitemap(string $url) |
||
52 | |||
53 | /** |
||
54 | * Check if there is the provided sitemap in the index. |
||
55 | * |
||
56 | * @param string $url |
||
57 | * |
||
58 | * @return bool |
||
59 | */ |
||
60 | public function hasSitemap(string $url): bool |
||
64 | |||
65 | /** |
||
66 | * Get the inflated template content. |
||
67 | * |
||
68 | * @return string |
||
69 | */ |
||
70 | public function render(): string |
||
78 | |||
79 | /** |
||
80 | * @param string $path |
||
81 | * |
||
82 | * @return $this |
||
83 | */ |
||
84 | public function writeToFile(string $path) |
||
90 | |||
91 | /** |
||
92 | * Create an HTTP response that represents the object. |
||
93 | * |
||
94 | * @param \Illuminate\Http\Request $request |
||
95 | * @return \Symfony\Component\HttpFoundation\Response |
||
96 | */ |
||
97 | public function toResponse($request) |
||
103 | } |
||
104 |
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: