Bug #19763 [Fbk]: Traits don't recognized right for PSR2 code style
| From: | gsherwood at squiz dot net | Date: | Sun, 06 Jan 2013 22:17:18 +0000 |
| Subject: | Bug #19763 [Fbk]: Traits don't recognized right for PSR2 code style | ||
| References: | 1 | Groups: | php.pear.bugs |
| Request: | Send a blank email to pear-bugs+get-9460@lists.php.net to get a copy of this message | ||
Edit report at https://pear.php.net/bugs/bug.php?id=19763&edit=1
ID: 19763
Updated by: gsherwood@squiz.net
Reported By: hinikato at mail dot ru
Summary: Traits don't recognized right for PSR2 code style
Status: Feedback
Type: Bug
Package: PHP_CodeSniffer
Operating System: Windows 7
Package Version: SVN
PHP Version: 5.4.7
Assigned To: squiz
Roadmap Versions:
New Comment:
Sorry, my mistake. I was testing on php 5.3 and this has obviously been
changed in
5.4 with the introduction of traits, even though the docs have not been.
The doc
example doesn't actually give a parse error in 5.4, as the manual
indicates, as it is
now valid syntax for traits.
Previous Comments:
------------------------------------------------------------------------
[2013-01-06 22:10:15] squiz
Sorry, my mistake. I was testing on php 5.3 and this has obviously been
changed in
5.4, even though the docs have not been. The doc example doesn't
actually give a
parse error in 5.4, as the manual indicates.
------------------------------------------------------------------------
[2013-01-06 21:17:39] squiz
-Status: Open
+Status: Feedback
-Assigned To:
+Assigned To: squiz
Your code contains a parse error. Use statements cannot be included
inside class
declarations like that. See "Scoping rules for importing" here:
http://php.net/manual/en/language.namespaces.importing.php
If you put the use statement in the global scope, or inside a namespace
block, the
checks will work correctly.
------------------------------------------------------------------------
[2013-01-01 14:12:49] hinikato
Description:
------------
The following code is reported as invalid. If I add a one empty line, it
detected as invalid also:
FILE: x:\path\Component\Container.php
--------------------------------------------------------------------------------
FOUND 1 ERROR(S) AFFECTING 1 LINE(S)
--------------------------------------------------------------------------------
8 | ERROR | The closing brace for the class must go on the next line
after the
| | body
--------------------------------------------------------------------------------
So it seems like there is a conflict between this two checks also.
Test script:
---------------
<?php
namespace Myak\Component;
class Container extends Component implements IContainer
{
use TContainer;
}
Expected result:
----------------
File is valid.
Actual result:
--------------
FILE: x:\path\Component\Container.php
--------------------------------------------------------------------------------
FOUND 1 ERROR(S) AFFECTING 1 LINE(S)
--------------------------------------------------------------------------------
6 | ERROR | There must be one blank line after the last USE statement;
0
| | found;
--------------------------------------------------------------------------------
------------------------------------------------------------------------
--
Edit this bug report at https://pear.php.net/bugs/bug.php?id=19763&edit=1