Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply fully_qualified_strict_types in annotations #3655

Open
ostrolucky opened this issue Mar 30, 2018 · 14 comments
Open

Apply fully_qualified_strict_types in annotations #3655

ostrolucky opened this issue Mar 30, 2018 · 14 comments
Labels
has userland alternative What's requested is already possible with userland packages kind/feature request topic/fqcn Fully Qualified Class Name usage and conversions topic/phpdoc PHPDoc tags, Doctrine Annotations etc.

Comments

@ostrolucky
Copy link
Contributor

I would like to apply this fixer across annotations as well. Here's what I expect to fix

<?php

class SomeClass
{
    /** @Foo\Bar */
    private $foo;
}

into

<?php

use Foo\Bar;

class SomeClass
{
    /** @Bar */
    private $foo;
}

How do you think solution should look like? As far as I see, so far no fixer outside DoctrineAnnotation fixes annotations

@julienfalque
Copy link
Member

👍 though I think I would be better to have a dedicated fixer in the DoctrineAnnotation namespace.

@julienfalque julienfalque added kind/feature request topic/phpdoc PHPDoc tags, Doctrine Annotations etc. labels Mar 30, 2018
@Slamdunk
Copy link
Contributor

Already discussed in #3644

@ostrolucky
Copy link
Contributor Author

ostrolucky commented Mar 30, 2018

Ah thanks for a link. Indeed, it would make sense to fix both cases (phpdoc param/return types and doctrine style classes prefixed with @).

@ostrolucky
Copy link
Contributor Author

After looking at it some more, I have realized FullyQualifiedStrictTypesFixer does not do what I want anyway. It changes FCQNs to short versions only if class has been imported. My goal is to import the class if it hasn't been imported.

@ostrolucky
Copy link
Contributor Author

ostrolucky commented Apr 21, 2018

For all of those who are looking for importing fcqn classes which were not imported, there are

SlevomatCodingStandard\Sniffs\Namespaces\ReferenceUsedNamesOnlySniff which does this
For PHP-CS-Fixer, there is Symplify\CodingStandard\Fixer\Import\ImportNamespacedNameFixer

@ostrolucky ostrolucky reopened this May 19, 2018
@Wirone Wirone added the status/to verify issue needs to be confirmed or analysed to continue label May 16, 2023
@Wirone Wirone added has userland alternative What's requested is already possible with userland packages topic/fqcn Fully Qualified Class Name usage and conversions and removed status/to verify issue needs to be confirmed or analysed to continue labels Jun 17, 2023
@Wirone Wirone changed the title Apply FullyQualifiedStrictTypesFixer in annotations Apply fully_qualified_strict_types in annotations Aug 14, 2023

This comment was marked as outdated.

@mvorisek
Copy link
Contributor

mvorisek commented Dec 30, 2023

I belive this was fixed by #5620

@Wirone
Copy link
Member

Wirone commented Dec 30, 2023

@mvorisek no, #5620 was about phpDoc tags only (@tag \F\Q\C\N), not annotations (@F\Q\C\N).

@keradus
Copy link
Member

keradus commented Dec 30, 2023

btw, what is this /** @MyClass */ annotation usage?

@mvorisek
Copy link
Contributor

"attributes defined in phpdoc"

/* @ORM\Column */ for example

https://packagist.org/packages/doctrine/annotations

@keradus
Copy link
Member

keradus commented Dec 30, 2023

I think Doctrine moved to attributes by now, if it's the only use case, maybe there is no big value of creating support for it.

@Wirone
Copy link
Member

Wirone commented Dec 30, 2023

From doctrine/annotations:

⚠️ PHP 8 introduced attributes, which are a native replacement for annotations. As such, this library is considered feature complete, and should receive exclusively bugfixes and security fixes.

So it has limited support, but is not strictly deprecated. From our perspective it shouldn't be a priority IMHO, but if anyone is willing to contribute, then we can consider merging 😉.

@mvorisek
Copy link
Contributor

mvorisek commented Jan 5, 2024

with #7679 this can be easily implemented

This comment was marked as outdated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has userland alternative What's requested is already possible with userland packages kind/feature request topic/fqcn Fully Qualified Class Name usage and conversions topic/phpdoc PHPDoc tags, Doctrine Annotations etc.
Projects
None yet
Development

No branches or pull requests

6 participants