coding-standards icon indicating copy to clipboard operation
coding-standards copied to clipboard

Rule "ordered_imports" does not use "imports_order"

Open dkd-kaehm opened this issue 3 years ago • 1 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Operating System

ne matter

Composer version

no matter

PHP version

8.1

TYPO3 Coding Standards Package version

Latest stable release

Additional version information

0.7.1

Current Behavior

The import statemnt is not ordered by import type see "use function " block example in core:

https://github.com/TYPO3/typo3/blob/60bcbf2cdf4a7d262d77127becfd72ec92a1a993/typo3/sysext/install/Classes/SystemEnvironment/ServerResponse/ServerResponseCheck.php#L20-L36

<?php

declare(strict_types=1);

/*
 * This file is part of the TYPO3 CMS project.
 *
 * It is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License, either version 2
 * of the License, or any later version.
 *
 * For the full copyright and license information, please read the
 * LICENSE.txt file that was distributed with this source code.
 *
 * The TYPO3 project - inspiring people to share!
 */

namespace TYPO3\CMS\Install\SystemEnvironment\ServerResponse;

use GuzzleHttp\Client;
use GuzzleHttp\Exception\BadResponseException;
use GuzzleHttp\Exception\TransferException;

use function GuzzleHttp\Promise\settle;

use Psr\Http\Message\ResponseInterface;
use TYPO3\CMS\Backend\Routing\UriBuilder;
use TYPO3\CMS\Core\Crypto\Random;
use TYPO3\CMS\Core\Http\Uri;
use TYPO3\CMS\Core\Messaging\FlashMessage;
use TYPO3\CMS\Core\Messaging\FlashMessageQueue;
use TYPO3\CMS\Core\Type\ContextualFeedbackSeverity;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Install\Controller\ServerResponseCheckController;
use TYPO3\CMS\Install\SystemEnvironment\CheckInterface;
use TYPO3\CMS\Reports\Status;

/**
 * Checks how use web server is interpreting static files concerning
 * their `content-type` and evaluated content in HTTP responses.
 *
 * @internal should only be used from within TYPO3 Core
 */
class ServerResponseCheck implements CheckInterface
{
...

Expected Behavior

The import statements are ordered by type like follows:

<?php

declare(strict_types=1);
....

use GuzzleHttp\Client;
use GuzzleHttp\Exception\BadResponseException;
use GuzzleHttp\Exception\TransferException;
use Psr\Http\Message\ResponseInterface;
// ...

use function GuzzleHttp\Promise\settle;

/**
 * Checks how use web server is interpreting static files concerning
 * their `content-type` and evaluated content in HTTP responses.
 *
 * @internal should only be used from within TYPO3 Core
 */
class ServerResponseCheck implements CheckInterface
{
...

Steps To Reproduce

No response

Anything else?

See: https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/v3.13.2/doc/rules/import/ordered_imports.rst

Would propose to replace the defined rule from 'ordered_imports' => true to

'ordered_imports' => [
    'imports_order' => ['class', 'function', 'const'],
    'sort_algorithm' => 'alpha'
]

I did the same on EXT:solr 12 LTS preparations.

dkd-kaehm avatar Jan 19 '23 16:01 dkd-kaehm

Hi @dkd-kaehm , the change is currently prepared in the core see https://review.typo3.org/c/Packages/TYPO3.CMS/+/79149

gilbertsoft avatar Jun 02 '23 12:06 gilbertsoft