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)
- Remove or add redundant `readonly` property modifier HOT 4
- ClassAttributesSeparationFixer - ['property' => 'none'] Add unwanted blank line when comment present
- Allow custom assertion methods in php_unit_test_case_static_method_calls
- Init command HOT 1
- Enum ordering support
- Bug in PHP-CS-Fixer with Laravel Pint 1.13.7 and php_unit_method_casing HOT 3
- `FullyQualifiedStrictTypesFixer` adds imports before PHP opening tag HOT 2
- Install now: 404 HOT 2
- `PhpUnitAttributesFixer` - ability to keep annotations HOT 2
- Please improve the documentation HOT 2
- PhpUnitDedicateAssertFixer is replacing functions with deprecated/removed method names of PHPUnit v9.1+
- Replace explicit `__invoke` call with regular call syntax HOT 11
- Enforing variable to be CamelCase Or snake_cae but not both at the same time HOT 1
- constant_case rule alters constant names
- Add support for `*` syntax in `OrderedAttributesFixer`
- New rule: Interface implemenations split across lines
- cs-fixer multicore bug with --path-mode and a specified file HOT 4
- Parallel runner not fixing any files HOT 10
- Displaying sum memory usage from all workers when parallel runner is used
- Install documentation misses recommended "tools/php-cs-fixer" dir method HOT 2
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.