#36214 [Opn->Bgs]: Conditional operator fails to work properly when both __set and __get are set

From: Date: Mon, 30 Jan 2006 18:43:19 +0000
Subject: #36214 [Opn->Bgs]: Conditional operator fails to work properly when both __set and __get are set
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-92656@lists.php.net to get a copy of this message
ID: 36214 Updated by: johannes@php.net Reported By: pexu at lyseo dot edu dot ouka dot fi -Status: Open +Status: Bogus Bug Type: Scripting Engine problem Operating System: Windows XP PHP Version: 5.1.2 New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php You're trying to acces a private property (arr) from outside the class. Previous Comments: ------------------------------------------------------------------------ [2006-01-30 19:34:55] pexu at lyseo dot edu dot ouka dot fi Description: ------------ When both __set and __get are set, conditional operator "?" fails to work when used to return variables from __get when working with arrays. A normal if .. else clause however works fine. With non-array variables there's no problem, either. If __set is not used, this bug doesn't seem to appear. Reproduce code: --------------- class overload { private $array = array(); public function __set($key, $value) { $this->array[$key] = $value; } public function __get($key) { return isset($this->array[$key]) ? $this->array[$key] : null; } } $ol = new overload; $ol->arr = array(); array_push($ol->arr, "element"); var_dump($ol->arr); Expected result: ---------------- array(1) { [0]=> string(7) "element" } Actual result: -------------- array(0) { } ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=36214&edit=1

« previous php.bugs (#92656) next »