mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 11:08:45 +02:00
migration symfony 5 4 (#300)
* symfony 5.4 (diff dev) * symfony 5.4 (working) * symfony 5.4 (update autoload) * symfony 5.4 (remove swiftmailer mailer implementation) * symfony 5.4 (php doc and split Global accessor class) ### Impacted packages: composer require php:">=7.2.5 <8.0.0" symfony/console:5.4.* symfony/dotenv:5.4.* symfony/framework-bundle:5.4.* symfony/twig-bundle:5.4.* symfony/yaml:5.4.* --update-with-dependencies composer require symfony/stopwatch:5.4.* symfony/web-profiler-bundle:5.4.* --dev --update-with-dependencies
This commit is contained in:
@@ -15,8 +15,10 @@ namespace Symfony\Component\Config\Resource;
|
||||
* DirectoryResource represents a resources stored in a subdirectory tree.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class DirectoryResource implements SelfCheckingResourceInterface, \Serializable
|
||||
class DirectoryResource implements SelfCheckingResourceInterface
|
||||
{
|
||||
private $resource;
|
||||
private $pattern;
|
||||
@@ -27,7 +29,7 @@ class DirectoryResource implements SelfCheckingResourceInterface, \Serializable
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function __construct($resource, $pattern = null)
|
||||
public function __construct(string $resource, string $pattern = null)
|
||||
{
|
||||
$this->resource = realpath($resource) ?: (file_exists($resource) ? $resource : false);
|
||||
$this->pattern = $pattern;
|
||||
@@ -37,28 +39,17 @@ class DirectoryResource implements SelfCheckingResourceInterface, \Serializable
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __toString()
|
||||
public function __toString(): string
|
||||
{
|
||||
return md5(serialize([$this->resource, $this->pattern]));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string The file path to the resource
|
||||
*/
|
||||
public function getResource()
|
||||
public function getResource(): string
|
||||
{
|
||||
return $this->resource;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the pattern to restrict monitored files.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getPattern()
|
||||
public function getPattern(): ?string
|
||||
{
|
||||
return $this->pattern;
|
||||
}
|
||||
@@ -66,7 +57,7 @@ class DirectoryResource implements SelfCheckingResourceInterface, \Serializable
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isFresh($timestamp)
|
||||
public function isFresh(int $timestamp): bool
|
||||
{
|
||||
if (!is_dir($this->resource)) {
|
||||
return false;
|
||||
@@ -84,7 +75,7 @@ class DirectoryResource implements SelfCheckingResourceInterface, \Serializable
|
||||
|
||||
// always monitor directories for changes, except the .. entries
|
||||
// (otherwise deleted files wouldn't get detected)
|
||||
if ($file->isDir() && '/..' === substr($file, -3)) {
|
||||
if ($file->isDir() && str_ends_with($file, '/..')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -103,20 +94,4 @@ class DirectoryResource implements SelfCheckingResourceInterface, \Serializable
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function serialize()
|
||||
{
|
||||
return serialize([$this->resource, $this->pattern]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function unserialize($serialized)
|
||||
{
|
||||
list($this->resource, $this->pattern) = unserialize($serialized);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user