Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5b69087

Browse filesBrowse files
committed
[Config] Add more type-hints as follow-up of #32201
1 parent 38b9b95 commit 5b69087
Copy full SHA for 5b69087

7 files changed

+13
-21
lines changed

‎src/Symfony/Component/Config/ConfigCacheFactory.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/ConfigCacheFactory.php
+1-5Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,8 @@ public function __construct(bool $debug)
3535
/**
3636
* {@inheritdoc}
3737
*/
38-
public function cache(string $file, $callback)
38+
public function cache(string $file, callable $callback)
3939
{
40-
if (!\is_callable($callback)) {
41-
throw new \InvalidArgumentException(sprintf('Invalid type for callback argument. Expected callable, but got "%s".', \gettype($callback)));
42-
}
43-
4440
$cache = new ConfigCache($file, $this->debug);
4541
if (!$cache->isFresh()) {
4642
$callback($cache);

‎src/Symfony/Component/Config/ConfigCacheFactoryInterface.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/ConfigCacheFactoryInterface.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ interface ConfigCacheFactoryInterface
2828
*
2929
* @return ConfigCacheInterface The cache instance
3030
*/
31-
public function cache(string $file, $callable);
31+
public function cache(string $file, callable $callable);
3232
}

‎src/Symfony/Component/Config/Definition/ArrayNode.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/Definition/ArrayNode.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public function setAllowNewKeys(bool $allow)
129129
*/
130130
public function setPerformDeepMerging(bool $boolean)
131131
{
132-
$this->performDeepMerging = (bool) $boolean;
132+
$this->performDeepMerging = $boolean;
133133
}
134134

135135
/**

‎src/Symfony/Component/Config/Definition/PrototypeNodeInterface.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/Definition/PrototypeNodeInterface.php
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ interface PrototypeNodeInterface extends NodeInterface
2020
{
2121
/**
2222
* Sets the name of the node.
23-
*
24-
* @param string $name The name of the node
2523
*/
2624
public function setName(string $name);
2725
}

‎src/Symfony/Component/Config/FileLocator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/FileLocator.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function __construct($paths = [])
3333
/**
3434
* {@inheritdoc}
3535
*/
36-
public function locate(string $name, string $currentPath = null, $first = true)
36+
public function locate(string $name, string $currentPath = null, bool $first = true)
3737
{
3838
if ('' == $name) {
3939
throw new \InvalidArgumentException('An empty file name is not valid to be located.');

‎src/Symfony/Component/Config/ResourceCheckerConfigCacheFactory.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/ResourceCheckerConfigCacheFactory.php
+1-5Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,8 @@ public function __construct(iterable $resourceCheckers = [])
3232
/**
3333
* {@inheritdoc}
3434
*/
35-
public function cache(string $file, $callback)
35+
public function cache(string $file, callable $callback)
3636
{
37-
if (!\is_callable($callback)) {
38-
throw new \InvalidArgumentException(sprintf('Invalid type for callback argument. Expected callable, but got "%s".', \gettype($callback)));
39-
}
40-
4137
$cache = new ResourceCheckerConfigCache($file, $this->resourceCheckers);
4238
if (!$cache->isFresh()) {
4339
$callback($cache);

‎src/Symfony/Component/Config/Tests/ConfigCacheFactoryTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/Tests/ConfigCacheFactoryTest.php
+8-6Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,19 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\Config\ConfigCacheFactory;
16+
use Symfony\Component\Config\ConfigCacheInterface;
17+
use Symfony\Component\HttpKernel\Tests\CacheWarmer\TestCacheWarmer;
1618

1719
class ConfigCacheFactoryTest extends TestCase
1820
{
19-
/**
20-
* @expectedException \InvalidArgumentException
21-
* @expectedExceptionMessage Invalid type for callback argument. Expected callable, but got "object".
22-
*/
23-
public function testCacheWithInvalidCallback()
21+
public function testCanCreateCache()
2422
{
2523
$cacheFactory = new ConfigCacheFactory(true);
2624

27-
$cacheFactory->cache('file', new \stdClass());
25+
$cache = $cacheFactory->cache('file', function (ConfigCacheInterface $cache) {
26+
return;
27+
});
28+
29+
$this->assertInstanceOf(ConfigCacheInterface::class, $cache);
2830
}
2931
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.