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

Error with type hint #22

Closed
thomasvargiu opened this issue Dec 12, 2018 · 5 comments
Closed

Error with type hint #22

thomasvargiu opened this issue Dec 12, 2018 · 5 comments

Comments

@thomasvargiu
Copy link
Contributor

thomasvargiu commented Dec 12, 2018

Crell\ApiProblem\ApiProblem sets $title (and $type) property only if argument isn't empty, but getters requires a string return value.

I think is possible to remove conditions in constructor.
If you enable strict types, currently it would throw an error.

Same thing for other properties, they are null by default, but getters' return values aren't nullable.

@Crell
Copy link
Owner

Crell commented Dec 12, 2018

Ak, I think you're correct. Removing the if checks in the constructor would resolve the issue for title and type, but not the other pre-defined properties. I think the solution is to give them all default values when declared, as an empty string is still easy enough for a caller to detect. (I really dislike nullables unless there's absolutely no other option.)

Happy to accept a PR if you get to it before I do. 😄

@thomasvargiu
Copy link
Contributor Author

I'm doing it. There is any reason why strict types is declared but disabled?

@Crell
Copy link
Owner

Crell commented Dec 13, 2018

Uh. I don't know what that means...? Strict types are declared at the top of the file. They can't be disabled after that in that file.

More likely, the tests just didn't happen to catch that use case.

@Crell
Copy link
Owner

Crell commented Dec 13, 2018

Oh. Wait, I just realized what you mean. No, that's just me being brain-dead stupid. Thanks for catching it. 😄 Yes, everything should always be strictly typed, always.

@Crell
Copy link
Owner

Crell commented Feb 4, 2019

I revised the PR with a new one, but kept all of your commits so that you got credit for them. 😄

3.1 release has been tagged. Assuming I have it setup correctly it should push out to Composer any minute now. Thanks @thomasvargiu!

@Crell Crell closed this as completed Feb 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants