@@ -38,7 +38,7 @@ class Filesystem
38
38
* @throws FileNotFoundException When originFile doesn't exist
39
39
* @throws IOException When copy fails
40
40
*/
41
- public function copy ($ originFile , $ targetFile , $ overwriteNewerFiles = false )
41
+ public function copy (string $ originFile , string $ targetFile , bool $ overwriteNewerFiles = false )
42
42
{
43
43
$ originIsLocal = stream_is_local ($ originFile ) || 0 === stripos ($ originFile , 'file:// ' );
44
44
if ($ originIsLocal && !is_file ($ originFile )) {
@@ -91,7 +91,7 @@ public function copy($originFile, $targetFile, $overwriteNewerFiles = false)
91
91
*
92
92
* @throws IOException On any directory creation failure
93
93
*/
94
- public function mkdir ($ dirs , $ mode = 0777 )
94
+ public function mkdir ($ dirs , int $ mode = 0777 )
95
95
{
96
96
foreach ($ this ->toIterable ($ dirs ) as $ dir ) {
97
97
if (is_dir ($ dir )) {
@@ -143,7 +143,7 @@ public function exists($files)
143
143
*
144
144
* @throws IOException When touch fails
145
145
*/
146
- public function touch ($ files , $ time = null , $ atime = null )
146
+ public function touch ($ files , int $ time = null , int $ atime = null )
147
147
{
148
148
foreach ($ this ->toIterable ($ files ) as $ file ) {
149
149
$ touch = $ time ? @touch ($ file , $ time , $ atime ) : @touch ($ file );
@@ -196,7 +196,7 @@ public function remove($files)
196
196
*
197
197
* @throws IOException When the change fails
198
198
*/
199
- public function chmod ($ files , $ mode , $ umask = 0000 , $ recursive = false )
199
+ public function chmod ($ files , int $ mode , int $ umask = 0000 , bool $ recursive = false )
200
200
{
201
201
foreach ($ this ->toIterable ($ files ) as $ file ) {
202
202
if (true !== @chmod ($ file , $ mode & ~$ umask )) {
@@ -217,7 +217,7 @@ public function chmod($files, $mode, $umask = 0000, $recursive = false)
217
217
*
218
218
* @throws IOException When the change fails
219
219
*/
220
- public function chown ($ files , $ user , $ recursive = false )
220
+ public function chown ($ files , string $ user , bool $ recursive = false )
221
221
{
222
222
foreach ($ this ->toIterable ($ files ) as $ file ) {
223
223
if ($ recursive && is_dir ($ file ) && !is_link ($ file )) {
@@ -244,7 +244,7 @@ public function chown($files, $user, $recursive = false)
244
244
*
245
245
* @throws IOException When the change fails
246
246
*/
247
- public function chgrp ($ files , $ group , $ recursive = false )
247
+ public function chgrp ($ files , string $ group , bool $ recursive = false )
248
248
{
249
249
foreach ($ this ->toIterable ($ files ) as $ file ) {
250
250
if ($ recursive && is_dir ($ file ) && !is_link ($ file )) {
@@ -272,7 +272,7 @@ public function chgrp($files, $group, $recursive = false)
272
272
* @throws IOException When target file or directory already exists
273
273
* @throws IOException When origin cannot be renamed
274
274
*/
275
- public function rename ($ origin , $ target , $ overwrite = false )
275
+ public function rename (string $ origin , string $ target , bool $ overwrite = false )
276
276
{
277
277
// we check that target does not exist
278
278
if (!$ overwrite && $ this ->isReadable ($ target )) {
@@ -300,7 +300,7 @@ public function rename($origin, $target, $overwrite = false)
300
300
*
301
301
* @throws IOException When windows path is longer than 258 characters
302
302
*/
303
- private function isReadable ($ filename )
303
+ private function isReadable (string $ filename )
304
304
{
305
305
$ maxPathLength = PHP_MAXPATHLEN - 2 ;
306
306
@@ -320,7 +320,7 @@ private function isReadable($filename)
320
320
*
321
321
* @throws IOException When symlink fails
322
322
*/
323
- public function symlink ($ originDir , $ targetDir , $ copyOnWindows = false )
323
+ public function symlink (string $ originDir , string $ targetDir , bool $ copyOnWindows = false )
324
324
{
325
325
if ('\\' === \DIRECTORY_SEPARATOR ) {
326
326
$ originDir = strtr ($ originDir , '/ ' , '\\' );
@@ -356,7 +356,7 @@ public function symlink($originDir, $targetDir, $copyOnWindows = false)
356
356
* @throws FileNotFoundException When original file is missing or not a file
357
357
* @throws IOException When link fails, including if link already exists
358
358
*/
359
- public function hardlink ($ originFile , $ targetFiles )
359
+ public function hardlink (string $ originFile , $ targetFiles )
360
360
{
361
361
if (!$ this ->exists ($ originFile )) {
362
362
throw new FileNotFoundException (null , 0 , null , $ originFile );
@@ -385,7 +385,7 @@ public function hardlink($originFile, $targetFiles)
385
385
* @param string $target
386
386
* @param string $linkType Name of the link type, typically 'symbolic' or 'hard'
387
387
*/
388
- private function linkException ($ origin , $ target , $ linkType )
388
+ private function linkException (string $ origin , string $ target , string $ linkType )
389
389
{
390
390
if (self ::$ lastError ) {
391
391
if ('\\' === \DIRECTORY_SEPARATOR && false !== strpos (self ::$ lastError , 'error code(1314) ' )) {
@@ -411,7 +411,7 @@ private function linkException($origin, $target, $linkType)
411
411
*
412
412
* @return string|null
413
413
*/
414
- public function readlink ($ path , $ canonicalize = false )
414
+ public function readlink (string $ path , bool $ canonicalize = false )
415
415
{
416
416
if (!$ canonicalize && !is_link ($ path )) {
417
417
return ;
@@ -444,7 +444,7 @@ public function readlink($path, $canonicalize = false)
444
444
*
445
445
* @return string Path of target relative to starting path
446
446
*/
447
- public function makePathRelative ($ endPath , $ startPath )
447
+ public function makePathRelative (string $ endPath , string $ startPath )
448
448
{
449
449
if (!$ this ->isAbsolutePath ($ startPath )) {
450
450
throw new InvalidArgumentException (sprintf ('The start path "%s" is not absolute. ' , $ startPath ));
@@ -535,7 +535,7 @@ public function makePathRelative($endPath, $startPath)
535
535
*
536
536
* @throws IOException When file type is unknown
537
537
*/
538
- public function mirror ($ originDir , $ targetDir , \Traversable $ iterator = null , $ options = [])
538
+ public function mirror (string $ originDir , string $ targetDir , \Traversable $ iterator = null , array $ options = [])
539
539
{
540
540
$ targetDir = rtrim ($ targetDir , '/ \\' );
541
541
$ originDir = rtrim ($ originDir , '/ \\' );
@@ -598,7 +598,7 @@ public function mirror($originDir, $targetDir, \Traversable $iterator = null, $o
598
598
*
599
599
* @return bool
600
600
*/
601
- public function isAbsolutePath ($ file )
601
+ public function isAbsolutePath (string $ file )
602
602
{
603
603
return strspn ($ file , '/ \\' , 0 , 1 )
604
604
|| (\strlen ($ file ) > 3 && ctype_alpha ($ file [0 ])
@@ -618,7 +618,7 @@ public function isAbsolutePath($file)
618
618
*
619
619
* @return string The new temporary filename (with path), or throw an exception on failure
620
620
*/
621
- public function tempnam ($ dir , $ prefix )
621
+ public function tempnam (string $ dir , string $ prefix )
622
622
{
623
623
list ($ scheme , $ hierarchy ) = $ this ->getSchemeAndHierarchy ($ dir );
624
624
@@ -669,7 +669,7 @@ public function tempnam($dir, $prefix)
669
669
*
670
670
* @throws IOException if the file cannot be written to
671
671
*/
672
- public function dumpFile ($ filename , $ content )
672
+ public function dumpFile (string $ filename , $ content )
673
673
{
674
674
if (\is_array ($ content )) {
675
675
throw new \TypeError (sprintf ('Argument 2 passed to %s() must be string or resource, %s given. ' , __METHOD__ , $ content ));
@@ -706,7 +706,7 @@ public function dumpFile($filename, $content)
706
706
*
707
707
* @throws IOException If the file is not writable
708
708
*/
709
- public function appendToFile ($ filename , $ content )
709
+ public function appendToFile (string $ filename , $ content )
710
710
{
711
711
if (\is_array ($ content )) {
712
712
throw new \TypeError (sprintf ('Argument 2 passed to %s() must be string or resource, %s given. ' , __METHOD__ , $ content ));
0 commit comments