Skip to content

Commit 4cfbd87

Browse files
committed
Use more type hints
Use return types, remove docblocks without remaining value.
1 parent b1783a8 commit 4cfbd87

5 files changed

Lines changed: 25 additions & 62 deletions

File tree

Tests/DependencyInjection/Compiler/ShortcodeCompilerPassTest.php

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ final class ShortcodeCompilerPassTest extends TestCase
2222
/** @var ContainerBuilder|\PHPUnit_Framework_MockObject_MockObject */
2323
private $containerBuilder;
2424

25-
protected function setUp()
25+
protected function setUp(): void
2626
{
2727
$this->compilerPass = new ShortcodeCompilerPass();
2828
$this->containerBuilder = $this->getMockBuilder(ContainerBuilder::class)
@@ -31,7 +31,7 @@ protected function setUp()
3131
}
3232

3333
/** @test */
34-
public function tagged_services_are_added_as_handlers_to_handler_container()
34+
public function tagged_services_are_added_as_handlers_to_handler_container(): void
3535
{
3636
$this->containerBuilder->expects($this->once())
3737
->method('findTaggedServiceIds')
@@ -66,10 +66,8 @@ public function tagged_services_are_added_as_handlers_to_handler_container()
6666
$this->compilerPass->process($this->containerBuilder);
6767
}
6868

69-
/**
70-
* @test
71-
*/
72-
public function no_tagged_services_do_no_harm()
69+
/** @test */
70+
public function no_tagged_services_do_no_harm(): void
7371
{
7472
$this->containerBuilder->expects($this->once())
7573
->method('findTaggedServiceIds')
@@ -79,7 +77,7 @@ public function no_tagged_services_do_no_harm()
7977
}
8078

8179
/** @test */
82-
public function shortcode_guide_service_gets_configured_if_set()
80+
public function shortcode_guide_service_gets_configured_if_set(): void
8381
{
8482
$this->containerBuilder->expects($this->once())
8583
->method('findTaggedServiceIds')
@@ -121,10 +119,8 @@ public function shortcode_guide_service_gets_configured_if_set()
121119
$this->compilerPass->process($this->containerBuilder);
122120
}
123121

124-
/**
125-
* @test
126-
*/
127-
public function missing_shortcode_guide_service_does_no_harm()
122+
/** @test */
123+
public function missing_shortcode_guide_service_does_no_harm(): void
128124
{
129125
$this->containerBuilder->expects($this->once())
130126
->method('findTaggedServiceIds')

Tests/Fixtures/PublicFragmentHandlerClass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*/
1111
class PublicFragmentHandlerClass implements CompilerPassInterface
1212
{
13-
public function process(ContainerBuilder $container)
13+
public function process(ContainerBuilder $container): void
1414
{
1515
$container->getDefinition('fragment.handler')->setPublic(true);
1616
}

Tests/Fixtures/TestKernel.php

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,9 @@ final class TestKernel extends Kernel
2020
use MicroKernelTrait;
2121

2222
/**
23-
* Returns an array of bundles to register.
24-
*
2523
* @return BundleInterface[] An array of bundle instances
2624
*/
27-
public function registerBundles()
25+
public function registerBundles(): array
2826
{
2927
return [
3028
new FrameworkBundle(),
@@ -33,29 +31,19 @@ public function registerBundles()
3331
];
3432
}
3533

36-
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader)
34+
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void
3735
{
3836
$loader->load(__DIR__.'/config/config.yml');
3937
$loader->load(__DIR__.'/config/test_shortcodes.xml');
4038
$container->addCompilerPass(new PublicFragmentHandlerClass());
4139
}
4240

43-
/**
44-
* Gets the cache directory.
45-
*
46-
* @return string The cache directory
47-
*/
48-
public function getCacheDir()
41+
public function getCacheDir(): string
4942
{
5043
return __DIR__.'/cache/'.$this->environment;
5144
}
5245

53-
/**
54-
* Gets the log directory.
55-
*
56-
* @return string The log directory
57-
*/
58-
public function getLogDir()
46+
public function getLogDir(): string
5947
{
6048
return __DIR__.'/logs';
6149
}
@@ -68,7 +56,7 @@ public function getLogDir()
6856
*
6957
* @param RouteCollectionBuilder $routes
7058
*/
71-
protected function configureRoutes(RouteCollectionBuilder $routes)
59+
protected function configureRoutes(RouteCollectionBuilder $routes): void
7260
{
7361
}
7462
}

Tests/Functional/ShortcodeFacadeTest.php

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,20 @@
44

55
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
66
use Symfony\Component\HttpFoundation\Request;
7+
use Symfony\Component\HttpFoundation\Response;
78
use Symfony\Component\HttpKernel\Controller\ControllerReference;
89
use Symfony\Component\HttpKernel\Fragment\FragmentHandler;
910

1011
final class ShortcodeFacadeTest extends KernelTestCase
1112
{
1213
private $fragmentHandler;
1314

14-
protected static function getKernelClass()
15+
protected static function getKernelClass(): string
1516
{
1617
return 'Webfactory\ShortcodeBundle\Tests\Fixtures\TestKernel';
1718
}
1819

19-
protected function setUp()
20+
protected function setUp(): void
2021
{
2122
parent::setUp();
2223
static::bootKernel();
@@ -46,7 +47,7 @@ public function processes_shortcodes(string $shortcode, ControllerReference $con
4647
);
4748
}
4849

49-
public function shortcodeFixtures()
50+
public function shortcodeFixtures(): array
5051
{
5152
return [
5253
['[test-esi foo=bar]', new ControllerReference('test-esi-controller', ['foo' => 'bar']), 'esi'],
@@ -55,7 +56,7 @@ public function shortcodeFixtures()
5556
}
5657

5758
/** @test */
58-
public function paragraphs_wrapping_shortcodes_get_removed()
59+
public function paragraphs_wrapping_shortcodes_get_removed(): void
5960
{
6061
$this->fragmentHandler->method('render')->willReturn('RESULT');
6162

@@ -66,21 +67,15 @@ public function paragraphs_wrapping_shortcodes_get_removed()
6667
}
6768

6869
/** @test */
69-
public function content_without_shortcodes_wont_be_changed()
70+
public function content_without_shortcodes_wont_be_changed(): void
7071
{
7172
$this->assertEquals(
7273
'<p>Content without shortcode</p>',
7374
$this->renderTwigTemplate("{{ '<p>Content without shortcode</p>' | shortcodes }}")
7475
);
7576
}
7677

77-
/**
78-
* @param string $templateCode
79-
* @param array $context
80-
*
81-
* @return string
82-
*/
83-
private function renderTwigTemplate($templateCode, array $context = [])
78+
private function renderTwigTemplate(string $templateCode, array $context = []): string
8479
{
8580
/** @var $container ContainerInterface */
8681
$container = static::$kernel->getContainer();

Tests/Functional/ShortcodeTest.php

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ abstract class ShortcodeTest extends WebTestCase
1313
/**
1414
* @return string name of the shortcode to test.
1515
*/
16-
abstract protected function getShortcodeToTest();
16+
abstract protected function getShortcodeToTest(): string;
1717

18-
protected function setUp()
18+
protected function setUp(): void
1919
{
2020
parent::setUp();
2121

@@ -26,12 +26,7 @@ protected function setUp()
2626
}
2727
}
2828

29-
/**
30-
* @param string|null $customParameters
31-
*
32-
* @return Crawler
33-
*/
34-
protected function crawlRenderedExample($customParameters = null)
29+
protected function crawlRenderedExample(string $customParameters = null): Crawler
3530
{
3631
$urlWithRenderedExample = $this->getUrlWithRenderedExample($customParameters);
3732

@@ -49,13 +44,7 @@ protected function crawlRenderedExample($customParameters = null)
4944
return $crawlerOnRenderedExample;
5045
}
5146

52-
/**
53-
* @param int $expectedStatusCode
54-
* @param string|null $customParameters
55-
*
56-
* @return Crawler
57-
*/
58-
protected function assertHttpStatusCodeWhenCrawlingRenderedExample($expectedStatusCode, $customParameters = null)
47+
protected function assertHttpStatusCodeWhenCrawlingRenderedExample(int $expectedStatusCode, string $customParameters = null): Crawler
5948
{
6049
$urlWithRenderedExample = $this->getUrlWithRenderedExample($customParameters);
6150

@@ -64,12 +53,7 @@ protected function assertHttpStatusCodeWhenCrawlingRenderedExample($expectedStat
6453
$this->assertEquals($expectedStatusCode, $client->getResponse()->getStatusCode());
6554
}
6655

67-
/**
68-
* @param string|null $customParameters
69-
*
70-
* @return string
71-
*/
72-
protected function getUrlWithRenderedExample($customParameters = null)
56+
protected function getUrlWithRenderedExample(string $customParameters = null): string
7357
{
7458
static::bootKernel();
7559

0 commit comments

Comments
 (0)