aboutsummaryrefslogtreecommitdiff
path: root/srcs/phpmyadmin/vendor/symfony/config/Resource
diff options
context:
space:
mode:
authorCharles Cabergs <me@cacharle.xyz>2020-07-27 10:05:23 +0200
committerCharles Cabergs <me@cacharle.xyz>2020-07-27 10:05:23 +0200
commit5bf66662a9bdd62c5bccab15e607cd95cfb8fcab (patch)
tree39a1a4629749056191c05dfd899f931701b7acf3 /srcs/phpmyadmin/vendor/symfony/config/Resource
parent5afd237bbd22028b85532b8c0b3fcead49a00764 (diff)
downloadft_server-5bf66662a9bdd62c5bccab15e607cd95cfb8fcab.tar.gz
ft_server-5bf66662a9bdd62c5bccab15e607cd95cfb8fcab.tar.bz2
ft_server-5bf66662a9bdd62c5bccab15e607cd95cfb8fcab.zip
Removed wordpress and phpmyadmin, my server doesn't handle it well and it brings shame on my famillyHEADmaster
Diffstat (limited to 'srcs/phpmyadmin/vendor/symfony/config/Resource')
-rw-r--r--srcs/phpmyadmin/vendor/symfony/config/Resource/ClassExistenceResource.php231
-rw-r--r--srcs/phpmyadmin/vendor/symfony/config/Resource/ComposerResource.php70
-rw-r--r--srcs/phpmyadmin/vendor/symfony/config/Resource/DirectoryResource.php108
-rw-r--r--srcs/phpmyadmin/vendor/symfony/config/Resource/FileExistenceResource.php62
-rw-r--r--srcs/phpmyadmin/vendor/symfony/config/Resource/FileResource.php67
-rw-r--r--srcs/phpmyadmin/vendor/symfony/config/Resource/GlobResource.php233
-rw-r--r--srcs/phpmyadmin/vendor/symfony/config/Resource/ReflectionClassResource.php221
-rw-r--r--srcs/phpmyadmin/vendor/symfony/config/Resource/ResourceInterface.php33
-rw-r--r--srcs/phpmyadmin/vendor/symfony/config/Resource/SelfCheckingResourceChecker.php36
-rw-r--r--srcs/phpmyadmin/vendor/symfony/config/Resource/SelfCheckingResourceInterface.php30
10 files changed, 0 insertions, 1091 deletions
diff --git a/srcs/phpmyadmin/vendor/symfony/config/Resource/ClassExistenceResource.php b/srcs/phpmyadmin/vendor/symfony/config/Resource/ClassExistenceResource.php
deleted file mode 100644
index 77cd8e5..0000000
--- a/srcs/phpmyadmin/vendor/symfony/config/Resource/ClassExistenceResource.php
+++ /dev/null
@@ -1,231 +0,0 @@
-<?php
-
-/*
- * This file is part of the Symfony package.
- *
- * (c) Fabien Potencier <fabien@symfony.com>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Component\Config\Resource;
-
-/**
- * ClassExistenceResource represents a class existence.
- * Freshness is only evaluated against resource existence.
- *
- * The resource must be a fully-qualified class name.
- *
- * @author Fabien Potencier <fabien@symfony.com>
- *
- * @final since Symfony 4.3
- */
-class ClassExistenceResource implements SelfCheckingResourceInterface
-{
- private $resource;
- private $exists;
-
- private static $autoloadLevel = 0;
- private static $autoloadedClass;
- private static $existsCache = [];
-
- /**
- * @param string $resource The fully-qualified class name
- * @param bool|null $exists Boolean when the existency check has already been done
- */
- public function __construct(string $resource, bool $exists = null)
- {
- $this->resource = $resource;
- if (null !== $exists) {
- $this->exists = [(bool) $exists, null];
- }
- }
-
- /**
- * {@inheritdoc}
- */
- public function __toString()
- {
- return $this->resource;
- }
-
- /**
- * @return string The file path to the resource
- */
- public function getResource()
- {
- return $this->resource;
- }
-
- /**
- * {@inheritdoc}
- *
- * @throws \ReflectionException when a parent class/interface/trait is not found
- */
- public function isFresh($timestamp)
- {
- $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) {
- $exists[1] = $e->getMessage();
-
- try {
- self::throwOnRequiredClass($this->resource, $e);
- } catch (\ReflectionException $e) {
- if (0 >= $timestamp) {
- throw $e;
- }
- }
- } catch (\Throwable $e) {
- $exists[1] = $e->getMessage();
- } finally {
- self::$autoloadedClass = $autoloadedClass;
- if (!--self::$autoloadLevel) {
- spl_autoload_unregister(__CLASS__.'::throwOnRequiredClass');
- }
- }
- }
-
- if (null === $this->exists) {
- $this->exists = $exists;
- }
-
- return $this->exists[0] xor !$exists[0];
- }
-
- /**
- * @internal
- */
- public function __sleep(): array
- {
- if (null === $this->exists) {
- $this->isFresh(0);
- }
-
- return ['resource', 'exists'];
- }
-
- /**
- * @internal
- */
- public function __wakeup()
- {
- if (\is_bool($this->exists)) {
- $this->exists = [$this->exists, null];
- }
- }
-
- /**
- * Throws a reflection exception when the passed class does not exist but is required.
- *
- * A class is considered "not required" when it's loaded as part of a "class_exists" or similar check.
- *
- * This function can be used as an autoload function to throw a reflection
- * exception if the class was not found by previous autoload functions.
- *
- * A previous exception can be passed. In this case, the class is considered as being
- * required totally, so if it doesn't exist, a reflection exception is always thrown.
- * If it exists, the previous exception is rethrown.
- *
- * @throws \ReflectionException
- *
- * @internal
- */
- public static function throwOnRequiredClass($class, \Exception $previous = null)
- {
- // If the passed class is the resource being checked, we shouldn't throw.
- if (null === $previous && self::$autoloadedClass === $class) {
- return;
- }
-
- if (class_exists($class, false) || interface_exists($class, false) || trait_exists($class, false)) {
- if (null !== $previous) {
- throw $previous;
- }
-
- return;
- }
-
- if ($previous instanceof \ReflectionException) {
- throw $previous;
- }
-
- $message = sprintf('Class "%s" not found.', $class);
-
- if (self::$autoloadedClass !== $class) {
- $message = substr_replace($message, sprintf(' while loading "%s"', self::$autoloadedClass), -1, 0);
- }
-
- if (null !== $previous) {
- $message = $previous->getMessage();
- }
-
- $e = new \ReflectionException($message, 0, $previous);
-
- if (null !== $previous) {
- throw $e;
- }
-
- $trace = debug_backtrace();
- $autoloadFrame = [
- 'function' => 'spl_autoload_call',
- 'args' => [$class],
- ];
-
- if (false === $i = array_search($autoloadFrame, $trace, true)) {
- throw $e;
- }
-
- if (isset($trace[++$i]['function']) && !isset($trace[$i]['class'])) {
- switch ($trace[$i]['function']) {
- case 'get_class_methods':
- case 'get_class_vars':
- case 'get_parent_class':
- case 'is_a':
- case 'is_subclass_of':
- case 'class_exists':
- case 'class_implements':
- case 'class_parents':
- case 'trait_exists':
- case 'defined':
- case 'interface_exists':
- case 'method_exists':
- case 'property_exists':
- case 'is_callable':
- return;
- }
-
- $props = [
- 'file' => isset($trace[$i]['file']) ? $trace[$i]['file'] : null,
- 'line' => isset($trace[$i]['line']) ? $trace[$i]['line'] : null,
- 'trace' => \array_slice($trace, 1 + $i),
- ];
-
- foreach ($props as $p => $v) {
- if (null !== $v) {
- $r = new \ReflectionProperty('Exception', $p);
- $r->setAccessible(true);
- $r->setValue($e, $v);
- }
- }
- }
-
- throw $e;
- }
-}
diff --git a/srcs/phpmyadmin/vendor/symfony/config/Resource/ComposerResource.php b/srcs/phpmyadmin/vendor/symfony/config/Resource/ComposerResource.php
deleted file mode 100644
index 822766b..0000000
--- a/srcs/phpmyadmin/vendor/symfony/config/Resource/ComposerResource.php
+++ /dev/null
@@ -1,70 +0,0 @@
-<?php
-
-/*
- * This file is part of the Symfony package.
- *
- * (c) Fabien Potencier <fabien@symfony.com>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Component\Config\Resource;
-
-/**
- * ComposerResource tracks the PHP version and Composer dependencies.
- *
- * @author Nicolas Grekas <p@tchwork.com>
- *
- * @final since Symfony 4.3
- */
-class ComposerResource implements SelfCheckingResourceInterface
-{
- private $vendors;
-
- private static $runtimeVendors;
-
- public function __construct()
- {
- self::refresh();
- $this->vendors = self::$runtimeVendors;
- }
-
- public function getVendors()
- {
- return array_keys($this->vendors);
- }
-
- /**
- * {@inheritdoc}
- */
- public function __toString()
- {
- return __CLASS__;
- }
-
- /**
- * {@inheritdoc}
- */
- public function isFresh($timestamp)
- {
- self::refresh();
-
- return array_values(self::$runtimeVendors) === array_values($this->vendors);
- }
-
- private static function refresh()
- {
- self::$runtimeVendors = [];
-
- foreach (get_declared_classes() as $class) {
- if ('C' === $class[0] && 0 === strpos($class, 'ComposerAutoloaderInit')) {
- $r = new \ReflectionClass($class);
- $v = \dirname($r->getFileName(), 2);
- if (file_exists($v.'/composer/installed.json')) {
- self::$runtimeVendors[$v] = @filemtime($v.'/composer/installed.json');
- }
- }
- }
- }
-}
diff --git a/srcs/phpmyadmin/vendor/symfony/config/Resource/DirectoryResource.php b/srcs/phpmyadmin/vendor/symfony/config/Resource/DirectoryResource.php
deleted file mode 100644
index 3d703db..0000000
--- a/srcs/phpmyadmin/vendor/symfony/config/Resource/DirectoryResource.php
+++ /dev/null
@@ -1,108 +0,0 @@
-<?php
-
-/*
- * This file is part of the Symfony package.
- *
- * (c) Fabien Potencier <fabien@symfony.com>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Component\Config\Resource;
-
-/**
- * DirectoryResource represents a resources stored in a subdirectory tree.
- *
- * @author Fabien Potencier <fabien@symfony.com>
- *
- * @final since Symfony 4.3
- */
-class DirectoryResource implements SelfCheckingResourceInterface
-{
- private $resource;
- private $pattern;
-
- /**
- * @param string $resource The file path to the resource
- * @param string|null $pattern A pattern to restrict monitored files
- *
- * @throws \InvalidArgumentException
- */
- public function __construct(string $resource, string $pattern = null)
- {
- $this->resource = realpath($resource) ?: (file_exists($resource) ? $resource : false);
- $this->pattern = $pattern;
-
- if (false === $this->resource || !is_dir($this->resource)) {
- throw new \InvalidArgumentException(sprintf('The directory "%s" does not exist.', $resource));
- }
- }
-
- /**
- * {@inheritdoc}
- */
- public function __toString()
- {
- return md5(serialize([$this->resource, $this->pattern]));
- }
-
- /**
- * @return string The file path to the resource
- */
- public function getResource()
- {
- return $this->resource;
- }
-
- /**
- * Returns the pattern to restrict monitored files.
- *
- * @return string|null
- */
- public function getPattern()
- {
- return $this->pattern;
- }
-
- /**
- * {@inheritdoc}
- */
- public function isFresh($timestamp)
- {
- if (!is_dir($this->resource)) {
- return false;
- }
-
- if ($timestamp < filemtime($this->resource)) {
- return false;
- }
-
- foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->resource), \RecursiveIteratorIterator::SELF_FIRST) as $file) {
- // if regex filtering is enabled only check matching files
- if ($this->pattern && $file->isFile() && !preg_match($this->pattern, $file->getBasename())) {
- continue;
- }
-
- // always monitor directories for changes, except the .. entries
- // (otherwise deleted files wouldn't get detected)
- if ($file->isDir() && '/..' === substr($file, -3)) {
- continue;
- }
-
- // for broken links
- try {
- $fileMTime = $file->getMTime();
- } catch (\RuntimeException $e) {
- continue;
- }
-
- // early return if a file's mtime exceeds the passed timestamp
- if ($timestamp < $fileMTime) {
- return false;
- }
- }
-
- return true;
- }
-}
diff --git a/srcs/phpmyadmin/vendor/symfony/config/Resource/FileExistenceResource.php b/srcs/phpmyadmin/vendor/symfony/config/Resource/FileExistenceResource.php
deleted file mode 100644
index 5723416..0000000
--- a/srcs/phpmyadmin/vendor/symfony/config/Resource/FileExistenceResource.php
+++ /dev/null
@@ -1,62 +0,0 @@
-<?php
-
-/*
- * This file is part of the Symfony package.
- *
- * (c) Fabien Potencier <fabien@symfony.com>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Component\Config\Resource;
-
-/**
- * FileExistenceResource represents a resource stored on the filesystem.
- * Freshness is only evaluated against resource creation or deletion.
- *
- * The resource can be a file or a directory.
- *
- * @author Charles-Henri Bruyand <charleshenri.bruyand@gmail.com>
- *
- * @final since Symfony 4.3
- */
-class FileExistenceResource implements SelfCheckingResourceInterface
-{
- private $resource;
-
- private $exists;
-
- /**
- * @param string $resource The file path to the resource
- */
- public function __construct(string $resource)
- {
- $this->resource = $resource;
- $this->exists = file_exists($resource);
- }
-
- /**
- * {@inheritdoc}
- */
- public function __toString()
- {
- return $this->resource;
- }
-
- /**
- * @return string The file path to the resource
- */
- public function getResource()
- {
- return $this->resource;
- }
-
- /**
- * {@inheritdoc}
- */
- public function isFresh($timestamp)
- {
- return file_exists($this->resource) === $this->exists;
- }
-}
diff --git a/srcs/phpmyadmin/vendor/symfony/config/Resource/FileResource.php b/srcs/phpmyadmin/vendor/symfony/config/Resource/FileResource.php
deleted file mode 100644
index 95fe8a0..0000000
--- a/srcs/phpmyadmin/vendor/symfony/config/Resource/FileResource.php
+++ /dev/null
@@ -1,67 +0,0 @@
-<?php
-
-/*
- * This file is part of the Symfony package.
- *
- * (c) Fabien Potencier <fabien@symfony.com>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Component\Config\Resource;
-
-/**
- * FileResource represents a resource stored on the filesystem.
- *
- * The resource can be a file or a directory.
- *
- * @author Fabien Potencier <fabien@symfony.com>
- *
- * @final since Symfony 4.3
- */
-class FileResource implements SelfCheckingResourceInterface
-{
- /**
- * @var string|false
- */
- private $resource;
-
- /**
- * @param string $resource The file path to the resource
- *
- * @throws \InvalidArgumentException
- */
- public function __construct(string $resource)
- {
- $this->resource = realpath($resource) ?: (file_exists($resource) ? $resource : false);
-
- if (false === $this->resource) {
- throw new \InvalidArgumentException(sprintf('The file "%s" does not exist.', $resource));
- }
- }
-
- /**
- * {@inheritdoc}
- */
- public function __toString()
- {
- return $this->resource;
- }
-
- /**
- * @return string The canonicalized, absolute path to the resource
- */
- public function getResource()
- {
- return $this->resource;
- }
-
- /**
- * {@inheritdoc}
- */
- public function isFresh($timestamp)
- {
- return false !== ($filemtime = @filemtime($this->resource)) && $filemtime <= $timestamp;
- }
-}
diff --git a/srcs/phpmyadmin/vendor/symfony/config/Resource/GlobResource.php b/srcs/phpmyadmin/vendor/symfony/config/Resource/GlobResource.php
deleted file mode 100644
index 9f6e0d8..0000000
--- a/srcs/phpmyadmin/vendor/symfony/config/Resource/GlobResource.php
+++ /dev/null
@@ -1,233 +0,0 @@
-<?php
-
-/*
- * This file is part of the Symfony package.
- *
- * (c) Fabien Potencier <fabien@symfony.com>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Component\Config\Resource;
-
-use Symfony\Component\Finder\Finder;
-use Symfony\Component\Finder\Glob;
-
-/**
- * GlobResource represents a set of resources stored on the filesystem.
- *
- * Only existence/removal is tracked (not mtimes.)
- *
- * @author Nicolas Grekas <p@tchwork.com>
- *
- * @final since Symfony 4.3
- */
-class GlobResource implements \IteratorAggregate, SelfCheckingResourceInterface
-{
- private $prefix;
- private $pattern;
- private $recursive;
- private $hash;
- private $forExclusion;
- private $excludedPrefixes;
- private $globBrace;
-
- /**
- * @param string $prefix A directory prefix
- * @param string $pattern A glob pattern
- * @param bool $recursive Whether directories should be scanned recursively or not
- *
- * @throws \InvalidArgumentException
- */
- public function __construct(string $prefix, string $pattern, bool $recursive, bool $forExclusion = false, array $excludedPrefixes = [])
- {
- ksort($excludedPrefixes);
- $this->prefix = realpath($prefix) ?: (file_exists($prefix) ? $prefix : false);
- $this->pattern = $pattern;
- $this->recursive = $recursive;
- $this->forExclusion = $forExclusion;
- $this->excludedPrefixes = $excludedPrefixes;
- $this->globBrace = \defined('GLOB_BRACE') ? GLOB_BRACE : 0;
-
- if (false === $this->prefix) {
- throw new \InvalidArgumentException(sprintf('The path "%s" does not exist.', $prefix));
- }
- }
-
- public function getPrefix()
- {
- return $this->prefix;
- }
-
- /**
- * {@inheritdoc}
- */
- public function __toString()
- {
- return 'glob.'.$this->prefix.(int) $this->recursive.$this->pattern.(int) $this->forExclusion.implode("\0", $this->excludedPrefixes);
- }
-
- /**
- * {@inheritdoc}
- */
- public function isFresh($timestamp)
- {
- $hash = $this->computeHash();
-
- if (null === $this->hash) {
- $this->hash = $hash;
- }
-
- return $this->hash === $hash;
- }
-
- /**
- * @internal
- */
- public function __sleep(): array
- {
- if (null === $this->hash) {
- $this->hash = $this->computeHash();
- }
-
- return ['prefix', 'pattern', 'recursive', 'hash', 'forExclusion', 'excludedPrefixes'];
- }
-
- /**
- * @return \Traversable
- */
- public function getIterator()
- {
- if (!file_exists($this->prefix) || (!$this->recursive && '' === $this->pattern)) {
- return;
- }
- $prefix = str_replace('\\', '/', $this->prefix);
- $paths = null;
-
- if (0 !== strpos($this->prefix, 'phar://') && false === strpos($this->pattern, '/**/')) {
- if ($this->globBrace || false === strpos($this->pattern, '{')) {
- $paths = glob($this->prefix.$this->pattern, GLOB_NOSORT | $this->globBrace);
- } elseif (false === strpos($this->pattern, '\\') || !preg_match('/\\\\[,{}]/', $this->pattern)) {
- foreach ($this->expandGlob($this->pattern) as $p) {
- $paths[] = glob($this->prefix.$p, GLOB_NOSORT);
- }
- $paths = array_merge(...$paths);
- }
- }
-
- if (null !== $paths) {
- sort($paths);
- foreach ($paths as $path) {
- if ($this->excludedPrefixes) {
- $normalizedPath = str_replace('\\', '/', $path);
- do {
- if (isset($this->excludedPrefixes[$dirPath = $normalizedPath])) {
- continue 2;
- }
- } while ($prefix !== $dirPath && $dirPath !== $normalizedPath = \dirname($dirPath));
- }
-
- if (is_file($path)) {
- yield $path => new \SplFileInfo($path);
- }
- if (!is_dir($path)) {
- continue;
- }
- if ($this->forExclusion) {
- yield $path => new \SplFileInfo($path);
- continue;
- }
- if (!$this->recursive || isset($this->excludedPrefixes[str_replace('\\', '/', $path)])) {
- continue;
- }
- $files = iterator_to_array(new \RecursiveIteratorIterator(
- new \RecursiveCallbackFilterIterator(
- new \RecursiveDirectoryIterator($path, \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS),
- function (\SplFileInfo $file, $path) {
- return !isset($this->excludedPrefixes[str_replace('\\', '/', $path)]) && '.' !== $file->getBasename()[0];
- }
- ),
- \RecursiveIteratorIterator::LEAVES_ONLY
- ));
- uasort($files, 'strnatcmp');
-
- foreach ($files as $path => $info) {
- if ($info->isFile()) {
- yield $path => $info;
- }
- }
- }
-
- return;
- }
-
- if (!class_exists(Finder::class)) {
- throw new \LogicException(sprintf('Extended glob pattern "%s" cannot be used as the Finder component is not installed.', $this->pattern));
- }
-
- $finder = new Finder();
- $regex = Glob::toRegex($this->pattern);
- if ($this->recursive) {
- $regex = substr_replace($regex, '(/|$)', -2, 1);
- }
-
- $prefixLen = \strlen($this->prefix);
- foreach ($finder->followLinks()->sortByName()->in($this->prefix) as $path => $info) {
- $normalizedPath = str_replace('\\', '/', $path);
- if (!preg_match($regex, substr($normalizedPath, $prefixLen)) || !$info->isFile()) {
- continue;
- }
- if ($this->excludedPrefixes) {
- do {
- if (isset($this->excludedPrefixes[$dirPath = $normalizedPath])) {
- continue 2;
- }
- } while ($prefix !== $dirPath && $dirPath !== $normalizedPath = \dirname($dirPath));
- }
-
- yield $path => $info;
- }
- }
-
- private function computeHash(): string
- {
- $hash = hash_init('md5');
-
- foreach ($this->getIterator() as $path => $info) {
- hash_update($hash, $path."\n");
- }
-
- return hash_final($hash);
- }
-
- private function expandGlob(string $pattern): array
- {
- $segments = preg_split('/\{([^{}]*+)\}/', $pattern, -1, PREG_SPLIT_DELIM_CAPTURE);
- $paths = [$segments[0]];
- $patterns = [];
-
- for ($i = 1; $i < \count($segments); $i += 2) {
- $patterns = [];
-
- foreach (explode(',', $segments[$i]) as $s) {
- foreach ($paths as $p) {
- $patterns[] = $p.$s.$segments[1 + $i];
- }
- }
-
- $paths = $patterns;
- }
-
- $j = 0;
- foreach ($patterns as $i => $p) {
- if (false !== strpos($p, '{')) {
- $p = $this->expandGlob($p);
- array_splice($paths, $i + $j, 1, $p);
- $j += \count($p) - 1;
- }
- }
-
- return $paths;
- }
-}
diff --git a/srcs/phpmyadmin/vendor/symfony/config/Resource/ReflectionClassResource.php b/srcs/phpmyadmin/vendor/symfony/config/Resource/ReflectionClassResource.php
deleted file mode 100644
index 48fdcd6..0000000
--- a/srcs/phpmyadmin/vendor/symfony/config/Resource/ReflectionClassResource.php
+++ /dev/null
@@ -1,221 +0,0 @@
-<?php
-
-/*
- * This file is part of the Symfony package.
- *
- * (c) Fabien Potencier <fabien@symfony.com>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Component\Config\Resource;
-
-use Symfony\Component\DependencyInjection\ServiceSubscriberInterface as LegacyServiceSubscriberInterface;
-use Symfony\Component\EventDispatcher\EventSubscriberInterface;
-use Symfony\Component\Messenger\Handler\MessageSubscriberInterface;
-use Symfony\Contracts\Service\ServiceSubscriberInterface;
-
-/**
- * @author Nicolas Grekas <p@tchwork.com>
- *
- * @final since Symfony 4.3
- */
-class ReflectionClassResource implements SelfCheckingResourceInterface
-{
- private $files = [];
- private $className;
- private $classReflector;
- private $excludedVendors = [];
- private $hash;
-
- public function __construct(\ReflectionClass $classReflector, array $excludedVendors = [])
- {
- $this->className = $classReflector->name;
- $this->classReflector = $classReflector;
- $this->excludedVendors = $excludedVendors;
- }
-
- public function isFresh($timestamp)
- {
- if (null === $this->hash) {
- $this->hash = $this->computeHash();
- $this->loadFiles($this->classReflector);
- }
-
- foreach ($this->files as $file => $v) {
- if (false === $filemtime = @filemtime($file)) {
- return false;
- }
-
- if ($filemtime > $timestamp) {
- return $this->hash === $this->computeHash();
- }
- }
-
- return true;
- }
-
- public function __toString()
- {
- return 'reflection.'.$this->className;
- }
-
- /**
- * @internal
- */
- public function __sleep(): array
- {
- if (null === $this->hash) {
- $this->hash = $this->computeHash();
- $this->loadFiles($this->classReflector);
- }
-
- return ['files', 'className', 'hash'];
- }
-
- private function loadFiles(\ReflectionClass $class)
- {
- foreach ($class->getInterfaces() as $v) {
- $this->loadFiles($v);
- }
- do {
- $file = $class->getFileName();
- if (false !== $file && file_exists($file)) {
- foreach ($this->excludedVendors as $vendor) {
- if (0 === strpos($file, $vendor) && false !== strpbrk(substr($file, \strlen($vendor), 1), '/'.\DIRECTORY_SEPARATOR)) {
- $file = false;
- break;
- }
- }
- if ($file) {
- $this->files[$file] = null;
- }
- }
- foreach ($class->getTraits() as $v) {
- $this->loadFiles($v);
- }
- } while ($class = $class->getParentClass());
- }
-
- private function computeHash(): string
- {
- if (null === $this->classReflector) {
- try {
- $this->classReflector = new \ReflectionClass($this->className);
- } catch (\ReflectionException $e) {
- // the class does not exist anymore
- return false;
- }
- }
- $hash = hash_init('md5');
-
- foreach ($this->generateSignature($this->classReflector) as $info) {
- hash_update($hash, $info);
- }
-
- return hash_final($hash);
- }
-
- private function generateSignature(\ReflectionClass $class): iterable
- {
- yield $class->getDocComment();
- yield (int) $class->isFinal();
- yield (int) $class->isAbstract();
-
- if ($class->isTrait()) {
- yield print_r(class_uses($class->name), true);
- } else {
- yield print_r(class_parents($class->name), true);
- yield print_r(class_implements($class->name), true);
- yield print_r($class->getConstants(), true);
- }
-
- if (!$class->isInterface()) {
- $defaults = $class->getDefaultProperties();
-
- foreach ($class->getProperties(\ReflectionProperty::IS_PUBLIC | \ReflectionProperty::IS_PROTECTED) as $p) {
- yield $p->getDocComment().$p;
- yield print_r(isset($defaults[$p->name]) && !\is_object($defaults[$p->name]) ? $defaults[$p->name] : null, true);
- }
- }
-
- foreach ($class->getMethods(\ReflectionMethod::IS_PUBLIC | \ReflectionMethod::IS_PROTECTED) as $m) {
- $defaults = [];
- $parametersWithUndefinedConstants = [];
- foreach ($m->getParameters() as $p) {
- if (!$p->isDefaultValueAvailable()) {
- $defaults[$p->name] = null;
-
- continue;
- }
-
- if (!$p->isDefaultValueConstant() || \defined($p->getDefaultValueConstantName())) {
- $defaults[$p->name] = $p->getDefaultValue();
-
- continue;
- }
-
- $defaults[$p->name] = $p->getDefaultValueConstantName();
- $parametersWithUndefinedConstants[$p->name] = true;
-