FAQ
Edit report at https://pear.php.net/bugs/bug.php?id=19695&edit=1

ID: 19695
Updated by: gsherwood@squiz.net
Reported By: rjt at zygous dot co dot uk
Summary: PSR-1 Namespace sniff - false positive for PHP5.2
style namespacing
Status: Bogus
Type: Bug
Package: PHP_CodeSniffer
Operating System: Linux
Package Version: SVN
PHP Version: 5_4 SVN-2012-11-07
Assigned To: squiz
Roadmap Versions:
New Comment:

The problem is that if you have recently bumped your PHP requirement to
5.3 and you
still use 5.2-style class names, the sniff would not report any issues.
Similarly, if you
just decided to start a new project and not use namespaces, the sniff
would still not
report errors.

Without some way of knowing exactly what version of PHP your project
requires, the
sniff can't ever really know what you should be using. The version of
PHP used to run
PHPCS is the closest I have to a version number without the PSR's
defining some sort
of requirements file or file comment line (like PEAR does).


Previous Comments:
------------------------------------------------------------------------

[2013-01-07 11:58:38] njh

Just a note that this is a problem for me too. My library (EasyRdf) is
still being used by people running PHP 5.2 and people using old style
name-spacing on PHP 5.3.

Would it be possible to work something into the test that says if class
contains underscores but the path matches it, then it is ok?

Something like:
implode(DIRECTORY_SEPARATOR, explode('_', 'Foo_Bar')).'.php' ==
__FILE__.

------------------------------------------------------------------------

[2012-11-11 22:21:37] squiz

Yes, the mailing list for the PHP FIG seems like it doesn't like
receiving mail, which is
a little odd given they have released a common PHP coding standard to
the
community. A great thing, but you're obviously going to get feedback.

Still, I'd ask there because it isn't the sort of call I could make as
I'm not a voting
member. If the authors of the standard decide to relax things and just
say that both
methods of namespacing are fine, then it's just a little bit of code to
remove.

------------------------------------------------------------------------

[2012-11-09 08:31:06] zygous

Would it be worth honouring the PEAR comment if that's present? From
what I've read of the PSRs I don't think that would be in contravention,
would it? Any means necessary to identify the target PHP version...

We have a lot of code written before PHP 5.3 that we're now running on
5.3 servers. It all works, so there's no reason to change namespacing,
and I believe it's PSR compliant in all other regards. It wasn't written
for 5.3, so needn't use 'real' namespaces.

I know the mailing list is fed-up of discussing. PSRs 1 and 2, but
perhaps iI should raise this on the list...

I'm not offended by the bogus status :-) Oh, and good job on the
sniffs!

------------------------------------------------------------------------

[2012-11-08 23:18:43] squiz

-Status: Feedback
+Status: Bogus
Yeah, it would be good if the PSR standards said something about
documenting the
min PHP version. PEAR has a requirement for this inside the file comment
on each
PHP file, but documentation is not covered at all by the PSRs.

Hopefully this will change one day, but maybe PHP5.2 support will be
dropped before
then anyway. THe PSRs seems to move a little slowly.

Wish I had a Not a Bug status, but I only have Bogus. Please don't be
offended.

------------------------------------------------------------------------

[2012-11-08 12:19:41] zygous

Yep, that all makes sense. It's a shame there's no PHPDoc tag to specify
a minimum required PHP version that PHPCS could check. Having to
maintain a custom set of sniffs would be a bit of a nuisance.

I guess this report can be resolved as not-a-bug then.

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://pear.php.net/bugs/bug.php?id=19695

Search Discussions

Discussion Posts

Previous

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 2 | next ›
Discussion Overview
grouppear-bugs @
categoriesphp
postedJan 7, '13 at 11:58a
activeJan 7, '13 at 8:42p
posts2
users2
websitepear.php.net

2 users in discussion

Njh: 1 post Gsherwood: 1 post

People

Translate

site design / logo © 2022 Grokbase