class PharFileInfo extends SplFileInfo (View source)

The PharFileInfo class provides a high-level interface to the contents and attributes of a single file within a phar archive.

Methods

__construct(string $filename)

(PHP >= 5.3.0, PECL phar >= 1.0.0)
Construct a Phar entry object

string
getPath()

Gets the path without filename

string
getFilename()

Gets the filename

string
getExtension()

Gets the file extension

string
getBasename(string $suffix = '')

Gets the base name of the file

string
getPathname()

Gets the path to the file

int|false
getPerms()

Gets file permissions

int|false
getInode()

Gets the inode for the file

int|false
getSize()

Gets file size

int|false
getOwner()

Gets the owner of the file

int|false
getGroup()

Gets the file group

int|false
getATime()

Gets last access time of the file

int|false
getMTime()

Gets the last modified time

int|false
getCTime()

Gets the inode change time

string|false
getType()

Gets file type

bool
isWritable()

Tells if the entry is writable

bool
isReadable()

Tells if file is readable

bool
isExecutable()

Tells if the file is executable

bool
isFile()

Tells if the object references a regular file

bool
isDir()

Tells if the file is a directory

bool
isLink()

Tells if the file is a link

string|false
getLinkTarget()

Gets the target of a link

string|false
getRealPath()

Gets absolute path to file

getFileInfo(T> $class = null)

Gets an SplFileInfo object for the file

getPathInfo(T> $class = null)

Gets an SplFileInfo object for the path

openFile(string $mode = 'r', bool $useIncludePath = false, resource $context = null)

Gets an SplFileObject object for the file

void
setFileClass(T> $class = SplFileObject::class)

Sets the class name used with SplFileInfo::openFile

void
setInfoClass(T> $class = SplFileInfo::class)

Sets the class used with getFileInfo and getPathInfo

string
__toString()

Returns the path to the file as a string

void
_bad_state_ex()

No description

__wakeup()

No description

array
__debugInfo()

No description

__destruct()

No description

void
chmod(int $perms)

(PHP >= 5.3.0, PECL phar >= 1.0.0)
Sets file-specific permission bits

bool
compress(int $compression)

(PHP >= 5.3.0, PECL phar >= 2.0.0)
Compresses the current Phar entry with either zlib or bzip2 compression

bool
decompress()

(PHP >= 5.3.0, PECL phar >= 2.0.0)
Decompresses the current Phar entry within the phar

bool
delMetadata()

(PHP >= 5.3.0, PECL phar >= 1.2.0)
Deletes the metadata of the entry

int
getCompressedSize()

(PHP >= 5.3.0, PECL phar >= 1.0.0)
Returns the actual size of the file (with compression) inside the Phar archive

int
getCRC32()

(PHP >= 5.3.0, PECL phar >= 1.0.0)
Returns CRC32 code or throws an exception if CRC has not been verified

string
getContent()

No description

mixed
getMetadata(array $unserializeOptions = [])

(PHP >= 5.3.0, PECL phar >= 1.0.0)
Returns file-specific meta-data saved with a file

int
getPharFlags()

(PHP >= 5.3.0, PECL phar >= 1.0.0)
Returns the Phar file entry flags

bool
hasMetadata()

(PHP >= 5.3.0, PECL phar >= 1.2.0)
Returns the metadata of the entry

bool
isCompressed(int $compression = null)

(PHP >= 5.3.0, PECL phar >= 1.0.0)
Returns whether the entry is compressed

bool
isCRCChecked()

(PHP >= 5.3.0, PECL phar >= 1.0.0)
Returns whether file entry has had its CRC verified

void
setMetadata(mixed $metadata)

(PHP >= 5.3.0, PECL phar >= 1.0.0)
Sets file-specific meta-data saved with a file

Details

__construct(string $filename)

(PHP >= 5.3.0, PECL phar >= 1.0.0)
Construct a Phar entry object

Parameters

string $filename

string getPath()

Since: 5.1.2

Gets the path without filename

Return Value

string

the path to the file.

string getFilename()

Since: 5.1.2

Gets the filename

Return Value

string

The filename.

string getExtension()

Since: 5.3.6

Gets the file extension

Return Value

string

a string containing the file extension, or an empty string if the file has no extension.

string getBasename(string $suffix = '')

Since: 5.2.2

Gets the base name of the file

Parameters

string $suffix

[optional]

Optional suffix to omit from the base name returned.

Return Value

string

the base name without path information.

string getPathname()

Since: 5.1.2

Gets the path to the file

Return Value

string

The path to the file.

int|false getPerms()

Since: 5.1.2

Gets file permissions

Return Value

int|false

The file permissions on success, or FALSE on failure.

int|false getInode()

Since: 5.1.2

Gets the inode for the file

Return Value

int|false

The inode number for the filesystem object on success, or FALSE on failure.

Exceptions

RuntimeException

int|false getSize()

Since: 5.1.2

Gets file size

Return Value

int|false

The filesize in bytes on success, or FALSE on failure.

Exceptions

RuntimeException

int|false getOwner()

Since: 5.1.2

Gets the owner of the file

Return Value

int|false

The owner id in numerical format on success, or FALSE on failure.

Exceptions

RuntimeException

int|false getGroup()

Since: 5.1.2

Gets the file group

Return Value

int|false

The group id in numerical format on success, or FALSE on failure.

Exceptions

RuntimeException

int|false getATime()

Since: 5.1.2

Gets last access time of the file

Return Value

int|false

The time the file was last accessed on success, or FALSE on failure.

Exceptions

RuntimeException

int|false getMTime()

Since: 5.1.2

Gets the last modified time

Return Value

int|false

The last modified time for the file, in a Unix timestamp on success, or FALSE on failure.

int|false getCTime()

Since: 5.1.2

Gets the inode change time

Return Value

int|false

The last change time, in a Unix timestamp on success, or FALSE on failure.

Exceptions

RuntimeException

string|false getType()

Since: 5.1.2

Gets file type

Return Value

string|false

A string representing the type of the entry. May be one of file, link, dir, block, fifo, char, socket, or unknown, or FALSE on failure. May be one of file, link, or dir

Exceptions

RuntimeException

bool isWritable()

Since: 5.1.2

Tells if the entry is writable

Return Value

bool

true if writable, false otherwise;

bool isReadable()

Since: 5.1.2

Tells if file is readable

Return Value

bool

true if readable, false otherwise.

bool isExecutable()

Since: 5.1.2

Tells if the file is executable

Return Value

bool

true if executable, false otherwise.

bool isFile()

Since: 5.1.2

Tells if the object references a regular file

Return Value

bool

true if the file exists and is a regular file (not a link), false otherwise.

bool isDir()

Since: 5.1.2

Tells if the file is a directory

Return Value

bool

true if a directory, false otherwise.

Since: 5.1.2

Tells if the file is a link

Return Value

bool

true if the file is a link, false otherwise.

string|false getLinkTarget()

Since: 5.2.2

Gets the target of a link

Return Value

string|false

The target of the filesystem link on success, or FALSE on failure.

Exceptions

RuntimeException

string|false getRealPath()

Since: 5.2.2

Gets absolute path to file

Return Value

string|false

the path to the file, or FALSE if the file does not exist.

SplFileInfo getFileInfo(T> $class = null)

Since: 5.1.2

Gets an SplFileInfo object for the file

Parameters

T> $class

[optional]

Name of an SplFileInfo derived class to use.

Return Value

SplFileInfo

An SplFileInfo object created for the file.

SplFileInfo|null getPathInfo(T> $class = null)

Since: 5.1.2

Gets an SplFileInfo object for the path

Parameters

T> $class

[optional]

Name of an SplFileInfo derived class to use.

Return Value

SplFileInfo|null

A SplFileInfo object for the parent path of the file on success, or NULL on failure.

SplFileObject openFile(string $mode = 'r', bool $useIncludePath = false, resource $context = null)

Since: 5.1.2

Gets an SplFileObject object for the file

Parameters

string $mode

[optional]

The mode for opening the file. See the fopen documentation for descriptions of possible modes. The default is read only.

bool $useIncludePath

[optional]

resource $context

[optional]

Return Value

SplFileObject

The opened file as an SplFileObject object.

Exceptions

RuntimeException

void setFileClass(T> $class = SplFileObject::class)

Since: 5.1.2

Sets the class name used with SplFileInfo::openFile

Parameters

T> $class

[optional]

The class name to use when openFile() is called.

Return Value

void

void setInfoClass(T> $class = SplFileInfo::class)

Since: 5.1.2

Sets the class used with getFileInfo and getPathInfo

Parameters

T> $class

[optional]

The class name to use.

Return Value

void

string __toString()

Since: 5.1.2

Returns the path to the file as a string

Return Value

string

Returns string representation of the object that implements this interface (and/or "__toString" magic method).

final void _bad_state_ex()

No description

Return Value

void

__wakeup()

No description

array __debugInfo()

Since: 7.4

No description

Return Value

array

__destruct()

No description

void chmod(int $perms)

(PHP >= 5.3.0, PECL phar >= 1.0.0)
Sets file-specific permission bits

Parameters

int $perms

permissions (see chmod)

Return Value

void

No value is returned.

bool compress(int $compression)

(PHP >= 5.3.0, PECL phar >= 2.0.0)
Compresses the current Phar entry with either zlib or bzip2 compression

Parameters

int $compression

Return Value

bool

TRUE on success or FALSE on failure.

bool decompress()

(PHP >= 5.3.0, PECL phar >= 2.0.0)
Decompresses the current Phar entry within the phar

Return Value

bool

TRUE on success or FALSE on failure.

bool delMetadata()

(PHP >= 5.3.0, PECL phar >= 1.2.0)
Deletes the metadata of the entry

Return Value

bool

TRUE if successful, FALSE if the entry had no metadata. As with all functionality that modifies the contents of a phar, the phar.readonly INI variable must be off in order to succeed if the file is within a Phar archive. Files within PharData archives do not have this restriction.

int getCompressedSize()

(PHP >= 5.3.0, PECL phar >= 1.0.0)
Returns the actual size of the file (with compression) inside the Phar archive

Return Value

int

The size in bytes of the file within the Phar archive on disk.

int getCRC32()

(PHP >= 5.3.0, PECL phar >= 1.0.0)
Returns CRC32 code or throws an exception if CRC has not been verified

Return Value

int

The crc32 checksum of the file within the Phar archive.

string getContent()

No description

Return Value

string

mixed getMetadata(array $unserializeOptions = [])

(PHP >= 5.3.0, PECL phar >= 1.0.0)
Returns file-specific meta-data saved with a file

Parameters

array $unserializeOptions

[optional] if is set to anything other than the default, the resulting metadata won't be cached and this won't return the value from the cache

Return Value

mixed

any PHP variable that can be serialized and is stored as meta-data for the file, or NULL if no meta-data is stored.

int getPharFlags()

(PHP >= 5.3.0, PECL phar >= 1.0.0)
Returns the Phar file entry flags

Return Value

int

The Phar flags (always 0 in the current implementation)

bool hasMetadata()

(PHP >= 5.3.0, PECL phar >= 1.2.0)
Returns the metadata of the entry

Return Value

bool

FALSE if no metadata is set or is NULL, TRUE if metadata is not NULL

bool isCompressed(int $compression = null)

(PHP >= 5.3.0, PECL phar >= 1.0.0)
Returns whether the entry is compressed

Parameters

int $compression

[optional]

One of Phar::GZ or Phar::BZ2, defaults to any compression.

Return Value

bool

TRUE if the file is compressed within the Phar archive, FALSE if not.

bool isCRCChecked()

(PHP >= 5.3.0, PECL phar >= 1.0.0)
Returns whether file entry has had its CRC verified

Return Value

bool

TRUE if the file has had its CRC verified, FALSE if not.

void setMetadata(mixed $metadata)

(PHP >= 5.3.0, PECL phar >= 1.0.0)
Sets file-specific meta-data saved with a file

Parameters

mixed $metadata

Any PHP variable containing information to store alongside a file

Return Value

void

No value is returned.