Skip to content

False line indented incorrectly #2597

@phil-blais

Description

@phil-blais

PHP_CodeSniffer version 3.4.2 (stable) by Squiz
PHP 7.3.3 (cli) (built: Mar 6 2019 21:53:02) ( NTS MSVC15 (Visual C++ 2017) x64 )

Issue started after updating to PHP 7.3 and latest PHPCS. Worked fine previously with PHP 5.6 and PHPCS 2.*.

Removing the indentation returns "expected 0, found 0". Has configuration changed for whitespaces?

Thanks

FILE: ...\Test\Logging\StreamHandler.php -------------------------------------------------------------------------------- FOUND 6 ERRORS AFFECTING 6 LINES -------------------------------------------------------------------------------- 9 | ERROR | [x] Line indented incorrectly; expected 0 tabs, found 1 10 | ERROR | [x] Line indented incorrectly; expected 0 tabs, found 1 11 | ERROR | [x] Line indented incorrectly; expected 0 tabs, found 1 12 | ERROR | [x] Line indented incorrectly; expected 0 tabs, found 1 13 | ERROR | [x] Line indented incorrectly; expected 0 tabs, found 1 14 | ERROR | [x] Line indented incorrectly; expected 0 tabs, found 1 -------------------------------------------------------------------------------- PHPCBF CAN FIX THE 6 MARKED SNIFF VIOLATIONS AUTOMATICALLY -------------------------------------------------------------------------------- Time: 243ms; Memory: 6MB 

File

<?php namespace Test\Logging; use Monolog\Handler\AbstractProcessingHandler; class StreamHandler extends AbstractProcessingHandler {	protected $stream;	protected $url;	private $errorMessage;	protected $filePermission;	protected $useLocking;	private $dirCreated; } 

Ruleset

<?xml version="1.0"?> <ruleset name="Test">	<description>Test</description>	<arg name="extensions" value="php"/>	<arg name="tab-width" value="3"/>	<!-- Ignore no-code-found -->	<rule ref="Internal.NoCodeFound">	<severity>0</severity>	</rule>	<!-- Ensures PHP believes the syntax is clean -->	<rule ref="Generic.PHP.Syntax"/>	<rule ref="PSR2">	<!-- Exclude from PSR1 -->	<exclude name="Squiz.Classes.ValidClassName"/>	<exclude name="PSR1.Classes.ClassDeclaration"/>	<exclude name="PSR1.Methods.CamelCapsMethodName"/>	<!-- Exclude from PSR2 -->	<exclude name="Generic.Formatting.DisallowMultipleStatements.SameLine"/>	<exclude name="Generic.Files.LineEndings"/>	<exclude name="PSR2.Files.EndFileNewline"/>	<exclude name="Generic.Files.LineLength"/>	<exclude name="Generic.WhiteSpace.DisallowTabIndent"/>	<exclude name="PSR2.Methods.MethodDeclaration.Underscore"/>	</rule>	<rule ref="Generic.WhiteSpace.DisallowSpaceIndent"/>	<rule ref="Generic.WhiteSpace.ScopeIndent">	<properties>	<property name="indent" value="3"/>	<property name="tabIndent" value="true"/>	</properties>	</rule> </ruleset> 

Debug

Start with token 0 on line 1 with indent 0 Open scope (T_CLASS) on line 8	=> added open scope 66 (T_CLOSE_CURLY_BRACKET) on line 15, pointing to condition 20 (T_CLASS) on line 7	=> indent set to 3 by token 28 (T_OPEN_CURLY_BRACKET)	* method prefix (T_PROTECTED) found on line 9; indent set to exact * [Line 9] Line indented incorrectly; expected 0 tabs, found 1	=> add adjustment of -1 for token 31 (T_PROTECTED) on line 9	* method prefix (T_PROTECTED) found on line 10; indent set to exact * [Line 10] Line indented incorrectly; expected 0 tabs, found 1	=> add adjustment of -1 for token 37 (T_PROTECTED) on line 10	* method prefix (T_PRIVATE) found on line 11; indent set to exact * [Line 11] Line indented incorrectly; expected 0 tabs, found 1	=> add adjustment of -1 for token 43 (T_PRIVATE) on line 11	* method prefix (T_PROTECTED) found on line 12; indent set to exact * [Line 12] Line indented incorrectly; expected 0 tabs, found 1	=> add adjustment of -1 for token 49 (T_PROTECTED) on line 12	* method prefix (T_PROTECTED) found on line 13; indent set to exact * [Line 13] Line indented incorrectly; expected 0 tabs, found 1	=> add adjustment of -1 for token 55 (T_PROTECTED) on line 13	* method prefix (T_PRIVATE) found on line 14; indent set to exact * [Line 14] Line indented incorrectly; expected 0 tabs, found 1	=> add adjustment of -1 for token 61 (T_PRIVATE) on line 14 Close scope (T_CLASS) on line 15	=> removed open scope 20 (T_CLASS) on line 7	* first token is 20 (T_CLASS) on line 7 *	=> indent set to 0 by token 66 (T_CLOSE_CURLY_BRACKET) 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions