1 | <?php |
||
22 | final class File extends \SplFileInfo |
||
23 | { |
||
24 | /** @var string The path relative to the site's working directory. */ |
||
25 | private $relativePath; |
||
26 | |||
27 | /** @var string The original raw path given to the constructor. */ |
||
28 | private $rawPath; |
||
29 | |||
30 | /** |
||
31 | * File Constructor. |
||
32 | * |
||
33 | * @param string $filePath an absolute file path or a path relative to the current working directory |
||
34 | * |
||
35 | * @since 0.2.0 |
||
36 | * |
||
37 | * @throws FileNotFoundException |
||
38 | */ |
||
39 | 178 | public function __construct($filePath) |
|
55 | |||
56 | /** |
||
57 | * Get a new File object for another file relative to this file. |
||
58 | * |
||
59 | * @param string $path |
||
60 | * |
||
61 | * @return File |
||
62 | */ |
||
63 | 11 | public function createFileForRelativePath($path) |
|
67 | |||
68 | /** |
||
69 | * Whether or not this file exists on the filesystem. |
||
70 | * |
||
71 | * @return bool |
||
72 | */ |
||
73 | 158 | public function exists() |
|
77 | |||
78 | /** |
||
79 | * Get the name of the file without an extension. |
||
80 | * |
||
81 | * @param null $suffix this value will be discarded and is only needed to be able to override the \SplFileInfo |
||
82 | * definition |
||
83 | * |
||
84 | * @since 0.2.0 |
||
85 | * |
||
86 | * @return string |
||
87 | */ |
||
88 | 97 | public function getBasename($suffix = null) |
|
92 | |||
93 | /** |
||
94 | * Get the name of the with the extension. |
||
95 | * |
||
96 | * @since 0.2.0 |
||
97 | * |
||
98 | * @return string |
||
99 | */ |
||
100 | 100 | public function getFilename() |
|
104 | |||
105 | /** |
||
106 | * Get the absolute path to this file. |
||
107 | * |
||
108 | * @since 0.2.0 |
||
109 | * |
||
110 | * @return string |
||
111 | */ |
||
112 | 176 | public function getAbsolutePath() |
|
116 | |||
117 | /** |
||
118 | * Get the path to the parent folder of this file. |
||
119 | * |
||
120 | * @since 0.2.0 |
||
121 | * |
||
122 | * @return string |
||
123 | */ |
||
124 | 1 | public function getParentFolder() |
|
128 | |||
129 | /** |
||
130 | * Get the file path to this file, relative to where it was created; likely the current working directory. |
||
131 | * |
||
132 | * @since 0.2.0 |
||
133 | * |
||
134 | * @return string |
||
135 | */ |
||
136 | 149 | public function getRelativeFilePath() |
|
140 | |||
141 | /** |
||
142 | * Get the path to the parent folder this file, relative to where it was created; likely the current working directory. |
||
143 | * |
||
144 | * @since 0.2.0 |
||
145 | * |
||
146 | * @return string |
||
147 | */ |
||
148 | 2 | public function getRelativeParentFolder() |
|
152 | |||
153 | /** |
||
154 | * Gets the last modified time. |
||
155 | * |
||
156 | * @return int The last modified time for the file, in a Unix timestamp |
||
157 | */ |
||
158 | public function getLastModified() |
||
162 | |||
163 | /** |
||
164 | * Get the contents of this file. |
||
165 | * |
||
166 | * @since 0.2.0 |
||
167 | * |
||
168 | * @throws \RuntimeException when the file could not be read |
||
169 | * |
||
170 | * @return string |
||
171 | */ |
||
172 | 157 | public function getContents() |
|
189 | |||
190 | /** |
||
191 | * Check if a file is safe to read. |
||
192 | * |
||
193 | * @throws FileNotFoundException |
||
194 | */ |
||
195 | 176 | private function isSafeToRead() |
|
207 | |||
208 | 4 | private function buildNotFoundException() |
|
217 | |||
218 | } |
||
219 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: