php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #49402 Documentation for extending Exception is outdated
Submitted: 2009-08-28 20:26 UTC Modified: 2009-09-01 10:21 UTC
From: juwe at clasennet dot de Assigned:
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: juwe at clasennet dot de
New email:
PHP Version: OS:

 

 [2009-08-28 20:26 UTC] juwe at clasennet dot de
Description:
------------
The documentation about extending exceptions (http://www.php.net/manual/en/language.exceptions.extending.php) describes an outdated version of the Exception class. 

The page says, the build-in Exception class would have this interface:

<?php
class Exception
{
    protected $message = 'Unknown exception';   // exception message
    protected $code = 0;                        // user defined exception code
    protected $file;                            // source filename of exception
    protected $line;                            // source line of exception

    function __construct($message = null, $code = 0);

    final function getMessage();                // message of exception 
    final function getCode();                   // code of exception
    final function getFile();                   // source filename
    final function getLine();                   // source line
    final function getTrace();                  // an array of the backtrace()
    final function getTraceAsString();          // formatted string of trace

    /* Overrideable */
    function __toString();                       // formatted string for display
}
?>


This is not true any longer. Suggested fix: Replace Example #1 with this code:

<?php
class Exception   {
    /* Properties */
    protected string $message ;
    private string $string ;
    protected int $code ;
    protected string $file ;
    protected int $line ;
    private array $trace ;
    /* Methods */
    public __construct ($message = "",$code = 0, Exception $previous = NULL ) ;
    final public string getMessage ( ) ;
    final public Exception getPrevious ( ) ;
    final public int getCode ( ) ;
    final public string getFile ( ) ;
    final public int getLine ( ) ;
    final public array getTrace ( ) ;
    final public string getTraceAsString ( ) ;
    public string __toString ( ) ;
    final private void __clone ( ) ;
}
?>

Additionally, the second example is missing a parameter for the constructor.


Reproduce code:
---------------
none

Expected result:
----------------
none, since there's no code.

Actual result:
--------------
???

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-09-01 10:20 UTC] svn@php.net
Automatic comment from SVN on behalf of rquadling
Revision: http://svn.php.net/viewvc/?view=revision&revision=287937
Log: Missing properties and methods of the built-in Exception class and note regarding the inability to clone an Exception.
Fixes bug #49402
 [2009-09-01 10:21 UTC] rquadling@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Tue Oct 06 23:00:02 2026 UTC