What are the Slack Archives?
Itโs a history of our time together in the Slack Community! Thereโs a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.
Because this space is not active, you wonโt be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..
Hello Spryker Community! We have a hot ๐ฅ discussion in the Spryker architecture team regarding
Hello Spryker Community!
We have a hot ๐ฅ discussion in the Spryker architecture team
regarding an RFC (PHP discipline), and I would like to ask for your opinion! :star-struck:
Please use your
๐ for supporting the RFC,
๐ for objecting
โ for โneeds clarificationโ
The RFC you can find in the attachment.
Looking forward to your feedback! ๐
Comments
-
I don't see any problem on implementing this change, so why not? In favor! ๐
0 -
I only see benefits with this proposal :thumbsup_all:
0 -
for me is not clear at what level are we supposed to check. RFC is unclear to me. Checking if function returned expected value is a good practice but at least from RFC it is unclear to me how it is related to transfer objects.
0 -
How I see it is that this RFC introduce a new method
set*OrFail()
and itโs up to the developer and the domain context to use that one or its former. You are not โsuppose to (or have to) checkโ it at certain level, but depending on what do you want to check, you have the possibility of usingsetFoo()
orsetFooOrFail()
. This might be interesting when setting values that you want to guaranteed that itโs notnull
, because in such cases you donโt have to do an early null check. What do you think?0 -
Then also method
fromArrayOrFail
can be added if not all properties have been set0 -
@U01AMFX8S31 There is seldom the case that all properties need to exist. Usually transfers have a lot of optional fields always. But there is indeed an issue checking validity of fromArray() generated ones - or more globally: Having a immutable one that has all required (non optional) fields defined for sure. But thats for another day probably ๐
0 -
Just keep in mind that transfers are part of the contract and projects might have a different need, like field being optional that is required in the core. This severely limits the extendability of Spryker as project will then need to override all the places where setOrFail method is called.
0 -
@UKHD8KTMF It is only used where the following code requires it not nullable. So your concerns are not relevant here under those conditions.
0 -
It is actually better than require method as this is replacing it.
0 -
If I would design things I would keep DTOs stupid and let the consumer decide what is required or not (or any other logic).
0 -
Butโฆ whatโs the problem considering
setOrFail()
as an alternative for the currentrequired()
method? I mean, I only see that you want to guaranteed that certain type is pass, otherwise you want to break asap because the data might be inconsistent. In the end, you you mentioned, this is a tool that the consumer will decide where or how to use, or did I miss something?0 -
setOrFail() is better than required() because it will fail immediately and not randomly in the code when someone call required in the code. This issue of transfer having a random required filed after an update of a module or installing something is very common when updating projects. setOrFail() will not solve the issue because of the way how we create transfers (from entities) with fromArray(). To fix that we would need mappers with explicit field mapping, but then we would lose the convenience. I guess that is a different discussion.
0 -
yes, fromArray()/toArray() would need an additional param with "required" fields array to check for not nullable or alike if we really want to get rid of require().
Such an RFC and feature could be also added, independently from what this solves right now.0 -
public function fromArrayOrFail(array $data, array $requiredList)
What would you think about this to cover the the topic of require() method deprecation fully? If we know certain ones to be required (not null) we could cover it this way even with this fromArray() usage.
0 -
Interesting indeed ๐ค I think this would be good, I donโt see any problem having/using that, actually
0 -
Thank you, everyone voting!
This change will be introduced shortly! ๐0
Categories
- All Categories
- 42 Getting Started & Guidelines
- 7 Getting Started in the Community
- 8 Additional Resources
- 7 Community Ideas and Feedback
- 76 Spryker News
- 929 Developer Corner
- 787 Spryker Development
- 89 Spryker Dev Environment
- 362 Spryker Releases
- 3 Oryx frontend framework
- 35 Propel ORM
- 68 Community Projects
- 3 Community Ideation Board
- 30 Hackathon
- 3 PHP Bridge
- 6 Gacela Project
- 26 Job Opportunities
- 3.2K ๐ Slack Archives
- 116 Academy
- 5 Business Users
- 370 Docker
- 551 Slack General
- 2K Help
- 75 Knowledge Sharing
- 6 Random Stuff
- 4 Code Testing
- 32 Product & Business Questions
- 70 Spryker Safari Questions
- 50 Random