Documentation

FilesystemInterface

Defines several stream-save filesystem actions.

Tags
used-by

Filesystem

since
1.6

Table of Contents

Methods

basename()  : string
Unicode-safe and stream-safe `\basename()` replacement.
dirname()  : string
Unicode-safe and stream-safe `\dirname()` replacement.
normalize()  : string
Normalize path by cleaning up `\`, `/./`, `//` and `/../`.
parent()  : string
Get parent path. Empty path is returned if there are no segments remaining.
pathinfo()  : array<string|int, mixed>|string
Unicode-safe and stream-safe `\pathinfo()` replacement.

Methods

basename()

Unicode-safe and stream-safe `\basename()` replacement.

public basename(string $path[, string|null $suffix = null ]) : string
APIYes
Parameters
$path : string

A filename or path, does not need to exist as a file.

$suffix : string|null = null

If the filename ends in suffix this will also be cut off.

Return values
string

dirname()

Unicode-safe and stream-safe `\dirname()` replacement.

public dirname(string $path[, int $levels = 1 ]) : string
APIYes
Parameters
$path : string

A filename or path, does not need to exist as a file.

$levels : int = 1

The number of parent directories to go up (>= 1).

Tags
see
http://php.net/manual/en/function.dirname.php
throws
RuntimeException
phpstan-param

positive-int $levels

Return values
string

Returns path to the directory.

normalize()

Normalize path by cleaning up `\`, `/./`, `//` and `/../`.

public normalize(string $path) : string
APIYes
Parameters
$path : string

A filename or path, does not need to exist as a file.

Tags
throws
RuntimeException
Return values
string

Returns normalized path.

parent()

Get parent path. Empty path is returned if there are no segments remaining.

public parent(string $path[, int $levels = 1 ]) : string
APIYes

Can be used recursively to get towards the root directory.

Parameters
$path : string

A filename or path, does not need to exist as a file.

$levels : int = 1

The number of parent directories to go up (>= 1).

Tags
throws
RuntimeException
phpstan-param

positive-int $levels

Return values
string

Returns parent path.

pathinfo()

Unicode-safe and stream-safe `\pathinfo()` replacement.

public pathinfo(string $path[, int|null $options = null ]) : array<string|int, mixed>|string
APIYes
Parameters
$path : string

A filename or path, does not need to exist as a file.

$options : int|null = null

A PATHINFO_* constant.

Tags
see
http://php.net/manual/en/function.pathinfo.php
Return values
array<string|int, mixed>|string

        
On this page

Search results