Created
July 8, 2015 08:44
-
-
Save artembeloglazov/967d56d6eb4253b980f0 to your computer and use it in GitHub Desktop.
Просмотр текущего стека и поиск нужных данных в вызываемых строках исходных кодов
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public function __set($name, $value) { | |
| try { | |
| $setterGetter = $this->setterGetter($name, 'set'); | |
| } catch (\Exception $e){ | |
| if($e->getCode() == 3000){ | |
| $stack = debug_backtrace(); | |
| if(isset($stack[0]['file'])){ | |
| $fileName = $stack[0]['file']; | |
| if(!array_key_exists($fileName, self::$fileCache)){ | |
| self::$fileCache[$fileName] = file($fileName); | |
| } | |
| $line = self::$fileCache[$fileName][$stack[0]['line'] - 1]; | |
| preg_match("/([a-zA-Z]*)->$name/", $line, $m); | |
| if(isset($m[1]) && ($m[1] == 'this')){ | |
| goto set; | |
| } | |
| } | |
| } | |
| throw new \Exception($e->getMessage(), $e->getCode()); | |
| } | |
| $value = $this->$setterGetter($value, $name); | |
| set: | |
| $this->$name = $value; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment