Luminova Framework

PHP Luminova: Local Files Directories Operations

Last updated: 2026-11-28 20:57:12

Read, write, and stream files, work with directories, and manage filesystem permissions and locks.

Use the Filesystem class for local files and directories. Create an instance to inspect one path through PHP’s SplFileInfo. Call the static methods to read or write data, copy and move files, create directories, or resolve paths. To send a file as an HTTP attachment, use File Downloader.


Examples

Creating a Filesystem Instance

use Luminova\Storage\Filesystem;

// Using constructor
$fs = new Filesystem('/path/to/file.txt');

// Using static info method
$fs = Filesystem::info('/path/to/file.txt');

// Using Factory Helper
$fs = Luminova\Foundation\Module\Factory::filesystem('/path/to/file.txt');

// Using Helper Function
$fs = Luminova\Funcs\factory('filesystem', false, '/path/to/file.txt');

Access Application Paths

Read an application directory as an instance property or look it up with Filesystem::path(). The result is an absolute path based on your application root.

echo $fs->views;
echo Filesystem::path('views');

Setting or Updating the File

$fs->setFilename('/new/path/to/file.txt');

After setting the path, use the instance to check the file and read its metadata.


Check Whether a File or Directory Exists

if ($fs->exists()) {
    echo "File exists!";
} else {
    echo "File does not exist!";
}

Read File Metadata

echo $fs->size;       // File size in bytes
echo $fs->extension;  // File extension
echo $fs->pathname;   // Full path
echo $fs->filename;   // file.txt
echo $fs->realPath;   // /full/path/to/file.txt
echo $fs->owner;      // UID of owner

Calls to methods such as getFilename() are forwarded to the underlying SplFileInfo object.

echo $fs->getFilename(); // Same as $fs->filename

Reading File Contents

$content = Filesystem::contents('/path/to/file.txt');

if ($content !== false) {
    echo $content;
}

Read only a portion of the file:

$content = Filesystem::contents('/path/to/file.txt', 100, 50);
// Reads 100 bytes starting at offset 50

Write a String

Filesystem::write('/path/to/file.txt', 'Hello World!');

Append to a File

Filesystem::write('/path/to/file.txt', "\nNew line", FILE_APPEND | LOCK_EX);

Write from a Stream

$stream = fopen('php://memory', 'rb+');
fwrite($stream, 'Stream content');
rewind($stream);

try {
    Filesystem::write('/path/to/file.txt', $stream, FILE_APPEND | LOCK_EX);
} finally {
    fclose($stream);
}

Streaming Large Files

$bytesSent = Filesystem::read('/path/to/largefile.zip', length: 1024 * 1024);
  • Reads in chunks up to the requested total length.
  • Returns the number of bytes sent, or false on failure.

Creating Directories

Filesystem::mkdir('writeable/storages/images', 0755);
  • Automatically creates parent directories if they don’t exist.

Copying Files or Directories

$copied = 0;
Filesystem::copy('source/folder', 'dest/folder', skipIfExists: true, copied: $copied);

echo "Copied $copied files.";

Moving Files or Directories

$moved = 0;
Filesystem::move('source/folder', 'dest/folder', skipIfExists: true, moved: $moved);

echo "Moved $moved files.";

Deleting Files or Directories

$deleted = Filesystem::delete('writeable/storages/temp', deleteBase: true);

echo "Deleted $deleted items.";

Filesystem::symbolic('/path/to/target', '/path/to/symlink');
  • Use a link path where you want the symbolic link created.

Measure a File or Directory

echo Filesystem::size('/path/to/file.txt'); // Returns bytes
echo Filesystem::size('folder');            // Returns total folder size

Working with Permissions

Convert Permissions to a Symbolic String

echo Filesystem::permissions(0755); // Output: rwxr-xr-x

Convert Symbolic Permissions to Octal Digits

echo Filesystem::toUnixPermission('rw-r--r--'); // Output: 0644

Set File or Directory Permissions

Filesystem::setPermission('/path/to/file.txt', 0644);

Class Definition

  • Full namespace: Luminova\Storage\Filesystem
  • This class implements PHP’s built-in Stringable interface.

Constants

ConstantValueDescription
FILE_BINARY2691Flag value recognized by write() when choosing binary mode.

Read-Only Path Properties

Read these paths on a Filesystem instance, or pass the property name to Filesystem::path(). The framework resolves paths relative to the application root.


app

Path to the application directory.

Type: string


modules

Path to the application modules.

Type: string


system

Path to the framework source directory.

Type: string


plugins

Path to the system third-party plugins.

Type: string


library

Path to the libraries and third-party modules.

Type: string


services

Path to the serialized shared services.

Type: string


controllers

Path to the application controllers.

Type: string


writeable

Path to the application’s writable runtime directory.

Type: string


logs

Path to the error logs.

Type: string


caches

Path to the application caches.

Type: string


public

Path to the public document root.

Type: string


assets

Path to the public assets directory.

Type: string


views

Path to the view templates.

Type: string


routes

Path to the application routes.

Type: string


languages

Path to the translation files.

Type: string


Methods

__construct

Create a filesystem helper, optionally associated with a file path for instance methods and file properties.

public function __construct(?string $filename = null)

Parameters:

ParameterTypeDescription
$filename?stringFile path for instance operations (default null).

setPermission

Set permissions for a file or directory.

public static function setPermission(string $location, int $permission): bool

Parameters:

ParameterTypeDescription
$locationstringThe path to the file or directory.
$permissionintThe permission to set (Unix file permissions e.g, 0777).

Return:

bool - Returns true on success, false on failure.


permissions

Converts Unix file permission code to its string representation.

public static function permissions(int $permission): string

Parameters:

ParameterTypeDescription
$permissionintThe unix file permission (e.g, 0777).

Return:

string - Return permission string representation.


write

Write or append data to a file.

Write a string, stream resource, or SplFileObject. The default mode opens the file for replacement before trying to acquire a lock, so the existing contents can be truncated even if locking fails. Use atomicWrite() when replacing a file must preserve the previous contents if the write fails.

public static function write(
    string $filename,
    mixed $content,
    int $flags = 0,
    int $retryLock = 1,
    float|int $delay = 0,
    mixed $context = null,
    int &$bytes = 0
): bool

Parameters:

ParameterTypeDescription
$filenamestringPath to the file to write.
$contentmixedThe data to write as a string, stream resource, or SplFileObject. Seekable inputs are rewound when needed.
$flagsintOptional file flags (e.g., FILE_APPEND, FILE_USE_INCLUDE_PATH, LOCK_EX) (default 0).
$retryLockintMaximum lock attempts when both LOCK_EX and LOCK_NB are set (default: 1).
$delayfloat|intDelay in seconds between data chunks (default: 0). The non-blocking lock retry uses the separate waitForLock() delay.
$contextmixedOptional stream context created via stream_context_create() (default null).
$bytesintThe number of bytes written, or 0 if writing fails (default 0).

Return:

bool - Whether at least one byte was written. An empty write can return false.

Throws:

Examples:

Write string:

Filesystem::write('/path/to/file.txt', 'Hello World', FILE_APPEND | LOCK_EX);

Write from stream:

$stream = fopen('php://memory', 'rb+');
fwrite($stream, 'Hello Stream');
rewind($stream);

try {
    Filesystem::write('/path/to/file.txt', $stream, FILE_APPEND | LOCK_EX);
} finally {
    fclose($stream);
}

mkdir

Create a directory if it does not exist.

This method attempts to create the directory with the specified permissions.Supports recursive creation of nested directories.

public static function mkdir(
    string $path,
    int $permissions = 0775,
    bool $recursive = true
): bool

Parameters:

ParameterTypeDescription
$pathstringThe directory path to create.
$permissionsintUnix permission bits (default: 0775), subject to the process umask.
$recursiveboolWhether to create nested directories recursively (default: true).

Return:

bool - Returns true if the directory already exists or was successfully created, false otherwise.

Throws:

Luminova\Exceptions\FileException - If unable to create the directory due to filesystem errors.

Examples:

Filesystem::mkdir('writeable/storages/images', 0755);

copy

Recursively copy files and directories from a source to a destination.

Optionally skip files or directories that already exist in the destination.

public static function copy(
    string $origin,
    string $dest,
    bool $skipIfExists = false,
    int &$copied = 0
): bool

Parameters:

ParameterTypeDescription
$originstringThe source directory or file path to copy.
$deststringThe destination directory path.
$skipIfExistsboolWhether to skip already existing files or directories (default: false).
$copiedintReference to store the number of successfully copied items (default 0).

Return:

bool - Whether at least one file or symbolic link was copied. An empty directory can be created even when the method returns false.

Throws:


move

Recursively move files and directories from a source to a destination.

Optionally skip files or directories that already exist in the destination.

public static function move(
    string $origin,
    string $dest,
    bool $skipIfExists = false,
    int &$moved = 0
): bool

Parameters:

ParameterTypeDescription
$originstringThe source directory or file path to move.
$deststringThe destination directory path.
$skipIfExistsboolWhether to skip already existing files or directories (default: false).
$movedintReference to store the number of successfully moved items (default 0).

Return:

bool - Whether at least one file or symbolic link was moved. An empty directory can be created at the destination even when the method returns false.

Throws:


size

Determine the size in bytes of a file, directory, or stream. String inputs are treated as filesystem paths.

Supported sources:

  • File path: returns file size.
  • Directory path: returns cumulative size of all files recursively.
  • Stream resource: returns size using fstat() (if available).
  • Luminova stream object or stream interface: uses the object’s size method. A stream interface with an unknown size returns zero.
public static function size(mixed $source): ?int

Parameters:

ParameterTypeDescription
$sourcemixedFile or directory path, stream resource, or stream object.

Return:

int|null - Returns the size in bytes, or null if the stream size cannot be determined.

Throws:

Luminova\Exceptions\FileException - If the source is invalid or does not exist.


read

Streams a file resource to output in chunks.

Reads text or binary files in chunks to limit memory use. The method closes streams it opens from file paths. The caller closes any resource it supplies.

public static function read(
    mixed $source,
    int $offset = 0,
    int $length = (1 << 21),
    float|int $delay = 0,
    float|int $timeout = 30,
    bool $blocking = true,
    ?int $filesize = null
): int|false

Parameters:

ParameterTypeDescription
$sourcemixedFile stream or file path.
$offsetintStarting byte offset (default 0).
$lengthintMaximum total bytes to read (default 2 MiB). Use zero to read through EOF or until the timeout.
$delayfloat&#124;intDelay in seconds between chunks (default 0).
$timeoutfloat&#124;intRead timeout in seconds (default 30). Zero disables the timeout.
$blockingboolWhether stream reads should use blocking mode (default true).
$filesize?intOptional known file size in bytes, auto-detected if null (default: null).

Return:

int|false - The number of bytes read, or false if reading cannot start.

Example

Read from resource.

$filename = 'large-file.pdf';
$handler = fopen($filename, 'rb');
if ($handler !== false) {
    try {
        Filesystem::read($handler, blocking: false);
    } finally {
        fclose($handler);
    }
}

Read directly from a file path.

Filesystem::read('/path/to/file.pdf', blocking: false);

delete

Deletes files and folders recursively.

public static function delete(
    string $location,
    bool $deleteBase = false
): int

Parameters:

ParameterTypeDescription
$locationstringDirectory or file to delete.
$deleteBaseboolWhether to delete the target directory itself (default false).

Return:

int - Number of files, symbolic links, and directories removed.


symbolic

Create a symlink to a target file or directory.

public static function symbolic(
    string $target,
    string $link,
    int $permissions = 0755
): bool

Parameters:

ParameterTypeDescription
$targetstringThe target file or directory.
$linkstringThe location of the link.
$permissionsintThe permissions for a newly created destination directory (default: 0755).

Return:

bool - Return true if the link was successfully created false otherwise.


isResource

Checks if a variable is a valid resource of the specified type.

public static function isResource(mixed $resource, ?string $type = null): bool

Parameters:

ParameterTypeDescription
$resourcemixedThe resource to check.
$type?stringThe expected resource type. Possible values are: 'stream-context', 'stream', etc.

Return:

bool - Returns true if the variable is a resource and matches the expected resource type, otherwise returns false.


isAccessible

Validate if the provided file path is safe, exists, and is readable.This method checks if the file path is valid, whether it is accessible, and ensures it's readable unless it's a UNC path.

public static function isAccessible(string $path): bool

Parameters:

ParameterTypeDescription
$pathstringThe file path to validate (relative or absolute).

Return:

bool - Returns true if the file is accessible and readable.


isPathPermitted

Check whether a path begins with a URI scheme such as phar://. Use resolvePath() when you also need to resolve the path or check a base directory boundary.

public static function isPathPermitted(string $path): bool

Parameters:

ParameterTypeDescription
$pathstringThe file path to check (relative or absolute).

Return:

bool - Whether the path lacks a leading URI scheme.


toUnixPermission

Convert permission string to Unix integer permission.

public static function toUnixPermission(string $permission, bool $decimal = false): string|int|null

Parameters:

ParameterTypeDescription
$permissionstringA nine-character string made of r, w, x, and -, such as rw-r--r--.
$decimalboolWhether to return an integer instead of the formatted octal string (default: false).

Return:

string|int|null - A four-digit octal string by default, the equivalent integer when $decimal is true, or null when the input length is not nine.


info

Create a Filesystem instance for the specified file or directory.

public static function info(string $filename): static

Parameters:

ParameterTypeDescription
$filenamestringThe file or directory path.

Return:

static - A new Filesystem instance.

Throws:


setFilename

Set or update the file for this Filesystem instance.

public function setFilename(string $filename): self

Parameters:

ParameterTypeDescription
$filenamestringThe path to the file.

Return:

self - Returns the instance of Filesystem.

Throws:


exists

Check if the file exists.

public function exists(): bool

Return:

bool - True if the path exists as a file, directory, or symbolic link, otherwise false.


chmod

Set the permissions of a file or directory.

public static function chmod(string $location, int $permission): bool

Parameters:

ParameterTypeDescription
$locationstringThe file or directory path.
$permissionintThe permissions to apply.

Return:

bool - True if the permissions were changed successfully, otherwise false.

Throws:


contents

Read file content with optional length, offset, and stream context.

public static function contents(
    string $filename,
    int $length = 0,
    int $offset = 0,
    bool $useInclude = false,
    mixed $context = null,
    float|int $delay = 0
): string|bool

Parameters:

ParameterTypeDescription
$filenamestringThe path to the file.
$lengthintThe maximum number of bytes to read, or 0 to read until EOF (default 0).
$offsetintThe byte offset at which reading begins (default 0).
$useIncludeboolWhether to search for the file in the include path (default false).
$contextmixedAn optional stream context created with stream_context_create() (default null).
$delayfloat&#124;intDelay in seconds between chunks (default: 0).

Return:

string|bool - Returns the file content, or false on failure.

Throws:


sink

Writes all data from a source to a destination stream.

public static function sink(
    mixed $destination,
    mixed $source,
    int $chunkSize = 16_384,
    float|int $delay = 0,
    ?string $filename = null
): int

Parameters:

ParameterTypeDescription
$destinationmixedWritable file handler.
$sourcemixedData source, either a SplFileObject, stream resource, or string.
$chunkSizeintMaximum number of bytes to read per iteration (default 16_384).
$delayfloat&#124;intDelay in seconds between chunks (default: 0).
$filename?stringOptional destination filename used in exception messages (default null).

Return:

int - Returns the total number of bytes written.

Throws:


atomicWrite

Write to a temporary file in the target directory, then rename it over the destination. The directory must already exist and be writable.

public static function atomicWrite(
    string $filename,
    mixed $content,
    ?int $mode = null,
    bool $acquireLock = false,
    bool $deleteLockFile = false
): int

Parameters:

ParameterTypeDescription
$filenamestringTarget file path.
$contentmixedString data or a readable stream resource.
$mode?intFile permissions. Null preserves the target file permissions (default null).
$acquireLockboolWhether to acquire an exclusive lock (default false).
$deleteLockFileboolWhether to delete lock file once done (default false).

Return:

int - Number of bytes written, including zero for an empty replacement. Failures throw.

Throws:

Examples:

use Luminova\Storage\Filesystem;

$path = Filesystem::path('writeable') . 'report.txt';
$bytes = Filesystem::atomicWrite($path, "Report ready\n");
echo $bytes; // 13

waitForLock

Waits until an exclusive lock can be acquired.

public static function waitForLock(
    mixed $file,
    int $retries = 10,
    float|int $delay = 100_000
): mixed

Parameters:

ParameterTypeDescription
$filemixedThe file path, stream resource, or open SplFileObject.
$retriesintMaximum number of retry attempts (default 10).
$delayfloat&#124;intDelay in seconds between failed attempts (signature default: 100_000). Pass an explicit short delay such as 0.1 when retrying.

Return:

mixed - Returns the locked file handler.

Throws:


lock

Acquires an exclusive lock on a file.

public static function lock(
    mixed $file,
    bool $blocking = true,
    ?int $lockWouldBlock = null
): mixed

Parameters:

ParameterTypeDescription
$filemixedA filename or open file handler.
$blockingboolWhether to wait for the lock to become available (default true).
$lockWouldBlock?intPassed by value. The caller cannot use it to read the lock result (default: null).

Return:

mixed - Returns the locked file handler.

Throws:


fileLock

Acquire an exclusive lock on a lock file under the application’s writable directory.

public static function fileLock(
    ?string $basename = null,
    int $dirPermissions = 02770,
    ?string &$lockFilepath = null
): mixed

Parameters:

ParameterTypeDescription
$basename?stringOptional identifier for the lock (default null).
$dirPermissionsintPermissions for the lock directory (default 02770).
$lockFilepath?stringReturns the generated lock file path (default null).

Return:

resource - Open stream holding the exclusive lock. Release the lock and close the stream after use.

Throws:


unlock

Release an acquired lock. The method leaves the resource open.

public static function unlock(mixed $handler): bool

Parameters:

ParameterTypeDescription
$handlermixedAn open file handler with an active lock.

Return:

bool - Returns true if the lock was released successfully, otherwise false.


tryLock

Attempts to acquire an exclusive lock on a file.

public static function tryLock(
    mixed $file,
    bool $blocking = true,
    ?int $lockWouldBlock = null
): mixed

Parameters:

ParameterTypeDescription
$filemixedThe file path, stream resource, or open SplFileObject.
$blockingboolWhether to wait until the lock becomes available (default true).
$lockWouldBlock?intPassed by value. The caller cannot use it to read the lock result (default: null).

Return:

mixed - Returns the locked file handler, or false if the lock cannot be acquired.


isLocked

Determine whether a file is currently locked by another process.

public static function isLocked(mixed $file): bool

Parameters:

ParameterTypeDescription
$filemixedA filename, stream resource or SplFileObject instance.

Return:

bool - Returns true if another process holds the lock, false otherwise.


createTempDir

Create a unique writable temporary directory.

public static function createTempDir(
    ?string $prefix = null,
    bool $localOnly = false
): ?string

Parameters:

ParameterTypeDescription
$prefix?stringOptional directory name prefix (default null).
$localOnlyboolWhether to use application-local storage only (default false).

Return:

string|null - The created directory path with a trailing directory separator, or null if creation fails.


createTempFile

Creates a writable temporary file.

public static function createTempFile(
    ?string $filename = null,
    ?string $extension = null,
    bool $localOnly = false
): ?string

Parameters:

ParameterTypeDescription
$filename?stringOptional filename prefix (default null).
$extension?stringOptional file extension without a leading dot (default null).
$localOnlyboolWhether to use only the application writable temp directory instead of the system temporary directory (default false).

Return:

string|null - Returns the created temporary file path, or null if the temporary directory or file cannot be created.


touch

Create a file or update its access and modification timestamps.

public static function touch(
    string $file,
    ?int $mtime = null,
    ?int $atime = null
): bool

Parameters:

ParameterTypeDescription
$filestringThe file path.
$mtime?intOptional modification timestamp (default null).
$atime?intOptional access timestamp (default null).

Return:

bool - Returns true if the operation succeeds, otherwise false.


createTempName

Create a unique temporary file name in the specified directory.

public static function createTempName(
    ?string $directory = null,
    string $prefix = 'tmp_'
): ?string

Parameters:

ParameterTypeDescription
$directory?stringDirectory where the temporary file should be created (default: /writeable/tmp/).
$prefixstringPrefix to prepend to the generated filename (default 'tmp_').

Return:

string|null - The path to the created temporary file, or null if the directory is not writable or the file cannot be created.


Create a symbolic link (symlink) to a target file or directory.

public static function symlink(
    string $target,
    string $link,
    int $permissions = 0755
): bool

Parameters:

ParameterTypeDescription
$targetstringThe target file or directory to link from.
$linkstringThe path where the symbolic link will be created.
$permissionsintThe permissions to set for the destination directory if it needs to be created (default: 0755).

Return:

bool - Returns true if symbolic link was successfully created, false otherwise.


lastModified

Get the last-modified Unix timestamp of a file source.

public static function lastModified(mixed $source): ?int

Parameters:

ParameterTypeDescription
$sourcemixedThe file source.

Return:

int|null - Returns the last-modified Unix timestamp, or null if unavailable.


isLikelyFile

Determine whether a string likely represents a filesystem path.

public static function isLikelyFile(string $value, bool $forFile = false): bool

Parameters:

ParameterTypeDescription
$valuestringThe string to evaluate.
$forFileboolIf true, enforces that the path looks like a file (with extension).

Return:

bool - Returns true if the string appears to be a filesystem path.


isWritable

Check if a local filesystem path is writable.

public static function isWritable(string $path): bool

Parameters:

ParameterTypeDescription
$pathstringAbsolute or relative filesystem path.

Return:

bool - Returns true if the path exists, is permitted, and writable.


isReadable

Check if a local filesystem path is readable.

public static function isReadable(string $path): bool

Parameters:

ParameterTypeDescription
$pathstringAbsolute or relative filesystem path.

Return:

bool - Returns true if the path exists, is permitted, and readable.


isPath

Determines whether a string looks like a directory path.

public static function isPath(string $path): bool

Parameters:

ParameterTypeDescription
$pathstringPath string to inspect.

Return:

bool - Return true if the value appears to represent a directory path.


isAbsolutePath

Determine whether a path is absolute.

public static function isAbsolutePath(string $path): bool

Parameters:

ParameterTypeDescription
$pathstringThe filesystem path to evaluate.

Return:

bool - Returns true if the path is absolute, false otherwise.


path

Resolve and normalize application paths.

public static function path(string $name): string

Parameters:

ParameterTypeDescription
$namestringPath key name (e.g. "app", "public").

Return:

string - Returns an absolute normalized path, or an empty string if the key is undefined.


toSeparator

Normalize directory separators to the specified format.

public static function toSeparator(string $path, string $separator = '/'): string

Parameters:

ParameterTypeDescription
$pathstringFile path to normalize.
$separatorstringThe directory separator to use.

Return:

string - Returns the path with normalized directory separators.


toOsSeparator

Normalize directory separators to the current operating system.

public static function toOsSeparator(string $path): string

Parameters:

ParameterTypeDescription
$pathstringFile path to normalize.

Return:

string - Returns the path with normalized directory separators.


normalize

Normalize path separators and remove redundant trailing separators.

public static function normalize(
    string $path,
    string $separator = DIRECTORY_SEPARATOR,
    bool $trimEnd = true
): string

Parameters:

ParameterTypeDescription
$pathstringThe path to normalize.
$separatorstringThe separator to use in the normalized path (default DIRECTORY_SEPARATOR).
$trimEndboolWhether to remove trailing separators (default true).

Return:

string - Returns the normalized path.


resolvePath

Resolve and validate a filesystem path with security controls.

public static function resolvePath(
    string $path,
    ?string $baseDir = null,
    bool $mustExist = false,
    bool $mustReadable = false,
    bool $blockSymlinks = true
): string

Parameters:

ParameterTypeDescription
$pathstringLocal path. Relative paths are resolved from the current working directory.
$baseDir?stringOptional base directory boundary (default: null). Relative base directories are resolved from the current working directory.
$mustExistboolWhether to require the path to exist (default: false).
$mustReadableboolWhether to require the path to be readable (default: false).
$blockSymlinksboolWhether to reject symbolic link traversal (default: true).

Return:

string - Returns the resolved absolute path.

Throws:

  • Luminova\Exceptions\FileException if the path is invalid, leaves the configured base directory, crosses a symlink when blocked, or fails a requested existence or readability check.

__get

Resolve application path names first. Otherwise, forward a property such as filename to the corresponding SplFileInfo getter.

public function __get(string $property): mixed

Parameters:

ParameterTypeDescription
$propertystringApplication path key or file metadata property.

Return:

mixed - Absolute application path, the getter result, or null if file information has not been initialized.

Throws:

  • OutOfBoundsException when file information is initialized but no getter matches.

__call

Forward a method call to the underlying SplFileInfo object.

public function __call(string $method, array $args): mixed

Parameters:

ParameterTypeDescription
$methodstringMethod to call on SplFileInfo.
$argsarray<int|string,mixed>Positional or named arguments to forward.

Return:

mixed - Return value of the delegated method.

Throws:

  • BadMethodCallException when file information has not been initialized or the method is unknown.

__isset

Check whether a name is a registered application path or a recognized metadata key on an initialized instance.

public function __isset(string $name): bool

Parameters:

ParameterTypeDescription
$namestringPath or metadata key to check.

Return:

bool - Whether the key is recognized. This check does not access the file.


__toString

Return the path represented by the current file information object.

public function __toString(): string

Return:

string - File pathname or an empty string when no file information has been initialized.