Skip to content

Commit d9a9844

Browse files
Merge remote-tracking branch 'upstream/2.12.x' into merge-ups
* upstream/2.12.x: (39 commits) #657 s/>/>= when checking for current PHP runtime in tests #657 prevent installation of older `thecodingmachine/safe` versions with `ocramius/proxy-manager` #657 upgraded `beberlei/assert` to allow `composer install` on `php: 8.0.0` environments #657 upgraded to stable `laminas/laminas-code` release #657 upgraded `laminas/laminas-code` and removed redundant conditional checks caused by upstream type refinement #657 upgraded `laminas/laminas-code` to a version supporting PHP 8.0+ #657 run unit tests also against PHP 8.0, CS checks on PHP 7.4 (for BC), static analysis only on 8.0 #657 CS: sorted import statements #657 CS: sorted import statements #657 removed internal `ClassGenerator` override from `laminas/laminas-code` #657 ensure that `ReflectionType#getName()` is only called on an actual `ReflectionNamedType` #628 added unit tests to verify correct codegen of proxies that extend classes with PHP 8.0 types Try PHP 8 with highest deps first Upgrade laminas/laminas-code Ignore PHP platform requirement Allow PHPBench 1.0.0-alpha2 Upgrade PHPUnit Allow PHP 8 Bump codelicia/xulieta from 0.1.2 to 0.1.5 Bump infection/infection from 0.16.4 to 0.20.2 ...
2 parents aa76978 + 0e23c12 commit d9a9844

File tree

46 files changed

+359
-200
lines changed

Some content is hidden

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

46 files changed

+359
-200
lines changed

src/ProxyManager/Factory/AbstractBaseFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
namespace ProxyManager\Factory;
66

7+
use Laminas\Code\Generator\ClassGenerator;
78
use OutOfBoundsException;
89
use ProxyManager\Configuration;
9-
use ProxyManager\Generator\ClassGenerator;
1010
use ProxyManager\ProxyGenerator\ProxyGeneratorInterface;
1111
use ProxyManager\Signature\Exception\InvalidSignatureException;
1212
use ProxyManager\Signature\Exception\MissingSignatureException;

src/ProxyManager/Generator/ClassGenerator.php

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,40 +6,13 @@
66

77
use Laminas\Code\Generator\ClassGenerator as LaminasClassGenerator;
88

9-
use function array_map;
10-
use function trim;
11-
129
/**
1310
* Class generator that ensures that interfaces/classes that are implemented/extended are FQCNs
11+
*
12+
* @internal do not use this in your code: it is only here for internal use
13+
* @deprecated this class was in use due to parent implementation not receiving prompt bugfixes, but
14+
* `laminas/laminas-code` is actively maintained and receives quick release iterations.
1415
*/
1516
class ClassGenerator extends LaminasClassGenerator
1617
{
17-
/**
18-
* {@inheritDoc}
19-
*/
20-
public function setExtendedClass($extendedClass): LaminasClassGenerator
21-
{
22-
if ($extendedClass) {
23-
$extendedClass = '\\' . trim($extendedClass, '\\');
24-
}
25-
26-
return parent::setExtendedClass($extendedClass);
27-
}
28-
29-
/**
30-
* {@inheritDoc}
31-
*
32-
* @param array<int, string> $interfaces
33-
*
34-
* @psalm-suppress MoreSpecificImplementedParamType parent interface does not specify type of array values
35-
*/
36-
public function setImplementedInterfaces(array $interfaces): LaminasClassGenerator
37-
{
38-
return parent::setImplementedInterfaces(array_map(
39-
static function (string $interface): string {
40-
return '\\' . trim($interface, '\\');
41-
},
42-
$interfaces
43-
));
44-
}
4518
}

src/ProxyManager/Generator/Util/ProxiedMethodReturnExpression.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace ProxyManager\Generator\Util;
66

77
use ReflectionMethod;
8+
use ReflectionNamedType;
89

910
/**
1011
* Utility class to generate return expressions in method, given a method signature.
@@ -19,11 +20,7 @@ public static function generate(string $returnedValueExpression, ?ReflectionMeth
1920
? null
2021
: $originalMethod->getReturnType();
2122

22-
$originalReturnTypeName = $originalReturnType === null
23-
? null
24-
: $originalReturnType->getName();
25-
26-
if ($originalReturnTypeName === 'void') {
23+
if ($originalReturnType instanceof ReflectionNamedType && $originalReturnType->getName() === 'void') {
2724
return $returnedValueExpression . ";\nreturn;";
2825
}
2926

src/ProxyManager/GeneratorStrategy/EvaluatingGeneratorStrategy.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
use Laminas\Code\Generator\ClassGenerator;
88
use Symfony\Component\Filesystem\Filesystem;
99

10-
use function assert;
1110
use function ini_get;
12-
use function is_string;
1311
use function unlink;
1412

1513
/**
@@ -38,7 +36,6 @@ public function __construct()
3836
public function generate(ClassGenerator $classGenerator): string
3937
{
4038
$code = $classGenerator->generate();
41-
assert(is_string($code));
4239

4340
// @codeCoverageIgnoreStart
4441
if (! $this->canEval) {

src/ProxyManager/GeneratorStrategy/FileWriterGeneratorStrategy.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
use Symfony\Component\Filesystem\Exception\IOException;
1212
use Symfony\Component\Filesystem\Filesystem;
1313

14-
use function assert;
15-
use function is_string;
1614
use function restore_error_handler;
1715
use function set_error_handler;
1816

@@ -46,9 +44,8 @@ public function __construct(FileLocatorInterface $fileLocator)
4644
public function generate(ClassGenerator $classGenerator): string
4745
{
4846
$generatedCode = $classGenerator->generate();
49-
assert(is_string($generatedCode));
50-
$className = $classGenerator->getNamespaceName() . '\\' . $classGenerator->getName();
51-
$fileName = $this->fileLocator->getProxyFileName($className);
47+
$className = $classGenerator->getNamespaceName() . '\\' . $classGenerator->getName();
48+
$fileName = $this->fileLocator->getProxyFileName($className);
5249

5350
set_error_handler($this->emptyErrorHandler);
5451

src/ProxyManager/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicGet.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function __construct(
3939
null,
4040
null,
4141
'returnValue',
42-
$originalClass->isInterface() ? $originalClass->getName() : null
42+
$originalClass
4343
);
4444
}
4545

src/ProxyManager/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicIsset.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function __construct(
3939
null,
4040
null,
4141
'returnValue',
42-
$originalClass->isInterface() ? $originalClass->getName() : null
42+
$originalClass
4343
);
4444
}
4545

src/ProxyManager/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicSet.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function __construct(
4343
'value',
4444
null,
4545
'returnValue',
46-
$originalClass->isInterface() ? $originalClass->getName() : null
46+
$originalClass
4747
);
4848
}
4949

src/ProxyManager/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicUnset.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function __construct(
3939
null,
4040
null,
4141
'returnValue',
42-
$originalClass->isInterface() ? $originalClass->getName() : null
42+
$originalClass
4343
);
4444
}
4545

src/ProxyManager/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicGet.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ public function __construct(
3939
$callParent = PublicScopeSimulator::getPublicAccessSimulationCode(
4040
PublicScopeSimulator::OPERATION_GET,
4141
'name',
42-
'value',
42+
null,
4343
$valueHolder,
4444
'returnValue',
45-
$originalClass->isInterface() ? $originalClass->getName() : null
45+
$originalClass
4646
);
4747

4848
if (! $publicProperties->isEmpty()) {

0 commit comments

Comments
 (0)