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

[5.5] Changing events property to avoid any conflicts with relations #17961

Merged
merged 1 commit into from
Mar 2, 2017
Merged

[5.5] Changing events property to avoid any conflicts with relations #17961

merged 1 commit into from
Mar 2, 2017

Conversation

arcanedev-maroc
Copy link
Contributor

@fernandobandeira
Copy link
Contributor

Maybe we should just document this as a reserved word somewhere since it won't be the only property name that may cause issues with relationship names.

Also if we were changing this personally i'd prefer to use something like _events since its shorter, this way we could maybe define and use a prefix to avoid these kind of conflicts in the future, still IMHO it's not worth changing this since it'll break packages that rely on this variable name...

@arcanedev-maroc
Copy link
Contributor Author

arcanedev-maroc commented Feb 16, 2017

Hi @fernandobandeira,

It's not going to be prefixed with underscore because it's against the PSR-2 coding style guide.

And since this change is a breaking compatibilty, i put it in the master branch instead.

I like the events as relationship name because it make sense when you work with calendars.

And $observableEvents property is also a good name (self explanatory) to solve this conflict.

@fernandobandeira
Copy link
Contributor

According to PSR-2

Property names SHOULD NOT be prefixed with a single underscore to indicate protected or private visibility.

We are not prefixing it to indicate protected or private visibility we would be prefixing to avoid a conflict, also we can use another prefix if undescore is a bad thing, PSR-2 doesn't seems to restrict this. ( It's up to your interpretation :trollface: )

Honestly docummenting it would be the best thing since you wouldn't create a BC and it seems like an edge case, just giving my opinion here... 😄

IK it won't look as nice as events but you can easilly rename it to something else, now think if a package is using this directly they'll have to make a check for versions >= 5.5 and use another variable just for this change that isn't really necessary...

@arcanedev-maroc
Copy link
Contributor Author

arcanedev-maroc commented Feb 16, 2017

If the events name was reserved for the model observers (HasEvents Trait) and may have conflicts when we using it as table (events) / model (Event) / relationship (events()) => name convention.

So it should warn us in the documentation before it's late 😢

@bryannielsen
Copy link
Contributor

I'd love to know what the official decision on this is. I have a few projects that refer to calendar events as well so I don't really want to rename the models/relationships if possible.

@taylorotwell taylorotwell merged commit b3d3243 into laravel:master Mar 2, 2017
@taylorotwell
Copy link
Member

Changed this to $dispatchesEvents.

@arcanedev-maroc
Copy link
Contributor Author

Great job @taylorotwell 👍

@arcanedev-maroc arcanedev-maroc deleted the patch-model_events branch March 2, 2017 14:24
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

Successfully merging this pull request may close these issues.

None yet

4 participants