Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUGFIX: Union type handling #3439

Draft
wants to merge 3 commits into
base: 8.3
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
TASK: Move union-type tests into main suite as we only support php 8 …
…nowadays
mficzel committed Jan 23, 2025
commit 8df5aa8525d0b78d75ec262fd4d81244ad59e44c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace Neos\Flow\Tests\Functional\Reflection\Fixtures\PHP8;
namespace Neos\Flow\Tests\Functional\Reflection\Fixtures;

/*
* This file is part of the Neos.Flow package.
17 changes: 7 additions & 10 deletions Neos.Flow/Tests/Functional/Reflection/ReflectionServiceTest.php
Original file line number Diff line number Diff line change
@@ -12,12 +12,12 @@
*/

use Neos\Flow\Reflection\ReflectionService;
use Neos\Flow\Tests\Functional\Persistence;
use Neos\Flow\Tests\Functional\Reflection;
use Neos\Flow\Tests\Functional\Reflection\Fixtures\Model\SubEntity;
use Neos\Flow\Tests\Functional\Reflection\Fixtures\Model\SubSubEntity;
use Neos\Flow\Tests\Functional\Reflection\Fixtures\Model\SubSubSubEntity;
use Neos\Flow\Tests\FunctionalTestCase;
use Neos\Flow\Tests\Functional\Reflection;
use Neos\Flow\Tests\Functional\Persistence;

/**
* Functional tests for the Reflection Service features
@@ -356,15 +356,12 @@ public function annotatedArrayTypeHintsWorkCorrectly()
*/
public function unionReturnTypesWorkCorrectly()
{
if (PHP_MAJOR_VERSION < 8) {
$this->markTestSkipped('Only for PHP 8 with UnionTypes');
}
$returnTypeA = $this->reflectionService->getMethodDeclaredReturnType(Reflection\Fixtures\PHP8\DummyClassWithUnionTypeHints::class, 'methodWithUnionReturnTypeA');
$returnTypeB = $this->reflectionService->getMethodDeclaredReturnType(Reflection\Fixtures\PHP8\DummyClassWithUnionTypeHints::class, 'methodWithUnionReturnTypesB');
$returnTypeC = $this->reflectionService->getMethodDeclaredReturnType(Reflection\Fixtures\PHP8\DummyClassWithUnionTypeHints::class, 'methodWithUnionReturnTypesC');
$returnTypeA = $this->reflectionService->getMethodDeclaredReturnType(Fixtures\DummyClassWithUnionTypeHints::class, 'methodWithUnionReturnTypeA');
$returnTypeB = $this->reflectionService->getMethodDeclaredReturnType(Fixtures\DummyClassWithUnionTypeHints::class, 'methodWithUnionReturnTypesB');
$returnTypeC = $this->reflectionService->getMethodDeclaredReturnType(Fixtures\DummyClassWithUnionTypeHints::class, 'methodWithUnionReturnTypesC');

self::assertEquals('string|false', $returnTypeA);
self::assertEquals('\Neos\Flow\Tests\Functional\Reflection\Fixtures\PHP8\DummyClassWithUnionTypeHints|false', $returnTypeB);
self::assertEquals('?\Neos\Flow\Tests\Functional\Reflection\Fixtures\PHP8\DummyClassWithUnionTypeHints', $returnTypeC);
self::assertEquals('\Neos\Flow\Tests\Functional\Reflection\Fixtures\DummyClassWithUnionTypeHints|false', $returnTypeB);
self::assertEquals('?\Neos\Flow\Tests\Functional\Reflection\Fixtures\DummyClassWithUnionTypeHints', $returnTypeC);
}
}