Conversation
"Guest Authors" as returned from get_coauthors() are just stdclass objects, which are not supported in UserFactory. This adds support at the integration level to instantiate these as CoAuthorsPlusUser instances directly.
|
Detaching this from |
Doing this mainly for simplicity's sake, since the status of this integration is up in the air. Further discussion to be had on PR #2157.
5fdb5f6 to
bcd4d90
Compare
This reverts commit f143bcd. This adds support for the Co-Authors Plus back in as it was when support was dropped. This is in case we decide to continue supporting it.
Codecov Report
@@ Coverage Diff @@
## 2.x-factories #2157 +/- ##
===============================================
Coverage ? 93.7%
Complexity ? 1610
===============================================
Files ? 54
Lines ? 4069
Branches ? 0
===============================================
Hits ? 3813
Misses ? 256
Partials ? 0
Continue to review full report at Codecov.
|
|
Oy! That wasn't any fun. But I think it's done?!?!?! Let's see how the tests go. There are a couple of things to review when it comes to |
|
The three static analysis errors are ... I'm a little unsure of the best way to resolve. Given that users shouldn't be extending the |
|
Not sure I necessarily agree that users shouldn't be extending the constructor. We just don't want constructors being called directly, so that all instantiation happens via Class Maps and funneled through Not really sure what PHPStan's issue with this actually is. I found the commit where they introduced this check, but no justification for it. cc @szepeviktor |
|
Please see https://3v4l.org/On7K3 |
|
So the issue is that type declarations on a subclass's constructor might conflict with the declarations on the parent? I don't think that's an issue here, since our constructor takes no arguments. If people want to override Thoughts? |
PHPStan is here with us to help prevent just that :) |
|
Understood, and it's a great tool for that. :) All I'm saying is that at some point we need to look at the costs and benefits of following its rules to the letter. And in this specific instance - which I argue is outside the scope of the problem that example lays out - I believe the costs outweigh the benefits. We'll never be able to standardize our way out of every fatal error, and even if we prevent this one from happening, without a guide for how to do it the right way, our users will just stumble onto Would love to hear from @jarednova or @gchtr on this too! |
|
PHPStan has a cost that may seem very high. |
|
I agree in principle, but I'm wondering what you see as being the long-term benefit in this particular case? Are you saying you disagree with my proposal? If so, why? |
|
I run web applications for SaaS teams and daily see that they cannot make a sustainable product without these "basic" tests:
That is my daily observation. |
Ticket: #2155
Issue
The Co-Authors Plus integration as it currently exists is incompatible with Factories and Class Maps. This is an attempt to make them compatible.
Solution
I describe the proposed solution in more detail in the issue write-up, but basically what I'm doing here is treating "guest authors" as a special case of the
timber/user/classmapfilter: instead of calling a Factory, it applies the filter directly.Impact
Should be none.
Usage Changes
None, other than adding support for class maps in this integration.
Considerations
I may be wrong about everything. :D
Testing
Updated tests where it made sense and added a test specifically for dealing with overriding the class instantiated for guest authors.