mirror of
https://github.com/php/php-src.git
synced 2025-08-18 15:08:55 +02:00
Merge branch 'PHP-5.4' into PHP-5.5
This commit is contained in:
commit
f39d12c821
6 changed files with 77 additions and 4 deletions
34
Zend/tests/traits/bug64235.phpt
Normal file
34
Zend/tests/traits/bug64235.phpt
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
--TEST--
|
||||||
|
Bug #64235 (Insteadof not work for class method in 5.4.11)
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class TestParentClass
|
||||||
|
{
|
||||||
|
public function method()
|
||||||
|
{
|
||||||
|
print_r('Parent method');
|
||||||
|
print "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
trait TestTrait
|
||||||
|
{
|
||||||
|
public function method()
|
||||||
|
{
|
||||||
|
print_r('Trait method');
|
||||||
|
print "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class TestChildClass extends TestParentClass
|
||||||
|
{
|
||||||
|
use TestTrait
|
||||||
|
{
|
||||||
|
TestTrait::method as methodAlias;
|
||||||
|
TestParentClass::method insteadof TestTrait;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
Fatal error: Class TestParentClass is not a trait, Only traits may be used in 'as' and 'insteadof' statements in %sbug64235.php on line %d
|
35
Zend/tests/traits/bug64235b.phpt
Normal file
35
Zend/tests/traits/bug64235b.phpt
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
--TEST--
|
||||||
|
Bug #64235 (Insteadof not work for class method in 5.4.11)
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class TestParentClass
|
||||||
|
{
|
||||||
|
public function method()
|
||||||
|
{
|
||||||
|
print_r('Parent method');
|
||||||
|
print "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
trait TestTrait
|
||||||
|
{
|
||||||
|
public function method()
|
||||||
|
{
|
||||||
|
print_r('Trait method');
|
||||||
|
print "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class TestChildClass extends TestParentClass
|
||||||
|
{
|
||||||
|
use TestTrait
|
||||||
|
{
|
||||||
|
TestTrait::method as methodAlias;
|
||||||
|
TestParentClass::method as TestParent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
Fatal error: Class TestParentClass is not a trait, Only traits may be used in 'as' and 'insteadof' statements in %sbug64235b.php on line %d
|
|
@ -14,4 +14,4 @@ class C {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
--EXPECTF--
|
--EXPECTF--
|
||||||
Fatal error: Trait T2 is not used in %s on line %d
|
Fatal error: Required Trait T2 wasn't added to C in %slanguage015.php on line %d
|
||||||
|
|
|
@ -14,4 +14,4 @@ class C {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
--EXPECTF--
|
--EXPECTF--
|
||||||
Fatal error: Trait T2 is not used in %s on line %d
|
Fatal error: Required Trait T2 wasn't added to C in %slanguage016.php on line %d
|
||||||
|
|
|
@ -14,4 +14,4 @@ class C {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
--EXPECTF--
|
--EXPECTF--
|
||||||
Fatal error: Trait T2 is not used in %s on line %d
|
Fatal error: Required Trait T2 wasn't added to C in %slanguage017.php on line %d
|
||||||
|
|
|
@ -4048,12 +4048,16 @@ static void zend_check_trait_usage(zend_class_entry *ce, zend_class_entry *trait
|
||||||
{
|
{
|
||||||
zend_uint i;
|
zend_uint i;
|
||||||
|
|
||||||
|
if ((trait->ce_flags & ZEND_ACC_TRAIT) != ZEND_ACC_TRAIT) {
|
||||||
|
zend_error(E_COMPILE_ERROR, "Class %s is not a trait, Only traits may be used in 'as' and 'insteadof' statements", trait->name);
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < ce->num_traits; i++) {
|
for (i = 0; i < ce->num_traits; i++) {
|
||||||
if (ce->traits[i] == trait) {
|
if (ce->traits[i] == trait) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
zend_error(E_COMPILE_ERROR, "Trait %s is not used", trait->name);
|
zend_error(E_COMPILE_ERROR, "Required Trait %s wasn't added to %s", trait->name, ce->name);
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue