diff --git a/src/Symfony/Component/Config/ConfigCacheFactory.php b/src/Symfony/Component/Config/ConfigCacheFactory.php index bcec95c11d9c1..11fd3cb3a2d45 100644 --- a/src/Symfony/Component/Config/ConfigCacheFactory.php +++ b/src/Symfony/Component/Config/ConfigCacheFactory.php @@ -35,12 +35,8 @@ public function __construct(bool $debug) /** * {@inheritdoc} */ - public function cache(string $file, $callback) + public function cache(string $file, callable $callback) { - if (!\is_callable($callback)) { - throw new \InvalidArgumentException(sprintf('Invalid type for callback argument. Expected callable, but got "%s".', \gettype($callback))); - } - $cache = new ConfigCache($file, $this->debug); if (!$cache->isFresh()) { $callback($cache); diff --git a/src/Symfony/Component/Config/ConfigCacheFactoryInterface.php b/src/Symfony/Component/Config/ConfigCacheFactoryInterface.php index 255b85a6575a7..7dfa0f2437972 100644 --- a/src/Symfony/Component/Config/ConfigCacheFactoryInterface.php +++ b/src/Symfony/Component/Config/ConfigCacheFactoryInterface.php @@ -28,5 +28,5 @@ interface ConfigCacheFactoryInterface * * @return ConfigCacheInterface The cache instance */ - public function cache(string $file, $callable); + public function cache(string $file, callable $callable); } diff --git a/src/Symfony/Component/Config/Definition/ArrayNode.php b/src/Symfony/Component/Config/Definition/ArrayNode.php index 9fabdd5628a4c..dfde17bc58070 100644 --- a/src/Symfony/Component/Config/Definition/ArrayNode.php +++ b/src/Symfony/Component/Config/Definition/ArrayNode.php @@ -129,7 +129,7 @@ public function setAllowNewKeys(bool $allow) */ public function setPerformDeepMerging(bool $boolean) { - $this->performDeepMerging = (bool) $boolean; + $this->performDeepMerging = $boolean; } /** diff --git a/src/Symfony/Component/Config/Definition/PrototypeNodeInterface.php b/src/Symfony/Component/Config/Definition/PrototypeNodeInterface.php index 53ed43667ffce..b160aa94a4963 100644 --- a/src/Symfony/Component/Config/Definition/PrototypeNodeInterface.php +++ b/src/Symfony/Component/Config/Definition/PrototypeNodeInterface.php @@ -20,8 +20,6 @@ interface PrototypeNodeInterface extends NodeInterface { /** * Sets the name of the node. - * - * @param string $name The name of the node */ public function setName(string $name); } diff --git a/src/Symfony/Component/Config/FileLocator.php b/src/Symfony/Component/Config/FileLocator.php index 345e63e6cd61e..e8d9b5545a8ab 100644 --- a/src/Symfony/Component/Config/FileLocator.php +++ b/src/Symfony/Component/Config/FileLocator.php @@ -33,7 +33,7 @@ public function __construct($paths = []) /** * {@inheritdoc} */ - public function locate(string $name, string $currentPath = null, $first = true) + public function locate(string $name, string $currentPath = null, bool $first = true) { if ('' == $name) { throw new \InvalidArgumentException('An empty file name is not valid to be located.'); diff --git a/src/Symfony/Component/Config/ResourceCheckerConfigCacheFactory.php b/src/Symfony/Component/Config/ResourceCheckerConfigCacheFactory.php index fc1702f3cb89a..e3bc9507903e0 100644 --- a/src/Symfony/Component/Config/ResourceCheckerConfigCacheFactory.php +++ b/src/Symfony/Component/Config/ResourceCheckerConfigCacheFactory.php @@ -32,12 +32,8 @@ public function __construct(iterable $resourceCheckers = []) /** * {@inheritdoc} */ - public function cache(string $file, $callback) + public function cache(string $file, callable $callback) { - if (!\is_callable($callback)) { - throw new \InvalidArgumentException(sprintf('Invalid type for callback argument. Expected callable, but got "%s".', \gettype($callback))); - } - $cache = new ResourceCheckerConfigCache($file, $this->resourceCheckers); if (!$cache->isFresh()) { $callback($cache); diff --git a/src/Symfony/Component/Config/Tests/ConfigCacheFactoryTest.php b/src/Symfony/Component/Config/Tests/ConfigCacheFactoryTest.php index 24e3224ce5ba0..39bd836a7ad0d 100644 --- a/src/Symfony/Component/Config/Tests/ConfigCacheFactoryTest.php +++ b/src/Symfony/Component/Config/Tests/ConfigCacheFactoryTest.php @@ -13,17 +13,18 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Config\ConfigCacheFactory; +use Symfony\Component\Config\ConfigCacheInterface; class ConfigCacheFactoryTest extends TestCase { - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Invalid type for callback argument. Expected callable, but got "object". - */ - public function testCacheWithInvalidCallback() + public function testCanCreateCache() { $cacheFactory = new ConfigCacheFactory(true); - $cacheFactory->cache('file', new \stdClass()); + $cache = $cacheFactory->cache('file', function (ConfigCacheInterface $cache) { + return; + }); + + $this->assertInstanceOf(ConfigCacheInterface::class, $cache); } }