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
 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 00:01:27 2024 UTC