Bug #19767 [Opn]: @codingStandardsIgnoreStart, @codingStandardsIgnoreEnd don't recognized
| From: | hinikato at mail dot ru | Date: | Wed, 02 Jan 2013 13:01:17 +0000 |
| Subject: | Bug #19767 [Opn]: @codingStandardsIgnoreStart, @codingStandardsIgnoreEnd don't recognized | ||
| References: | 1 | Groups: | php.pear.bugs |
| Request: | Send a blank email to pear-bugs+get-9441@lists.php.net to get a copy of this message | ||
Edit report at https://pear.php.net/bugs/bug.php?id=19767&edit=1
ID: 19767
Updated by: hinikato@mail.ru
Reported By: hinikato at mail dot ru
Summary: @codingStandardsIgnoreStart,
@codingStandardsIgnoreEnd don't recognized
Status: Open
Type: Bug
Package: PHP_CodeSniffer
-Operating System:
+Operating System: Windows 7
Package Version: SVN
PHP Version: 5.4.7
Roadmap Versions:
New Comment:
-Operating System:
+Operating System: Windows 7
Previous Comments:
------------------------------------------------------------------------
[2013-01-01 14:26:43] hinikato
Description:
------------
PHPCS reports error.
Test script:
---------------
<?php
namespace Myak\Base;
class Timer
{
const DEFAULT_NAME = 'default';
public static $requestStartedAt = null;
protected $startedAt;
public function __construct($name = self::DEFAULT_NAME)
{
$this->startedAt = microtime(true);
}
/**
* Main method to get current time.
*
* @return float Number of seconds.
*/
public function diff($sinceRequestStarted = true)
{
return microtime(true) - ($sinceRequestStarted ?
self::$requestStartedAt : $this->startedAt);
}
}
// @codingStandardsIgnoreStart
// The code below was found at PHP_Timer.
if (isset($_SERVER['REQUEST_TIME_FLOAT'])) {
Timer::$requestStartedAt = $_SERVER['REQUEST_TIME_FLOAT'];
} elseif (isset($_SERVER['REQUEST_TIME'])) {
Timer::$requestStartedAt = $_SERVER['REQUEST_TIME'];
} else {
Timer::$requestStartedAt = microtime(true);
}
// @codingStandardsIgnoreEnd
Expected result:
----------------
The part of code must be skipped.
Actual result:
--------------
FILE: x:\path\Timer.php
--------------------------------------------------------------------------------
FOUND 0 ERROR(S) AND 1 WARNING(S) AFFECTING 1 LINE(S)
--------------------------------------------------------------------------------
1 | WARNING | A file should declare new symbols (classes, functions,
| | constants, etc.) and cause no other side effects, or it
should
| | execute logic with side effects, but should not do both.
The
| | first symbol is defined on line 4 and the first side
effect is
| | on line 31.
--------------------------------------------------------------------------------
------------------------------------------------------------------------
--
Edit this bug report at https://pear.php.net/bugs/bug.php?id=19767&edit=1