-
-
Notifications
You must be signed in to change notification settings - Fork 188
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
Conversation
This depends on doctrine/migrations#980 now |
FYI: I converted this PR to a draft so that it doesn't get merged by accident (=> see doctrine/migrations#980) |
The blocker has been solved by the doctrine team for christmas, even for 2.3.x versions :) see doctrine/migrations#1102 But...
❓ ❔ ❓ WTF Travis? |
Oh boi... 🤷♂️ |
Holy cow - there you go ✔️🎁 |
Oops, the PHP 8 tests actually fail - they just were allowed to fail because they were still "nightly" 🙈 |
Intermediary result: |
…meter::getClass This method is deprecated in favor of getType(). See https://www.php.net/manual/de/migration80.deprecated.php#migration80.deprecated.reflection
Fully qualified namespaces emit a `T_NAME_FULLY_QUALIFIED` token in PHP8.
3c93473
to
e083f68
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some comments for easier review
@@ -589,7 +589,7 @@ public function requireOnceDoesNotSwallowPhpNoticesOfTheIncludedFile() | |||
$backend->setCache($mockCache); | |||
|
|||
$entryIdentifier = 'SomePhpEntryWithPhpNotice'; | |||
$backend->set($entryIdentifier, '<?php $undefined ++; ?>'); |
There was a problem hiding this comment.
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
@@ -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); ?>'); |
There was a problem hiding this comment.
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.
*/ | ||
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; |
There was a problem hiding this comment.
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
*/ | ||
public function getBuiltinType() | ||
{ | ||
$type = $this->getType(); | ||
if ($type === null || !$type->isBuiltin()) { | ||
if (!$type instanceof \ReflectionNamedType) { |
There was a problem hiding this comment.
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
@@ -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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PHP8 named parameters...
// 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') { |
There was a problem hiding this comment.
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
if ($type === T_STRING) { | ||
$namespaceParts[] = $value; | ||
$namespaceParts[] = ltrim($value, '\\'); |
There was a problem hiding this comment.
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.
@@ -422,14 +422,14 @@ public function round($subject, $precision = 0) | |||
*/ | |||
public function sign($x) | |||
{ | |||
if ($x < 0) { | |||
if (!is_numeric($x)) { |
There was a problem hiding this comment.
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.
Will be resolved once doctrine/migrations#1131 is released. It's merged into 2.3.x-dev already, so won't take too long I guess. I would still keep the odd semi-fix of neos/behat@f68dea2, just in case. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice one, thanks for taking care.
+1 (by reading). Just a question/suggestion re "double-shrug" comments :)
https://twitter.com/paxuclus/status/1373351604930412547 - still need a second approval :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏 Some minor tweaks, please.
Neos.Flow/Classes/ObjectManagement/Configuration/ConfigurationBuilder.php
Outdated
Show resolved
Hide resolved
Neos.Flow/Classes/ObjectManagement/Configuration/ConfigurationBuilder.php
Outdated
Show resolved
Hide resolved
Thanks @kdambekalns ! All valid feedback and applied :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️
👿 were are those unrelated test failures coming from now? 😫 |
Maybe they are not enitrely unrelated? Could be from 23f4bc3#diff-7d0a1ee9681327fd82562aa2d7fcd5ed3b083a2283085f8c760eb4fab0e8c73aR1808, no? |
🤔 ... |
There you go :) |
This makes our code base work on PHP 8. It does not yet add support for PHP 8 features. See #2404 for this.
Related to #2233