Open konstmal opened 1 year ago
How were you able to get this error? PHP version, laravel version?
PHP v 8.0.1 Laravel v8.83.27
PHP v 8.0.1 Laravel v8.83.27
Sorry, forgot to mention, what is the pacakge-version
?
Also, could you please add a minimum reproducable example?
I caught the error in 3.3.0 version, where was added type hint for functions In 3.2.0 there are no problems
I caught the error in 3.3.0 version, where was added type hint for functions In 3.2.0 there are no problems
I tried using this code snippet:
return $transformation->resource(User::all())->serializer(NoopSerializer::class)->transform();
But it did not break.
$anyUser = User::query()->first(); return [ 'other' => transformation($anyUser, new UserTransformer())->transform(), ];
This is my code, and the error exists where $anyUser has some null fields
same problem, reverted back to v3.2.0
+1
Would be nice to have a fix for this.. this code is obviously not working:
public function null(): array
{
return null; # Cannot return null if type must be array
}
I guess the type definition for this method should be ?array
, because null
must be returned for relationships, that cannot be resolved, so that they actually return null
instead of []
.
Flugg\Responder\Serializers\NoopSerializer::null(): Return value must be of type array, null returned at /var/www/html/vendor/flugger/laravel-responder/src/Serializers/NoopSerializer.php:51)
In NoopSerializer returned type of null() function is array, but function always returns null