-
-
Notifications
You must be signed in to change notification settings - Fork 84
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
Actually check that __toString method exists #56
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isValid()
can also verify whether a string $value
is a valid UUID, so I think the ||
and &&
conditions need to be reworked here.
What might be best is to check whether it’s an instance of a UuidInterface
, and in the UuidInterface
define the __toString()
method as part of the required class interface.
Fixed. |
The build is failing because the line is too long. Do you mind breaking that statement into multiple lines? |
Check before we try to cast to string
I've split it into multiple lines, but do you prefer trailing conditionals or the other way round? :) |
The way you've formatted it is fine. Oops! One more error:
You can run |
I think we need to update the phpcs rule. I'm following the draft PSR-12: https://github.com/php-fig/fig-standards/blob/master/proposed/extended-coding-style-guide.md#51-if-elseif-else
|
Anyway, that phpcs rule is wrong. PSR-2 does not care if you add a newline. It only cares about space: https://www.php-fig.org/psr/psr-2/#5-control-structures
|
A newline character is technically a space character. 😄 At any rate, I have updated the project to use PHP CodeSniffer 3.3.1 and the new PSR-12 sniffs. Unfortunately, phpcs currently has a bug with the specific rule that covers control structure spacing, so I'm ignoring that rule for now:
Thanks for your contribution! 🎉 |
Oops! Now, it should be passing on Travis CI. f139239 😄 |
Space is space. Whitespace is whitespace. Space is whitespace yes, but whitespace is not space. 😂 |
😆 |
Check before we try to cast to string.