Skip to content

Rector does not properly detect usage of whitespaces or tabs #2944

@alexanderschnitzler

Description

@alexanderschnitzler

Bug Report

Subject Details
Rector version e.g. v0.7.2 (invoke vendor/bin/rector --version)
Installed as global binary via composer

Hi,
I am using version 0.7.2 (issue exists since 0.7.1) and rector messes with my doc block indents.
It replaces whitespace with tabs btw.

[EDIT] I tracked it down using git bisect and it tells me that the following commit introduced that behavior: bf97e87

The file used in this report can be found here:
https://github.com/TYPO3/TYPO3.CMS/blob/4188bca895e0009d7571e034c2ee4ca908dc59c8/typo3/sysext/backend/Classes/Controller/LoginController.php

rector process typo3/sysext/backend/Classes/Controller/LoginController.php --set=php53 --debug
File "/home/alexander/Development/TYPO3-development/10/TYPO3.CMS/vendor/autoload.php" is about to be loaded in "AutoloadIncluder::includeCwdVendorAutoloadIfExists()" on line 63"
File "/home/alexander/composer-packages/rector/rector/vendor/rector/rector/../../autoload.php" is about to be loaded in "AutoloadIncluder::autoloadProjectAutoloaderFile()" on line 95"
File "/home/alexander/Development/TYPO3-development/10/TYPO3.CMS/vendor/autoload.php" is about to be loaded in "AutoloadIncluder::includeCwdVendorAutoloadIfExists()" on line 63"
File "/home/alexander/composer-packages/rector/rector/vendor/rector/rector/../../autoload.php" is about to be loaded in "AutoloadIncluder::autoloadProjectAutoloaderFile()" on line 95"
Rector v0.7.2
Config file: rector.yml

[parsing] typo3/sysext/backend/Classes/Controller/LoginController.php
[refactoring] typo3/sysext/backend/Classes/Controller/LoginController.php
    [applying] Rector\Php53\Rector\FuncCall\DirNameFileConstantToDirConstantRector
    [applying] Rector\Php53\Rector\FuncCall\DirNameFileConstantToDirConstantRector
    [applying] Rector\Php53\Rector\FuncCall\DirNameFileConstantToDirConstantRector
    [applying] Rector\Php53\Rector\FuncCall\DirNameFileConstantToDirConstantRector
    [applying] Rector\Php53\Rector\FuncCall\DirNameFileConstantToDirConstantRector
    [applying] Rector\Php53\Rector\Ternary\TernaryToElvisRector
    [applying] Rector\Php53\Rector\FuncCall\DirNameFileConstantToDirConstantRector
    [applying] Rector\Php53\Rector\FuncCall\DirNameFileConstantToDirConstantRector
    [applying] Rector\Php53\Rector\FuncCall\DirNameFileConstantToDirConstantRector
    [applying] Rector\Php53\Rector\FuncCall\DirNameFileConstantToDirConstantRector
    [applying] Rector\Php53\Rector\FuncCall\DirNameFileConstantToDirConstantRector
    [applying] Rector\Php53\Rector\FuncCall\DirNameFileConstantToDirConstantRector
    [applying] Rector\Php53\Rector\FuncCall\DirNameFileConstantToDirConstantRector
    [applying] Rector\Php53\Rector\FuncCall\DirNameFileConstantToDirConstantRector
    [applying] Rector\Php53\Rector\FuncCall\DirNameFileConstantToDirConstantRector
    [applying] Rector\Php53\Rector\FuncCall\DirNameFileConstantToDirConstantRector
    [applying] Rector\Php53\Rector\FuncCall\DirNameFileConstantToDirConstantRector
    [applying] Rector\Php53\Rector\FuncCall\DirNameFileConstantToDirConstantRector
    [applying] Rector\Php53\Rector\FuncCall\DirNameFileConstantToDirConstantRector
    [applying] Rector\Php53\Rector\FuncCall\DirNameFileConstantToDirConstantRector
[printing] typo3/sysext/backend/Classes/Controller/LoginController.php


1 file with changes
===================

1) typo3/sysext/backend/Classes/Controller/LoginController.php

    ---------- begin diff ----------
--- Original
+++ New
@@ -78,13 +78,13 @@
     protected $loginProviders = [];

     /**
-     * Login-refresh bool; The backend will call this script
-     * with this value set when the login is close to being expired
-     * and the form needs to be redrawn.
-     *
-     * @var bool
-     */
-    protected $loginRefresh;
+				 * Login-refresh bool; The backend will call this script
+				 * with this value set when the login is close to being expired
+				 * and the form needs to be redrawn.
+				 *
+				 * @var bool
+				 */
+				protected $loginRefresh;

     /**
      * Value of forms submit button for login.
@@ -131,13 +131,13 @@
     }

     /**
-     * Injects the request and response objects for the current request or subrequest
-     * As this controller goes only through the main() method, it is rather simple for now
-     *
-     * @param ServerRequestInterface $request the current request
-     * @return ResponseInterface the finished response with the content
-     */
-    public function formAction(ServerRequestInterface $request): ResponseInterface
+				 * Injects the request and response objects for the current request or subrequest
+				 * As this controller goes only through the main() method, it is rather simple for now
+				 *
+				 * @param ServerRequestInterface $request the current request
+				 * @return ResponseInterface the finished response with the content
+				 */
+				public function formAction(ServerRequestInterface $request): ResponseInterface
     {
         $this->init($request);
         return new HtmlResponse($this->createLoginLogoutForm($request));
@@ -448,12 +448,12 @@
     }

     /**
-     * Gets news from sys_news and converts them into a format suitable for
-     * showing them at the login screen.
-     *
-     * @return array An array of login news.
-     */
-    protected function getSystemNews(): array
+				 * Gets news from sys_news and converts them into a format suitable for
+				 * showing them at the login screen.
+				 *
+				 * @return array An array of login news.
+				 */
+				protected function getSystemNews(): array
     {
         $systemNewsTable = 'sys_news';
         $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
@@ -476,15 +476,15 @@
     }

     /**
-     * Returns the uri of a relative reference, resolves the "EXT:" prefix
-     * (way of referring to files inside extensions) and checks that the file is inside
-     * the project root of the TYPO3 installation
-     *
-     * @param string $filename The input filename/filepath to evaluate
-     * @return string Returns the filename of $filename if valid, otherwise blank string.
-     * @internal
-     */
-    private function getUriForFileName($filename): string
+				 * Returns the uri of a relative reference, resolves the "EXT:" prefix
+				 * (way of referring to files inside extensions) and checks that the file is inside
+				 * the project root of the TYPO3 installation
+				 *
+				 * @param string $filename The input filename/filepath to evaluate
+				 * @return string Returns the filename of $filename if valid, otherwise blank string.
+				 * @internal
+				 */
+				private function getUriForFileName($filename): string
     {
         // Check if it's already a URL
         if (preg_match('/^(https?:)?\/\//', $filename)) {
@@ -556,13 +556,13 @@
     }

     /**
-     * Detect the login provider, get from request or choose the
-     * first one as default
-     *
-     * @param ServerRequestInterface $request
-     * @return string
-     */
-    protected function detectLoginProvider(ServerRequestInterface $request): string
+				 * Detect the login provider, get from request or choose the
+				 * first one as default
+				 *
+				 * @param ServerRequestInterface $request
+				 * @return string
+				 */
+				protected function detectLoginProvider(ServerRequestInterface $request): string
     {
         $parsedBody = $request->getParsedBody();
         $queryParams = $request->getQueryParams();
    ----------- end diff -----------

Expected Behaviour

I'd expect rector to not touch the indents at all.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions