Check array keys existence prior to their usage when removing methods in CustomMethods

This commit is contained in:
Michal Kleiner 2019-01-09 15:53:05 +08:00
parent 79a89e751d
commit 52a039f631
1 changed files with 7 additions and 2 deletions

View File

@ -282,10 +282,15 @@ trait CustomMethods
if (!isset(self::$extra_methods[$class][$method])) {
continue;
}
$methodInfo = self::$extra_methods[$class][$method];
if ($methodInfo['property'] === $property && $methodInfo['index'] === $index) {
if (
// always check for property
(isset($methodInfo['property']) && $methodInfo['property'] === $property) &&
// check for index only if provided (otherwise assume true)
(($index && isset($methodInfo['index']) && $methodInfo['index'] === $index) || true)
) {
unset(self::$extra_methods[$class][$method]);
}
}