MaGnetas
MaGnetas
Worked for me after I set transformed data to the state rather than local variable: ``` js const [chartData, setChartData] = React.useState([]); React.useEffect(() => { const data = Object.entries(backendData).map(([field1, field2])...
> Hellooo @magnetas! šš» Did you know Carbon has built-in PHPStan extensions? Hi @szepeviktor! First of all thank you for such a prompt reaction! I wasn't aware of this, but...
> ...as for this specific case: try returning a non-nullable value. well...the thing is eloquent model timestamp fields are nullable (i.e. before persisting them they are null. Also DB columns...
> > Maybe we have a š bug? > > https://github.com/nunomaduro/larastan/blob/6327eb91b4256615b0193eb62403d91fc6f2eb98/tests/Type/data/model-properties.php#L60 Yes, this seems to be related. If this assertion passes it'd mean that created_at is nullable Carbon\Carbon instance. However...
@szepeviktor could this be the problem? https://github.com/nunomaduro/larastan/blob/6327eb91b4256615b0193eb62403d91fc6f2eb98/src/Properties/ModelCastHelper.php#L154-L156 If `$dateClass` is illuminate carbon then types are unified (illuminate and nestbot carbon). I get a `ObjectType` instance that has both `className` and...
Technically `Date::now()` is used to set the timestamp values. And we also have this: https://github.com/nunomaduro/larastan/blob/6327eb91b4256615b0193eb62403d91fc6f2eb98/tests/Type/data/date-extension.php#L24 which passes as well...
> You can debug it in your function: `\PHPStan\dumpType($user->created_at);` Neat! This is what I get: ``` ------ --------------------------------- Line SomeClass.php ------ --------------------------------- 14 Dumped type: Carbon\Carbon|null ------ --------------------------------- ```
Just commented these three lines out in my example project, cleared phpstan cache and ran analysis again - all green. https://github.com/nunomaduro/larastan/blob/11bdd132565d37e808e4ac985a580b492c2d8887/src/Properties/ModelCastHelper.php#L154-L156 Also `dumpType` now returns proper value - `Illuminate\Support\Carbon|null` Not...
Just tried applying the same (commenting out those three lines with union) to actual Laravel 10 project. I get 18 such errors across the codebase using phpstan level 3. Skipping...
> Would be great if you could merge this. Cannot use this package on Laravel 10 now. Iām requiring this branch instead of tag/version temporarily in my Laravel 10 project...