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

FQN is not reported in property annotation #258

Closed
morozov opened this issue Feb 3, 2018 · 6 comments
Closed

FQN is not reported in property annotation #258

morozov opened this issue Feb 3, 2018 · 6 comments

Comments

@morozov
Copy link

morozov commented Feb 3, 2018

Example script:

<?php

namespace Acme;

class Foo
{
    /**
     * @var \Doctrine\DBAL\Connection
     */
    public $conn;
}

$conn = new \Doctrine\DBAL\Connection();

Actual output:

------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------------------
 13 | ERROR | [x] Class \Doctrine\DBAL\Connection should not be referenced via a fully
    |       |     qualified name, but via a use statement.
------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------

Expected output: line 8 should be reported as containing FQN as well.

Please see doctrine/dbal#3002 (comment) for the reference.

@kukulich
Copy link
Contributor

kukulich commented Feb 3, 2018

Hmm, the sniff does not check any doccomment but it should be possible very easy. I hope :)

@kukulich
Copy link
Contributor

kukulich commented Feb 4, 2018

@morozov Could you please try c732809 ?

@morozov
Copy link
Author

morozov commented Feb 5, 2018

Thanks @kukulich. I checked out the commit above and enabled searchAnnotations for SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly in our ruleset.xml. Still same output.

Most likely, I'm just doing something wrong. @Majkl578 could you please check this?

@Majkl578
Copy link
Contributor

Majkl578 commented Feb 5, 2018

Testing on ORM, seems to work, or at least report errors like:

FILE: lib/Doctrine/ORM/Query/Exec/AbstractSqlExecutor.php
--------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------------------------------------
 56 | ERROR | [x] Class \Doctrine\DBAL\Driver\Statement should not be referenced via a fully qualified name, but via a use statement.

For @return here.

To enable, require slevomat/coding-standard: dev-master as 4.3.99 and just add:

            <property name="searchAnnotations" type="boolean" value="true"/>

and delete cache file .phpcs-cache.

@morozov
Copy link
Author

morozov commented Feb 5, 2018

Clearing cache worked for me:

------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
------------------------------------------------------------------------------------------------
  8 | ERROR | [x] Class \Doctrine\DBAL\Connection should not be referenced via a fully
    |       |     qualified name, but via a use statement.
 13 | ERROR | [x] Class \Doctrine\DBAL\Connection should not be referenced via a fully
    |       |     qualified name, but via a use statement.
------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------

Thank you @Majkl578.

@kukulich kukulich closed this as completed Feb 5, 2018
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants