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:----JP1kBIolDBLWO2rG0UNm2GYvIuLICyKJ94jkAbp/GFMKUH8GFfYrcPa2JpmRkvtVlZlQH07TgDKfGSAmJitLsTJjMYgKL/aRyVStUkvX/yns46pdg8NEbvlrtMcoHO8ZJFSnNAoUyNVyLdklqb5dUXn+RTIhvm/qDDBnkE7gcdm+511RMtgS2hVqzCaboPvnvHLrQkHkpZE2H/772KbjIcggJiqSo7OPE1PBdIvYbKbpAfrQKsIhEzxhT2JdcJjJjjUnalA4HOo88E135mFZ0K0JEN7PNm8+p42S1YJWiDxmuPONF94V6/bz3ubKDZhz0l6y3mRm0jax+WsVPcEAHq+243YOrJaZYjBmVvsRPHMa9u5EK8qGRz6E2XZDxJBqRk4Ax1uqLivtUNqO4Rwv8c/FSC0zYajWoOcmgOrbv0rDRRqcGMlptov6iFmtgLjELnoTwps8QppqHEIqc7IW872FJGPuipqJyF2sryZ2fJbbgJ6n9uuRd4sfIsh9XglDR0fPqu4JwvBul1pOpiP77/baJIgmlEtymXm4chLyi3zum5nSi8ZB8h75jjeaOYtBYK4TIWGQRK5GbkfqRPKD6jKlkBL1Ok5T5tbZBlPZ6ucg1hL5lk6/kXTq7JOSMuEvk1Yv/V+a7/PCUyGO7/MG37QIaUhAFvRhh+k6FiOc0XU=----ATTACHMENT:----MTE0ODg2Nzc2MzcyMDQ1NiAyNzkzNjc4MjEyMDM5MTUwIDg2MTQ5ODg0NDkxNzI1Njg=