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

Sensitive Component Name #2756

Merged
merged 2 commits into from
Apr 28, 2021
Merged

Sensitive Component Name #2756

merged 2 commits into from
Apr 28, 2021

Conversation

reziamini
Copy link
Contributor

Now we can use names for our component which has been reserved by PHP and when we make these components we will get syntax error!
With this PR Livewire creates components more carefully.

@reziamini reziamini changed the title Component name Sensitive Component Name Apr 22, 2021
@joshhanley
Copy link
Member

@rezaamini-ir great PR! My only feedback is in the future to provide some more information. For example, for this PR, add a screenshot of the syntax error and links to the documentation where you got the keywords, would really help support your submission.

I wasn't sure about this, so without the screenshot and docs link I had to test this myself and investigate, which it looks like you have already done, so adding that info here would have saved me having to do it too 🙂

This is the error you get if you try to create a Livewire component called List

image

See the full list of reserved keywords here, which even though some of them may be function names, they still can't be used as class names https://www.php.net/manual/en/reserved.keywords.php

Some of them represent things which look like functions, some look like constants, and so on - but they're not, really: they are language constructs. You cannot use any of the following words as constants, class names, function or method names.

Good find though @rezaamini-ir.

Hope this helps!

@reziamini
Copy link
Contributor Author

@joshhanley Thanks for your opinion
But I think it's clear and doesn't need screenshot.
Also I have used Laravel Generator Class for these words and I believe it's sync with PHP reserved names.

@calebporzio
Copy link
Collaborator

Thanks for the PR, and thanks for the nudge @joshhanley.

@rezaamini-ir - this type of thing DEFINITELY warrants more info. That screenshot was all I needed to convince me this is a good PR to merge. Otherwise, I wouldn't know the exact user experience of the problem without going and digging in myself. And because I haven't heard many others talking about this, I'd have probably closed it.

Thanks again to both of you!

@calebporzio calebporzio merged commit f03db4d into livewire:master Apr 28, 2021
@reziamini reziamini deleted the component_name branch April 28, 2021 15:25
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

3 participants