-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[V6] [BC] Return string on getPermissionClass(), getRoleClass() #2368
Conversation
c8b6a1e
to
9670839
Compare
Thanks for this. Need to research the use-cases where Issues were logged and PRs contributed to add those Get methods, to anticipate what will break by userland code having expectation of them returning an instance instead of a class-name string. |
@lk77 will this PR cause problems to your custom models? |
@drbyte i don't think so, we don't have that use case anymore, but i think it's something that can be useful to someone else. those who have a custom model will need to make the necessary changes, like accessing the model using The instance won't be stored which will result in less memory usage. i pulled the pr branch and everything was working fine, the custom model did get called, and i didn't saw any fallback to the Permission::class Using the app helper to retrieve a model instance do not really make sense, they are meant to be statically called, i think at the time i kept the app() calls and only made the parameter dynamic, but getting rid of the app helper and using static calls is way better, and i think it can potentially better solve the initial issue, having an instance stored on a property can be less reliable than statically calling a FQCN |
@erikn69 I'm good with this, unless you feel there's more to explore with it before merging. Do you want to rebase it onto latest |
I think it's the right way to go, and it's ok for a major release, REBASED |
Agreed. |
This PR is for testing discussion #2367, this could be a breaking change if someone uses
getPermissionClass(), getRoleClass()
Tests with this change
-> Time: 00:09.050, Memory: 46.00 MB
Test without this change
-> Time: 00:09.427, Memory: 48.00 MB
Seems like this change uses less memory, also I think that this uses less cycles because it is not calling
app()
helper on every instance, and avoid making contract instances on every time(Tested on PHP 8.1)