@@ -42,7 +42,7 @@ class File
4242 *
4343 * Current file absolute path
4444 */
45- public ? string $ path = null ;
45+ public string | null $ path = null ;
4646
4747 /**
4848 * Constructor
@@ -62,7 +62,7 @@ public function __construct(string $path)
6262 *
6363 * @return int|bool Returns the number of bytes that were written to the file, or FALSE on failure.
6464 */
65- public function put (string $ data , bool $ lock = false )
65+ public function put (string $ data , bool $ lock = false ): int | bool
6666 {
6767 return file_put_contents ($ this ->path , $ data , $ lock ? LOCK_EX : 0 );
6868 }
@@ -72,9 +72,9 @@ public function put(string $data, bool $lock = false)
7272 *
7373 * @param bool $lock Acquire an exclusive lock on the file while proceeding to the reading.
7474 *
75- * @return string|false The file contents or false on failure.
75+ * @return string|bool The file contents or false on failure.
7676 */
77- public function get ($ lock = false )
77+ public function get ($ lock = false ): string | bool
7878 {
7979 if ($ this ->isFile ($ this ->path )) {
8080 $ contents = $ lock ? $ this ->sharedGet () : file_get_contents ($ this ->path );
@@ -90,9 +90,9 @@ public function get($lock = false)
9090 /**
9191 * Get contents of a file with shared access.
9292 *
93- * @return string|false The file contents or false on failure.
93+ * @return string|bool The file contents or false on failure.
9494 */
95- public function sharedGet ()
95+ public function sharedGet (): string | bool
9696 {
9797 $ contents = false ;
9898
@@ -142,7 +142,7 @@ public function isEqual(string $file): bool
142142 *
143143 * @return int|bool Returns the number of bytes that were written to the file, or FALSE on failure.
144144 */
145- public function prepend (string $ data )
145+ public function prepend (string $ data ): int | bool
146146 {
147147 if ($ this ->exists ($ this ->path )) {
148148 return $ this ->put ($ data . $ this ->get ($ this ->path ));
@@ -158,7 +158,7 @@ public function prepend(string $data)
158158 *
159159 * @return int|bool Returns the number of bytes that were written to the file, or FALSE on failure.
160160 */
161- public function append (string $ data )
161+ public function append (string $ data ): int | bool
162162 {
163163 return file_put_contents ($ this ->path , $ data , FILE_APPEND );
164164 }
@@ -287,7 +287,7 @@ public function name(): string
287287 *
288288 * @return string|null Current path
289289 */
290- public function path (): ? string
290+ public function path (): string | null
291291 {
292292 return $ this ->path ;
293293 }
@@ -387,7 +387,7 @@ public function isFile(): bool
387387 *
388388 * @return mixed
389389 */
390- public function chmod (? int $ mode = null )
390+ public function chmod (int | null $ mode = null )
391391 {
392392 if ($ mode ) {
393393 return chmod ($ this ->path , $ mode );
0 commit comments