Doc #62537 [NEW]: Composed class has fatal error with duplicate, equal array properties

From: Date: Wed, 11 Jul 2012 19:45:00 +0000
Subject: Doc #62537 [NEW]: Composed class has fatal error with duplicate, equal array properties
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-8550@lists.php.net to get a copy of this message
From:             jeremeamia at gmail dot com
Operating system: Ubuntu
PHP version:      5.4.4
Package:          Documentation problem
Bug Type:         Documentation Problem
Bug description:Composed class has fatal error with duplicate, equal array properties

Description:
------------
---
From manual page: http://www.php.net/language.oop5.traits
---

The manual says, "If a trait defines a property then a class can not define
a 
property with the same name, otherwise an error is issued. It is an
E_STRICT if 
the class definition is compatible (same visibility and initial value) or
fatal 
error otherwise."

This does not appear to be true when the same-named properties have array
values. 
See the test script for a quick example. It seems that it behaves as the 
documentation describes only with scalar values.

This is either missing/erroneous documentation (i.e. the behavior is
intended), or 
it is a bug (i.e. equal array values should not cause a fatal error).

Test script:
---------------
trait Foo {public $var = [];}
trait Bar {public $var = [];}
class Baz {use Foo, Bar;}

Expected result:
----------------
To behave as the documentation describes, i.e. no fatal errors occuring.

Actual result:
--------------
PHP Fatal error:  Foo and Bar define the same property ($var) in the
composition 
of Baz. However, the definition differs and is considered incompatible.

-- 
Edit bug report at https://bugs.php.net/bug.php?id=62537&edit=1
-- 
Try a snapshot (PHP 5.4):            https://bugs.php.net/fix.php?id=62537&r=trysnapshot54
Try a snapshot (PHP 5.3):            https://bugs.php.net/fix.php?id=62537&r=trysnapshot53
Try a snapshot (trunk):              https://bugs.php.net/fix.php?id=62537&r=trysnapshottrunk
Fixed in SVN:                        https://bugs.php.net/fix.php?id=62537&r=fixed
Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=62537&r=needdocs
Fixed in release:                    https://bugs.php.net/fix.php?id=62537&r=alreadyfixed
Need backtrace:                      https://bugs.php.net/fix.php?id=62537&r=needtrace
Need Reproduce Script:               https://bugs.php.net/fix.php?id=62537&r=needscript
Try newer version:                   https://bugs.php.net/fix.php?id=62537&r=oldversion
Not developer issue:                 https://bugs.php.net/fix.php?id=62537&r=support
Expected behavior:                   https://bugs.php.net/fix.php?id=62537&r=notwrong
Not enough info:                     https://bugs.php.net/fix.php?id=62537&r=notenoughinfo
Submitted twice:                     https://bugs.php.net/fix.php?id=62537&r=submittedtwice
register_globals:                    https://bugs.php.net/fix.php?id=62537&r=globals
PHP 4 support discontinued:          https://bugs.php.net/fix.php?id=62537&r=php4
Daylight Savings:                    https://bugs.php.net/fix.php?id=62537&r=dst
IIS Stability:                       https://bugs.php.net/fix.php?id=62537&r=isapi
Install GNU Sed:                     https://bugs.php.net/fix.php?id=62537&r=gnused
Floating point limitations:          https://bugs.php.net/fix.php?id=62537&r=float
No Zend Extensions:                  https://bugs.php.net/fix.php?id=62537&r=nozend
MySQL Configuration Error:           https://bugs.php.net/fix.php?id=62537&r=mysqlcfg



Thread (5 messages)

« previous php.doc.bugs (#8550) next »