Bug #67672 [Opn->Dup]: const in trait differs and is considered incompatible

From: Date: Mon, 15 Jan 2018 11:45:42 +0000
Subject: Bug #67672 [Opn->Dup]: const in trait differs and is considered incompatible
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-213543@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=67672&edit=1

 ID:                 67672
 Updated by:         nikic@php.net
 Reported by:        carschrotter at gmail dot com
 Summary:            const in trait differs and is considered
                     incompatible
-Status:             Open
+Status:             Duplicate
 Type:               Bug
 Package:            *General Issues
 Operating System:   Debian 8
 PHP Version:        5.6.0RC2
 Block user comment: N
 Private report:     N

 New Comment:

This has the same root cause as bug #74922, which is fixed in master.


Previous Comments:
------------------------------------------------------------------------
[2014-07-23 20:12:27] 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();
}



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=67672&edit=1


Thread (2 messages)

« previous php.bugs (#213543) next »