algolia / algolia/scout-extended
PHP 8.4 deprecated implicitly nullable parameters and registerMacros() method fails.
- Dominant language
- PHP
- Stars
- 420
- Forks
- 94
- PR merge metrics
- No merged PRs in 30d
Description
PHP 8.4 has deprecated implicitly nullable parameters. In previous versions, writing array $transformers = null was valid, but now PHP requires an explicit nullable type declaration using ?.
## Error:
```log
PHP Deprecated: {closure:Algolia\ScoutExtended\ScoutExtendedServiceProvider::registerMacros():128}(): Implicitly marking parameter $transformers as nullable is deprecated, the explicit nullable type must be used instead in /var/www/html/vendor/algolia/scout-extended/src/ScoutExtendedServiceProvider.php on line 128
```
## Fix:
`Algolia\ScoutExtended\ScoutExtendedServiceProvider:L126`
```php
\Illuminate\Database\Eloquent\Builder::macro('transform', function (array $array, ?array $transformers = null) {
foreach ($transformers ?? UpdateJob::getTransformers() as $transformer) {
$array = app($transformer)->transform($this->getModel(), $array);
}
return $array;
});
```
This should fix the issue and makes the package fully compatible with the latest php version. Let me know if I should make a PR for this change :-)
Contributor guide
Research direction
Open Algolia\ScoutExtended\ScoutExtendedServiceProvider.php around line 126 and inspect the registerMacros() transform macro. Update the parameter declaration as described, then verify the package no longer emits the PHP 8.4 implicit-nullability deprecation; the issue names no test file or command.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- laravel, php
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 58/100