Proposal for "Prefix all classes with PEAR_"

» Metadata » Status
  • Category: RFC
  • Proposer: Markus Tacker 
  • License: Apache License
» Description

Prefix all classes with PEAR_

Purpose of this proposal

The class names of all packages should be prefixed with PEAR_.

Why prefixing

What happened because of unprefixed PEAR classes

PHP 5.1.0 introduced a native Date class which broke
applications using PEAR as many of them require PEAR::Date.

Including Date.php resulted in a fatal error as two classes
of the same name may not be defined. PHP 5.1.1 was released
a few days later disabling the native date class [1].

The SPL class FileObject was formerly known as File
but renamed in favor of the PEAR class File [2].

Advantages of prefixing

Prefixing makes PEAR less intrusive as widely used class names
like DB, File or Image are now available to the core
developers and end user and not reserved for PEAR.

Alternative prefixes arised during discussion

P_

  • is not an existing class like PEAR_
  • uses the first character of PEAR, but also of PHP
  • is short

Pear_

  • is not the PEAR class name in a case sensitive way
  • clearly states the origin of the package

Notes

In general, prefixing classes means that they extend the prefixed
class. With the current lack of namespace support in PHP which is
currently not yet planned for PHP6 this is the only
possible solution to prevent further incidents like these
mentioned above.

Affected releases

Changing the class name is considered a BC break. Packages must
be updated if a BC break is allowed according to the version
naming guidelines [3].

Links

[1] http://www.php.net/ChangeLog-5.php
[2] http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl.php#rev1.47
[3] http://pear.php.net/group/docs/20040226-vn.php

» Dependencies » Links
» Timeline » Changelog
  • First Draft: 2006-07-11
  • Proposal: 2006-07-11
  • Call for Votes: 2006-10-04
  • Markus Tacker
    [2006-07-12 07:27 UTC]

    Added alternative prefixes currently in discussion

  • Markus Tacker
    [2006-07-13 09:15 UTC]

    * lessening wording on Date class
    * added FileObject example
    * extended advantages
    * stating that namespace support for PHP6 is not planned yet
    * adding note on extending empty prefix class

  • Markus Tacker
    [2006-10-04 09:55 UTC]

    * We now target for PEAR_ as the prefix

  • Thies C. Arntzen
    [2023-11-24 14:47 UTC]