1 | <?php |
||
29 | class Openstack extends Sync |
||
30 | { |
||
31 | use Clearable; |
||
32 | |||
33 | /** |
||
34 | * OpenStack identify url |
||
35 | * |
||
36 | * @var string |
||
37 | */ |
||
38 | protected $authUrl; |
||
39 | |||
40 | /** |
||
41 | * OpenStack region |
||
42 | * |
||
43 | * @var string |
||
44 | */ |
||
45 | protected $region; |
||
46 | |||
47 | /** |
||
48 | * @var string |
||
49 | */ |
||
50 | protected $username; |
||
51 | |||
52 | /** |
||
53 | * @var string |
||
54 | */ |
||
55 | protected $password; |
||
56 | |||
57 | /** |
||
58 | * Object Store container name |
||
59 | * |
||
60 | * @var string |
||
61 | */ |
||
62 | protected $containerName; |
||
63 | |||
64 | /** |
||
65 | * OpenStack service name |
||
66 | * |
||
67 | * @var string |
||
68 | */ |
||
69 | protected $serviceName; |
||
70 | |||
71 | /** |
||
72 | * Max stream upload size, files over this size have to be uploaded as Dynamic Large Objects |
||
73 | * |
||
74 | * @var int |
||
75 | */ |
||
76 | protected $maxStreamUploadSize = 5368709120; |
||
77 | |||
78 | /** |
||
79 | * Path where to copy the backup. |
||
80 | * |
||
81 | * @var string |
||
82 | */ |
||
83 | protected $path = ''; |
||
84 | |||
85 | /** |
||
86 | * @var Container |
||
87 | */ |
||
88 | protected $container; |
||
89 | |||
90 | /** |
||
91 | * @return string |
||
92 | */ |
||
93 | public function getPath(): string |
||
97 | |||
98 | /** |
||
99 | * (non-PHPDoc) |
||
100 | * |
||
101 | * @see \phpbu\App\Backup\Sync::setup() |
||
102 | * @param array $config |
||
103 | * @throws \phpbu\App\Backup\Sync\Exception |
||
104 | * @throws \phpbu\App\Exception |
||
105 | */ |
||
106 | 9 | public function setup(array $config) |
|
128 | |||
129 | /** |
||
130 | * Execute the sync. |
||
131 | * |
||
132 | * @see \phpbu\App\Backup\Sync::sync() |
||
133 | * @param \phpbu\App\Backup\Target $target |
||
134 | * @param \phpbu\App\Result $result |
||
135 | * @throws \phpbu\App\Backup\Sync\Exception |
||
136 | * @throws \OpenStack\Common\Error\BadResponseError |
||
137 | */ |
||
138 | public function sync(Target $target, Result $result) |
||
167 | |||
168 | /** |
||
169 | * Simulate the sync execution. |
||
170 | * |
||
171 | * @param \phpbu\App\Backup\Target $target |
||
172 | * @param \phpbu\App\Result $result |
||
173 | */ |
||
174 | 1 | public function simulate(Target $target, Result $result) |
|
187 | |||
188 | /** |
||
189 | * Creates collector for OpenStack |
||
190 | * |
||
191 | * @param \phpbu\App\Backup\Target $target |
||
192 | * @return \phpbu\App\Backup\Collector |
||
193 | */ |
||
194 | protected function createCollector(Target $target): Collector |
||
198 | |||
199 | /** |
||
200 | * @param ObjectStoreService $service |
||
201 | * @param Result $result |
||
202 | * @return \OpenStack\ObjectStore\v1\Models\Container |
||
203 | * @throws \OpenStack\Common\Error\BadResponseError |
||
204 | */ |
||
205 | protected function getOrCreateContainer(ObjectStoreService $service, Result $result) |
||
213 | |||
214 | /** |
||
215 | * Get the upload path |
||
216 | * |
||
217 | * @param \phpbu\App\Backup\Target $target |
||
218 | * @return string |
||
219 | */ |
||
220 | 2 | public function getUploadPath(Target $target) |
|
224 | |||
225 | /** |
||
226 | * @param Result $result |
||
227 | * @return void |
||
228 | * @throws \OpenStack\Common\Error\BadResponseError |
||
229 | */ |
||
230 | protected function connect(Result $result) |
||
249 | } |
||
250 |
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: