Augmentation vers version 3.3.0
This commit is contained in:
22
vendor/symfony/config/Resource/FileResource.php
vendored
22
vendor/symfony/config/Resource/FileResource.php
vendored
@@ -27,10 +27,16 @@ class FileResource implements SelfCheckingResourceInterface, \Serializable
|
||||
|
||||
/**
|
||||
* @param string $resource The file path to the resource
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function __construct($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));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -38,11 +44,11 @@ class FileResource implements SelfCheckingResourceInterface, \Serializable
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return (string) $this->resource;
|
||||
return $this->resource;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* @return string The canonicalized, absolute path to the resource
|
||||
*/
|
||||
public function getResource()
|
||||
{
|
||||
@@ -54,18 +60,20 @@ class FileResource implements SelfCheckingResourceInterface, \Serializable
|
||||
*/
|
||||
public function isFresh($timestamp)
|
||||
{
|
||||
if (false === $this->resource || !file_exists($this->resource)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return filemtime($this->resource) <= $timestamp;
|
||||
return false !== ($filemtime = @filemtime($this->resource)) && $filemtime <= $timestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function serialize()
|
||||
{
|
||||
return serialize($this->resource);
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function unserialize($serialized)
|
||||
{
|
||||
$this->resource = unserialize($serialized);
|
||||
|
||||
Reference in New Issue
Block a user