Skip to content

Commit

Permalink
Upgrade laminas-code to 4.4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
karyna-t committed Aug 18, 2021
1 parent 7e364fd commit 67898d6
Show file tree
Hide file tree
Showing 36 changed files with 407 additions and 381 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"elasticsearch/elasticsearch": "~7.13.1",
"guzzlehttp/guzzle": "^6.3.3",
"laminas/laminas-captcha": "^2.10",
"laminas/laminas-code": "^3.5.1",
"laminas/laminas-code": "~4.4.2",
"laminas/laminas-db": "^2.12.0",
"laminas/laminas-dependency-plugin": "^2.1.0",
"laminas/laminas-di": "^3.2.0",
Expand Down
31 changes: 15 additions & 16 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
namespace Magento\TestFramework\Integrity\Library;

use Laminas\Code\Reflection\ClassReflection;
use Laminas\Code\Reflection\FileReflection;
use Laminas\Code\Reflection\ParameterReflection;
use ReflectionClass;
use ReflectionException;
use ReflectionParameter;
Expand All @@ -18,40 +16,36 @@
class Injectable
{
/**
* @var \ReflectionException[]
* @var string[]
*/
protected $dependencies = [];

/**
* Get dependencies
*
* @param FileReflection $fileReflection
* @return \ReflectionException[]
* @throws \ReflectionException
* @param ClassReflection $class
*
* @return string[]
* @throws ReflectionException
*/
public function getDependencies(FileReflection $fileReflection)
public function getDependencies(ClassReflection $class): array
{
foreach ($fileReflection->getClasses() as $class) {
/** @var ClassReflection $class */
foreach ($class->getMethods() as $method) {
/** @var \Laminas\Code\Reflection\MethodReflection $method */
if ($method->getDeclaringClass()->getName() != $class->getName()) {
continue;
}
foreach ($class->getMethods() as $method) {
if ($method->getDeclaringClass()->getName() !== $class->getName()) {
continue;
}

foreach ($method->getParameters() as $parameter) {
try {
/** @var ParameterReflection $parameter */
$dependency = $this->getParameterClass($parameter);
if ($dependency instanceof ClassReflection) {
$this->dependencies[] = $dependency->getName();
}
} catch (\ReflectionException $e) {
if (preg_match('#^Class ([A-Za-z0-9_\\\\]+) does not exist$#', $e->getMessage(), $result)) {
$this->dependencies[] = $result[1];
} else {
throw $e;
}
foreach ($method->getParameters() as $parameter) {
try {
$dependency = $this->getParameterClass($parameter);
if ($dependency !== null) {
$this->dependencies[] = $dependency->getName();
}
} catch (ReflectionException $e) {
if (preg_match('#^Class ([A-Za-z0-9_\\\\]+) does not exist$#', $e->getMessage(), $result)) {
$this->dependencies[] = $result[1];
} else {
throw $e;
}
}
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\TestFramework\Integrity\Library;

use Laminas\Code\Reflection\ClassReflection;
use PHPUnit\Framework\TestCase;
use ReflectionException;

require_once __DIR__ . '/_files/DummyInjectableClass.php';

/**
* Test for Magento\TestFramework\Integrity\Library\Injectable
*/
class InjectableTest extends TestCase
{
/**
* Covered getDependencies
*
* @return void
* @throws ReflectionException
*/
public function testGetDependencies(): void
{
$injectable = new Injectable();
$classReflection = new ClassReflection(DummyInjectableClass::class);

$actualResult = $injectable->getDependencies($classReflection);
$expectedResult = [
'Magento\Framework\DataObject',
'TestNamespace\Some\SomeTestClass',
'TestNamespace\Other\Test',
];

$this->assertEquals($expectedResult, $actualResult);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Test\Integrity\Library\PhpParser;

use Magento\TestFramework\Integrity\Library\PhpParser\ParserFactory;
namespace Magento\TestFramework\Integrity\Library\PhpParser;

/**
*/
Expand Down
Loading

0 comments on commit 67898d6

Please sign in to comment.