annotate vendor/symfony/dependency-injection/Config/AutowireServiceResource.php @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents 129ea1e6d783
children
rev   line source
Chris@0 1 <?php
Chris@0 2
Chris@0 3 /*
Chris@0 4 * This file is part of the Symfony package.
Chris@0 5 *
Chris@0 6 * (c) Fabien Potencier <fabien@symfony.com>
Chris@0 7 *
Chris@0 8 * For the full copyright and license information, please view the LICENSE
Chris@0 9 * file that was distributed with this source code.
Chris@0 10 */
Chris@0 11
Chris@0 12 namespace Symfony\Component\DependencyInjection\Config;
Chris@0 13
Chris@14 14 @trigger_error('The '.__NAMESPACE__.'\AutowireServiceResource class is deprecated since Symfony 3.3 and will be removed in 4.0. Use ContainerBuilder::getReflectionClass() instead.', E_USER_DEPRECATED);
Chris@14 15
Chris@0 16 use Symfony\Component\Config\Resource\SelfCheckingResourceInterface;
Chris@0 17 use Symfony\Component\DependencyInjection\Compiler\AutowirePass;
Chris@0 18
Chris@14 19 /**
Chris@14 20 * @deprecated since version 3.3, to be removed in 4.0. Use ContainerBuilder::getReflectionClass() instead.
Chris@14 21 */
Chris@0 22 class AutowireServiceResource implements SelfCheckingResourceInterface, \Serializable
Chris@0 23 {
Chris@0 24 private $class;
Chris@0 25 private $filePath;
Chris@17 26 private $autowiringMetadata = [];
Chris@0 27
Chris@0 28 public function __construct($class, $path, array $autowiringMetadata)
Chris@0 29 {
Chris@0 30 $this->class = $class;
Chris@0 31 $this->filePath = $path;
Chris@0 32 $this->autowiringMetadata = $autowiringMetadata;
Chris@0 33 }
Chris@0 34
Chris@0 35 public function isFresh($timestamp)
Chris@0 36 {
Chris@0 37 if (!file_exists($this->filePath)) {
Chris@0 38 return false;
Chris@0 39 }
Chris@0 40
Chris@0 41 // has the file *not* been modified? Definitely fresh
Chris@0 42 if (@filemtime($this->filePath) <= $timestamp) {
Chris@0 43 return true;
Chris@0 44 }
Chris@0 45
Chris@0 46 try {
Chris@0 47 $reflectionClass = new \ReflectionClass($this->class);
Chris@0 48 } catch (\ReflectionException $e) {
Chris@0 49 // the class does not exist anymore!
Chris@0 50 return false;
Chris@0 51 }
Chris@0 52
Chris@0 53 return (array) $this === (array) AutowirePass::createResourceForClass($reflectionClass);
Chris@0 54 }
Chris@0 55
Chris@0 56 public function __toString()
Chris@0 57 {
Chris@0 58 return 'service.autowire.'.$this->class;
Chris@0 59 }
Chris@0 60
Chris@17 61 /**
Chris@17 62 * @internal
Chris@17 63 */
Chris@0 64 public function serialize()
Chris@0 65 {
Chris@17 66 return serialize([$this->class, $this->filePath, $this->autowiringMetadata]);
Chris@0 67 }
Chris@0 68
Chris@17 69 /**
Chris@17 70 * @internal
Chris@17 71 */
Chris@0 72 public function unserialize($serialized)
Chris@0 73 {
Chris@14 74 if (\PHP_VERSION_ID >= 70000) {
Chris@17 75 list($this->class, $this->filePath, $this->autowiringMetadata) = unserialize($serialized, ['allowed_classes' => false]);
Chris@14 76 } else {
Chris@14 77 list($this->class, $this->filePath, $this->autowiringMetadata) = unserialize($serialized);
Chris@14 78 }
Chris@0 79 }
Chris@0 80
Chris@0 81 /**
Chris@0 82 * @deprecated Implemented for compatibility with Symfony 2.8
Chris@0 83 */
Chris@0 84 public function getResource()
Chris@0 85 {
Chris@0 86 return $this->filePath;
Chris@0 87 }
Chris@0 88 }