Skip to content
Snippets Groups Projects
Commit de401b43 authored by Benni Mack's avatar Benni Mack Committed by Oliver Hader
Browse files

[BUGFIX] Revert "Make ClassSchema PHP 8 compatible"

The change makes "e712dc9e"
existing Extbase installations broken, so this is reverted.

Change-Id: I141e100a1dcbfe6c2d9b41af090c1c120052a8f4
Resolves: #93745
Reverts: #92946
Releases: master, 10.4
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/68329


Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: default avatarcore-ci <typo3@b13.com>
Tested-by: default avatarOliver Hader <oliver.hader@typo3.org>
Reviewed-by: default avatarOliver Hader <oliver.hader@typo3.org>
parent 9b1b65ad
Branches
Tags
No related merge requests found
......@@ -363,7 +363,7 @@ class ClassSchema
$this->methods[$methodName]['params'][$parameterName] = [];
$this->methods[$methodName]['params'][$parameterName]['position'] = $parameterPosition; // compat
$this->methods[$methodName]['params'][$parameterName]['byReference'] = $reflectionParameter->isPassedByReference(); // compat
$this->methods[$methodName]['params'][$parameterName]['array'] = false; // compat
$this->methods[$methodName]['params'][$parameterName]['array'] = $reflectionParameter->isArray(); // compat
$this->methods[$methodName]['params'][$parameterName]['optional'] = $reflectionParameter->isOptional();
$this->methods[$methodName]['params'][$parameterName]['allowsNull'] = $reflectionParameter->allowsNull();
$this->methods[$methodName]['params'][$parameterName]['class'] = null; // compat
......@@ -378,23 +378,14 @@ class ClassSchema
$this->methods[$methodName]['params'][$parameterName]['defaultValue'] = $reflectionParameter->getDefaultValue();
}
$reflectionType = $reflectionParameter->getType();
if ($reflectionType instanceof \ReflectionNamedType) {
if (($reflectionType = $reflectionParameter->getType()) instanceof \ReflectionNamedType) {
$this->methods[$methodName]['params'][$parameterName]['type'] = $reflectionType->getName();
$this->methods[$methodName]['params'][$parameterName]['allowsNull'] = $reflectionType->allowsNull();
}
if ($reflectionType->getName() === 'array') {
$this->methods[$methodName]['params'][$parameterName]['array'] = true;
}
if (!$reflectionType->isBuiltin()) {
$parameterTypeName = $reflectionType->getName();
if (!class_exists($parameterTypeName) && !interface_exists($parameterTypeName)) {
throw new \ReflectionException(sprintf('Class %s does not exist', $parameterTypeName), 1606575969);
}
$this->methods[$methodName]['params'][$parameterName]['class'] = $parameterTypeName;
$this->methods[$methodName]['params'][$parameterName]['type'] = ltrim($parameterTypeName, '\\');
}
if (($parameterClass = $reflectionParameter->getClass()) instanceof \ReflectionClass) {
$this->methods[$methodName]['params'][$parameterName]['class'] = $parameterClass->getName();
$this->methods[$methodName]['params'][$parameterName]['type'] = ltrim($parameterClass->getName(), '\\');
}
if ($docComment !== '' && $this->methods[$methodName]['params'][$parameterName]['type'] === null) {
......@@ -421,10 +412,10 @@ class ClassSchema
}
// Extbase DI
if ($reflectionType instanceof \ReflectionNamedType && !$reflectionType->isBuiltin()
if ($reflectionParameter->getClass() instanceof \ReflectionClass
&& ($reflectionMethod->isConstructor() || $this->hasInjectMethodName($reflectionMethod))
) {
$this->methods[$methodName]['params'][$parameterName]['dependency'] = $reflectionType->getName();
$this->methods[$methodName]['params'][$parameterName]['dependency'] = $reflectionParameter->getClass()->getName();
}
// Extbase Validation
......
......@@ -90,19 +90,6 @@ class MethodParameterTest extends UnitTestCase
);
}
/**
* @test
*/
public function classSchemaDetectsArrayParamTypeFromTypeHint(): void
{
self::assertTrue(
(new ClassSchema(DummyClassWithAllTypesOfMethods::class))
->getMethod('methodWithTypeHintedArrayParam')
->getParameter('param')
->isArray()
);
}
/**
* @test
*/
......
......@@ -120,7 +120,6 @@ class ClassSchemaTest extends UnitTestCase
'methodWithNullableParam',
'methodWithDefaultValueParam',
'methodWithTypeHintedParam',
'methodWithTypeHintedArrayParam',
'methodWithDocBlockTypeHintOnly',
],
array_keys((new ClassSchema(DummyClassWithAllTypesOfMethods::class))->getMethods())
......
......@@ -82,10 +82,6 @@ class DummyClassWithAllTypesOfMethods
{
}
public static function methodWithTypeHintedArrayParam(array $param)
{
}
/**
* @param \TYPO3\CMS\Extbase\Tests\Unit\Reflection\Fixture\DummyClassWithAllTypesOfMethods $param
*/
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment