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

PSR0 support #28

Open
xendk opened this issue Apr 16, 2017 · 2 comments
Open

PSR0 support #28

xendk opened this issue Apr 16, 2017 · 2 comments

Comments

@xendk
Copy link
Contributor

xendk commented Apr 16, 2017

Carrying over from #27 where I wrote:

I tried implementing the other completion, and it was going rather well, until I discovered that the PSR0 loader doesn't quite live up to the spec: http://www.php-fig.org/psr/psr-0/

It's only in class names that the underscores can be used as separator, so the original test that checks if Psr0Ns_T to Psr0Ns_TheClass is wrong. I then carried that misunderstanding on in the subdir handling.

Trying to fix that up gave me all kind of troubles, so before carrying on, I'd like to ask how important underscore completion is? Or could we get away with just always completing with backslashes? I mean, following the specs, Psr0Ns\TheS should offer both Psr0Ns\TheSubdir_ and Psr0Ns\TheSubdir\ as possible completions, and that's, IMHO, just ugly. And if you're using PSR4, backslashes should work just fine.

And @stevenremot wrote:

Ah, that's true. We can open another issue on that, but I think the impact is pretty limited because:

PSR-0 is deprecated
Most of the time, you use either namespaces or big class names, so there is not that much risk of mixing stuffs. At least that's my experience

Well, that's where I don't quite follow. I remember the big class names of yore and figured PSR0 tries to retain some compatibility with that, but according to the spec they still need to be prefixed by the vendor namespace.

So the file Dir/Sub_Dir/Class.php can be used as Vendor\Dir\Sub_Dir\Class or Vendor\Dir_Sub_Dir_Class or Vendor\Dir_Sub_Dir\Class or Vendor\Dir\Sub_Dir_Class, but not Vendor\Dir\Sub\Dir\Class or Vendor_Dir_Sub_Dir_Class.

Are you seeing different rules in the wild?

Whatever the case, it needs to match up with the classname actually used in the PHP file, but we can't read that.

In order to live up to the spec, as I see it, completion should simply offer subdirs as both SubDir\ and Subdir_, in order for PSR0 completion being able to provide whatever the user wants to use, and drop any other attempts at guessing. Though it will properly increase the number of completion steps (pressing tab, whatever) for the user, as each directory will basically appear twice. And leave it up to the developer to choose the one used in the PHP file.

Agree?

@xendk xendk mentioned this issue Apr 16, 2017
@stevenremot
Copy link
Collaborator

stevenremot commented Apr 17, 2017

I agree that we have to propose directories with either '\' or '_'. So yeah, it's more annoying for the developer, but it's because of PSR-0, not because of us, so I have no problem with it.

@xendk
Copy link
Contributor Author

xendk commented Apr 17, 2017

I'll look into it when the dust settles after #27

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

No branches or pull requests

2 participants