parent
a1b09926a3
commit
c75b4d565b
6 changed files with 93 additions and 9 deletions
@ -0,0 +1,13 @@ |
||||
<?php |
||||
|
||||
class FinalConstantParent |
||||
{ |
||||
final public const VALUE = 1; |
||||
} |
||||
|
||||
class FinalConstantChild extends FinalConstantParent |
||||
{ |
||||
public const VALUE = 2; |
||||
} |
||||
|
||||
function main() {} |
||||
@ -0,0 +1,13 @@ |
||||
<?php |
||||
|
||||
class TypedConstantParent |
||||
{ |
||||
public const int VALUE = 1; |
||||
} |
||||
|
||||
class UntypedConstantChild extends TypedConstantParent |
||||
{ |
||||
public const VALUE = 1; |
||||
} |
||||
|
||||
function main() {} |
||||
@ -0,0 +1,43 @@ |
||||
--TEST-- |
||||
parent class constants resolve across namespaces |
||||
--FILE-- |
||||
<?php |
||||
|
||||
namespace Library { |
||||
class Base |
||||
{ |
||||
public const TOKEN = 'base'; |
||||
} |
||||
} |
||||
|
||||
namespace Application { |
||||
class Sibling |
||||
{ |
||||
} |
||||
|
||||
class Child extends \Library\Base |
||||
{ |
||||
public const PARENT_NAME = parent::class; |
||||
public const SIBLING_NAME = Sibling::class; |
||||
|
||||
public static function dumpParent(): void |
||||
{ |
||||
var_dump(parent::class, parent::TOKEN); |
||||
} |
||||
} |
||||
} |
||||
|
||||
namespace { |
||||
function main(): void |
||||
{ |
||||
var_dump(\Application\Child::PARENT_NAME); |
||||
var_dump(\Application\Child::SIBLING_NAME); |
||||
\Application\Child::dumpParent(); |
||||
} |
||||
} |
||||
?> |
||||
--EXPECT-- |
||||
string(12) "Library\Base" |
||||
string(19) "Application\Sibling" |
||||
string(12) "Library\Base" |
||||
string(4) "base" |
||||
Loading…
Reference in new issue