PHP-CS-Fixer icon indicating copy to clipboard operation
PHP-CS-Fixer copied to clipboard

Support for complex PHPDoc types in `fully_qualified_strict_types`

Open mvorisek opened this issue 2 years ago • 7 comments

Feature request

With the latest release - v3.42.0 - the fully_qualified_strict_types rule does fix some phpdoc to imported types, but not all.

The following code:

<?php

use DataTables;
use DataTables\Database;
use DataTables\Editor;
use DataTables\SearchPaneOptions;

/**
 * @param SearchPaneOptions|callable(Database, \DataTables\Editor): (array|bool) $spInput
 */
function searchPaneOptions($spInput = null) {}

is fixed to:

<?php

use DataTables\Database;
use DataTables\SearchPaneOptions;

/**
 * @param SearchPaneOptions|callable(Database, \DataTables\Editor): (array|bool) $spInput
 */
function searchPaneOptions($spInput = null) {}

applied rules: braces_position, no_unused_imports, single_line_empty_body

but I would expect the following result instead:

<?php

use DataTables\Database;
use DataTables\Editor;
use DataTables\SearchPaneOptions;

/**
 * @param SearchPaneOptions|callable(Database, Editor): (array|bool) $spInput
 */
function searchPaneOptions($spInput = null) {}

mvorisek avatar Dec 25 '23 10:12 mvorisek

Related with #5620, all fixes on types must be based on parsed TypeExpression.

mvorisek avatar Dec 25 '23 11:12 mvorisek

It's not a bug, because initial support for phpDoc was introduced only for simple tags, like @tag \F\Q\C\N. At any point it wasn't aiming for full phpDoc support. I am going to convert this into feature request.

Wirone avatar Dec 27 '23 00:12 Wirone

I also have a problem with this rule in this update. It removes the inline namespaces even when I use the same class with different namespaces.

Before:

use App\Actions\CreateUrl;

...

CreateUrl::run();
App\Actions\Folder1\CreateUrl::run();
App\Actions\Folder2\CreateUrl::run();

...

After:

use App\Actions\CreateUrl;

...

CreateUrl::run();
CreateUrl::run();
CreateUrl::run();

...

alexmandrikdev avatar Dec 27 '23 15:12 alexmandrikdev

even unioned (A|B) and intersected (A&B) types are not supported

mvorisek avatar Dec 31 '23 13:12 mvorisek

I plan to work on this after #7719

mvorisek avatar Jan 14 '24 12:01 mvorisek

Since this issue has not had any activity within the last 90 days, I have marked it as stale.

The purpose of this action is to enforce backlog review once in a while. This is mostly for maintainers and helps with keeping repository in good condition, because stale issues and PRs can accumulate over time and make it harder for others to find relevant information. It is also possible that some changes has been made to the repo already, and issue or PR became outdated, but wasn't closed for some reason. This action helps with periodic review and closing of such stale items in automated way.

You may let maintainers handle this or verify current relevancy by yourself, to help with re-triage. Any activity will remove stale label so it won't be automatically closed at this point.

I will close it if no further activity occurs within the next 30 days.

github-actions[bot] avatar Apr 26 '24 12:04 github-actions[bot]

Since this issue has not had any activity within the last 90 days, I have marked it as stale.

The purpose of this action is to enforce backlog review once in a while. This is mostly for maintainers and helps with keeping repository in good condition, because stale issues and PRs can accumulate over time and make it harder for others to find relevant information. It is also possible that some changes has been made to the repo already, and issue or PR became outdated, but wasn't closed for some reason. This action helps with periodic review and closing of such stale items in automated way.

You may let maintainers handle this or verify current relevancy by yourself, to help with re-triage. Any activity will remove stale label so it won't be automatically closed at this point.

I will close it if no further activity occurs within the next 30 days.

github-actions[bot] avatar Jul 28 '24 12:07 github-actions[bot]