-
-
Notifications
You must be signed in to change notification settings - Fork 135
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
Type inheritance hints via interfaces to allow type hinting in projects #78
Comments
Another point: Due to the typehint changes |
Hey, sorry for the late response. The guys at spatie are super busy and I will try to clean things up now. I got your point and agree. The reason was that no one, during development, mentioned or thought about any tools like phpstan but only IDE. So we decided to go with My idea would be to have an interface, trait and class per type.
With this we could prevent copy'n'paste the methods into every class (traits) would have type security (interfaces) and allow classes/types to extend multiple types. Because we already have #66 and #79 in the pipeline combined with a general release (rdfa changed) I would like to wait until they are done. I'm also open for another, simpler, idea which solves the problem without removing the ability to extend multiple types. |
Fwiw, after releasing the
I think it'd make sense to revisit this idea at some point. |
At all this change wouldn't be breaking. So we could do it at every time (the label is over estimated). |
Hi, sorry for not replying. Didn't see it. :-) I like the Contract stuff. Unfortunately I first upgraded to 2.x on a PHP 7.2 project and only got 2.8.0 which has missing EventContract on Event etc. Forcing composer to upgrade only this lib while ignoring php platform requirements made it work after basically changing the code to typehinting SchemaOrgEventContract instead of SchemaOrgEvent. Thus e.g. SchemaOrgLiteraryEvent and generic SchemaOrgEvent can be returned by the same methods even though Is there a reason for the need for php 7.4? The code seems to run w/ 7.2 which is still supported for 7 months, 7.3 for 1 year and 7 months. A library like this lives on projects that might be conservative to upgrading php versions while still needing updates of the schema org schemas. A bit more conservative approach when new features of newer php versions are not used would be nice. Even though I agree that it's easier for package maintainers and forces people to actually upgrade thei php stacks. :-) Thanks for your work! May close this issue, I guess. The irregularities of the actual schema org stuff (virtual location etc) are nothing this project can do anything about. |
Hey, The reason wasn't really based in the user used code but in the tests and generator code. So yes, we could split dev and prod required PHP versions. But this would again increase the technical depth. |
I know, I'm late on the 2.x BC about type inheritance: I e.g. typehinted SchemaOrgEvent on some methods and now that e.g. a SchemaOrgLiteraryEvent is no longer of type SchemaOrgEvent the php typehinting breaks. Good you chose 2.0 release. ;-)
I wonder what your stance is on generating interfaces for the previously subclassed classes so code that is using this lib can typehint
IsEvent
(or similar) instead of deciding between nothing orBaseType
.I had a look at the old issues but am not sure whether this was an option. I understand there might be problems with the
LocalBusiness
having (some?) stuff fromOrganization
andPlace
.The text was updated successfully, but these errors were encountered: