summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Marr <gron@php.net>2011-11-23 21:24:34 +0000
committerStefan Marr <gron@php.net>2011-11-23 21:24:34 +0000
commit35d38e4772c4c6c0f92475471252fc08659ac84f (patch)
treed4e153ab8d72b53c6999d7d1e2965808616a88e3
parent517e28309dcbd40bdc4cb127785853172e64ecdb (diff)
downloadphp-git-35d38e4772c4c6c0f92475471252fc08659ac84f.tar.gz
Fixed Bug #60369 Crash with static property in trait
-rw-r--r--Zend/tests/traits/bug60369.phpt17
-rw-r--r--Zend/zend_compile.c5
2 files changed, 20 insertions, 2 deletions
diff --git a/Zend/tests/traits/bug60369.phpt b/Zend/tests/traits/bug60369.phpt
new file mode 100644
index 0000000000..bfc1ee303f
--- /dev/null
+++ b/Zend/tests/traits/bug60369.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Bug #60369 (Crash with static property in trait)
+--FILE--
+<?php
+
+trait PropertiesTrait {
+ static $same = true;
+}
+
+class Properties {
+ use PropertiesTrait;
+ public $same = true;
+}
+
+?>
+--EXPECTF--
+Fatal error: Properties and PropertiesTrait define the same property ($same) in the composition of Properties. However, the definition differs and is considered incompatible. Class was composed in %s on line %d \ No newline at end of file
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index 40d2e93a97..215edf61d2 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -4272,10 +4272,11 @@ static void zend_do_traits_property_binding(zend_class_entry *ce TSRMLS_DC) /* {
/* this one is inherited, lets look it up in its own class */
zend_hash_quick_find(&coliding_prop->ce->properties_info, prop_name, prop_name_length+1, prop_hash, (void **) &coliding_prop);
}
- if ((coliding_prop->flags & ZEND_ACC_PPP_MASK) == (property_info->flags & ZEND_ACC_PPP_MASK)) {
+ if ( (coliding_prop->flags & (ZEND_ACC_PPP_MASK | ZEND_ACC_STATIC))
+ == (property_info->flags & (ZEND_ACC_PPP_MASK | ZEND_ACC_STATIC))) {
/* flags are identical, now the value needs to be checked */
if (property_info->flags & ZEND_ACC_STATIC) {
- not_compatible = (FAILURE == compare_function(&compare_result,
+ not_compatible = (FAILURE == compare_function(&compare_result,
ce->default_static_members_table[coliding_prop->offset],
ce->traits[i]->default_static_members_table[property_info->offset] TSRMLS_CC))
|| (Z_LVAL(compare_result) != 0);