php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #54038 "static" scope resolution operator
Submitted: 2011-02-18 00:43 UTC Modified: 2011-10-14 11:40 UTC
From: delphists at apollo dot lv Assigned: salathe (profile)
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: delphists at apollo dot lv
New email:
PHP Version: OS:

 

 [2011-02-18 00:43 UTC] delphists at apollo dot lv
Description:
------------
It's stated in http://php.net/manual/en/language.oop5.paamayim-nekudotayim.php that "Two special keywords _self_ and _parent_ are used to access properties or methods from inside the class definition", but there's also 3rd keyword which is not mentioned - "static".

Test script:
---------------
<?php

    header('content-type: text/plain');
    
    class ParentClass {

        const property = 'parent';

        public function getPropertySelf() {
            // use 'property' const of ParentClass
            return self::property;
        }

        public function getPropertyStatic() {
            // use 'property' const of called class
            return static::property;
        }

    }

    class ChildClass extends ParentClass {
        const property = 'child';
    }

    $obj = new ChildClass();
    var_dump($obj->getPropertySelf()); // string(6) "parent"
    var_dump($obj->getPropertyStatic()); // string(5) "child"



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-10-14 11:37 UTC] salathe@php.net
Automatic comment from SVN on behalf of salathe
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=318102
Log: static is special keyword too (patch by anon 11351, doc #54038)
 [2011-10-14 11:40 UTC] salathe@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: salathe
 [2011-10-14 11:40 UTC] salathe@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-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 31 22:01:27 2024 UTC