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

Make use of PHP 7.4 syntax #2470

Merged
merged 2 commits into from
Oct 3, 2022
Merged

Conversation

IonBazan
Copy link
Member

@IonBazan IonBazan commented Sep 30, 2022

Q A
Type improvement
BC Break no
Fixed issues -

Summary

Migrates some of the old syntax to PHP 7.4 where applicable:

  • Arrow functions
  • Null-coalesce assignment operator
  • array_key_first and is_iterable

Migrates usage of PHPUnit API:

  • Adds @doesNotPerformAssertions where no assertions are performed
  • Uses $this->createMock() shorthand

Linked to #2464

@@ -21,7 +23,7 @@ public static function documentNotFound(string $className, $identifier): self
return new self(sprintf(
'The "%s" document with identifier %s could not be found.',
$className,
json_encode($identifier)
json_encode($identifier, JSON_THROW_ON_ERROR)
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 something I'm not really sure if we should add here, as it can be considered a breaking change.

Copy link
Contributor

Choose a reason for hiding this comment

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

You could catch the JsonException first if it occurs and concatenate it to the end of the message / set it as $previous exception. Then it should no longer be a BC break, as it would no longer change the type of an exception that might come out of it, while providing that little bit of extra information.

Copy link
Member

Choose a reason for hiding this comment

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

$previous is the way to go IMO 👍

@@ -25,6 +24,8 @@ class MemoryUsageTest extends BaseTest
{
/**
* Output for jwage "Memory increased by 14.09 kb"
*
* @doesNotPerformAssertions
Copy link
Member

Choose a reason for hiding this comment

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

Since you've found this test: I wonder if it's needed :D I mean nobody looks at tests that did not fail explicitly

Copy link
Member

@malarzm malarzm Oct 2, 2022

Choose a reason for hiding this comment

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

And this one won't be failing with an exception either

Copy link
Member Author

Choose a reason for hiding this comment

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

Those tests are excluded from the test run in phpunit.xml.dist:

    <groups>
        <exclude>
            <group>performance</group>
        </exclude>
    </groups>

I think their main purpose was to quickly test the performance and memory usage before adding phpbench (the test is dated 2014).

Copy link
Member Author

Choose a reason for hiding this comment

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

I think I we could keep these tests for now, for historical reasons and perhaps delete them in a separate PR if you don't mind. I'd like to keep the diff ass small as possible here.

Copy link
Member

Choose a reason for hiding this comment

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

Sure 👍

@@ -20,6 +20,8 @@ class HydrationPerformanceTest extends BaseTest
{
/**
* [jwage: 10000 objects in ~6 seconds]
*
* @doesNotPerformAssertions
Copy link
Member

Choose a reason for hiding this comment

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

Same here. Additionally phpbench is in use for Performance tests nowadays

@IonBazan IonBazan marked this pull request as ready for review October 3, 2022 07:12
@malarzm malarzm added the Task label Oct 3, 2022
@malarzm malarzm added this to the 2.5.0 milestone Oct 3, 2022
@malarzm malarzm merged commit a95ea45 into doctrine:2.5.x Oct 3, 2022
@malarzm
Copy link
Member

malarzm commented Oct 3, 2022

Thanks @IonBazan!

@IonBazan IonBazan deleted the feature/php-7.4 branch October 4, 2022 03:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants