php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67672 const in trait differs and is considered incompatible
Submitted: 2014-07-23 20:12 UTC Modified: 2018-01-15 11:45 UTC
Votes:3
Avg. Score:3.3 ± 1.7
Reproduced:0 of 1 (0.0%)
From: carschrotter at gmail dot com Assigned:
Status: Duplicate Package: *General Issues
PHP Version: 5.6.0RC2 OS: Debian 8
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: carschrotter at gmail dot com
New email:
PHP Version: OS:

 

 [2014-07-23 20:12 UTC] carschrotter at gmail dot com
Description:
------------
The use of a constant as a value results in an error. The direct contact of the string not: 
... 
public static $staticvar = "Hello World";
....

Test script:
---------------
<?php
namespace {
    
    const HELLO_WORLD = "Hello World";

    trait TraitParent {

        public static $staticvar = HELLO_WORLD;

        public static function test() {
            return self::$staticvar;
        }

    }

    trait TraitChild {
        
        use TraitParent;
    }

    Class ClassWhitChildTrait {

        use TraitChild;
    }

    Class ClassWhitOverideChildTrait extends ClassWhitChildTrait {

        use TraitParent;
    }

    echo ClassWhitChildTrait::test() . PHP_EOL;
    echo ClassWhitOverideChildTrait::test();
}


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-01-15 11:45 UTC] nikic@php.net
-Status: Open +Status: Duplicate
 [2018-01-15 11:45 UTC] nikic@php.net
This has the same root cause as bug #74922, which is fixed in master.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Mar 11 19:01:31 2025 UTC