|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2019-06-07 08:51 UTC] dmitry@php.net
[2019-06-07 08:51 UTC] dmitry@php.net
-Status: Open
+Status: Closed
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 06:00:02 2025 UTC |
Description: ------------ I know that get_defined_vars() is not returning $this but for every developer it feels like a variable that is currently defined inside an object context. As you can never overwrite $this - even outside an object context it would make sense that the extract function always work as $this is defined and use the appropriate method (skip/prefix). Test script: --------------- <?php $arr = ['this' => 'hello world']; extract($arr, EXTR_SKIP); extract($arr, EXTR_PREFIX_INVALID, 'v_'); var_dump($v_hello === $arr['this']); Expected result: ---------------- bool(true) Actual result: -------------- PHP Fatal error: Uncaught Error: Cannot re-assign $this in /tmp/test.php:4 Stack trace: #0 /tmp/test.php(4): extract(Array, 1) #1 {main} thrown in /tmp/test.php on line 4