php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #75359 multiple declaration for visibility or const inline.
Submitted: 2017-10-11 12:13 UTC Modified: 2017-10-11 17:18 UTC
From: saymongcsw at gmail dot com Assigned:
Status: Verified Package: Documentation problem
PHP Version: Irrelevant OS: irrevelant
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: saymongcsw at gmail dot com
New email:
PHP Version: OS:

 

 [2017-10-11 12:13 UTC] saymongcsw at gmail dot com
Description:
------------
I've found cool feature that isn't documented yet so it is as undefined behavior. And works in all PHP since 5.0.2+ and/or earlier.
I.e. missing documentation for multiple declaration visibility and/or constants.

http://php.net/manual/en/language.oop5.visibility.php
http://php.net/manual/en/language.oop5.constants.php

Demo: https://3v4l.org/qRnlk

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

class test1
{
    const a = 'b', b = 'a', c = 'c';

    public function __construct()
    {
        echo self::b, self::a, self::c, PHP_EOL;
    }
}

class test2
{
    private $a = 'b', $b = 'a', $c = 'c';
}

try {
    new test1; // abc
    echo test2::$b, test2::$a, test2::$c; // Cannot access private property test2::$b
} catch (Error $e) {
    echo $e->getMessage();
}


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-10-11 13:38 UTC] cmb@php.net
-Status: Open +Status: Verified -Type: Feature/Change Request +Type: Bug
 [2017-10-11 13:56 UTC] requinix@php.net
Why is this a bug? ::a and ::$a are two different things. Meanwhile writing "test2::$b" is incorrect both because $b is not static and because it's private, but with Errors only one of those can be reported at a time.
 [2017-10-11 17:18 UTC] cmb@php.net
-Type: Bug +Type: Documentation Problem
 [2017-10-11 17:18 UTC] cmb@php.net
> Why is this a bug?

Of course, it is a doc bug (not a feature request).
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 19:01:29 2024 UTC