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
Don't require a forward slash for exception example #697
Conversation
@samdark @KorvinSzanto Merge ASAP please |
I'm not sure that this resolves the point brought up on this list, why are we disallowing use statements for classes in the root namespace? https://3v4l.org/QSnaf |
I think this example is meant to be when you're not in a namespace. |
Indeed and it was due to comments of people saying they refuse to always use \Exception when they don't need to when actually the PSR never required the forward slash, it just disallowed the import.
|
I'm not sure where I stand on the issue, it sounds a little heavy handed to me tbh. I just wanted to make sure we're really addressing the issue. |
…sr-12 * 'master' of github.com:php-fig/fig-standards: (21 commits) Switched from specifying HTML to markup in general. Update the status of PSR-6 Update CONTRIBUTING.md Update Slovenian translation according to php-fig/fig-standards@0a26e50 Errata: StreamableInterface should be StreamInterface Corrigindo um erro de grafia Fix and improve PSR-4 add PSR-4 translate optimize PSR-3 optimize PSR-2 optimize PSR-1 optimize PSR-0 optimize PSR-3 修复括号和花括号问题. thx deloz! PSR-2 部分修改 PSR-1 部分修正 PSR-0 部分修正 fix 4.3自成一行的问题 thx WangTaizhou Fix url and add PSR-2 and PSR-3 tranlsate PSR-1 ...
I've added a small clarification on here too. I didn't mean to add two things to the PR but oh well. It's a common question and certainly within scope. Also most projects don't import root classes anyway. |
I think this would be a case where it would actually make sense to do a survey. :) I don't know that I've seen consistency here anywhere and honestly I'm not sure that it matters too much. For me, personally, I'd prefer people always Requiring me to always |
@simensen I agree. I'm not sure we need to make a judgement on this at all. |
@simensen I also think having explicit Exempting root classes from |
@simensen Is exactly right -- this is not a PHP-7-specific requirement, and as such is amenable to survey. |
Personally I import any namespaces are are not in the classes namespace. That way you can see right at the top what namespaces that class requires. That helps with portability (assuming you haven't got an IDE that does all that grunt work for you). This includes \Exception, and project aliases such as Laravel's \Log, \Input etc. Also - can we stop talking about forward slashes.
|
IMO this statement reads more like a work instruction, telling you what to do. It should just describe the end result, what the relationships are between constructs in the code. TBH, I can't even follow what this sentence is saying anyway - it is just confusing even after reading five times. Can it be split up into smaller chunks? |
Don't require a forward slash for exception example
Clarify that forward slash is not required.