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

Prepare PHP 8 compatibility #5813

Merged

Conversation

alexander-schranz
Copy link
Member

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Fixed tickets fixes #
Related issues/PRs #
License MIT
Documentation PR sulu/sulu-docs#

What's in this PR?

Add PHP 8 compatibility

Why?

This fixes codes which are needed for the PHP 8 compatibility to be changed. See also #5757

@alexander-schranz alexander-schranz added the DX Affecting the end developer label Feb 11, 2021
@alexander-schranz alexander-schranz changed the base branch from 2.x to 2.1 February 11, 2021 15:27
@@ -54,7 +54,7 @@ public function provide($entity, $name)
$locale = $this->translator->getLocale();

try {
if (\method_exists($entity, 'getLocale')) {
if (\is_object($entity) && \method_exists($entity, 'getLocale')) {
Copy link
Member Author

Choose a reason for hiding this comment

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

@@ -214,7 +214,7 @@ protected function processPut($entities, $requestEntities, $deleteCallback, $upd
// FIXME: this is just a hack to avoid relations that start with index != 0
// FIXME: otherwise deserialization process will parse relations as object instead of an array
// reindex entities
if (\count($entities) > 0 && \method_exists($entities, 'getValues')) {
if (\count($entities) > 0 && \is_object($entities) && \method_exists($entities, 'getValues')) {
Copy link
Member Author

Choose a reason for hiding this comment

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

@@ -250,7 +250,8 @@ public function extractSnippetTypeFromPath($path)
$newPath = PathHelper::getParentPath($path);
$newPath = \substr($newPath, \strlen($snippetsPath));

if (false === $newPath) {
// $newPath can be false or empty because of return difference of substr depending on php version (<= 7.4, 8.0)
if (!$newPath) {
Copy link
Member Author

Choose a reason for hiding this comment

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

@@ -105,16 +105,26 @@ public function provideSortObjects()
'[foo]', ['2', '1', '3'],
],

// multi dimensional array missing key
// multi dimensional array missing key asc
Copy link
Member Author

Choose a reason for hiding this comment

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

@alexander-schranz alexander-schranz changed the title Add PHP 8 compatibility Prepare PHP 8 compatibility Feb 11, 2021
@niklasnatter niklasnatter merged commit da97d94 into sulu:2.1 Feb 11, 2021
@alexander-schranz alexander-schranz deleted the feature/php-8-compatibility branch February 11, 2021 15:32
@alexander-schranz alexander-schranz mentioned this pull request Feb 11, 2021
52 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DX Affecting the end developer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants