Comments (5)
Hey @norkunas
thank you for this report.
but that's just nonsense to add this to 100+ factories
you're absolutely right, we're gonna find a solution!
After some times scratching my head looking for an explanation, I think I've found the problem:
https://phpstan.org/r/a7f5de6f-afaf-4972-8d51-a6932bfd9cc8
It seems that PHPStan "lose" the inherited array definition if the return type is changed 🤷
so I think that it thinks the prototype of the method is array<array-key, mixed>
which is not covariant with array<string, mixed>
I think as an easy fix, you could replace all return types from array
to array|callable
. Would you try and tell me if it works for you?
I've asked on PHPStan's GitHub if this is a bug or a feature 😅 and we'll see what to do... (maybe the solution would be to modify this return type with rector rules)
from foundry.
Yup, max level/bleeding edge :)
I think we're stuck for now and I hate this 😬
I just added everywhere @return array<string, mixed>
for now, so no rush :)
from foundry.
ok so this is a bug in PHPStan... I think the simplest solution is to add return type array|callable
everywhere.
I'll add a rector rule for this
from foundry.
But then if you don't return a callable, phpstan complains also and says to narrow type, this is included in issue description :)
from foundry.
wow sorry, I haven't seen that
big 🤦 here
that's strange it did not occurred to me... is that coming from level 9? (I'm only using level 8 on my projects)
I think we're stuck for now and I hate this 😬
I got plans to create a PHPStan extension for Foundry where we can fix this, but I don't know when I'll got enough time. (And I expect Psalm users to show up, with some related problems 🤷)
from foundry.
Related Issues (20)
- Issue with Proxy Entities in Version 2 HOT 14
- Zenstruck\Foundry\Factory::$class must not be accessed before initialization HOT 6
- Find functions do not refresh entity HOT 2
- Attribute wrapped in a Foundry Proxy is not compatible with `Symfony\Component\VarExporter\LazyProxyTrait` HOT 6
- Foundry should not remove symfony-s errorHandlers HOT 6
- Global state relationships and flush_after HOT 13
- How to fix deprecation notices HOT 7
- [2.0] Problem with inversed `OneToOne` relationships HOT 4
- [2.0] No autocompletion for Proxy objects HOT 2
- [2.0] ResetDatabase with DamaDoctrineTestBundle and symfony/doctrine-messenger library HOT 1
- [2.0] Re-add `assertPersisted()` & `assertNotPersisted()` HOT 6
- [2.0] Customize Faker's locale HOT 6
- Foundry 2 with PHPUnit changes the error handler of Symfony HOT 4
- createMany does not work with references to third entities HOT 1
- Cannot access actual factory instance in after/before Instantiate hooks HOT 1
- Memory leak during PHPunit test with the ResetDatabase HOT 12
- Using `Zenstruck\Foundry\Test\Factories` triggers deprecations HOT 2
- Database reset randomly fails HOT 12
- DAMA 8 breaks Foundry and blocks upgrading to Symfony 7 HOT 9
- Allow to reset many databases in migrate mode HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from foundry.