Skip to content

Commit f8ce412

Browse files
authored
Merge pull request #33605 from karyna-tsymbal-atwix/improvement/m2-33509-laminas-code-upgrade-4.4.2
Upgrade laminas-code to 4.4.2
2 parents 0d0086e + 7d9a238 commit f8ce412

File tree

36 files changed

+404
-378
lines changed

36 files changed

+404
-378
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"elasticsearch/elasticsearch": "~7.13.1",
3838
"guzzlehttp/guzzle": "^6.3.3",
3939
"laminas/laminas-captcha": "^2.10",
40-
"laminas/laminas-code": "^3.5.1",
40+
"laminas/laminas-code": "~4.4.2",
4141
"laminas/laminas-db": "^2.12.0",
4242
"laminas/laminas-dependency-plugin": "^2.1.0",
4343
"laminas/laminas-di": "^3.2.0",

composer.lock

Lines changed: 15 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dev/tests/static/framework/Magento/TestFramework/Integrity/Library/Injectable.php

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
namespace Magento\TestFramework\Integrity\Library;
77

88
use Laminas\Code\Reflection\ClassReflection;
9-
use Laminas\Code\Reflection\FileReflection;
10-
use Laminas\Code\Reflection\ParameterReflection;
119
use ReflectionClass;
1210
use ReflectionException;
1311
use ReflectionParameter;
@@ -18,40 +16,36 @@
1816
class Injectable
1917
{
2018
/**
21-
* @var \ReflectionException[]
19+
* @var string[]
2220
*/
2321
protected $dependencies = [];
2422

2523
/**
2624
* Get dependencies
2725
*
28-
* @param FileReflection $fileReflection
29-
* @return \ReflectionException[]
30-
* @throws \ReflectionException
26+
* @param ClassReflection $class
27+
*
28+
* @return string[]
29+
* @throws ReflectionException
3130
*/
32-
public function getDependencies(FileReflection $fileReflection)
31+
public function getDependencies(ClassReflection $class): array
3332
{
34-
foreach ($fileReflection->getClasses() as $class) {
35-
/** @var ClassReflection $class */
36-
foreach ($class->getMethods() as $method) {
37-
/** @var \Laminas\Code\Reflection\MethodReflection $method */
38-
if ($method->getDeclaringClass()->getName() != $class->getName()) {
39-
continue;
40-
}
33+
foreach ($class->getMethods() as $method) {
34+
if ($method->getDeclaringClass()->getName() !== $class->getName()) {
35+
continue;
36+
}
4137

42-
foreach ($method->getParameters() as $parameter) {
43-
try {
44-
/** @var ParameterReflection $parameter */
45-
$dependency = $this->getParameterClass($parameter);
46-
if ($dependency instanceof ClassReflection) {
47-
$this->dependencies[] = $dependency->getName();
48-
}
49-
} catch (\ReflectionException $e) {
50-
if (preg_match('#^Class ([A-Za-z0-9_\\\\]+) does not exist$#', $e->getMessage(), $result)) {
51-
$this->dependencies[] = $result[1];
52-
} else {
53-
throw $e;
54-
}
38+
foreach ($method->getParameters() as $parameter) {
39+
try {
40+
$dependency = $this->getParameterClass($parameter);
41+
if ($dependency !== null) {
42+
$this->dependencies[] = $dependency->getName();
43+
}
44+
} catch (ReflectionException $e) {
45+
if (preg_match('#^Class ([A-Za-z0-9_\\\\]+) does not exist$#', $e->getMessage(), $result)) {
46+
$this->dependencies[] = $result[1];
47+
} else {
48+
throw $e;
5549
}
5650
}
5751
}

dev/tests/static/framework/tests/unit/testsuite/Magento/Test/Integrity/Library/InjectableTest.php

Lines changed: 0 additions & 180 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\TestFramework\Integrity\Library;
9+
10+
use Laminas\Code\Reflection\ClassReflection;
11+
use PHPUnit\Framework\TestCase;
12+
use ReflectionException;
13+
14+
require_once __DIR__ . '/_files/DummyInjectableClass.php';
15+
16+
/**
17+
* Test for Magento\TestFramework\Integrity\Library\Injectable
18+
*/
19+
class InjectableTest extends TestCase
20+
{
21+
/**
22+
* Covered getDependencies
23+
*
24+
* @return void
25+
* @throws ReflectionException
26+
*/
27+
public function testGetDependencies(): void
28+
{
29+
$injectable = new Injectable();
30+
$classReflection = new ClassReflection(DummyInjectableClass::class);
31+
32+
$actualResult = $injectable->getDependencies($classReflection);
33+
$expectedResult = [
34+
'Magento\Framework\DataObject',
35+
'TestNamespace\Some\SomeTestClass',
36+
'TestNamespace\Other\Test',
37+
];
38+
39+
$this->assertEquals($expectedResult, $actualResult);
40+
}
41+
}
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
namespace Magento\Test\Integrity\Library\PhpParser;
7-
8-
use Magento\TestFramework\Integrity\Library\PhpParser\ParserFactory;
6+
namespace Magento\TestFramework\Integrity\Library\PhpParser;
97

108
/**
119
*/

0 commit comments

Comments
 (0)