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

PHP 8.x Support #33

Merged
merged 5 commits into from
Aug 26, 2022
Merged

PHP 8.x Support #33

merged 5 commits into from
Aug 26, 2022

Conversation

szainmehdi
Copy link
Contributor

Makes this package installable on PHP 8.x, and adds PHP 8.1 to the testing matrix.

@@ -3,6 +3,7 @@
namespace Weebly\Mutate\Database;

use Closure;
use Illuminate\Contracts\Support\Arrayable;
Copy link
Collaborator

Choose a reason for hiding this comment

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

use statement got added, but this doesn't seem to be used anywhere in the file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's actually used here

public function whereKey($id)
{
if (is_array($id) || $id instanceof Arrayable) {
$this->whereIn($this->model->getQualifiedKeyName(), $id);

This is technically a bugfix ;)

*/
#[\ReturnTypeWillChange]
Copy link
Collaborator

Choose a reason for hiding this comment

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

What behavior are we driving from this? The composer.json still says php 7.x is OK. On 7, this will be a comment does that cause a problem?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adding this attribute is necessary to prevent these errors in PHPStan (also, PHP will throw an error when executing this code in PHP 8.1 if this attribute is not added or the return type is not set correctly.

 ------ -------------------------------------------------------------------------------------------------------------------------------------------------------------------
  Line   src/MutatorProvider.php
 ------ -------------------------------------------------------------------------------------------------------------------------------------------------------------------
  69     Return type mixed of method Weebly\Mutate\MutatorProvider::offsetExists() is not covariant with tentative return type bool of method ArrayAccess::offsetExists().
         💡 Make it covariant, or use the #[\ReturnTypeWillChange] attribute to temporarily suppress the error.
  89     Return type mixed of method Weebly\Mutate\MutatorProvider::offsetSet() is not covariant with tentative return type void of method ArrayAccess::offsetSet().
         💡 Make it covariant, or use the #[\ReturnTypeWillChange] attribute to temporarily suppress the error.
  97     Return type mixed of method Weebly\Mutate\MutatorProvider::offsetUnset() is not covariant with tentative return type void of method ArrayAccess::offsetUnset().
         💡 Make it covariant, or use the #[\ReturnTypeWillChange] attribute to temporarily suppress the error.
 ------ -------------------------------------------------------------------------------------------------------------------------------------------------------------------

In older PHP versions, since it is # prefixed, it will be ignored as a comment and will be perfectly fine, since it doesn't apply anyway.

@szainmehdi szainmehdi merged commit 9260fb5 into master Aug 26, 2022
@szainmehdi szainmehdi deleted the php-8-support branch August 26, 2022 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants