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

Fix PHP 8.2 warning: Use [static::class, '…'] instead of 'static::… for callbacks #570

Merged
merged 7 commits into from
Dec 13, 2022

Conversation

MyIgel
Copy link

@MyIgel MyIgel commented Dec 10, 2022

What is the reason for this PR?

This implements remaining changes for #479 (Use of "static" in callables is deprecated in PHP 8.2) and is an extension of #528 (Ensure php 8.2 compatibility)

Author's checklist

Summary of changes

Use self::class . '::[…]' instead of 'static::[…]' on callbacks which triggered a PHP 8.2 warning. Implementation analogous to php.watch.

The phpstan "errors" can be ignored as that functionality still works for PHP 7.4 and is thus added to ignoreErrors.

Review checklist

  • All checks have passed
  • Changes are approved by maintainer

@MyIgel
Copy link
Author

MyIgel commented Dec 10, 2022

I guess the BC Check / Roave BC Check can be ignored? :D

@localheinz
Copy link
Member

@MyIgel

Yes, we are waiting for someone (perhaps @Nyholm) to fix this issue.

src/Faker/Provider/Base.php Outdated Show resolved Hide resolved
Copy link
Member

@localheinz localheinz left a comment

Choose a reason for hiding this comment

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

Can you also apply this diff?

diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 1c521356..37222a4f 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -13,7 +13,7 @@
         <listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener"/>
     </listeners>
     <php>
-        <env name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=404"/>
+        <env name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=0"/>
     </php>
     <testsuites>
         <testsuite name="Faker Test Suite">

src/Faker/Provider/Base.php Outdated Show resolved Hide resolved
src/Faker/Provider/Base.php Outdated Show resolved Hide resolved
src/Faker/Provider/Base.php Outdated Show resolved Hide resolved
src/Faker/Provider/Base.php Outdated Show resolved Hide resolved
src/Faker/Provider/Base.php Outdated Show resolved Hide resolved
src/Faker/Provider/en_CA/Address.php Outdated Show resolved Hide resolved
@localheinz localheinz linked an issue Dec 10, 2022 that may be closed by this pull request
@localheinz localheinz mentioned this pull request Dec 10, 2022
5 tasks
@localheinz localheinz added the bug Something isn't working label Dec 10, 2022
@@ -363,7 +363,7 @@ public static function shuffleString($string = '', $encoding = 'UTF-8')
return implode('', static::shuffleArray($array));
}

private static function replaceWildcard($string, $wildcard = '#', $callback = 'static::randomDigit')
private static function replaceWildcard($string, $wildcard, $callback)
Copy link
Member

Choose a reason for hiding this comment

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

Method is private and always invoked with arguments for all parameters - no need for default values.

Also see #571.

@localheinz localheinz changed the title Fix PHP 8.2 warning: Use self::class . '::[…]' instead of 'static::[…]' for callbacks Fix PHP 8.2 warning: Use [static::class, '…'] instead of 'static::… for callbacks Dec 10, 2022
@MyIgel
Copy link
Author

MyIgel commented Dec 10, 2022

I guess the changes should be squashed on merge?

@localheinz
Copy link
Member

Thank you, @GrahamCampbell and @MyIgel!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use of "static" in callables is deprecated in PHP 8.2
3 participants