Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use proper types for end & start time when mapping ProcessResult #10

Conversation

Chemaclass
Copy link
Contributor

The types are wrong when mapping from the entity to the transfers.

You can clearly see why this can be a problem by looking at the code below:

ProcessResultTransfer::getStartTime(): ?int # Expected to be a unix type
// VS
SpyProcessResultEntityTransfer::getStartTime(): ?string # Expected to be a string date time

@Chemaclass Chemaclass force-pushed the bugfix/wrong-types-while-mapping-process-result branch from 9c8c403 to 68a902a Compare July 26, 2021 08:30
@tvaleriy
Copy link

Hi Jose Maria! Thank you for your contribution into Spryker! And sorry for the late reply. I'll create an internal ticket for our development team so once they have time they will validate this PR and merge it. I will keep you updated here.

Best,
Spryker Support Team

@dereuromark
Copy link
Contributor

The previous commit Was better.
Empty() should not be used around methods.

@Chemaclass
Copy link
Contributor Author

@dereuromark I used empty() due to the falsy (I think it was null) for $processResultEntityTransfer->getStartTime() in:

$processResultTransfer->setStartTime(strtotime($processResultEntityTransfer->getStartTime()));

Another alternative avoiding using empty() could be:

if ($processResultEntityTransfer->getStartTime()) {
  $processResultTransfer->setStartTime(strtotime($processResultEntityTransfer->getStartTime()));
}

But I don't see a real difference between this ☝️ with or without empty().
And I am curious, why do you say that "Empty() should not be used around methods."?

@dereuromark
Copy link
Contributor

if () or if (!) also works here, and is cleaner as it is non cloaking
See also https://documentation.spryker.com/docs/code-style-guide#comparison

@Chemaclass
Copy link
Contributor Author

@dereuromark thanks for the link! I updated the PR using !== null instead of empty()

@spryker-bot spryker-bot merged commit 011e945 into spryker-middleware:master Apr 11, 2024
@Chemaclass Chemaclass deleted the bugfix/wrong-types-while-mapping-process-result branch April 11, 2024 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

6 participants