Complex classes like Filesystem often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Filesystem, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 11 | class Filesystem |
||
| 12 | { |
||
| 13 | /** |
||
| 14 | * Returns trailing name component of path |
||
| 15 | * |
||
| 16 | * @param string $path A path. |
||
| 17 | * @param string $suffix If the name component ends in suffix this will also |
||
| 18 | * be cut off. |
||
| 19 | * |
||
| 20 | * @return string |
||
| 21 | */ |
||
| 22 | public function basename(string $path, string $suffix = null) : string |
||
| 26 | |||
| 27 | /** |
||
| 28 | * Changes file group |
||
| 29 | * |
||
| 30 | * @param string $filename Path to the file. |
||
| 31 | * @param mixed $group A group name or number. |
||
| 32 | * |
||
| 33 | * @return bool |
||
| 34 | */ |
||
| 35 | public function chgrp(string $filename, $group) : bool |
||
| 39 | |||
| 40 | /** |
||
| 41 | * Changes file mode |
||
| 42 | * |
||
| 43 | * @param string $filename Path to the file. |
||
| 44 | * @param int $mode Note that mode is not automatically |
||
| 45 | * assumed to be an octal value, so to ensure the expected operation, |
||
| 46 | * you need to prefix mode with a zero (0). |
||
| 47 | * Strings such as "g+w" will not work properly. |
||
| 48 | * |
||
| 49 | * @return bool |
||
| 50 | */ |
||
| 51 | public function chmod(string $filename, int $mode) : bool |
||
| 55 | |||
| 56 | /** |
||
| 57 | * Changes file owner |
||
| 58 | * |
||
| 59 | * @param string $filename Path to the file. |
||
| 60 | * @param mixed $user A user name or number. |
||
| 61 | * |
||
| 62 | * @return bool |
||
| 63 | */ |
||
| 64 | public function chown(string $filename, $user) : bool |
||
| 68 | |||
| 69 | /** |
||
| 70 | * Clears file status cache |
||
| 71 | * |
||
| 72 | * @param bool $clearRealpathCache Whether to clear the realpath cache or not. |
||
| 73 | * @param string $filename Clear the realpath and the stat cache for a specific filename only; only |
||
| 74 | * used if $clearRealpathCache is . |
||
| 75 | * |
||
| 76 | * @return void |
||
| 77 | */ |
||
| 78 | public function clearStatCache(bool $clearRealpathCache = null, string $filename = null) |
||
| 82 | |||
| 83 | /** |
||
| 84 | * Copies file |
||
| 85 | * |
||
| 86 | * @param string $source Path to the source file. |
||
| 87 | * @param string $dest The destination path. If dest is a URL, the |
||
| 88 | * copy operation may fail if the wrapper does not support overwriting of |
||
| 89 | * existing files. |
||
| 90 | * @param resource $context A valid context resource created with |
||
| 91 | * stream_context_create. |
||
| 92 | * |
||
| 93 | * @return bool |
||
| 94 | */ |
||
| 95 | public function copy(string $source, string $dest, $context = null) : bool |
||
| 99 | |||
| 100 | /** |
||
| 101 | * Returns a parent directory's path |
||
| 102 | * |
||
| 103 | * @param string $path A path. |
||
| 104 | * @param int $levels The number of parent directories to go up. |
||
| 105 | * |
||
| 106 | * @return string |
||
| 107 | */ |
||
| 108 | public function dirName(string $path, int $levels = null) : string |
||
| 112 | |||
| 113 | /** |
||
| 114 | * Returns available space on filesystem or disk partition |
||
| 115 | * |
||
| 116 | * @param string $directory A directory of the filesystem or disk partition. |
||
| 117 | * |
||
| 118 | * @return float |
||
| 119 | */ |
||
| 120 | public function diskFreeSpace(string $directory) : float |
||
| 124 | |||
| 125 | /** |
||
| 126 | * Returns the total size of a filesystem or disk partition |
||
| 127 | * |
||
| 128 | * @param string $directory A directory of the filesystem or disk partition. |
||
| 129 | * |
||
| 130 | * @return float |
||
| 131 | */ |
||
| 132 | public function diskTotalSpace(string $directory) : float |
||
| 136 | |||
| 137 | /** |
||
| 138 | * Closes an open file pointer |
||
| 139 | * |
||
| 140 | * @param resource $handle The file pointer must be valid, and must point to a file successfully |
||
| 141 | * opened by fopen or fsockopen. |
||
| 142 | * |
||
| 143 | * @return bool |
||
| 144 | */ |
||
| 145 | public function fclose($handle) : bool |
||
| 149 | |||
| 150 | /** |
||
| 151 | * Tests for end-of-file on a file pointer |
||
| 152 | * |
||
| 153 | * @param resource $handle |
||
| 154 | * |
||
| 155 | * @return bool |
||
| 156 | */ |
||
| 157 | public function feof($handle) : bool |
||
| 161 | |||
| 162 | /** |
||
| 163 | * Flushes the output to a file |
||
| 164 | * |
||
| 165 | * @param resource $handle |
||
| 166 | * |
||
| 167 | * @return bool |
||
| 168 | */ |
||
| 169 | public function fflush($handle) : bool |
||
| 173 | |||
| 174 | /** |
||
| 175 | * Gets character from file pointer |
||
| 176 | * |
||
| 177 | * @param resource $handle |
||
| 178 | * |
||
| 179 | * @return string |
||
| 180 | */ |
||
| 181 | public function fgetc($handle) : string |
||
| 185 | |||
| 186 | /** |
||
| 187 | * Gets line from file pointer and parse for CSV fields |
||
| 188 | * |
||
| 189 | * @param resource $handle A valid file pointer to a file successfully opened by |
||
| 190 | * fopen, popen, or |
||
| 191 | * fsockopen. |
||
| 192 | * @param int $length Must be greater than the longest line (in characters) to be found in |
||
| 193 | * the CSV file (allowing for trailing line-end characters). It became |
||
| 194 | * optional in PHP 5. Omitting this parameter (or setting it to 0 in PHP |
||
| 195 | * 5.1.0 and later) the maximum line length is not limited, which is |
||
| 196 | * slightly slower. |
||
| 197 | * @param string $delimiter The optional delimiter parameter sets the field delimiter (one character only). |
||
| 198 | * @param string $enclosure The optional enclosure parameter sets the field enclosure character (one character |
||
| 199 | * only). |
||
| 200 | * @param string $escape The optional escape parameter sets the escape character (one character only). |
||
| 201 | * |
||
| 202 | * @return array |
||
| 203 | */ |
||
| 204 | public function fgetcsv( |
||
| 213 | |||
| 214 | /** |
||
| 215 | * Gets line from file pointer |
||
| 216 | * |
||
| 217 | * @param resource $handle |
||
| 218 | * @param int $length Reading ends when length - 1 bytes have been |
||
| 219 | * read, or a newline (which is included in the return value), or an EOF |
||
| 220 | * (whichever comes first). If no length is specified, it will keep |
||
| 221 | * reading from the stream until it reaches the end of the line. |
||
| 222 | * |
||
| 223 | * @return string |
||
| 224 | */ |
||
| 225 | public function fgets($handle, int $length = null) : string |
||
| 229 | |||
| 230 | /** |
||
| 231 | * Gets line from file pointer and strip HTML tags |
||
| 232 | * |
||
| 233 | * @param resource $handle |
||
| 234 | * @param int $length Length of the data to be retrieved. |
||
| 235 | * @param string $allowableTags You can use the optional third parameter to specify tags which should |
||
| 236 | * not be stripped. |
||
| 237 | * |
||
| 238 | * @return string |
||
| 239 | */ |
||
| 240 | public function fgetss($handle, int $length = null, string $allowableTags = null) : string |
||
| 244 | |||
| 245 | /** |
||
| 246 | * Checks whether a file or directory exists |
||
| 247 | * |
||
| 248 | * @param string $filename Path to the file or directory. |
||
| 249 | * |
||
| 250 | * @return bool |
||
| 251 | */ |
||
| 252 | public function fileExists(string $filename) : bool |
||
| 256 | |||
| 257 | /** |
||
| 258 | * Reads entire file into a string |
||
| 259 | * |
||
| 260 | * @param string $filename Name of the file to read. |
||
| 261 | * @param bool $useIncludePath |
||
| 262 | * @param resource $context A valid context resource created with |
||
| 263 | * stream_context_create. If you don't need to use a |
||
| 264 | * custom context, you can skip this parameter by . |
||
| 265 | * @param int $offset The offset where the reading starts on the original stream. |
||
| 266 | * @param int $maxlen Maximum length of data read. The default is to read until end |
||
| 267 | * of file is reached. Note that this parameter is applied to the |
||
| 268 | * stream processed by the filters. |
||
| 269 | * |
||
| 270 | * @return string |
||
| 271 | */ |
||
| 272 | public function fileGetContents( |
||
| 281 | |||
| 282 | /** |
||
| 283 | * Write a string to a file |
||
| 284 | * |
||
| 285 | * @param string $filename Path to the file where to write the data. |
||
| 286 | * @param mixed $data The data to write. Can be either a string, an |
||
| 287 | * array or a stream resource. |
||
| 288 | * @param int $flags The value of flags can be any combination of |
||
| 289 | * the following flags, joined with the binary OR (|) |
||
| 290 | * operator. |
||
| 291 | * @param resource $context A valid context resource created with |
||
| 292 | * stream_context_create. |
||
| 293 | * |
||
| 294 | * @return int |
||
| 295 | */ |
||
| 296 | public function filePutContents(string $filename, $data, int $flags = null, $context = null) : int |
||
| 300 | |||
| 301 | /** |
||
| 302 | * Reads entire file into an array |
||
| 303 | * |
||
| 304 | * @param string $filename Path to the file. |
||
| 305 | * @param int $flags The optional parameter flags can be one, or |
||
| 306 | * more, of the following constants: |
||
| 307 | * |
||
| 308 | * |
||
| 309 | * |
||
| 310 | * FILE_USE_INCLUDE_PATH |
||
| 311 | * |
||
| 312 | * |
||
| 313 | * |
||
| 314 | * Search for the file in the include_path. |
||
| 315 | * |
||
| 316 | * |
||
| 317 | * |
||
| 318 | * |
||
| 319 | * |
||
| 320 | * FILE_IGNORE_NEW_LINES |
||
| 321 | * |
||
| 322 | * |
||
| 323 | * |
||
| 324 | * Do not add newline at the end of each array element |
||
| 325 | * |
||
| 326 | * |
||
| 327 | * |
||
| 328 | * |
||
| 329 | * |
||
| 330 | * FILE_SKIP_EMPTY_LINES |
||
| 331 | * |
||
| 332 | * |
||
| 333 | * |
||
| 334 | * Skip empty lines |
||
| 335 | * @param resource $context A context resource created with the |
||
| 336 | * stream_context_create function. |
||
| 337 | * |
||
| 338 | * @return array |
||
| 339 | */ |
||
| 340 | public function file(string $filename, int $flags = null, $context = null) : array |
||
| 344 | |||
| 345 | /** |
||
| 346 | * Gets last access time of file |
||
| 347 | * |
||
| 348 | * @param string $filename Path to the file. |
||
| 349 | * |
||
| 350 | * @return int |
||
| 351 | */ |
||
| 352 | public function fileatime(string $filename) : int |
||
| 356 | |||
| 357 | /** |
||
| 358 | * Gets inode change time of file |
||
| 359 | * |
||
| 360 | * @param string $filename Path to the file. |
||
| 361 | * |
||
| 362 | * @return int |
||
| 363 | */ |
||
| 364 | public function filectime(string $filename) : int |
||
| 368 | |||
| 369 | /** |
||
| 370 | * Gets file group |
||
| 371 | * |
||
| 372 | * @param string $filename Path to the file. |
||
| 373 | * |
||
| 374 | * @return int |
||
| 375 | */ |
||
| 376 | public function fileroup(string $filename) : int |
||
| 380 | |||
| 381 | /** |
||
| 382 | * Gets file inode |
||
| 383 | * |
||
| 384 | * @param string $filename Path to the file. |
||
| 385 | * |
||
| 386 | * @return int |
||
| 387 | */ |
||
| 388 | public function fileinode(string $filename) : int |
||
| 392 | |||
| 393 | /** |
||
| 394 | * Gets file modification time |
||
| 395 | * |
||
| 396 | * @param string $filename Path to the file. |
||
| 397 | * |
||
| 398 | * @return int |
||
| 399 | */ |
||
| 400 | public function filemtime(string $filename) : int |
||
| 404 | |||
| 405 | /** |
||
| 406 | * Gets file owner |
||
| 407 | * |
||
| 408 | * @param string $filename Path to the file. |
||
| 409 | * |
||
| 410 | * @return int |
||
| 411 | */ |
||
| 412 | public function fileowner(string $filename) : int |
||
| 416 | |||
| 417 | /** |
||
| 418 | * Gets file permissions |
||
| 419 | * |
||
| 420 | * @param string $filename Path to the file. |
||
| 421 | * |
||
| 422 | * @return int |
||
| 423 | */ |
||
| 424 | public function fileperms(string $filename) : int |
||
| 428 | |||
| 429 | /** |
||
| 430 | * Gets file size |
||
| 431 | * |
||
| 432 | * @param string $filename Path to the file. |
||
| 433 | * |
||
| 434 | * @return int |
||
| 435 | */ |
||
| 436 | public function filesize(string $filename) : int |
||
| 440 | |||
| 441 | /** |
||
| 442 | * Gets file type |
||
| 443 | * |
||
| 444 | * @param string $filename Path to the file. |
||
| 445 | * |
||
| 446 | * @return string |
||
| 447 | */ |
||
| 448 | public function filetype(string $filename) : string |
||
| 452 | |||
| 453 | /** |
||
| 454 | * Portable advisory file locking |
||
| 455 | * |
||
| 456 | * @param resource $handle |
||
| 457 | * @param int $operation operation is one of the following: |
||
| 458 | * |
||
| 459 | * |
||
| 460 | * |
||
| 461 | * LOCK_SH to acquire a shared lock (reader). |
||
| 462 | * |
||
| 463 | * |
||
| 464 | * |
||
| 465 | * |
||
| 466 | * LOCK_EX to acquire an exclusive lock (writer). |
||
| 467 | * |
||
| 468 | * |
||
| 469 | * |
||
| 470 | * |
||
| 471 | * LOCK_UN to release a lock (shared or exclusive). |
||
| 472 | * @param int $wouldblock The optional third argument is set to 1 if the lock would block |
||
| 473 | * (EWOULDBLOCK errno condition). |
||
| 474 | * |
||
| 475 | * @return bool |
||
| 476 | */ |
||
| 477 | public function flock($handle, int $operation, int &$wouldblock = null) : bool |
||
| 481 | |||
| 482 | /** |
||
| 483 | * Match filename against a pattern |
||
| 484 | * |
||
| 485 | * @param string $pattern The shell wildcard pattern. |
||
| 486 | * @param string $string The tested string. This function is especially useful for filenames, |
||
| 487 | * but may also be used on regular strings. |
||
| 488 | * @param int $flags The value of flags can be any combination of |
||
| 489 | * the following flags, joined with the |
||
| 490 | * binary OR (|) operator. |
||
| 491 | * |
||
| 492 | * |
||
| 493 | * A list of possible flags for fnmatch |
||
| 494 | * |
||
| 495 | * |
||
| 496 | * |
||
| 497 | * |
||
| 498 | * Flag |
||
| 499 | * Description |
||
| 500 | * |
||
| 501 | * |
||
| 502 | * |
||
| 503 | * |
||
| 504 | * FNM_NOESCAPE |
||
| 505 | * |
||
| 506 | * Disable backslash escaping. |
||
| 507 | * |
||
| 508 | * |
||
| 509 | * |
||
| 510 | * FNM_PATHNAME |
||
| 511 | * |
||
| 512 | * Slash in string only matches slash in the given pattern. |
||
| 513 | * |
||
| 514 | * |
||
| 515 | * |
||
| 516 | * FNM_PERIOD |
||
| 517 | * |
||
| 518 | * Leading period in string must be exactly matched by period in the given pattern. |
||
| 519 | * |
||
| 520 | * |
||
| 521 | * |
||
| 522 | * FNM_CASEFOLD |
||
| 523 | * |
||
| 524 | * Caseless match. Part of the GNU extension. |
||
| 525 | * |
||
| 526 | * @return bool |
||
| 527 | */ |
||
| 528 | public function fnmatch(string $pattern, string $string, int $flags = null) : bool |
||
| 532 | |||
| 533 | /** |
||
| 534 | * Opens file or URL |
||
| 535 | * |
||
| 536 | * @param string $filename If filename is of the form "scheme://...", it |
||
| 537 | * is assumed to be a URL and PHP will search for a protocol handler |
||
| 538 | * (also known as a wrapper) for that scheme. If no wrappers for that |
||
| 539 | * protocol are registered, PHP will emit a notice to help you track |
||
| 540 | * potential problems in your script and then continue as though |
||
| 541 | * filename specifies a regular file. |
||
| 542 | * @param string $mode The mode parameter specifies the type of access |
||
| 543 | * you require to the stream. It may be any of the following: |
||
| 544 | * |
||
| 545 | * |
||
| 546 | * A list of possible modes for fopen |
||
| 547 | * using mode |
||
| 548 | * |
||
| 549 | * |
||
| 550 | * |
||
| 551 | * |
||
| 552 | * mode |
||
| 553 | * Description |
||
| 554 | * |
||
| 555 | * |
||
| 556 | * |
||
| 557 | * |
||
| 558 | * 'r' |
||
| 559 | * |
||
| 560 | * Open for reading only; place the file pointer at the |
||
| 561 | * beginning of the file. |
||
| 562 | * |
||
| 563 | * |
||
| 564 | * |
||
| 565 | * 'r+' |
||
| 566 | * |
||
| 567 | * Open for reading and writing; place the file pointer at |
||
| 568 | * the beginning of the file. |
||
| 569 | * |
||
| 570 | * |
||
| 571 | * |
||
| 572 | * 'w' |
||
| 573 | * |
||
| 574 | * Open for writing only; place the file pointer at the |
||
| 575 | * beginning of the file and truncate the file to zero length. |
||
| 576 | * If the file does not exist, attempt to create it. |
||
| 577 | * |
||
| 578 | * |
||
| 579 | * |
||
| 580 | * 'w+' |
||
| 581 | * |
||
| 582 | * Open for reading and writing; place the file pointer at |
||
| 583 | * the beginning of the file and truncate the file to zero |
||
| 584 | * length. If the file does not exist, attempt to create it. |
||
| 585 | * |
||
| 586 | * |
||
| 587 | * |
||
| 588 | * 'a' |
||
| 589 | * |
||
| 590 | * Open for writing only; place the file pointer at the end of |
||
| 591 | * the file. If the file does not exist, attempt to create it. |
||
| 592 | * In this mode, fseek only affects |
||
| 593 | * the reading position, writes are always appended. |
||
| 594 | * |
||
| 595 | * |
||
| 596 | * |
||
| 597 | * 'a+' |
||
| 598 | * |
||
| 599 | * Open for reading and writing; place the file pointer at |
||
| 600 | * the end of the file. If the file does not exist, attempt to |
||
| 601 | * create it. In this mode, fseek only affects |
||
| 602 | * the reading position, writes are always appended. |
||
| 603 | * |
||
| 604 | * |
||
| 605 | * |
||
| 606 | * 'x' |
||
| 607 | * |
||
| 608 | * Create and open for writing only; place the file pointer at the |
||
| 609 | * beginning of the file. If the file already exists, the |
||
| 610 | * fopen call will fail by returning and |
||
| 611 | * generating an error of level E_WARNING. If |
||
| 612 | * the file does not exist, attempt to create it. This is equivalent |
||
| 613 | * to specifying O_EXCL|O_CREAT flags for the |
||
| 614 | * underlying open(2) system call. |
||
| 615 | * |
||
| 616 | * |
||
| 617 | * |
||
| 618 | * 'x+' |
||
| 619 | * |
||
| 620 | * Create and open for reading and writing; otherwise it has the |
||
| 621 | * same behavior as 'x'. |
||
| 622 | * |
||
| 623 | * |
||
| 624 | * |
||
| 625 | * 'c' |
||
| 626 | * |
||
| 627 | * Open the file for writing only. If the file does not exist, it is |
||
| 628 | * created. If it exists, it is neither truncated (as opposed to |
||
| 629 | * 'w'), nor the call to this function fails (as is |
||
| 630 | * the case with 'x'). The file pointer is |
||
| 631 | * positioned on the beginning of the file. This may be useful if it's |
||
| 632 | * desired to get an advisory lock (see flock) |
||
| 633 | * before attempting to modify the file, as using |
||
| 634 | * 'w' could truncate the file before the lock |
||
| 635 | * was obtained (if truncation is desired, |
||
| 636 | * ftruncate can be used after the lock is |
||
| 637 | * requested). |
||
| 638 | * |
||
| 639 | * |
||
| 640 | * |
||
| 641 | * 'c+' |
||
| 642 | * |
||
| 643 | * Open the file for reading and writing; otherwise it has the same |
||
| 644 | * behavior as 'c'. |
||
| 645 | * @param bool $useIncludePath The optional third use_include_path parameter |
||
| 646 | * can be set to '1' or if you want to search for the file in the |
||
| 647 | * include_path, too. |
||
| 648 | * @param resource $context |
||
| 649 | * |
||
| 650 | * @return resource |
||
| 651 | */ |
||
| 652 | public function fopen(string $filename, string $mode, bool $useIncludePath = null, $context = null) |
||
| 656 | |||
| 657 | /** |
||
| 658 | * Output all remaining data on a file pointer |
||
| 659 | * |
||
| 660 | * @param resource $handle |
||
| 661 | * |
||
| 662 | * @return int |
||
| 663 | */ |
||
| 664 | public function fpassthru($handle) : int |
||
| 668 | |||
| 669 | /** |
||
| 670 | * Format line as CSV and write to file pointer |
||
| 671 | * |
||
| 672 | * @param resource $handle |
||
| 673 | * @param array $fields An array of values. |
||
| 674 | * @param string $delimiter The optional delimiter parameter sets the field |
||
| 675 | * delimiter (one character only). |
||
| 676 | * @param string $enclosure The optional enclosure parameter sets the field |
||
| 677 | * enclosure (one character only). |
||
| 678 | * @param string $escapeChar The optional escape_char parameter sets the |
||
| 679 | * escape character (one character only). |
||
| 680 | * |
||
| 681 | * @return int |
||
| 682 | */ |
||
| 683 | public function fputcsv( |
||
| 692 | |||
| 693 | /** |
||
| 694 | * Binary-safe file read |
||
| 695 | * |
||
| 696 | * @param resource $handle |
||
| 697 | * @param int $length Up to length number of bytes read. |
||
| 698 | * |
||
| 699 | * @return string |
||
| 700 | */ |
||
| 701 | public function fread($handle, int $length) : string |
||
| 705 | |||
| 706 | /** |
||
| 707 | * Parses input from a file according to a format |
||
| 708 | * |
||
| 709 | * @param resource $handle |
||
| 710 | * @param string $format The specified format as described in the |
||
| 711 | * sprintf documentation. |
||
| 712 | * |
||
| 713 | * @return mixed |
||
| 714 | */ |
||
| 715 | public function fscanf($handle, string $format) |
||
| 719 | |||
| 720 | /** |
||
| 721 | * Seeks on a file pointer |
||
| 722 | * |
||
| 723 | * @param resource $handle |
||
| 724 | * @param int $offset The offset. |
||
| 725 | * @param int $whence whence values are: |
||
| 726 | * |
||
| 727 | * SEEK_SET - Set position equal to offset bytes. |
||
| 728 | * SEEK_CUR - Set position to current location plus offset. |
||
| 729 | * SEEK_END - Set position to end-of-file plus offset. |
||
| 730 | * |
||
| 731 | * @return int |
||
| 732 | */ |
||
| 733 | public function fseek($handle, int $offset, int $whence = null) : int |
||
| 737 | |||
| 738 | /** |
||
| 739 | * Gets information about a file using an open file pointer |
||
| 740 | * |
||
| 741 | * @param resource $handle |
||
| 742 | * |
||
| 743 | * @return array |
||
| 744 | */ |
||
| 745 | public function fstat($handle) : array |
||
| 749 | |||
| 750 | /** |
||
| 751 | * Returns the current position of the file read/write pointer |
||
| 752 | * |
||
| 753 | * @param resource $handle The file pointer must be valid, and must point to a file successfully |
||
| 754 | * opened by fopen or popen. |
||
| 755 | * ftell gives undefined results for append-only streams |
||
| 756 | * (opened with "a" flag). |
||
| 757 | * |
||
| 758 | * @return int |
||
| 759 | */ |
||
| 760 | public function ftell($handle) : int |
||
| 764 | |||
| 765 | /** |
||
| 766 | * Truncates a file to a given length |
||
| 767 | * |
||
| 768 | * @param resource $handle The file pointer. |
||
| 769 | * @param int $size The size to truncate to. |
||
| 770 | * |
||
| 771 | * @return bool |
||
| 772 | */ |
||
| 773 | public function ftruncate($handle, int $size) : bool |
||
| 777 | |||
| 778 | /** |
||
| 779 | * Binary-safe file write |
||
| 780 | * |
||
| 781 | * @param resource $handle |
||
| 782 | * @param string $string The string that is to be written. |
||
| 783 | * @param int $length If the length argument is given, writing will |
||
| 784 | * stop after length bytes have been written or |
||
| 785 | * the end of string is reached, whichever comes |
||
| 786 | * first. |
||
| 787 | * |
||
| 788 | * @return int |
||
| 789 | */ |
||
| 790 | public function fwrite($handle, string $string, int $length = null) : int |
||
| 794 | |||
| 795 | /** |
||
| 796 | * Find pathnames matching a pattern |
||
| 797 | * |
||
| 798 | * @param string $pattern The pattern. No tilde expansion or parameter substitution is done. |
||
| 799 | * @param int $flags Valid flags: |
||
| 800 | * |
||
| 801 | * |
||
| 802 | * |
||
| 803 | * GLOB_MARK - Adds a slash to each directory returned |
||
| 804 | * |
||
| 805 | * |
||
| 806 | * |
||
| 807 | * |
||
| 808 | * GLOB_NOSORT - Return files as they appear in the |
||
| 809 | * directory (no sorting). When this flag is not used, the pathnames are |
||
| 810 | * sorted alphabetically |
||
| 811 | * |
||
| 812 | * |
||
| 813 | * |
||
| 814 | * |
||
| 815 | * GLOB_NOCHECK - Return the search pattern if no |
||
| 816 | * files matching it were found |
||
| 817 | * |
||
| 818 | * |
||
| 819 | * |
||
| 820 | * |
||
| 821 | * GLOB_NOESCAPE - Backslashes do not quote |
||
| 822 | * metacharacters |
||
| 823 | * |
||
| 824 | * |
||
| 825 | * |
||
| 826 | * |
||
| 827 | * GLOB_BRACE - Expands {a,b,c} to match 'a', 'b', |
||
| 828 | * or 'c' |
||
| 829 | * |
||
| 830 | * |
||
| 831 | * |
||
| 832 | * |
||
| 833 | * GLOB_ONLYDIR - Return only directory entries |
||
| 834 | * which match the pattern |
||
| 835 | * |
||
| 836 | * |
||
| 837 | * |
||
| 838 | * |
||
| 839 | * GLOB_ERR - Stop on read errors (like unreadable |
||
| 840 | * directories), by default errors are ignored. |
||
| 841 | * |
||
| 842 | * @return array |
||
| 843 | */ |
||
| 844 | public function glob(string $pattern, int $flags = null) : array |
||
| 848 | |||
| 849 | /** |
||
| 850 | * Tells whether the filename is a directory |
||
| 851 | * |
||
| 852 | * @param string $filename Path to the file. If filename is a relative |
||
| 853 | * filename, it will be checked relative to the current working |
||
| 854 | * directory. If filename is a symbolic or hard link |
||
| 855 | * then the link will be resolved and checked. If you have enabled , |
||
| 856 | * or open_basedir further |
||
| 857 | * restrictions may apply. |
||
| 858 | * |
||
| 859 | * @return bool |
||
| 860 | */ |
||
| 861 | public function isDir(string $filename) : bool |
||
| 865 | |||
| 866 | /** |
||
| 867 | * Tells whether the filename is executable |
||
| 868 | * |
||
| 869 | * @param string $filename Path to the file. |
||
| 870 | * |
||
| 871 | * @return bool |
||
| 872 | */ |
||
| 873 | public function isExecutable(string $filename) : bool |
||
| 877 | |||
| 878 | /** |
||
| 879 | * Tells whether the filename is a regular file |
||
| 880 | * |
||
| 881 | * @param string $filename Path to the file. |
||
| 882 | * |
||
| 883 | * @return bool |
||
| 884 | */ |
||
| 885 | public function isFile(string $filename) : bool |
||
| 889 | |||
| 890 | /** |
||
| 891 | * Tells whether the filename is a symbolic link |
||
| 892 | * |
||
| 893 | * @param string $filename Path to the file. |
||
| 894 | * |
||
| 895 | * @return bool |
||
| 896 | */ |
||
| 897 | public function isLink(string $filename) : bool |
||
| 901 | |||
| 902 | /** |
||
| 903 | * Tells whether a file exists and is readable |
||
| 904 | * |
||
| 905 | * @param string $filename Path to the file. |
||
| 906 | * |
||
| 907 | * @return bool |
||
| 908 | */ |
||
| 909 | public function isReadable(string $filename) : bool |
||
| 913 | |||
| 914 | /** |
||
| 915 | * Tells whether the file was uploaded via HTTP POST |
||
| 916 | * |
||
| 917 | * @param string $filename The filename being checked. |
||
| 918 | * |
||
| 919 | * @return bool |
||
| 920 | */ |
||
| 921 | public function isUploadedFile(string $filename) : bool |
||
| 925 | |||
| 926 | /** |
||
| 927 | * Tells whether the filename is writable |
||
| 928 | * |
||
| 929 | * @param string $filename The filename being checked. |
||
| 930 | * |
||
| 931 | * @return bool |
||
| 932 | */ |
||
| 933 | public function isWritable(string $filename) : bool |
||
| 937 | |||
| 938 | /** |
||
| 939 | * Changes group ownership of symlink |
||
| 940 | * |
||
| 941 | * @param string $filename Path to the symlink. |
||
| 942 | * @param mixed $group The group specified by name or number. |
||
| 943 | * |
||
| 944 | * @return bool |
||
| 945 | */ |
||
| 946 | public function lchgrp(string $filename, $group) : bool |
||
| 950 | |||
| 951 | /** |
||
| 952 | * Changes user ownership of symlink |
||
| 953 | * |
||
| 954 | * @param string $filename Path to the file. |
||
| 955 | * @param mixed $user User name or number. |
||
| 956 | * |
||
| 957 | * @return bool |
||
| 958 | */ |
||
| 959 | public function lchown(string $filename, $user) : bool |
||
| 963 | |||
| 964 | /** |
||
| 965 | * Create a hard link |
||
| 966 | * |
||
| 967 | * @param string $target Target of the link. |
||
| 968 | * @param string $link The link name. |
||
| 969 | * |
||
| 970 | * @return bool |
||
| 971 | */ |
||
| 972 | public function link(string $target, string $link) : bool |
||
| 976 | |||
| 977 | /** |
||
| 978 | * Gets information about a link |
||
| 979 | * |
||
| 980 | * @param string $path Path to the link. |
||
| 981 | * |
||
| 982 | * @return int |
||
| 983 | */ |
||
| 984 | public function linkinfo(string $path) : int |
||
| 988 | |||
| 989 | /** |
||
| 990 | * Gives information about a file or symbolic link |
||
| 991 | * |
||
| 992 | * @param string $filename Path to a file or a symbolic link. |
||
| 993 | * |
||
| 994 | * @return array |
||
| 995 | */ |
||
| 996 | public function lstat(string $filename) : array |
||
| 1000 | |||
| 1001 | /** |
||
| 1002 | * Makes directory |
||
| 1003 | * |
||
| 1004 | * @param string $pathname The directory path. |
||
| 1005 | * @param int $mode The mode is 0777 by default, which means the widest possible |
||
| 1006 | * access. For more information on modes, read the details |
||
| 1007 | * on the chmod page. |
||
| 1008 | * @param bool $recursive Allows the creation of nested directories specified in the |
||
| 1009 | * pathname. |
||
| 1010 | * @param resource $context |
||
| 1011 | * |
||
| 1012 | * @return bool |
||
| 1013 | */ |
||
| 1014 | public function mkdir(string $pathname, int $mode = null, bool $recursive = null, $context = null) : bool |
||
| 1018 | |||
| 1019 | /** |
||
| 1020 | * Moves an uploaded file to a new location |
||
| 1021 | * |
||
| 1022 | * @param string $filename The filename of the uploaded file. |
||
| 1023 | * @param string $destination The destination of the moved file. |
||
| 1024 | * |
||
| 1025 | * @return bool |
||
| 1026 | */ |
||
| 1027 | public function moveUploadedFile(string $filename, string $destination) : bool |
||
| 1031 | |||
| 1032 | /** |
||
| 1033 | * Parse a configuration file |
||
| 1034 | * |
||
| 1035 | * @param string $filename The filename of the ini file being parsed. |
||
| 1036 | * @param bool $processSections By setting the process_sections |
||
| 1037 | * parameter to , you get a multidimensional array, with |
||
| 1038 | * the section names and settings included. The default |
||
| 1039 | * for process_sections is |
||
| 1040 | * @param int $scannerMode Can either be INI_SCANNER_NORMAL (default) or |
||
| 1041 | * INI_SCANNER_RAW. If INI_SCANNER_RAW |
||
| 1042 | * is supplied, then option values will not be parsed. |
||
| 1043 | * |
||
| 1044 | * @return array |
||
| 1045 | */ |
||
| 1046 | public function parseIniFile(string $filename, bool $processSections = null, int $scannerMode = null) : array |
||
| 1050 | |||
| 1051 | /** |
||
| 1052 | * Parse a configuration string |
||
| 1053 | * |
||
| 1054 | * @param string $ini The contents of the ini file being parsed. |
||
| 1055 | * @param bool $processSections By setting the process_sections |
||
| 1056 | * parameter to , you get a multidimensional array, with |
||
| 1057 | * the section names and settings included. The default |
||
| 1058 | * for process_sections is |
||
| 1059 | * @param int $scannerMode Can either be INI_SCANNER_NORMAL (default) or |
||
| 1060 | * INI_SCANNER_RAW. If INI_SCANNER_RAW |
||
| 1061 | * is supplied, then option values will not be parsed. |
||
| 1062 | * |
||
| 1063 | * @return array |
||
| 1064 | */ |
||
| 1065 | public function parseIniString(string $ini, bool $processSections = null, int $scannerMode = null) : array |
||
| 1069 | |||
| 1070 | /** |
||
| 1071 | * Returns information about a file path |
||
| 1072 | * |
||
| 1073 | * @param string $path The path to be parsed. |
||
| 1074 | * @param int $options If present, specifies a specific element to be returned; one of |
||
| 1075 | * PATHINFO_DIRNAME, |
||
| 1076 | * PATHINFO_BASENAME, |
||
| 1077 | * PATHINFO_EXTENSION or |
||
| 1078 | * PATHINFO_FILENAME. |
||
| 1079 | * |
||
| 1080 | * @return mixed |
||
| 1081 | */ |
||
| 1082 | public function pathinfo(string $path, int $options = null) |
||
| 1086 | |||
| 1087 | /** |
||
| 1088 | * Closes process file pointer |
||
| 1089 | * |
||
| 1090 | * @param resource $handle The file pointer must be valid, and must have been returned by a |
||
| 1091 | * successful call to popen. |
||
| 1092 | * |
||
| 1093 | * @return int |
||
| 1094 | */ |
||
| 1095 | public function pclose($handle) : int |
||
| 1099 | |||
| 1100 | /** |
||
| 1101 | * Opens process file pointer |
||
| 1102 | * |
||
| 1103 | * @param string $command The command |
||
| 1104 | * @param string $mode The mode |
||
| 1105 | * |
||
| 1106 | * @return resource |
||
| 1107 | */ |
||
| 1108 | public function popen(string $command, string $mode) |
||
| 1112 | |||
| 1113 | /** |
||
| 1114 | * Outputs a file |
||
| 1115 | * |
||
| 1116 | * @param string $filename The filename being read. |
||
| 1117 | * @param bool $useIncludePath You can use the optional second parameter and set it to , if |
||
| 1118 | * you want to search for the file in the include_path, too. |
||
| 1119 | * @param resource $context A context stream resource. |
||
| 1120 | * |
||
| 1121 | * @return int |
||
| 1122 | */ |
||
| 1123 | public function readfile(string $filename, bool $useIncludePath = null, $context = null) : int |
||
| 1127 | |||
| 1128 | /** |
||
| 1129 | * Returns the target of a symbolic link |
||
| 1130 | * |
||
| 1131 | * @param string $path The symbolic link path. |
||
| 1132 | * |
||
| 1133 | * @return string |
||
| 1134 | */ |
||
| 1135 | public function readlink(string $path) : string |
||
| 1139 | |||
| 1140 | /** |
||
| 1141 | * Get realpath cache entries |
||
| 1142 | * |
||
| 1143 | * @return array |
||
| 1144 | */ |
||
| 1145 | public function realpathCacheGet() : array |
||
| 1149 | |||
| 1150 | /** |
||
| 1151 | * Get realpath cache size |
||
| 1152 | * |
||
| 1153 | * @return int |
||
| 1154 | */ |
||
| 1155 | public function realpathCacheSize() : int |
||
| 1159 | |||
| 1160 | /** |
||
| 1161 | * Returns canonicalized absolute pathname |
||
| 1162 | * |
||
| 1163 | * @param string $path The path being checked. |
||
| 1164 | * |
||
| 1165 | * |
||
| 1166 | * Whilst a path must be supplied, the value can be blank or |
||
| 1167 | * In these cases, the value is interpreted as the current directory. |
||
| 1168 | * |
||
| 1169 | * @return string |
||
| 1170 | */ |
||
| 1171 | public function realpath(string $path) : string |
||
| 1175 | |||
| 1176 | /** |
||
| 1177 | * Renames a file or directory |
||
| 1178 | * |
||
| 1179 | * @param string $oldname |
||
| 1180 | * @param string $newname The new name. |
||
| 1181 | * @param resource $context |
||
| 1182 | * |
||
| 1183 | * @return bool |
||
| 1184 | */ |
||
| 1185 | public function rename(string $oldname, string $newname, $context = null) : bool |
||
| 1189 | |||
| 1190 | /** |
||
| 1191 | * Rewind the position of a file pointer |
||
| 1192 | * |
||
| 1193 | * @param resource $handle The file pointer must be valid, and must point to a file |
||
| 1194 | * successfully opened by fopen. |
||
| 1195 | * |
||
| 1196 | * @return bool |
||
| 1197 | */ |
||
| 1198 | public function rewind($handle) : bool |
||
| 1202 | |||
| 1203 | /** |
||
| 1204 | * Removes directory |
||
| 1205 | * |
||
| 1206 | * @param string $dirname Path to the directory. |
||
| 1207 | * @param resource $context |
||
| 1208 | * |
||
| 1209 | * @return bool |
||
| 1210 | */ |
||
| 1211 | public function rmdir(string $dirname, $context = null) : bool |
||
| 1215 | |||
| 1216 | /** |
||
| 1217 | * Gives information about a file |
||
| 1218 | * |
||
| 1219 | * @param string $filename Path to the file. |
||
| 1220 | * |
||
| 1221 | * @return array |
||
| 1222 | */ |
||
| 1223 | public function stat(string $filename) : array |
||
| 1227 | |||
| 1228 | /** |
||
| 1229 | * Creates a symbolic link |
||
| 1230 | * |
||
| 1231 | * @param string $target Target of the link. |
||
| 1232 | * @param string $link The link name. |
||
| 1233 | * |
||
| 1234 | * @return bool |
||
| 1235 | */ |
||
| 1236 | public function symlink(string $target, string $link) : bool |
||
| 1240 | |||
| 1241 | /** |
||
| 1242 | * Create file with unique file name |
||
| 1243 | * |
||
| 1244 | * @param string $dir The directory where the temporary filename will be created. |
||
| 1245 | * @param string $prefix The prefix of the generated temporary filename. |
||
| 1246 | * |
||
| 1247 | * @return string |
||
| 1248 | */ |
||
| 1249 | public function tempnam(string $dir, string $prefix) : string |
||
| 1253 | |||
| 1254 | /** |
||
| 1255 | * Creates a temporary file |
||
| 1256 | * |
||
| 1257 | * @return resource |
||
| 1258 | */ |
||
| 1259 | public function tmpfile() |
||
| 1263 | |||
| 1264 | /** |
||
| 1265 | * Sets access and modification time of file |
||
| 1266 | * |
||
| 1267 | * @param string $filename The name of the file being touched. |
||
| 1268 | * @param int $time The touch time. If time is not supplied, |
||
| 1269 | * the current system time is used. |
||
| 1270 | * @param int $atime If present, the access time of the given filename is set to |
||
| 1271 | * the value of atime. Otherwise, it is set to |
||
| 1272 | * the value passed to the time parameter. |
||
| 1273 | * If neither are present, the current system time is used. |
||
| 1274 | * |
||
| 1275 | * @return bool |
||
| 1276 | */ |
||
| 1277 | public function touch(string $filename, int $time = null, int $atime = null) : bool |
||
| 1281 | |||
| 1282 | /** |
||
| 1283 | * Changes the current umask |
||
| 1284 | * |
||
| 1285 | * @param int $mask The new umask. |
||
| 1286 | * |
||
| 1287 | * @return int |
||
| 1288 | */ |
||
| 1289 | public function umask(int $mask = null) : int |
||
| 1293 | |||
| 1294 | /** |
||
| 1295 | * Deletes a file |
||
| 1296 | * |
||
| 1297 | * @param string $filename Path to the file. |
||
| 1298 | * @param resource $context |
||
| 1299 | * |
||
| 1300 | * @return bool |
||
| 1301 | */ |
||
| 1302 | public function unlink(string $filename, $context = null) : bool |
||
| 1306 | |||
| 1307 | } |
||
| 1308 | |||
| 1309 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.