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

TASK: Add basic support for PHP8 #2287

Merged
merged 34 commits into from
Mar 22, 2021
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
0326ac6
TASK: Allow doctrine/orm 2.8.x-dev to test PHP 8 compatibility
albe Nov 28, 2020
7093af5
TASK: Conditionally invoke libxml_disable_entity_loader
albe Jan 3, 2021
5169338
TASK: Remove usage of ReflectionParamater::isArray and ReflectionPara…
albe Jan 3, 2021
9077b6f
TASK: Avoid named parameter passing in Signal DispatcherTest
albe Jan 3, 2021
7561613
TASK: Fix PhpAnalyzer for PHP8
albe Jan 3, 2021
3cfe0c9
TASK: Fix PhpAnalyzer for PHP8
albe Jan 3, 2021
e083f68
TASK: Enable PHP 8.0 build
albe Feb 24, 2021
d84c96b
BUGFIX: Fix signal named arguments
albe Feb 24, 2021
0da755f
FEATURE: Increase PHP 8 compatibility
bwaidelich Jan 27, 2021
c6eae50
TASK: Handle potential exceptions in unlink
albe Feb 25, 2021
d39a5c3
TASK: Fix code style
albe Feb 25, 2021
fb76c96
TASK: Fix trigger_error levels in tests
albe Feb 25, 2021
dc19a84
TASK: Fix expectation for PHP 8
albe Feb 25, 2021
b050c36
BUGFIX: Fix Math.sign EEL Helper for PHP 8
albe Feb 25, 2021
754379f
BUGFIX: Correctly check for notice errors in required backed
albe Feb 25, 2021
1aaa37b
BUGFIX: Cast math function arguments to float
albe Feb 25, 2021
d70ba63
BUGFIX: Handle PHP8 TypeError in get_class_methods
albe Feb 25, 2021
310b5c0
TASK: Revert array_values duplicate change
albe Feb 25, 2021
094d325
TASK: Fix return typehint for getBuiltinType
albe Feb 25, 2021
9bc2700
TASK: Update psalm baseline
albe Feb 25, 2021
e85f76b
TASK: Adjust doctrine dependency version
albe Feb 25, 2021
be4725e
BUGFIX: Fix method return types in proxies
albe Feb 25, 2021
9c84381
BUGFIX: Fix method return types in PHP8
albe Feb 25, 2021
3ac08f0
TASK: Adapt required argument test for PHP8
albe Feb 25, 2021
d31db02
TASK: Add null to method return type
albe Feb 25, 2021
b985f37
TASK: Add PHP 8.0 to test matrix instead of experimental step
albe Feb 26, 2021
b2c60da
TASK: Improve double-shrug catching comment
albe Mar 15, 2021
a417883
TASK: Try/catch every single unlink instead of multiple
albe Mar 15, 2021
b94e684
Merge branch '7.0' into albe-doctrine-php8
albe Mar 15, 2021
b61942b
TASK: Replace missing double-shrug catching comment
albe Mar 15, 2021
6d3c5ca
Merge branch '7.0' into albe-doctrine-php8
albe Mar 21, 2021
23f4bc3
TASK: Apply suggestions from code review
albe Mar 22, 2021
82d5c85
TASK: Add test for unnamed dispatch signal arguments
albe Mar 22, 2021
c5268c8
BUGFIX: Use typehint annotations for arrays
albe Mar 22, 2021
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
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php-versions: ['7.3', '7.4']
php-versions: ['7.3', '7.4', '8.0']
dependencies: ['highest']
composer-arguments: [''] # to run --ignore-platform-reqs in experimental builds
static-analysis: ['no']
Expand All @@ -27,8 +27,8 @@ jobs:
experimental: false
dependencies: 'highest'

# Experimental build for PHP 8
#- php-versions: '8.0'
# Experimental build for PHP nightly
#- php-versions: 'nightly'
# composer-arguments: '--ignore-platform-reqs'
# static-analysis: 'no'
# experimental: true
Expand Down
6 changes: 5 additions & 1 deletion Neos.Cache/Classes/Backend/FileBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,11 @@ public function flush(): void
{
Files::emptyDirectoryRecursively($this->cacheDirectory);
if ($this->frozen === true) {
@unlink($this->cacheDirectory . 'FrozenCache.data');
try {
@unlink($this->cacheDirectory . 'FrozenCache.data');
} catch (\Throwable $e) {
// PHP 8 apparently throws for unlink even with shutup operator, but we really don't care at this place. It's also the only way to handle this race-condition free.
}
$this->frozen = false;
}
}
Expand Down
4 changes: 2 additions & 2 deletions Neos.Cache/Tests/Unit/Backend/FileBackendTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ public function requireOnceDoesNotSwallowPhpWarningsOfTheIncludedFile()
$backend->setCache($mockCache);

$entryIdentifier = 'SomePhpEntryWithPhpWarning';
$backend->set($entryIdentifier, '<?php trigger_error("Warning!", E_WARNING); ?>');
$backend->set($entryIdentifier, '<?php trigger_error("Warning!", E_USER_WARNING); ?>');
$backend->requireOnce($entryIdentifier);
}

Expand All @@ -589,7 +589,7 @@ public function requireOnceDoesNotSwallowPhpNoticesOfTheIncludedFile()
$backend->setCache($mockCache);

$entryIdentifier = 'SomePhpEntryWithPhpNotice';
$backend->set($entryIdentifier, '<?php $undefined ++; ?>');
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is no longer a E_NOTICE in PHP8

$backend->set($entryIdentifier, '<?php trigger_error("Notice!", E_USER_NOTICE); ?>');
$backend->requireOnce($entryIdentifier);
}

Expand Down
4 changes: 2 additions & 2 deletions Neos.Cache/Tests/Unit/Backend/SimpleFileBackendTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ public function requireOnceDoesNotSwallowPhpWarningsOfTheIncludedFile()
$entryIdentifier = 'SomePhpEntryWithPhpWarning';

$simpleFileBackend = $this->getSimpleFileBackend();
$simpleFileBackend->set($entryIdentifier, '<?php trigger_error("Warning!", E_WARNING); ?>');
$simpleFileBackend->set($entryIdentifier, '<?php trigger_error("Warning!", E_USER_WARNING); ?>');
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only E_USER_X can be manually triggered. PHP 7 was lenient with this though.

$simpleFileBackend->requireOnce($entryIdentifier);
}

Expand All @@ -418,7 +418,7 @@ public function requireOnceDoesNotSwallowPhpNoticesOfTheIncludedFile()
$entryIdentifier = 'SomePhpEntryWithPhpNotice';

$simpleFileBackend = $this->getSimpleFileBackend();
$simpleFileBackend->set($entryIdentifier, '<?php $undefined ++; ?>');
$simpleFileBackend->set($entryIdentifier, '<?php trigger_error("Notice!", E_USER_NOTICE); ?>');
$simpleFileBackend->requireOnce($entryIdentifier);
}

Expand Down
14 changes: 7 additions & 7 deletions Neos.Eel/Classes/Helper/MathHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ public function round($subject, $precision = 0)
if (!is_numeric($subject)) {
return NAN;
}
$subject = floatval($subject);
$subject = (float)$subject;
if ($precision != null && !is_int($precision)) {
return NAN;
}
Expand All @@ -422,14 +422,14 @@ public function round($subject, $precision = 0)
*/
public function sign($x)
{
if ($x < 0) {
if (!is_numeric($x)) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In PHP8 'foo' compares differently to a number: see https://3v4l.org/Zhdsh
It is more sane to first check the non-numeric case and return NAN anyway, as it is done similarly in other math helper functions.

return NAN;
} elseif ($x < 0) {
return -1;
} elseif ($x > 0) {
return 1;
} elseif ($x === 0 || $x === 0.0) {
return 0;
} else {
return NAN;
return 0;
}
}

Expand Down Expand Up @@ -492,9 +492,9 @@ public function trunc($x)
$sign = $this->sign($x);
switch ($sign) {
case -1:
return (int)ceil($x);
return (int)ceil((float)$x);
case 1:
return (int)floor($x);
return (int)floor((float)$x);
default:
return $sign;
}
Expand Down
19 changes: 16 additions & 3 deletions Neos.Flow/Classes/Core/LockManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,15 @@ protected function removeExpiredLock()
if (filemtime($this->lockFlagPathAndFilename) >= (time() - self::LOCKFILE_MAXIMUM_AGE)) {
return;
}
@unlink($this->lockFlagPathAndFilename);
@unlink($this->lockPathAndFilename);
try {
@unlink($this->lockFlagPathAndFilename);
} catch (\Throwable $e) {
// PHP 8 apparently throws for unlink even with shutup operator, but we really don't care at this place. It's also the only way to handle this race-condition free.
}
try {
@unlink($this->lockPathAndFilename);
} catch (\Throwable $e) {
}
}

/**
Expand Down Expand Up @@ -135,7 +142,13 @@ public function unlockSite()
fclose($this->lockResource);
unlink($this->lockPathAndFilename);
}
@unlink($this->lockFlagPathAndFilename);
if ($this->isSiteLocked()) {
try {
@unlink($this->lockFlagPathAndFilename);
} catch (\Throwable $e) {
// PHP 8 apparently throws for unlink even with shutup operator, but we really don't care at this place. It's also the only way to handle this race-condition free.
}
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,11 @@ protected function autowireProperties(array &$objectConfigurations)
continue;
}

$classMethodNames = get_class_methods($className);
try {
$classMethodNames = get_class_methods($className);
} catch (\TypeError $error) {
throw new UnknownClassException(sprintf('The class "%s" defined in the object configuration for object "%s", defined in package: %s, does not exist.', $className, $objectConfiguration->getObjectName(), $objectConfiguration->getPackageKey()), 1352371371);
albe marked this conversation as resolved.
Show resolved Hide resolved
}
if (!is_array($classMethodNames)) {
if (!class_exists($className)) {
throw new UnknownClassException(sprintf('The class "%s" defined in the object configuration for object "%s", defined in package: %s, does not exist.', $className, $objectConfiguration->getObjectName(), $objectConfiguration->getPackageKey()), 1352371371);
Expand Down
6 changes: 5 additions & 1 deletion Neos.Flow/Classes/Package/PackageManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,11 @@ protected function savePackageStates(array $orderedPackageStates): void
// Clean legacy file TODO: Remove at some point
$legacyPackageStatesPath = FLOW_PATH_CONFIGURATION . 'PackageStates.php';
if (is_file($legacyPackageStatesPath)) {
@unlink($legacyPackageStatesPath);
try {
@unlink($legacyPackageStatesPath);
} catch (\Throwable $e) {
// PHP 8 apparently throws for unlink even with shutup operator, but we really don't care at this place. It's also the only way to handle this race-condition free.
}
}
OpcodeCacheHelper::clearAllActive($this->packageInformationCacheFilePath);

Expand Down
13 changes: 10 additions & 3 deletions Neos.Flow/Classes/Property/TypeConverter/MediaTypeConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,19 @@ protected function convertMediaType($requestBody, $mediaType)
}
break;
case 'xml':
$entityLoaderValue = libxml_disable_entity_loader(true);
// TODO: Remove those lines once the minimum PHP version is 8.0
if (PHP_MAJOR_VERSION < 8) {
$entityLoaderValue = libxml_disable_entity_loader(true);
}
try {
$xmlElement = new \SimpleXMLElement(urldecode($requestBody), LIBXML_NOERROR);
libxml_disable_entity_loader($entityLoaderValue);
if (PHP_MAJOR_VERSION < 8) {
libxml_disable_entity_loader($entityLoaderValue);
}
} catch (\Exception $exception) {
libxml_disable_entity_loader($entityLoaderValue);
if (PHP_MAJOR_VERSION < 8) {
libxml_disable_entity_loader($entityLoaderValue);
}
return [];
}
$result = Arrays::convertObjectToArray($xmlElement);
Expand Down
4 changes: 2 additions & 2 deletions Neos.Flow/Classes/Reflection/MethodReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,15 @@ public function getDescription()
}

/**
* @return string The name of a type (e.g. string, \stdClass) if it was declared as a return type, null otherwise
* @return string|null The name of a type (e.g. string, \stdClass) if it was declared as a return type, null otherwise
*/
public function getDeclaredReturnType()
{
if (!is_callable([$this, 'getReturnType'])) {
return null;
}
$type = $this->getReturnType();
return $type !== null ? (string)$type : null;
return $type !== null ? ltrim((string)$type, '?') : null;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PHP8 returns the nullable type operator

}

/**
Expand Down
6 changes: 3 additions & 3 deletions Neos.Flow/Classes/Reflection/ParameterReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ public function getClass()
}

/**
* @return string The name of a builtin type (e.g. string, int) if it was declared for the parameter (scalar type declaration), null otherwise
* @return string|null The name of a builtin type (e.g. string, int) if it was declared for the parameter (scalar type declaration), null otherwise
*/
public function getBuiltinType()
{
$type = $this->getType();
if ($type === null || !$type->isBuiltin()) {
if (!$type instanceof \ReflectionNamedType) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be a ReflectionUnionType in PHP 8

return null;
}
return $type instanceof \ReflectionNamedType ? $type->getName() : (string)$type;
return $type->isBuiltin() ? $type->getName() : null;
}
}
23 changes: 11 additions & 12 deletions Neos.Flow/Classes/Reflection/ReflectionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -1788,9 +1788,6 @@ protected function convertParameterReflectionToArray(ParameterReflection $parame
if ($parameter->isPassedByReference()) {
$parameterInformation[self::DATA_PARAMETER_BY_REFERENCE] = true;
}
if ($parameter->isArray()) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isArray() is deprecated in PHP 8 - we should just handle array like any other builtin type

$parameterInformation[self::DATA_PARAMETER_ARRAY] = true;
}
if ($parameter->isOptional()) {
$parameterInformation[self::DATA_PARAMETER_OPTIONAL] = true;
}
Expand All @@ -1800,11 +1797,20 @@ protected function convertParameterReflectionToArray(ParameterReflection $parame

$parameterType = $parameter->getType();
if ($parameterType !== null) {
// TODO: This needs to handle ReflectionUnionType
$parameterType = ($parameterType instanceof \ReflectionNamedType) ? $parameterType->getName() : $parameterType->__toString();
}
if ($parameter->getClass() !== null) {
if ($parameterType !== null && !TypeHandling::isSimpleType($parameterType)) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isSimpleType() is true for array

// We use parameter type here to make class_alias usage work and return the hinted class name instead of the alias
$parameterInformation[self::DATA_PARAMETER_CLASS] = $parameterType;
} elseif ($parameterType === 'array') {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Else here makes sure that array is not marked as DATA_PARAMETER_SCALAR_DECLARATION

$parameterInformation[self::DATA_PARAMETER_ARRAY] = true;
albe marked this conversation as resolved.
Show resolved Hide resolved
} else {
$builtinType = $parameter->getBuiltinType();
if ($builtinType !== null) {
$parameterInformation[self::DATA_PARAMETER_TYPE] = $builtinType;
$parameterInformation[self::DATA_PARAMETER_SCALAR_DECLARATION] = true;
}
}
if ($parameter->isOptional() && $parameter->isDefaultValueAvailable()) {
$parameterInformation[self::DATA_PARAMETER_DEFAULT_VALUE] = $parameter->getDefaultValue();
Expand All @@ -1816,17 +1822,10 @@ protected function convertParameterReflectionToArray(ParameterReflection $parame
$parameterType = $this->expandType($method->getDeclaringClass(), $explodedParameters[0]);
}
}
if (!$parameter->isArray()) {
$builtinType = $parameter->getBuiltinType();
if ($builtinType !== null) {
$parameterInformation[self::DATA_PARAMETER_TYPE] = $builtinType;
$parameterInformation[self::DATA_PARAMETER_SCALAR_DECLARATION] = true;
}
}
if (!isset($parameterInformation[self::DATA_PARAMETER_TYPE]) && $parameterType !== null) {
$parameterInformation[self::DATA_PARAMETER_TYPE] = $this->cleanClassName($parameterType);
} elseif (!isset($parameterInformation[self::DATA_PARAMETER_TYPE])) {
$parameterInformation[self::DATA_PARAMETER_TYPE] = $parameter->isArray() ? 'array' : 'mixed';
$parameterInformation[self::DATA_PARAMETER_TYPE] = 'mixed';
}

return $parameterInformation;
Expand Down
2 changes: 1 addition & 1 deletion Neos.Flow/Classes/SignalSlot/Dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public function dispatch(string $signalClassName, string $signalName, array $sig
}

foreach ($this->slots[$signalClassName][$signalName] as $slotInformation) {
$finalSignalArguments = $signalArguments;
$finalSignalArguments = array_values($signalArguments);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PHP8 named parameters...

if (isset($slotInformation['object'])) {
$object = $slotInformation['object'];
} elseif (strpos($slotInformation['method'], '::') === 0) {
Expand Down
8 changes: 7 additions & 1 deletion Neos.Flow/Classes/Utility/PhpAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,14 @@ public function extractNamespace(): ?string
break;
}
list($type, $value) = $token;
if (defined('T_NAME_QUALIFIED') && $type === T_NAME_QUALIFIED) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tokenization of namespaces changed in PHP8 and now provides T_NAME_(FULLY_)QUALIFIED instead of a couple of T_STRING tokens.

return $value;
}
if (defined('T_NAME_FULLY_QUALIFIED') && $type === T_NAME_FULLY_QUALIFIED) {
return ltrim($value, '\\');
}
if ($type === T_STRING) {
$namespaceParts[] = $value;
$namespaceParts[] = ltrim($value, '\\');
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not 100% sure any more this is required, because in PHP8 namespace is parsed with above tokens. But we always expect namespaces to not start with \ and this guarantees it.

continue;
}
if ($type !== T_NS_SEPARATOR && $type !== T_WHITESPACE) {
Expand Down
20 changes: 19 additions & 1 deletion Neos.Flow/Tests/Functional/Mvc/ActionControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,6 @@ public function argumentTestsDataProvider()
'required date string' => ['requiredDate', '1980-12-13T14:22:12+02:00', '1980-12-13'],
'required date - missing value' => ['requiredDate', null, $requiredArgumentExceptionText],
'required date - mapping error' => ['requiredDate', 'no date', 'Validation failed while trying to call Neos\Flow\Tests\Functional\Mvc\Fixtures\Controller\ActionControllerTestBController->requiredDateAction().'],
'required date - empty value' => ['requiredDate', '', 'Uncaught Exception in Flow Argument 1 passed to Neos\Flow\Tests\Functional\Mvc\Fixtures\Controller\ActionControllerTestBController_Original::requiredDateAction() must be an instance of DateTime, null given'],
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exception text changed in PHP8, so needs to be tested depending on PHP version => see below

'optional date string' => ['optionalDate', '1980-12-13T14:22:12+02:00', '1980-12-13'],
'optional date - default value' => ['optionalDate', null, 'null'],
'optional date - mapping error' => ['optionalDate', 'no date', 'Validation failed while trying to call Neos\Flow\Tests\Functional\Mvc\Fixtures\Controller\ActionControllerTestBController->optionalDateAction().'],
Expand Down Expand Up @@ -460,6 +459,25 @@ public function argumentTests($action, $argument, $expectedResult)
self::assertTrue(strpos(trim($response->getBody()->getContents()), (string)$expectedResult) === 0, sprintf('The resulting string did not start with the expected string. Expected: "%s", Actual: "%s"', $expectedResult, $response->getBody()->getContents()));
}

/**
* @test
*/
public function requiredDateNullArgumentTest()
{
$arguments = [
'argument' => '',
];

$uri = str_replace('{@action}', 'requireddate', 'http://localhost/test/mvc/actioncontrollertestb/{@action}');
$response = $this->browser->request($uri, 'POST', $arguments);
if (PHP_MAJOR_VERSION < 8) {
$expectedResult = 'Uncaught Exception in Flow Argument 1 passed to Neos\Flow\Tests\Functional\Mvc\Fixtures\Controller\ActionControllerTestBController_Original::requiredDateAction() must be an instance of DateTime, null given';
} else {
$expectedResult = 'Uncaught Exception in Flow Neos\Flow\Tests\Functional\Mvc\Fixtures\Controller\ActionControllerTestBController_Original::requiredDateAction(): Argument #1 ($argument) must be of type DateTime, null given';
}
self::assertTrue(strpos(trim($response->getBody()->getContents()), (string)$expectedResult) === 0, sprintf('The resulting string did not start with the expected string. Expected: "%s", Actual: "%s"', $expectedResult, $response->getBody()->getContents()));
}

/**
* @test
*/
Expand Down
14 changes: 7 additions & 7 deletions Neos.Flow/Tests/Unit/SignalSlot/DispatcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public function dispatchPassesTheSignalArgumentsToTheSlotMethod(): void
$dispatcher->connect('Foo', 'bar', $mockSlot, '', false);
$dispatcher->injectObjectManager($mockObjectManager);

$dispatcher->dispatch('Foo', 'bar', ['foo' => 'bar', 'baz' => 'quux']);
$dispatcher->dispatch('Foo', 'bar', ['bar', 'quux']);
albe marked this conversation as resolved.
Show resolved Hide resolved
self::assertSame(['bar', 'quux'], $arguments);
}

Expand All @@ -160,7 +160,7 @@ public function dispatchPassesTheSignalArgumentsToTheStaticSlotMethod(): void
$dispatcher->connect('Foo', 'bar', get_class($this), '::staticSlot', false);
$dispatcher->injectObjectManager($mockObjectManager);

$dispatcher->dispatch('Foo', 'bar', ['foo' => 'bar', 'baz' => 'quux']);
$dispatcher->dispatch('Foo', 'bar', ['bar', 'quux']);
albe marked this conversation as resolved.
Show resolved Hide resolved
self::assertSame(['bar', 'quux'], self::$arguments);
}

Expand All @@ -172,8 +172,8 @@ public function dispatchPassesTheSignalArgumentsToTheStaticSlotMethodIfNoObjectm
$dispatcher = new Dispatcher();
$dispatcher->connect('Foo', 'bar', get_class($this), '::staticSlot', false);

$dispatcher->dispatch('Foo', 'bar', ['no' => 'object', 'manager' => 'exists']);
self::assertSame(['object', 'exists'], self::$arguments);
$dispatcher->dispatch('Foo', 'bar', ['no', 'object', 'manager', 'exists']);
self::assertSame(['no', 'object', 'manager', 'exists'], self::$arguments);
albe marked this conversation as resolved.
Show resolved Hide resolved
}

/**
Expand Down Expand Up @@ -210,7 +210,7 @@ public function dispatchRetrievesSlotInstanceFromTheObjectManagerIfOnlyAClassNam
$dispatcher->injectObjectManager($mockObjectManager);
$dispatcher->connect('Foo', 'bar', $slotClassName, 'slot', false);

$dispatcher->dispatch('Foo', 'bar', ['foo' => 'bar', 'baz' => 'quux']);
$dispatcher->dispatch('Foo', 'bar', ['bar', 'quux']);
albe marked this conversation as resolved.
Show resolved Hide resolved
self::assertSame($mockSlot->arguments, ['bar', 'quux']);
}

Expand Down Expand Up @@ -247,7 +247,7 @@ public function dispatchThrowsAnExceptionIfTheSpecifiedSlotMethodDoesNotExist():
$dispatcher->injectObjectManager($mockObjectManager);
$dispatcher->connect('Foo', 'bar', $slotClassName, 'unknownMethodName', true);

$dispatcher->dispatch('Foo', 'bar', ['foo' => 'bar', 'baz' => 'quux']);
$dispatcher->dispatch('Foo', 'bar', ['bar', 'quux']);
albe marked this conversation as resolved.
Show resolved Hide resolved
}

/**
Expand All @@ -266,7 +266,7 @@ public function dispatchPassesArgumentContainingSlotInformationLastIfTheConnecti
$dispatcher->connect('SignalClassName', 'methodName', $mockSlot, '', true);
$dispatcher->injectObjectManager($mockObjectManager);

$dispatcher->dispatch('SignalClassName', 'methodName', ['foo' => 'bar', 'baz' => 'quux']);
$dispatcher->dispatch('SignalClassName', 'methodName', ['bar', 'quux']);
albe marked this conversation as resolved.
Show resolved Hide resolved
self::assertSame(['bar', 'quux', 'SignalClassName::methodName'], $arguments);
}

Expand Down
Loading