Skip to content

Remove classes from aliases list #2980

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

Merged
merged 1 commit into from
Sep 2, 2014
Merged

Remove classes from aliases list #2980

merged 1 commit into from
Sep 2, 2014

Conversation

driesvints
Copy link
Member

Eloquent and Seeder were used to extend from. Extending from aliases is a bad practice because it's hard to mock an none existing object when testing (see urls below) and you can't get any autocomplete from then in your IDE's. This lets us being less reliant on packages like this one: https://github.com/barryvdh/laravel-ide-helper
Not that I'm saying it's a bad package. Just saying it's better to be less reliant.

The SoftDeletingTrait should be imported just like the UserTrait and the RemindableTrait. Same reasons as above.

PS: It's the same reason why I'd like to remove Str from this list. I'm not entirely sure atm what FormRequest is going to be used for but if it's in the same context as Eloquent and Seeder then it should be removed as well imo.

@Garbee
Copy link
Contributor

Garbee commented Aug 30, 2014

👍

@GrahamCampbell
Copy link
Member

Big 👍 from me. I always use the full class names in my code anyway.

@crynobone
Copy link
Member

:( this going to make evaluating badly written package slightly harder for me.

@driesvints
Copy link
Member Author

Mior, can you go into more detail on this?

On 30 Aug 2014, at 18:48, Mior Muhammad Zaki notifications@github.com wrote:

:( this going to make evaluating badly written package slightly harder for me.


Reply to this email directly or view it on GitHub.

@crynobone
Copy link
Member

@driesvints it was a sarcastic comment. I do actually welcome this, and if anyone insist to have it he/she still are able to do so by editing the config, it just not bundle in by default.

Package that have use Eloquent instead of use Illuminate\Database\Eloquent\Model indicate poor understanding on how package should be written and will not work if you use Slim (or anything else) with Eloquent (using capsule).

@GrahamCampbell
Copy link
Member

@crynobone I completely agree. I see such use statements in packages all the time, and the really bug me.

@barryvdh
Copy link
Contributor

Yes I agree, +1 for making my package less relevant ;) Especially because you can't really do anything with traits in the helper, and they are a bit weird to class alias.

@crynobone
Copy link
Member

One example that I personally experience recently, we had one proof of concept app using CodeIgniter with multiple illuminate components which was working nicely for us. However we need to include a Barcode integration to it and we did find one laravel package that allow that, normally you can just manually load the package by mimicking the service provider but in this case the package include use Str which was not available in our case and we had to create a class alias manually to solve it. If the package has instead use Illluminate\Support\Str we wouldn't need any hack.

@franzliedke
Copy link
Contributor

+1 from me, too.
Am 30.08.2014 19:41 schrieb "Mior Muhammad Zaki" notifications@github.com:

One example that I personally experience recently, we had one proof of
concept app using CodeIgniter with multiple illuminate components which was
working nicely for us. However we need to include a Barcode integration to
it and we did find one laravel package that allow that, normally you can
just manually load the package by mimicking the service provider but in
this case the package include use Str which was not available in our case
and we had to create a class alias manually to solve it. If the package has
instead use Illluminate\Support\Str we wouldn't need any hack.


Reply to this email directly or view it on GitHub
#2980 (comment).

Eloquent and Seeder were used to extend from which is a bad practice.
The SoftDeletingTrait should be imported just like the UserTrait and the RemindableTrait.
Str was also removed because it's just a shortcut for the namespace. People can always re-add it if they like.
I wasn't entirely sure what FormRequest was doing here but I have a feeling it's going to be used for the same reasons as one of the above classes. So I removed it as well.
@driesvints
Copy link
Member Author

@crynobone ok, lol sorry. Didn't get that.

I've now removed the Str alias as well. I agree with you guys. It shouldn't be in there as default. People can always add it if they like. Perhaps we should make a note in the docs?

I've also removed the FormRequest class. Taylor: is that ok?

Updated commit message:

Eloquent and Seeder were used to extend from which is a bad practice.
The SoftDeletingTrait should be imported just like the UserTrait and the RemindableTrait.
Str was also removed because it's just a shortcut for the namespace. People can always re-add it if they like. We also get autocompletion this way.
I wasn't entirely sure what FormRequest was doing here but I have a feeling it's going to be used for the same reasons as one of the above classes. So I removed it as well.

@GrahamCampbell
Copy link
Member

👍

1 similar comment
@Anahkiasen
Copy link
Contributor

👍

taylorotwell added a commit that referenced this pull request Sep 2, 2014
@taylorotwell taylorotwell merged commit 8b18b40 into laravel:develop Sep 2, 2014
@driesvints driesvints deleted the feature/dont-extend-class-aliases branch September 2, 2014 07:12
@cpass78 cpass78 mentioned this pull request Sep 26, 2014
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.

8 participants