1 | <?php |
||
19 | class VersionUpdateStrategy implements StrategyInterface |
||
20 | { |
||
21 | |||
22 | const UPDATE_SERVER_URL = 'https://svn-buddy-updater.herokuapp.com'; |
||
23 | |||
24 | /** |
||
25 | * Stability. |
||
26 | * |
||
27 | * @var string |
||
28 | */ |
||
29 | protected $stability = Stability::STABLE; |
||
30 | |||
31 | /** |
||
32 | * Local version. |
||
33 | * |
||
34 | * @var string |
||
35 | */ |
||
36 | protected $localVersion; |
||
37 | |||
38 | /** |
||
39 | * Url, from where remote version can be downloaded. |
||
40 | * |
||
41 | * @var string |
||
42 | */ |
||
43 | protected $remoteUrl; |
||
44 | |||
45 | /** |
||
46 | * Sets stability. |
||
47 | * |
||
48 | * @param string $stability Stability. |
||
49 | * |
||
50 | * @return void |
||
51 | */ |
||
52 | public function setStability($stability) |
||
56 | |||
57 | /** |
||
58 | * Set version string of the local phar |
||
59 | * |
||
60 | * @param string $version Version. |
||
61 | * |
||
62 | * @return void |
||
63 | */ |
||
64 | public function setCurrentLocalVersion($version) |
||
68 | |||
69 | /** |
||
70 | * Download the remote Phar file. |
||
71 | * |
||
72 | * @param Updater $updater Updater. |
||
73 | * |
||
74 | * @return void |
||
75 | * @throws \LogicException When there is nothing to download. |
||
76 | */ |
||
77 | public function download(Updater $updater) |
||
85 | |||
86 | /** |
||
87 | * Retrieve the current version available remotely. |
||
88 | * |
||
89 | * @param Updater $updater Updater. |
||
90 | * |
||
91 | * @return string |
||
92 | * @throws \LogicException When update channel doesn't exist. |
||
93 | */ |
||
94 | public function getCurrentRemoteVersion(Updater $updater) |
||
110 | |||
111 | /** |
||
112 | * Retrieve the current version of the local phar file. |
||
113 | * |
||
114 | * @param Updater $updater Updater. |
||
115 | * |
||
116 | * @return string |
||
117 | */ |
||
118 | public function getCurrentLocalVersion(Updater $updater) |
||
122 | |||
123 | /** |
||
124 | * Downloads file securely. |
||
125 | * |
||
126 | * @param string $url Url. |
||
127 | * |
||
128 | * @return string |
||
129 | * @throws HttpRequestException When failed to download a file. |
||
130 | */ |
||
131 | protected function downloadFile($url) |
||
143 | |||
144 | } |
||
145 |
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: