ReflectionException example


    public function getStaticReflectionParserForDeclaringClass($type$name)
    {
        $this->parse();
        if (isset($this->docComment[$type][$name])) {
            return $this;
        }
        if (empty($this->parentClassName)) {
            return $this->getParentStaticReflectionParser()->getStaticReflectionParserForDeclaringClass($type$name);
        }
        throw new ReflectionException('Invalid ' . $type . ' "' . $name . '"');
    }
}
public function getUseStatements()
    {
        return $this->staticReflectionParser->getUseStatements();
    }

    /** * {@inheritDoc} */
    #[\ReturnTypeWillChange]     public function getMethod($name)
    {
        throw new ReflectionException('Method not implemented');
    }

    /** * {@inheritDoc} */
    #[\ReturnTypeWillChange]     public function getProperty($name)
    {
        throw new ReflectionException('Method not implemented');
    }

    
/** * @throws \ReflectionException when a parent class/interface/trait is not found */
    public function isFresh(int $timestamp): bool
    {
        $loaded = class_exists($this->resource, false) || interface_exists($this->resource, false) || trait_exists($this->resource, false);

        if (null !== $exists = &self::$existsCache[$this->resource]) {
            if ($loaded) {
                $exists = [true, null];
            } elseif (0 >= $timestamp && !$exists[0] && null !== $exists[1]) {
                throw new \ReflectionException($exists[1]);
            }
        } elseif ([false, null] === $exists = [$loaded, null]) {
            if (!self::$autoloadLevel++) {
                spl_autoload_register(__CLASS__.'::throwOnRequiredClass');
            }
            $autoloadedClass = self::$autoloadedClass;
            self::$autoloadedClass = ltrim($this->resource, '\\');

            try {
                $exists[0] = class_exists($this->resource) || interface_exists($this->resource, false) || trait_exists($this->resource, false);
            } catch (\Exception $e) {
                
file_put_contents($filesprintf("\n\$classes = [];\n%s\$preloaded = Preloader::preload(\$classes, \$preloaded);\n", implode('', $classes)), \FILE_APPEND);
    }

    public static function preload(array $classes, array $preloaded = []): array
    {
        set_error_handler(function D$t$m$f$l) {
            if (error_reporting() & $t) {
                if (__FILE__ !== $f) {
                    throw new \ErrorException($m, 0, $t$f$l);
                }

                throw new \ReflectionException($m);
            }
        });

        $prev = [];

        try {
            while ($prev !== $classes) {
                $prev = $classes;
                foreach ($classes as $c) {
                    if (!isset($preloaded[$c])) {
                        self::doPreload($c$preloaded);
                    }
file_put_contents($filesprintf("\n\$classes = [];\n%s\$preloaded = Preloader::preload(\$classes, \$preloaded);\n", implode('', $classes)), \FILE_APPEND);
    }

    public static function preload(array $classes, array $preloaded = []): array
    {
        set_error_handler(function D$t$m$f$l) {
            if (error_reporting() & $t) {
                if (__FILE__ !== $f) {
                    throw new \ErrorException($m, 0, $t$f$l);
                }

                throw new \ReflectionException($m);
            }
        });

        $prev = [];

        try {
            while ($prev !== $classes) {
                $prev = $classes;
                foreach ($classes as $c) {
                    if (!isset($preloaded[$c])) {
                        self::doPreload($c$preloaded);
                    }
Home | Imprint | This part of the site doesn't use cookies.