Bug #70044 [Fbk->Opn]: Magic __set(), first parameter "undefined" when passed an array "part"

From: Date: Sun, 12 Jul 2015 02:23:31 +0000
Subject: Bug #70044 [Fbk->Opn]: Magic __set(), first parameter "undefined" when passed an array "part"
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-194342@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70044&edit=1 ID: 70044 User updated by: landers dot robert at gmail dot com Reported by: landers dot robert at gmail dot com -Summary: Magic __set not getting called +Summary: Magic __set(), first parameter "undefined" when passed an array "part" -Status: Feedback +Status: Open Type: Bug Package: Unknown/Other Function Operating System: Docker/Ubuntu PHP Version: 7.0.0beta1 Block user comment: N Private report: N New Comment: After some further investigation, it looks like the "var name" parameter is not set or unset when called like this. I updated the title to reflect this. Previous Comments: ------------------------------------------------------------------------ [2015-07-12 02:16:55] landers dot robert at gmail dot com Here's a derived example. Looks like __set doesn't like arrays... <?php class baseClass { var $vars = []; function __get($var) { echo "got $var<br>"; var_dump($this->vars[$var]); } function __set($var, $value) { echo "set $var = $value<br>"; $this->vars[$var] = $value; echo "<pre>"; var_dump($this->vars[$var]); echo "</pre><br>"; } } $base = new baseClass(); $base->base_class = []; $base->base_class['test'] = "hi"; // this doesn't work! ?> But $var should be set to "something", it doesn't look like it is set to anything useful. ------------------------------------------------------------------------ [2015-07-11 07:32:16] requinix@php.net Thank you for this bug report. To properly diagnose the problem, we need a short but complete example script to be able to reproduce this bug ourselves. A proper reproducing script starts with <?php and ends with ?>, is max. 10-20 lines long and does not require any external resources such as databases, etc. If the script requires a database to demonstrate the issue, please make sure it creates all necessary tables, stored procedures etc. Please avoid embedding huge scripts into the report. ------------------------------------------------------------------------ [2015-07-11 07:14:56] landers dot robert at gmail dot com Description: ------------ After banging my head for a bit, I've discovered that my magic __set wasn't getting called. Magic function not being called, see: https://github.com/WickedMonkeySoftware/appti2ude/commit/80e36c00a440dbe0e1a31ad75c14aee275aeba0a#diff-af625482fd8d321b53c4003a64bc2c7cR173 Test script: --------------- I've already highlighted the exact function in that link. To reproduce: git clone git@github.com:WickedMonkeySoftware/appti2ude.git appti2ude cd appti2ude composer install (doesn't do anything) ./develop.sh visit webpage/ip develop.sh requires docker, you can also just point a vhost at the cloned directory and hit index.php. Expected result: ---------------- You should see output along the lines of "Set $var" in the output. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=70044&edit=1

« previous php.bugs (#194342) next »