@@ -24,7 +24,7 @@ class FileSystem
2424 * @return void
2525 * @throws Nette\IOException
2626 */
27- public static function createDir ($ dir , $ mode = 0777 )
27+ public static function createDir (string $ dir , int $ mode = 0777 )
2828 {
2929 if (!is_dir ($ dir ) && !@mkdir ($ dir , $ mode , TRUE ) && !is_dir ($ dir )) { // @ - dir may already exist
3030 throw new Nette \IOException ("Unable to create directory ' $ dir'. " . error_get_last ()['message ' ]);
@@ -37,7 +37,7 @@ public static function createDir($dir, $mode = 0777)
3737 * @return void
3838 * @throws Nette\IOException
3939 */
40- public static function copy ($ source , $ dest , $ overwrite = TRUE )
40+ public static function copy (string $ source , string $ dest , bool $ overwrite = TRUE )
4141 {
4242 if (stream_is_local ($ source ) && !file_exists ($ source )) {
4343 throw new Nette \IOException ("File or directory ' $ source' not found. " );
@@ -72,7 +72,7 @@ public static function copy($source, $dest, $overwrite = TRUE)
7272 * @return void
7373 * @throws Nette\IOException
7474 */
75- public static function delete ($ path )
75+ public static function delete (string $ path )
7676 {
7777 if (is_file ($ path ) || is_link ($ path )) {
7878 $ func = DIRECTORY_SEPARATOR === '\\' && is_dir ($ path ) ? 'rmdir ' : 'unlink ' ;
@@ -97,7 +97,7 @@ public static function delete($path)
9797 * @throws Nette\IOException
9898 * @throws Nette\InvalidStateException if the target file or directory already exist
9999 */
100- public static function rename ($ name , $ newName , $ overwrite = TRUE )
100+ public static function rename (string $ name , string $ newName , bool $ overwrite = TRUE )
101101 {
102102 if (!$ overwrite && file_exists ($ newName )) {
103103 throw new Nette \InvalidStateException ("File or directory ' $ newName' already exists. " );
@@ -120,7 +120,7 @@ public static function rename($name, $newName, $overwrite = TRUE)
120120 * @return string
121121 * @throws Nette\IOException
122122 */
123- public static function read ($ file )
123+ public static function read (string $ file ): string
124124 {
125125 $ content = @file_get_contents ($ file ); // @ is escalated to exception
126126 if ($ content === FALSE ) {
@@ -135,7 +135,7 @@ public static function read($file)
135135 * @return void
136136 * @throws Nette\IOException
137137 */
138- public static function write ($ file , $ content , $ mode = 0666 )
138+ public static function write (string $ file , string $ content , int $ mode = 0666 )
139139 {
140140 static ::createDir (dirname ($ file ));
141141 if (@file_put_contents ($ file , $ content ) === FALSE ) { // @ is escalated to exception
@@ -151,7 +151,7 @@ public static function write($file, $content, $mode = 0666)
151151 * Is path absolute?
152152 * @return bool
153153 */
154- public static function isAbsolute ($ path )
154+ public static function isAbsolute (string $ path ): bool
155155 {
156156 return (bool ) preg_match ('#([a-z]:)?[/ \\\\]|[a-z][a-z0-9+.-]*://#Ai ' , $ path );
157157 }
0 commit comments