Skip to content

Commit e1e7754

Browse files
alongoszadamwojs
andauthored
IBX-9727: Added missing type hints (#34)
* [Rector] Applied SetList::TYPE_DECLARATION built-in Rector set Applied Rectors: * Rector\TypeDeclaration\Rector\Class_\AddTestsVoidReturnTypeWhereNoReturnRector * Rector\TypeDeclaration\Rector\ClassMethod\AddMethodCallBasedStrictParamTypeRector * Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeBasedOnPHPUnitDataProviderRector * Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeFromPropertyTypeRector * Rector\TypeDeclaration\Rector\ClassMethod\ParamTypeByMethodCallTypeRector * Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnDirectArrayRector * Rector\TypeDeclaration\Rector\ClassMethod\StringReturnTypeFromStrictStringReturnsRector * Rector\TypeDeclaration\Rector\Class_\TypedPropertyFromCreateMockAssignRector * Applied code review suggestions --------- Co-authored-by: Adam Wójs <[email protected]>
1 parent a963073 commit e1e7754

File tree

9 files changed

+29
-41
lines changed

9 files changed

+29
-41
lines changed

src/lib/Asset/AssetPathResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class AssetPathResolver implements AssetPathResolverInterface
1919

2020
private ?LoggerInterface $logger;
2121

22-
public function __construct(array $designPaths, $webRootDir, LoggerInterface $logger = null)
22+
public function __construct(array $designPaths, string $webRootDir, LoggerInterface $logger = null)
2323
{
2424
$this->designPaths = $designPaths;
2525
$this->webRootDir = $webRootDir;

src/lib/Asset/ProvisionedPathResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class ProvisionedPathResolver implements AssetPathResolverInterface, AssetPathPr
2020

2121
private string $webRootDir;
2222

23-
public function __construct(array $resolvedPaths, AssetPathResolverInterface $innerResolver, $webRootDir)
23+
public function __construct(array $resolvedPaths, AssetPathResolverInterface $innerResolver, string $webRootDir)
2424
{
2525
$this->resolvedPaths = $resolvedPaths;
2626
$this->innerResolver = $innerResolver;

src/lib/Templating/TemplatePathRegistry.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class TemplatePathRegistry implements TemplatePathRegistryInterface, Serializabl
1616

1717
private string $kernelRootDir;
1818

19-
public function __construct($kernelRootDir)
19+
public function __construct(string $kernelRootDir)
2020
{
2121
$this->kernelRootDir = $kernelRootDir;
2222
}

src/lib/Templating/Twig/TwigThemeLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function getNamespaces(): array
7777
/**
7878
* @param string|string[] $paths
7979
*/
80-
public function setPaths(string|array $paths, $namespace = FilesystemLoader::MAIN_NAMESPACE): void
80+
public function setPaths(string|array $paths, string $namespace = FilesystemLoader::MAIN_NAMESPACE): void
8181
{
8282
$this->innerFilesystemLoader->setPaths($paths, $namespace);
8383
}

tests/lib/Asset/AssetPathResolverTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
class AssetPathResolverTest extends TestCase
1717
{
18-
public function testResolveAssetPathFail()
18+
public function testResolveAssetPathFail(): void
1919
{
2020
$logger = $this->createMock(LoggerInterface::class);
2121
$logger
@@ -30,15 +30,15 @@ public function testResolveAssetPathFail()
3030
/**
3131
* @covers \Ibexa\DesignEngine\Asset\AssetPathResolver::resolveAssetPath
3232
*/
33-
public function testResolveInvalidDesign()
33+
public function testResolveInvalidDesign(): void
3434
{
3535
$resolver = new AssetPathResolver([], __DIR__);
3636
$assetPath = 'images/foo.png';
3737
$this->expectException(InvalidDesignException::class);
3838
self::assertSame($assetPath, $resolver->resolveAssetPath($assetPath, 'foo'));
3939
}
4040

41-
public function resolveAssetPathProvider()
41+
public function resolveAssetPathProvider(): array
4242
{
4343
return [
4444
[
@@ -107,7 +107,7 @@ public function resolveAssetPathProvider()
107107
/**
108108
* @dataProvider resolveAssetPathProvider
109109
*/
110-
public function testResolveAssetPath(array $designPaths, array $existingPaths, $path, $resolvedPath)
110+
public function testResolveAssetPath(array $designPaths, array $existingPaths, string $path, string $resolvedPath): void
111111
{
112112
$webrootDir = vfsStream::setup('web');
113113
foreach ($designPaths['foo'] as $designPath) {

tests/lib/Asset/ProvisionedPathResolverTest.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,12 @@
1111
use Ibexa\DesignEngine\Asset\AssetPathResolverInterface;
1212
use Ibexa\DesignEngine\Asset\ProvisionedPathResolver;
1313
use org\bovigo\vfs\vfsStream;
14+
use PHPUnit\Framework\MockObject\MockObject;
1415
use PHPUnit\Framework\TestCase;
1516

1617
class ProvisionedPathResolverTest extends TestCase
1718
{
18-
/**
19-
* @var \PHPUnit\Framework\MockObject\MockObject|\Ibexa\DesignEngine\Asset\AssetPathResolverInterface
20-
*/
21-
private $innerResolver;
19+
private AssetPathResolverInterface&MockObject $innerResolver;
2220

2321
/**
2422
* @var \org\bovigo\vfs\vfsStreamDirectory
@@ -32,7 +30,7 @@ protected function setUp(): void
3230
$this->webrootDir = vfsStream::setup('web');
3331
}
3432

35-
public function testResolvePathNotProvisioned()
33+
public function testResolvePathNotProvisioned(): void
3634
{
3735
$assetLogicalPath = 'images/some_image.jpg';
3836
$design = 'foo';
@@ -51,7 +49,7 @@ public function testResolvePathNotProvisioned()
5149
self::assertSame($expected, $resolver->resolveAssetPath($assetLogicalPath, $design));
5250
}
5351

54-
public function testResolveProvisionedPath()
52+
public function testResolveProvisionedPath(): void
5553
{
5654
$expected = 'some/path/images/some_image.jpg';
5755
$assetLogicalPath = 'images/some_image.jpg';
@@ -64,7 +62,7 @@ public function testResolveProvisionedPath()
6462
self::assertSame($expected, $resolver->resolveAssetPath($assetLogicalPath, $design));
6563
}
6664

67-
public function testProvisionResolvedPaths()
65+
public function testProvisionResolvedPaths(): void
6866
{
6967
$design = 'some_design';
7068
$themesPaths = [

tests/lib/Asset/ThemePackageTest.php

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,17 @@
1010
use Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface;
1111
use Ibexa\DesignEngine\Asset\AssetPathResolverInterface;
1212
use Ibexa\DesignEngine\Asset\ThemePackage;
13+
use PHPUnit\Framework\MockObject\MockObject;
1314
use PHPUnit\Framework\TestCase;
1415
use Symfony\Component\Asset\PackageInterface;
1516

1617
class ThemePackageTest extends TestCase
1718
{
18-
/**
19-
* @var \PHPUnit\Framework\MockObject\MockObject|\Ibexa\DesignEngine\Asset\AssetPathResolverInterface
20-
*/
21-
private $assetPathResolver;
19+
private AssetPathResolverInterface&MockObject $assetPathResolver;
2220

23-
/**
24-
* @var \PHPUnit\Framework\MockObject\MockObject|\Symfony\Component\Asset\PackageInterface
25-
*/
26-
private $innerPackage;
21+
private PackageInterface&MockObject $innerPackage;
2722

28-
/**
29-
* @var \PHPUnit\Framework\MockObject\MockObject|\Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface
30-
*/
31-
private $configResolver;
23+
private ConfigResolverInterface&MockObject $configResolver;
3224

3325
protected function setUp(): void
3426
{
@@ -39,7 +31,7 @@ protected function setUp(): void
3931
$this->configResolver = $this->createMock(ConfigResolverInterface::class);
4032
}
4133

42-
public function testGetUrl()
34+
public function testGetUrl(): void
4335
{
4436
$assetPath = 'images/foo.png';
4537
$fullAssetPath = 'assets/' . $assetPath;
@@ -65,7 +57,7 @@ public function testGetUrl()
6557
self::assertSame("/$fullAssetPath", $package->getUrl($assetPath));
6658
}
6759

68-
public function testGetVersion()
60+
public function testGetVersion(): void
6961
{
7062
$assetPath = 'images/foo.png';
7163
$fullAssetPath = 'assets/' . $assetPath;

tests/lib/Templating/TemplatePathRegistryTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212

1313
class TemplatePathRegistryTest extends TestCase
1414
{
15-
private function getExpectedRelativePath($templateFullPath, $kernelRootDir)
15+
private function getExpectedRelativePath(string $templateFullPath, string $kernelRootDir): string
1616
{
1717
return str_replace($kernelRootDir . '/', '', $templateFullPath);
1818
}
1919

20-
public function testMapTemplatePath()
20+
public function testMapTemplatePath(): void
2121
{
2222
$kernelRootDir = __DIR__;
2323
$templateLogicalName = '@foo/bar.html.twig';
@@ -32,7 +32,7 @@ public function testMapTemplatePath()
3232
);
3333
}
3434

35-
public function testGetTemplatePath()
35+
public function testGetTemplatePath(): void
3636
{
3737
$kernelRootDir = __DIR__;
3838
$templateLogicalName = '@foo/bar.html.twig';
@@ -46,7 +46,7 @@ public function testGetTemplatePath()
4646
);
4747
}
4848

49-
public function testGetTemplatePathNotMapped()
49+
public function testGetTemplatePathNotMapped(): void
5050
{
5151
$kernelRootDir = __DIR__;
5252
$templateLogicalName = '@foo/bar.html.twig';

tests/lib/Templating/ThemeTemplateNameResolverTest.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,12 @@
99

1010
use Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface;
1111
use Ibexa\DesignEngine\Templating\ThemeTemplateNameResolver;
12+
use PHPUnit\Framework\MockObject\MockObject;
1213
use PHPUnit\Framework\TestCase;
1314

1415
class ThemeTemplateNameResolverTest extends TestCase
1516
{
16-
/**
17-
* @var \PHPUnit\Framework\MockObject\MockObject|\Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface
18-
*/
19-
private $configResolver;
17+
private ConfigResolverInterface&MockObject $configResolver;
2018

2119
protected function setUp(): void
2220
{
@@ -25,7 +23,7 @@ protected function setUp(): void
2523
$this->configResolver = $this->createMock(ConfigResolverInterface::class);
2624
}
2725

28-
public function templateNameProvider()
26+
public function templateNameProvider(): array
2927
{
3028
return [
3129
[null, 'foo.html.twig', 'foo.html.twig'],
@@ -37,7 +35,7 @@ public function templateNameProvider()
3735
/**
3836
* @dataProvider templateNameProvider
3937
*/
40-
public function testResolveTemplateName($currentDesign, $templateName, $expectedTemplateName)
38+
public function testResolveTemplateName(?string $currentDesign, string $templateName, string $expectedTemplateName): void
4139
{
4240
$this->configResolver
4341
->method('getParameter')
@@ -47,7 +45,7 @@ public function testResolveTemplateName($currentDesign, $templateName, $expected
4745
self::assertSame($expectedTemplateName, $resolver->resolveTemplateName($templateName));
4846
}
4947

50-
public function isTemplateDesignNamespacedProvider()
48+
public function isTemplateDesignNamespacedProvider(): array
5149
{
5250
return [
5351
[null, 'foo.html.twig', false],
@@ -60,7 +58,7 @@ public function isTemplateDesignNamespacedProvider()
6058
/**
6159
* @dataProvider isTemplateDesignNamespacedProvider
6260
*/
63-
public function testIsTemplateDesignNamespaced($currentDesign, $templateName, $expected)
61+
public function testIsTemplateDesignNamespaced(?string $currentDesign, string $templateName, bool $expected): void
6462
{
6563
$this->configResolver
6664
->method('getParameter')

0 commit comments

Comments
 (0)