Skip to content

Commit ac7c34a

Browse files
authored
Merge pull request #22 from samsonasik/apply-php80
Apply PHP 8.0 Syntax and constructor promotion
2 parents 046519d + eeef357 commit ac7c34a

File tree

6 files changed

+15
-25
lines changed

6 files changed

+15
-25
lines changed

src/ArrayParametersTrait.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,9 @@ trait ArrayParametersTrait
2828
* using PHP's type casting
2929
* - scalar values result in an exception
3030
*
31-
* @param mixed $params
3231
* @throws Exception\InvalidArgumentException
3332
*/
34-
private function normalizeParams($params): array
33+
private function normalizeParams(mixed $params): array
3534
{
3635
if (null === $params) {
3736
return [];

src/DefaultParamsTrait.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,9 @@ trait DefaultParamsTrait
3131
* @param string $templateName Name of template to which the param applies;
3232
* use TEMPLATE_ALL to apply to all templates.
3333
* @param string $param Param name.
34-
* @param mixed $value
3534
* @throws Exception\InvalidArgumentException
3635
*/
37-
public function addDefaultParam(string $templateName, string $param, $value): void
36+
public function addDefaultParam(string $templateName, string $param, mixed $value): void
3837
{
3938
if (! $templateName) {
4039
throw new Exception\InvalidArgumentException('$templateName must be a non-empty string');

src/TemplatePath.php

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

55
namespace Mezzio\Template;
66

7-
class TemplatePath
8-
{
9-
/** @var string */
10-
protected $path;
11-
12-
/** @var string|null */
13-
protected $namespace;
7+
use Stringable;
148

15-
public function __construct(string $path, ?string $namespace = null)
9+
class TemplatePath implements Stringable
10+
{
11+
public function __construct(protected string $path, protected ?string $namespace = null)
1612
{
17-
$this->path = $path;
18-
$this->namespace = $namespace;
1913
}
2014

2115
/**

src/TemplateRendererInterface.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ public function getPaths(): array;
5656
* @param string $templateName Name of template to which the param applies;
5757
* use TEMPLATE_ALL to apply to all templates.
5858
* @param string $param Param name.
59-
* @param mixed $value
6059
*/
61-
public function addDefaultParam(string $templateName, string $param, $value): void;
60+
public function addDefaultParam(string $templateName, string $param, mixed $value): void;
6261
}

test/ArrayParametersTraitTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,9 @@ public function nonNullScalarParameters(): array
6969

7070
/**
7171
* @dataProvider nonNullScalarParameters
72-
* @param mixed $scalar
7372
* @param string $expectedString
7473
*/
75-
public function testNonNullScalarsRaiseAnException($scalar, $expectedString): void
74+
public function testNonNullScalarsRaiseAnException(mixed $scalar, $expectedString): void
7675
{
7776
$this->expectException(InvalidArgumentException::class);
7877
$this->expectExceptionMessage($expectedString);

test/TemplatePathAssertionsTrait.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,23 @@
1111

1212
trait TemplatePathAssertionsTrait
1313
{
14-
/** @param mixed $path */
15-
public function assertTemplatePath($path, TemplatePath $templatePath, ?string $message = null): void
14+
public function assertTemplatePath(mixed $path, TemplatePath $templatePath, ?string $message = null): void
1615
{
1716
$message = $message ?: sprintf('Failed to assert TemplatePath contained path %s', (string) $path);
1817
self::assertEquals($path, $templatePath->getPath(), $message);
1918
}
2019

21-
/** @param mixed $path */
22-
public function assertTemplatePathString($path, TemplatePath $templatePath, ?string $message = null): void
20+
public function assertTemplatePathString(mixed $path, TemplatePath $templatePath, ?string $message = null): void
2321
{
2422
$message = $message ?: sprintf('Failed to assert TemplatePath casts to string path %s', (string) $path);
2523
self::assertEquals($path, (string) $templatePath, $message);
2624
}
2725

28-
/** @param mixed $namespace */
29-
public function assertTemplatePathNamespace($namespace, TemplatePath $templatePath, ?string $message = null): void
30-
{
26+
public function assertTemplatePathNamespace(
27+
mixed $namespace,
28+
TemplatePath $templatePath,
29+
?string $message = null
30+
): void {
3131
$message = $message ?: sprintf(
3232
'Failed to assert TemplatePath namespace matched %s',
3333
var_export($namespace, true)

0 commit comments

Comments
 (0)