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