Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 658a35e

Browse files
committedMar 13, 2020
Requires PHP 7.2.5+, Symfony 5
1 parent 3f178ef commit 658a35e

13 files changed

+60
-53
lines changed
 

‎.editorconfig

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,7 @@ indent_style = space
99
indent_size = 4
1010

1111
[*.yml]
12-
indent_style = space
1312
indent_size = 2
1413

15-
[*.md]
16-
indent_style = space
17-
indent_size = 4
18-
1914
[Makefile]
2015
indent_style = tab
21-
indent_size = 4

‎.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ cache:
99
language: php
1010

1111
php:
12-
- 7.1
1312
- 7.2
1413
- 7.3
14+
- 7.4
1515

1616
script:
17-
- if [[ $TRAVIS_PHP_VERSION == "7.1" ]]; then make test-coveralls; else make test; fi
17+
- if [[ $TRAVIS_PHP_VERSION == "7.2" ]]; then make test-coveralls; else make test; fi

‎Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM php:7.1-alpine3.8
1+
FROM php:7.2-alpine
22

33
RUN apk add --no-cache make $PHPIZE_DEPS \
44
&& pecl install xdebug \

‎LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
The olvlvl/symfony-dependency-injection-proxy package is free software.
22
It is released under the terms of the following BSD License.
33

4-
Copyright (c) 2018 by Olivier Laviale
4+
Copyright (c) 2018-2020 by Olivier Laviale
55
All rights reserved.
66

77
Redistribution and use in source and binary forms, with or without modification,

‎README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ use Psr\Log\LoggerInterface;
2424
class ExceptionHandler
2525
{
2626
private $logger;
27-
27+
2828
public function __construct(LoggerInterface $logger)
2929
{
3030
$this->logger = $logger;
3131
}
32-
32+
3333
// …
3434
}
3535
```
@@ -143,7 +143,7 @@ ArrayObject:
143143

144144
## Requirements
145145

146-
The package requires PHP 7.1 or later.
146+
The package requires PHP 7.2.5 or later.
147147

148148

149149

‎composer.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@
1111
}
1212
],
1313
"require": {
14-
"php": ">=7.1",
14+
"php": ">=7.2.5",
1515
"ext-json": "*",
16-
"symfony/dependency-injection": "^4.2"
16+
"symfony/dependency-injection": "^5.0"
17+
},
18+
"require-dev": {
19+
"symfony/config": "^5.0"
1720
},
1821
"autoload": {
1922
"psr-4": {

‎lib/FactoryRenderer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function __invoke(string $interface, string $factoryCode): string
3737
'($this->service ?: $this->service = ($this->factory)())'
3838
);
3939

40-
return <<<PHP
40+
return <<<PHPTPL
4141
new class(
4242
function () {
4343
return $factoryCode;
@@ -53,7 +53,7 @@ public function __construct(callable \$factory)
5353
5454
$methods
5555
};
56-
PHP;
56+
PHPTPL;
5757
}
5858

5959
/**

‎lib/MethodRenderer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ public function __invoke(ReflectionMethod $method, string $getterCode): string
2525
$call = $this->renderCall($method);
2626
$mayReturn = ($method->hasReturnType() && $method->getReturnType()->getName() === 'void') ? '' : 'return ';
2727

28-
return <<<PHP
28+
return <<<PHPTPL
2929
$signature
3030
{
3131
{$mayReturn}{$getterCode}->$call;
3232
}
33-
PHP;
33+
PHPTPL;
3434
}
3535

3636
private function renderMethodSignature(ReflectionMethod $method): string

‎lib/ProxyDumper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,13 @@ public function getProxyFactoryCode(Definition $definition, $id, $factoryCode)
6767
$interface = $this->findInterface($definition);
6868
$proxy = ltrim($this->renderFactory($interface, $factoryCode));
6969

70-
return <<<PHP
70+
return <<<PHPTPL
7171
if (\$lazyLoad) {
7272
return {$store}$proxy
7373
}
7474
7575
76-
PHP;
76+
PHPTPL;
7777
}
7878

7979
/**

‎tests/FactoryRendererTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function testRender()
3939
});
4040

4141
$stu = new FactoryRenderer($methodRenderer->reveal());
42-
$expected = <<<PHP
42+
$expected = <<<PHPTPL
4343
new class(
4444
function () {
4545
return $factoryCode;
@@ -56,7 +56,7 @@ public function __construct(callable \$factory)
5656
codeFor:serialize
5757
codeFor:unserialize
5858
};
59-
PHP;
59+
PHPTPL;
6060
$this->assertEquals($expected, $stu($interface, $factoryCode));
6161
}
6262
}

‎tests/MethodRendererTest.php

Lines changed: 36 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -43,123 +43,131 @@ public function provideRender(): array
4343
return new ReflectionMethod(SampleInterfaceForMethodRenderer72::class, $method);
4444
};
4545

46-
$cases = [
46+
return [
4747

4848
[
4949
$reflectionFor('aStaticMethodWithoutParametersOrReturnType'),
5050
$getterCode,
51-
<<<PHP
51+
<<<PHPTPL
5252
public static function aStaticMethodWithoutParametersOrReturnType()
5353
{
5454
return {$getterCode}->aStaticMethodWithoutParametersOrReturnType();
5555
}
56-
PHP
56+
PHPTPL
5757
],
5858

5959
[
6060
$reflectionFor('aMethodWithoutParametersOrReturnType'),
6161
$getterCode,
62-
<<<PHP
62+
<<<PHPTPL
6363
public function aMethodWithoutParametersOrReturnType()
6464
{
6565
return {$getterCode}->aMethodWithoutParametersOrReturnType();
6666
}
67-
PHP
67+
PHPTPL
6868
],
6969

7070
[
7171
$reflectionFor('aMethodWithoutParametersButABuiltInReturnType'),
7272
$getterCode,
73-
<<<PHP
73+
<<<PHPTPL
7474
public function aMethodWithoutParametersButABuiltInReturnType(): array
7575
{
7676
return {$getterCode}->aMethodWithoutParametersButABuiltInReturnType();
7777
}
78-
PHP
78+
PHPTPL
7979
],
8080

8181
[
8282
$reflectionFor('aMethodWithoutParametersButABuiltInReturnTypeNullable'),
8383
$getterCode,
84-
<<<PHP
84+
<<<PHPTPL
8585
public function aMethodWithoutParametersButABuiltInReturnTypeNullable(): ?array
8686
{
8787
return {$getterCode}->aMethodWithoutParametersButABuiltInReturnTypeNullable();
8888
}
89-
PHP
89+
PHPTPL
9090
],
9191

9292
[
9393
$reflectionFor('aMethodWithoutParametersButANonBuiltInReturnType'),
9494
$getterCode,
95-
<<<PHP
95+
<<<PHPTPL
9696
public function aMethodWithoutParametersButANonBuiltInReturnType(): \ArrayAccess
9797
{
9898
return {$getterCode}->aMethodWithoutParametersButANonBuiltInReturnType();
9999
}
100-
PHP
100+
PHPTPL
101101
],
102102

103103
[
104104
$reflectionFor('aMethodWithoutParametersButANonBuiltInReturnTypeNullable'),
105105
$getterCode,
106-
<<<PHP
106+
<<<PHPTPL
107107
public function aMethodWithoutParametersButANonBuiltInReturnTypeNullable(): ?\ArrayAccess
108108
{
109109
return {$getterCode}->aMethodWithoutParametersButANonBuiltInReturnTypeNullable();
110110
}
111-
PHP
111+
PHPTPL
112112
],
113113

114114
[
115115
$reflectionFor('aMethodWithParameters1'),
116116
$getterCode,
117-
<<<PHP
117+
<<<PHPTPL
118118
public function aMethodWithParameters1(\$a, bool \$b, ?int \$c, \$d = null)
119119
{
120120
return {$getterCode}->aMethodWithParameters1(\$a, \$b, \$c, \$d);
121121
}
122-
PHP
122+
PHPTPL
123123
],
124124

125125
[
126126
$reflectionFor('aMethodWithParameters2'),
127127
$getterCode,
128-
<<<PHP
128+
<<<PHPTPL
129129
public function aMethodWithParameters2(\ArrayAccess \$a, ?\ArrayAccess \$b, ?\ArrayAccess \$c = null)
130130
{
131131
return {$getterCode}->aMethodWithParameters2(\$a, \$b, \$c);
132132
}
133-
PHP
133+
PHPTPL
134134
],
135135

136136
[
137137
$reflectionFor('aMethodWithParameters3'),
138138
$getterCode,
139-
<<<PHP
139+
<<<PHPTPL
140140
public function aMethodWithParameters3(\$a = 123, \$b = "abc", \$c = "aConstantValue")
141141
{
142142
return {$getterCode}->aMethodWithParameters3(\$a, \$b, \$c);
143143
}
144-
PHP
144+
PHPTPL
145145
],
146146

147-
];
148-
149-
if (PHP_VERSION_ID >= 72000) {
150-
$cases[] = [
147+
[
151148

152149
$reflectionFor72('aMethodWithReturnTypeVoid'),
153150
$getterCode,
154-
<<<PHP
151+
<<<PHPTPL
155152
public function aMethodWithReturnTypeVoid(\$a): void
156153
{
157154
{$getterCode}->aMethodWithReturnTypeVoid(\$a);
158155
}
159-
PHP
160-
];
161-
}
156+
PHPTPL
157+
],
158+
159+
[
160+
161+
$reflectionFor72('aMethodWithReturnTypeObject'),
162+
$getterCode,
163+
<<<PHPTPL
164+
public function aMethodWithReturnTypeObject(\$a): object
165+
{
166+
return {$getterCode}->aMethodWithReturnTypeObject(\$a);
167+
}
168+
PHPTPL
169+
],
162170

163-
return $cases;
171+
];
164172
}
165173
}

‎tests/ProxyDumperTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,13 @@ public function testGetProxyFactoryCode(string $id, bool $private, bool $shared,
111111
$factoryRenderer->reveal()
112112
);
113113

114-
$expected = <<<PHP
114+
$expected = <<<PHPTPL
115115
if (\$lazyLoad) {
116116
return {$expectedStore}$proxyFactoryCode
117117
}
118118
119119
120-
PHP;
120+
PHPTPL;
121121

122122
$this->assertEquals($expected, $stu->getProxyFactoryCode($definition, $id, $factoryCode));
123123
}

‎tests/cases/SampleInterfaceForMethodRenderer72.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,6 @@
1414
interface SampleInterfaceForMethodRenderer72
1515
{
1616
public function aMethodWithReturnTypeVoid($a): void;
17+
18+
public function aMethodWithReturnTypeObject($a): object;
1719
}

0 commit comments

Comments
 (0)
Please sign in to comment.