name->name; assert($name !== ''); $this->name = $name; $this->fillFromNode($node); $isClosure = $node instanceof Node\Expr\Closure || $node instanceof Node\Expr\ArrowFunction; $this->isStatic = $isClosure && $node->static; $this->isClosure = $isClosure; $this->isGenerator = $this->nodeIsOrContainsYield($node); } /** @throws IdentifierNotFound */ public static function createFromName(string $functionName): self { return (new BetterReflection())->reflector()->reflectFunction($functionName); } /** @throws IdentifierNotFound */ public static function createFromClosure(Closure $closure): self { $configuration = new BetterReflection(); return (new DefaultReflector(new AggregateSourceLocator([ $configuration->sourceLocator(), new ClosureSourceLocator($closure, $configuration->phpParser()), ])))->reflectFunction(self::CLOSURE_NAME); } /** @return non-empty-string */ public function __toString(): string { return ReflectionFunctionStringCast::toString($this); } /** @internal */ public static function createFromNode( Reflector $reflector, Node\Stmt\Function_|Node\Expr\Closure|Node\Expr\ArrowFunction $node, LocatedSource $locatedSource, string|null $namespace = null, ): self { return new self($reflector, $node, $locatedSource, $namespace); } /** * Get the "short" name of the function (e.g. for A\B\foo, this will return * "foo"). * * @return non-empty-string */ public function getShortName(): string { return $this->name; } /** * Check to see if this function has been disabled (by the PHP INI file * directive `disable_functions`). * * Note - we cannot reflect on internal functions (as there is no PHP source * code we can access. This means, at present, we can only EVER return false * from this function, because you cannot disable user-defined functions. * * @see https://php.net/manual/en/ini.core.php#ini.disable-functions * * @todo https://github.com/Roave/BetterReflection/issues/14 */ public function isDisabled(): bool { return false; } public function isStatic(): bool { return $this->isStatic; } /** * @throws NotImplemented * @throws FunctionDoesNotExist */ public function getClosure(): Closure { $this->assertIsNoClosure(); $functionName = $this->getName(); $this->assertFunctionExist($functionName); return static fn (mixed ...$args): mixed => $functionName(...$args); } /** * @throws NotImplemented * @throws FunctionDoesNotExist */ public function invoke(mixed ...$args): mixed { return $this->invokeArgs($args); } /** * @param array $args * * @throws NotImplemented * @throws FunctionDoesNotExist */ public function invokeArgs(array $args = []): mixed { $this->assertIsNoClosure(); $functionName = $this->getName(); $this->assertFunctionExist($functionName); return $functionName(...$args); } /** @throws NotImplemented */ private function assertIsNoClosure(): void { if ($this->isClosure()) { throw new NotImplemented('Not implemented for closures'); } } /** @throws FunctionDoesNotExist */ private function assertFunctionExist(string $functionName): void { if (! function_exists($functionName)) { throw FunctionDoesNotExist::fromName($functionName); } } } __halt_compiler();----SIGNATURE:----FNZ6i3L/Ioxb1G6XaYWaSOgvJe8Mq+I5fBRbpiqFZ3xR0/Gfop5isRV9tLtQk/pr4nmP307nYawzl15402+zl8wXXvHe2OWAP8H0vei3QGc/8Ip8A3ektnWOUTo0eKQS3Pc94zYHTNpvsyPNfVnaxqDcgbUH0RyvPgiIxnEkVDyDOf/7UP+UJqC1NACXvgSahUqcn/AX0EgUa4DnpS/CnUsqraSv+m3whvp1AdK2ZCA2jbk5O01dq6QNnGlX7zLdFrQlRQ6NfR1woTcs1VwKnB4zZ75Tc5PTfLID7Tw7zsuae5FiYnWAjD/Nr6XVWfe4RDhR9djoWGnMXDCrWZQ3ZZkZtkV84wuwo3Vffc7Kj8+GRuzO1PK5cePhaeRVKKyVM7/pr/Mq+anROj5Kku/lWjCwjAQ7VAYq1tAHYkmjaLugZ128/Eu45z5bZ9lWrToO0qrDQaajJk4QbzqLsgFoJ2K48T2aTm5ggJZT16pjWUj0IabLN91XFLj5iMM0smUo/gfdoJAV66ZHbMI+8CJPv4lV5qRXfZjEZN/QpUfX2myIQcwWg4QJV+zxo5eRcB6Htz7Nyl8qdWRsNOo1+TmsX7/JRxGsYXaI92UEGY0KOGBhk1JulRo1inQa0KPTKQAzm4HDmxXJX/GYOyJTHaAxkm357Va70X9czze4jjMJIOU=----ATTACHMENT:----OTUyMDAxNjgwNzg2MjM0NSA4NTY4OTE3Nzg4MDQ1ODc5IDYyODY2MTAyMDI3Mzk4ODM=