Comments (16)
I was just about to report this, @Wirone let's revert #5620, the fixing must be done on TypeExpression parsed phpdoc, see #7619 issue for it (which should be then converted to feature request probably).
In our case, the fully_qualified_strict_types
fixer is also unexpectedly fixing whitespace:
/**
- * @see http://editor.datatables.net
+ * @see http://editor.datatables.net
*/
define('DATATABLES', true);
from php-cs-fixer.
My explanation was not correct.
Rector does not import. php-cs-fixer does not import, but it just converts FQCNs to short classnames.
Because we use the same name space to both class files and the test files for them.
Adding the same class annotation may be a bug in Rector, but I don't expect it to be fixed anytime soon.
So we are having trouble with the php-cs-fixer changing the classname in @see
.
So I would appreciate to revert the behavior or to have an option to disable it.
from php-cs-fixer.
Because we use the same name space to both class files and the test files for them.
Ah, that's the reason why it is shortened 👍. I've created #7628 which provides ability to configure fully_qualified_strict_types
fixer with a list of phpDoc tags that should be processed, so you can disable processing for @see
while keeping it for other tags, or disable this feature completely if you want.
from php-cs-fixer.
What's actually breaking here? If the fixer shortened FQCN it means it was already imported in your class, so it should work anyway. Is navigating in the IDE not working?
from php-cs-fixer.
see my updated post above, the fixer does now crazy things as applied on \S+
regex instead of properly parsed phpdoc which can be invalid, contain actually spaces (callable(): T
, (A | B)
, ...).
from php-cs-fixer.
@see [URI | "FQSEN"] [<description>]
https://github.com/php-fig/fig-standards/blob/master/proposed/phpdoc-tags.md#513-see
PagerRendererTest
is not a FQSEN. \CodeIgniter\Pager\PagerRendererTest
is a FQSEN.
from php-cs-fixer.
also see is often like \A\B->name()
which is not fixed now, so inconsistency is introduced
from php-cs-fixer.
What's actually breaking here?
The Rector rule AddSeeTestAnnotationRector intentionally uses FQCN.
php-cs-fixer breaks the @see
tag.
And the Rector rule adds another @see
tag like:
1) system/Commands/Database/MigrateStatus.php:18
---------- begin diff ----------
@@ @@
* Displays a list of all migrations and whether they've been run or not.
*
* @see MigrateStatusTest
+ * @see \CodeIgniter\Commands\Database\MigrateStatusTest
*/
class MigrateStatus extends BaseCommand
{
----------- end diff -----------
Applied rules:
* AddSeeTestAnnotationRector
from php-cs-fixer.
First of all, phpDoc is modified only if the short symbol is matched, so it shouldn't touch @see
with URL 🤔. Secondly, instead of reverting this we just can introduce the config option and disable it by default, which should fix @GrahamCampbell's concerns.
Anyway, I won't be able to work on it today, family time for me.
from php-cs-fixer.
@kenjis thanks for the info. IMHO if short version in the annotation works as expected then maybe it's a bug in Rector, which should not add another @see
tag 🤷♂️? That's why I asked if navigation works after shortening.
from php-cs-fixer.
First of all, phpDoc is modified only if the short symbol is matched, so it shouldn't touch
@see
with URL 🤔.
here is the full source: https://github.com/DataTables/Editor-PHP/blob/4447b5996615bf25e0fc189cde3449fc578c755e/DataTables.php#L11
fixer output:
SSSSSSSSSSSSSSSSSSSSFSSSSSSSSSSSS 33 / 33 (100%)
Legend: .-no changes, F-fixed, S-skipped (cached or empty file), I-invalid file syntax (file ignored), E-error
1) ...\datatables-Editor-PHP\DataTables.php (fully_qualified_strict_types)
Fixed 1 of 33 files in 0.047 seconds, 6.000 MB memory used
it seems like the fixer tries to trim the phpdoc even if otherwise unchanged, also, it seems it does so only in this one file, and not in others with the same @see
phpdocs... strange.
from php-cs-fixer.
In #7622 I've provided some basic improvements for how FQCNs are handled in phpDoc, so it won't touch non-FQCNs anymore and it won't change whitespace between the tag and the value. These are clear bugs that should be fixed. Config option for enabling/disabling phpDoc support is not that urgent IMHO, I will try to provide it but later.
from php-cs-fixer.
@Wirone Thank you for your comments.
In terms of class names, the short name is also correct. However, that Rector rule uses FQCN because it does not import (use
) the class, i.e., it does not change the source code at all.
php-cs-fixer ignores that intent and imports the class.
from php-cs-fixer.
@kenjis Rector also have an option for importing names. On the other hand, Fixer imports symbols only if the config option is enabled - did you do it? Because it wasn't included in any rule set yet.
from php-cs-fixer.
We are using $rectorConfig->importNames();
.
from php-cs-fixer.
@kenjis so it's Rector who imports names, and then Fixer (which you probably run after Rector, as suggested) only shortens already imported names 😉.
from php-cs-fixer.
Related Issues (20)
- Adding `composer.lock` in VCS ? HOT 8
- full_opening_tag does not fix a short tag without a space after it HOT 1
- Problem with PHP version 8.3 HOT 3
- Nowdoc/heredoc strings do not have whitespace removed from the end of them HOT 5
- Support for complex PHPDoc types in `fully_qualified_strict_types` HOT 4
- `escape_implicit_backslashes` should also unfix escaped backslashed
- Odd grouping behaviour with `ordered_imports` HOT 2
- `fully_qualified_strict_types` problem with same-name, different-namespace symbols HOT 5
- Rule `declare_strict_types` does not work on files that start with a "hashbang" line HOT 4
- Parse error when @PhpCsFixer rule is enabled
- Verbose progress should still be `dots` HOT 10
- v3.44.0 requires Normalizer class, but composer.json does not require ext-intl. HOT 2
- `fully_qualified_strict_types` does not respect locally declared symbols when importing FQCNs HOT 6
- fully_qualified_strict_types - convert of Foo\Bar::class to 'Bar::class' should not happen for imported function HOT 9
- `fully_qualified_strict_types` must fix attributes HOT 1
- `no_useless_concat_operator` should work with heredoc/nowdoc too
- per-cs: add trailing_comma_in_multiline rule
- Add fixer to split multiple attributes in one opening attribute tag HOT 3
- Two different fixers should not handle same imports HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from php-cs-fixer.