Augmentation vers version 3.3.0

This commit is contained in:
Gauvain Boiché
2020-03-31 15:31:03 +02:00
parent d926806907
commit a1864c0414
2618 changed files with 406015 additions and 31377 deletions

View File

@@ -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);