|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-07-19 09:34 UTC] dmitry@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 08:00:01 2025 UTC |
Description: ------------ In object that implements ArrayAccess and accesses itself as array inside its own method, $this is not available ("Undefined variable: this") Reproduce code: --------------- <?php class Foo implements ArrayAccess { function offsetExists ($offset) {/*...*/} function offsetGet ($offset) {/*...*/} function offsetSet ($offset, $value) {/*...*/} function offsetUnset ($offset) {/*...*/} function fail() { $this['blah']; } function succeed() { $this; $this['blah']; } } $bar = new Foo(); $bar->succeed(); $bar->fail(); Expected result: ---------------- No error. Both methods should work. Actual result: -------------- Notice: Undefined variable: this in c:\www\test.php5 on line 13