Security update for Core, with self-updated composer
[yaffs-website] / vendor / symfony / config / Resource / FileResource.php
index 00b2957ca5191ecb635ae47842703620a768048d..6ad130518854c1609190f5792e586cde2c31f55b 100644 (file)
@@ -29,10 +29,16 @@ class FileResource implements SelfCheckingResourceInterface, \Serializable
      * Constructor.
      *
      * @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));
+        }
     }
 
     /**
@@ -40,11 +46,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()
     {
@@ -56,11 +62,7 @@ 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 file_exists($this->resource) && @filemtime($this->resource) <= $timestamp;
     }
 
     public function serialize()