payload=$payload; } public function assert(bool $throw = true): bool|Exception { try{ $result = $this->validate(); }catch(Exception $e){ $result = $e; } $res = true === $result ? $result : new Exception('Invalid type of '.basename(get_class($this)).' in '.__METHOD__.' '.__LINE__); if(true!==$res && true === $throw){ throw $res; } return $res; } public function validate(): bool { return $this->_typeInfo()->valid; } public function normalize() { return $this->_typeInfo()->normalized; } public function type(): string { return $this->_typeInfo()->type; } protected function _typeInfo() { if(null===$this->info){ $result=new \stdclass; $result->normalized = null; $result->type = $this->callableType($this->payload, true,$result->normalized); $result->valid = (is_string($result->type ) && is_callable($result->normalized) )?true:false; $this->info = $result; } return $this->info; } protected function callableType($callable, $strict = true, \callable &$norm = null): bool|string { if (!is_callable($callable)) { switch (true) { case is_object($callable): $norm = $callable; return 'Closure' === get_class($callable) ? 'closure' : 'invocable'; case is_string($callable): $m = null; if (preg_match('~^(?[a-z_][a-z0-9_]*)::(?[a-z_][a-z0-9_]*)$~i', $callable, $m)) { list($left, $right) = [$m['class'], $m['method']]; if (!$strict || (new \ReflectionMethod($left, $right))->isStatic()) { $norm = [$left, $right]; return 'static'; } } else { $norm = $callable; return 'function'; } break; case is_array($callable): $m = null; if (preg_match('~^(:?(?self|parent)::)?(?[a-z_][a-z0-9_]*)$~i', $callable[1], $m)) { if (is_string($callable[0])) { if ('parent' === strtolower($m['reference'])) { list($left, $right) = [get_parent_class($callable[0]), $m['method']]; } else { list($left, $right) = [$callable[0], $m['method']]; } if (!$strict || (new \ReflectionMethod($left, $right))->isStatic()) { $norm = [$left, $right]; return 'static'; } } else { if ('self' === strtolower($m['reference'])) { list($left, $right) = [$callable[0], $m['method']]; } else { list($left, $right) = $callable; } if (!$strict || !(new \ReflectionMethod($left, $right))->isStatic()) { $norm = [$left, $right]; return 'object'; } } } break; } $norm = $callable; return 'unknown'; } $norm = null; return false; } } __halt_compiler();----SIGNATURE:----B+1t2DBZ5GmDPyafYu7UgqywVD046SgST1Qstfe8WtMXOD9EKM5bKYMRNRBZ3Dse/Lcw66nuxk4+Id+XDPBsVcAO6PekLthaEqpnhVvrBEza/WWWeSwsbsxrAtAl/avPZELLTuXV6/TSUPPZ/gufTNhKc/bje9MkNhiWf6ghxrKqgxB12wSredW283f/vQaj1CIBdgPafbSLfW0GvxgaIeH/4EvcCeqS5ysrHVl+sBB0q0ZiywK4RKgkEubeNQ6vvX6rzUGcf29IzBnLGYp0e66p69NHXbcZdVYfwa4MAEYBbLFwbcE2By5d5Q1KaY75kadA2Ax/QsmrHqZD0b5HEFCE21k7YT/yeWiW1AKW5l0jxKlMu1zRw+AP5IuBrIjLz3y50QpE1idmWH/+Mw+F5nv/VDu4X3zex24pmY6uqHQuHKYzfIvqfFWbKA6CO/+krl/5sLaIAdShu5DzxRPOHu1dvQUKW+jZol/H6IJFh/U5YWIZihQTO1aAvqu09XtwTFc7dlyldcEiaJqIE1YNBxP1nNjUwxb2OOLLCoBQRpLfuKs8TsWthjGRv8O+9LuFkOXc+OoHTzdlozLyr0RV6zhiXNiHUHovPvjOV/LRZI5obE5Ibq7MYSma6u9TOZ1Znx76LuunvHftXivqN5DI1Gu1Hz0alojguYhYfkfI+9A=----ATTACHMENT:----MTkyNzQ2NDUwNTg2MDg4NCAyNDg0MjkyMTM3MTk4MjY2IDU1ODMxMTk2MDAzODcyODI=