private static function staticContextIsOk($self, $static, $method) { try { $Rm = new \ReflectionMethod($static, $method); $Dc = $Rm->getDeclaringClass(); if (!$Dc) { if (self::$debug) { self::debug("Failed to get geclaring class for {$static}::{$method}"); } return false; } $decl_class = $Dc->getName(); if ($decl_class === $self) { return true; } // In PHP 5.5 the declared class is actually correct class, but it never a trait. // So we need to find the actual trait then if it is applicable to the class $Dt = self::getDeclaringTrait($decl_class, $method); if (!$Dt) { if (self::$debug) { self::debug("Failed to get geclaring trait for {$static}::{$method} ({$decl_class}::{$method}"); } return false; } if ($Dt->getName() === $self) { return true; } } catch (\ReflectionException $e) { if (self::$debug) { self::debug("Failed to get reflection method for {$static}::{$method}: {$e}"); } } return false; }