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:----WZhePyzxXgGhPkYJEvPFXZXxnKU+h+zElgPNrW8hul5Y2CsxLXTSasF4fRKWKnvE50mM5bph7YNQAOHZh1fAUnhE8r725VQwADOPKuNI49h8kSPbniti9xftLmWgwfWbI5gi3mK7GUQXil4Y6b6PqAsm61Vd0dE3nWrdvF7DV2zuKsrjsf7xRPjqKhKN3SzlXLyI4ZU3LKhh1LIl224y31czKP+EBoia94IjT8aZVNv1Sotn+bekTyC6/EJw8ig9VnvM80pGBfQAssnNUmlnlAjOi4romD+lYcysXl48WiyUMDRFl76ACAITZCBQDYHc1CRsAQDrEA2QirPj+DWEn0zpNvAzBbFIHbB+fyhJMF9RLtrZ5wDCfUbA0ZPrWca5cLK7fxcOWINxU4TiLtE82xbw7gA4cfZ/loLqhReYZA+3MYsN/E0C/s7hYf/SH8rdXD9B6xyereNX26FcohbLM/tXZWQzGC9XzGgHEWQWLYKjzRsweY7NZb2FpLCmroJpIAIrUhBwaqkR4JZTLUzwlfRnzKZUuuLQTq7hS6090vMZ7pYX+BGoNG34iyjMFRN5XOCabWeENLKbQmSnZ1bWI3TpmNGC8QVYevYV38n+2nDhxGt0+k4Z4c3Rl/nWEoaG2lkdX0ikbTmDSnDTKhVgct/71zvLiLey3TinO3xlPnQ=----ATTACHMENT:----NDI5OTM3MjExOTQ1MDc4NSA2NjQwODcyODg4NzQ5MDkwIDg5MTQ2MzcyOTc1NTU4MTM=