eloquent-preferences
eloquent-preferences copied to clipboard
Deprecated: strpos(): Passing null to parameter #1 ($haystack)
This error for me fires many times when running PHPunit. Not sure what the exact scenario is for recreating it as we run hundreds of tests.
Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /../vendor/klaude/eloquent-preferences/src/HasPreferences.php on line 306
We are running laravel v9 with PHP 8.1
Howdy, @TheFrankman. Thanks for the issue and for using the library. I haven't done much testing in PHP 8+ and Laravel 9 yet, but it looks high time to start. I'll look into this in the coming days.
@klaude - thanks for the swift response. I did look into create a PR for this, but it's a bit more complicated that I first thought. Please let me know if there is anything else I can do to help!
Oh, and this is also an issue on Laravel 8.x
That helps a lot, thanks! It may be time cut out a bunch of old Laravel and PHP compatibility work then release versions 1.0.0 and 2.0.0 with older code support and newer code support.
@klaude I think this can just be resolved like so :
Old code :
if (method_exists($this, 'asDecimal') && strpos($castTo, 'decimal:') === 0) {
return $this->asDecimal($value, explode(':', $castTo, 2)[1]);
}
New code :
if (method_exists($this, 'asDecimal') && $castTo && strpos($castTo, 'decimal:') === 0) {
return $this->asDecimal($value, explode(':', $castTo, 2)[1]);
}
I'm going to create a fork for now because this issue is blocking our unit tests and therefore, deployments.