Skip to content

Commit 1782e6d

Browse files
committed
Merge branch '6.2' into 6.3
* 6.2: Add return types and parameter types
2 parents 3a8132c + f90b324 commit 1782e6d

File tree

105 files changed

+369
-337
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+369
-337
lines changed

best_practices.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,15 +411,15 @@ checks that all application URLs load successfully::
411411
/**
412412
* @dataProvider urlProvider
413413
*/
414-
public function testPageIsSuccessful($url)
414+
public function testPageIsSuccessful($url): void
415415
{
416416
$client = self::createClient();
417417
$client->request('GET', $url);
418418

419419
$this->assertResponseIsSuccessful();
420420
}
421421

422-
public function urlProvider()
422+
public function urlProvider(): \Generator
423423
{
424424
yield ['/'];
425425
yield ['/posts'];

bundles/configuration.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ The ``Configuration`` class to handle the sample configuration looks like::
183183

184184
class Configuration implements ConfigurationInterface
185185
{
186-
public function getConfigTreeBuilder()
186+
public function getConfigTreeBuilder(): TreeBuilder
187187
{
188188
$treeBuilder = new TreeBuilder('acme_social');
189189

@@ -217,7 +217,7 @@ force validation (e.g. if an additional option was passed, an exception will be
217217
thrown)::
218218

219219
// src/Acme/SocialBundle/DependencyInjection/AcmeSocialExtension.php
220-
public function load(array $configs, ContainerBuilder $container)
220+
public function load(array $configs, ContainerBuilder $container): void
221221
{
222222
$configuration = new Configuration();
223223

@@ -259,7 +259,7 @@ In your extension, you can load this and dynamically set its arguments::
259259
use Symfony\Component\Config\FileLocator;
260260
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
261261

262-
public function load(array $configs, ContainerBuilder $container)
262+
public function load(array $configs, ContainerBuilder $container): void
263263
{
264264
$loader = new XmlFileLoader($container, new FileLocator(dirname(__DIR__).'/Resources/config'));
265265
$loader->load('services.xml');
@@ -288,7 +288,7 @@ In your extension, you can load this and dynamically set its arguments::
288288
class AcmeHelloExtension extends ConfigurableExtension
289289
{
290290
// note that this method is called loadInternal and not load
291-
protected function loadInternal(array $mergedConfig, ContainerBuilder $container)
291+
protected function loadInternal(array $mergedConfig, ContainerBuilder $container): void
292292
{
293293
// ...
294294
}
@@ -304,7 +304,7 @@ In your extension, you can load this and dynamically set its arguments::
304304
(e.g. by overriding configurations and using :phpfunction:`isset` to check
305305
for the existence of a value). Be aware that it'll be very hard to support XML::
306306

307-
public function load(array $configs, ContainerBuilder $container)
307+
public function load(array $configs, ContainerBuilder $container): void
308308
{
309309
$config = [];
310310
// let resources override the previous set value
@@ -458,7 +458,7 @@ the extension. You might want to change this to a more professional URL::
458458
{
459459
// ...
460460

461-
public function getNamespace()
461+
public function getNamespace(): string
462462
{
463463
return 'http://acme_company.com/schema/dic/hello';
464464
}
@@ -490,7 +490,7 @@ can place it anywhere you like. You should return this path as the base path::
490490
{
491491
// ...
492492

493-
public function getXsdValidationBasePath()
493+
public function getXsdValidationBasePath(): string
494494
{
495495
return __DIR__.'/../Resources/config/schema';
496496
}

bundles/extension.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ This is how the extension of an AcmeHelloBundle should look like::
3434

3535
class AcmeHelloExtension extends Extension
3636
{
37-
public function load(array $configs, ContainerBuilder $container)
37+
public function load(array $configs, ContainerBuilder $container): void
3838
{
3939
// ... you'll load the files here later
4040
}
@@ -90,7 +90,7 @@ For instance, assume you have a file called ``services.xml`` in the
9090
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
9191

9292
// ...
93-
public function load(array $configs, ContainerBuilder $container)
93+
public function load(array $configs, ContainerBuilder $container): void
9494
{
9595
$loader = new XmlFileLoader(
9696
$container,
@@ -167,7 +167,7 @@ they are compiled when generating the application cache to improve the overall
167167
performance. Define the list of annotated classes to compile in the
168168
``addAnnotatedClassesToCompile()`` method::
169169

170-
public function load(array $configs, ContainerBuilder $container)
170+
public function load(array $configs, ContainerBuilder $container): void
171171
{
172172
// ...
173173

bundles/prepend_extension.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ To give an Extension the power to do this, it needs to implement
3131
{
3232
// ...
3333

34-
public function prepend(ContainerBuilder $container)
34+
public function prepend(ContainerBuilder $container): void
3535
{
3636
// ...
3737
}
@@ -52,7 +52,7 @@ a configuration setting in multiple bundles as well as disable a flag in multipl
5252
in case a specific other bundle is not registered::
5353

5454
// src/Acme/HelloBundle/DependencyInjection/AcmeHelloExtension.php
55-
public function prepend(ContainerBuilder $container)
55+
public function prepend(ContainerBuilder $container): void
5656
{
5757
// get all bundles
5858
$bundles = $container->getParameter('kernel.bundles');

cache.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,9 +307,10 @@ with either :class:`Symfony\\Contracts\\Cache\\CacheInterface` or
307307
``Psr\Cache\CacheItemPoolInterface``::
308308

309309
use Symfony\Contracts\Cache\CacheInterface;
310+
// ...
310311

311312
// from a controller method
312-
public function listProducts(CacheInterface $customThingCache)
313+
public function listProducts(CacheInterface $customThingCache): Response
313314
{
314315
// ...
315316
}
@@ -555,7 +556,7 @@ the same key could be invalidated with one function call::
555556
) {
556557
}
557558

558-
public function someMethod()
559+
public function someMethod(): void
559560
{
560561
$value0 = $this->myCachePool->get('item_0', function (ItemInterface $item): string {
561562
$item->tag(['foo', 'bar']);

components/asset.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,12 @@ every day::
210210
$this->version = date('Ymd');
211211
}
212212

213-
public function getVersion(string $path)
213+
public function getVersion(string $path): \DateTimeInterface
214214
{
215215
return $this->version;
216216
}
217217

218-
public function applyVersion(string $path)
218+
public function applyVersion(string $path): string
219219
{
220220
return sprintf('%s?v=%s', $path, $this->getVersion($path));
221221
}

components/browser_kit.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ This method accepts a request and should return a response::
3838

3939
class Client extends AbstractBrowser
4040
{
41-
protected function doRequest($request)
41+
protected function doRequest($request): Response
4242
{
4343
// ... convert request into a response
4444

components/config/definition.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ implements the :class:`Symfony\\Component\\Config\\Definition\\ConfigurationInte
5454

5555
class DatabaseConfiguration implements ConfigurationInterface
5656
{
57-
public function getConfigTreeBuilder()
57+
public function getConfigTreeBuilder(): TreeBuilder
5858
{
5959
$treeBuilder = new TreeBuilder('database');
6060

@@ -568,7 +568,9 @@ be large and you may want to split it up into sections. You can do this
568568
by making a section a separate node and then appending it into the main
569569
tree with ``append()``::
570570

571-
public function getConfigTreeBuilder()
571+
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
572+
573+
public function getConfigTreeBuilder(): TreeBuilder
572574
{
573575
$treeBuilder = new TreeBuilder('database');
574576

@@ -597,7 +599,7 @@ tree with ``append()``::
597599
return $treeBuilder;
598600
}
599601

600-
public function addParametersNode()
602+
public function addParametersNode(): NodeDefinition
601603
{
602604
$treeBuilder = new TreeBuilder('parameters');
603605

components/config/resources.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ which allows for recursively importing other resources::
4343

4444
class YamlUserLoader extends FileLoader
4545
{
46-
public function load($resource, $type = null)
46+
public function load($resource, $type = null): void
4747
{
4848
$configValues = Yaml::parse(file_get_contents($resource));
4949

@@ -54,7 +54,7 @@ which allows for recursively importing other resources::
5454
// $this->import('extra_users.yaml');
5555
}
5656

57-
public function supports($resource, $type = null)
57+
public function supports($resource, $type = null): bool
5858
{
5959
return is_string($resource) && 'yaml' === pathinfo(
6060
$resource,

components/console/changing_default_command.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,16 @@ name to the ``setDefaultCommand()`` method::
1515
#[AsCommand(name: 'hello:world')]
1616
class HelloWorldCommand extends Command
1717
{
18-
protected function configure()
18+
protected function configure(): void
1919
{
2020
$this->setDescription('Outputs "Hello World"');
2121
}
2222

23-
protected function execute(InputInterface $input, OutputInterface $output)
23+
protected function execute(InputInterface $input, OutputInterface $output): int
2424
{
2525
$output->writeln('Hello World');
26+
27+
return Command::SUCCESS;
2628
}
2729
}
2830

0 commit comments

Comments
 (0)