rfc:streamline-phar-api

This is an old revision of the document!


Request for comments: Streamline Phar API

Abstract

This proposal aims to streamline the Phar API to make it more usable and intuitive.

Concrete change proposals

SplFileInfo

PharFileInfo is derived from SplFileInfo. Every change in SplFileInfo will be visible in PharFileInfo.

setContent/getContent

Proposal

Add two simple methods to write/retrieve content.

Code
$file = new SplFileInfo("file");
$file->setContent('foo');
echo $file->getContent(); // returns 'foo'

get*Time() methods

  • getMTime()
  • getATime()
  • getCTime()
Proposal

Rename the methods to make them more independent from their origin, the UNIX naming scheme and therefore better to understand for a people with non-UNIX backgrounds. Leave the original method names but trigger deprecation warnings and remove them in PHP 6.

  • getMTime() => getModificationTime()
  • getATime() => getAccessTime()
  • getCTime() => getCreateTime()

PharFileInfo

setCompressed*() methods

  • setCompressedBZIP2()
  • setCompressedGZ()
  • setUncompressed()
Proposal

Unify this methods to a single method compress(). The compress method will take one argument indicating the compression algorithm. The compression algorithm is represented as a Phar class constant. The setUncompressed() method should be renamed to uncompress().

Code
$file->compress(Phar::BZ2); // Compress with bzip2
$file->compress(Phar::GZ);  // Compress with gzip
$file->uncompress();

isCompressed*() methods

  • isCompressedBZIP2()
  • isCompressedGZ()
  • isCompressed()
Proposal

Unify this methods to one PharFileInfo::isCompressed(). The new isCompressed() would take an optional argument with the compression algorithm. The compression algorithm is represented as a Phar class constant.

Code
$file->isCompressed(); // Is the file compressed at all?
$file->isCompressed(Phar::GZ); // Is the file gzip compressed?
$file->isCompressed(Phar::BZ2); // Is the file bzip compressed?
rfc/streamline-phar-api.1206715152.txt.gz · Last modified: 2017/09/22 13:28 (external edit)