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

PHP Integrator 3.1 Linter errors #349

Closed
ghost opened this issue Oct 29, 2017 · 3 comments
Closed

PHP Integrator 3.1 Linter errors #349

ghost opened this issue Oct 29, 2017 · 3 comments

Comments

@ghost
Copy link

ghost commented Oct 29, 2017

I've upgraded to the newest version and now PHP Integrator lints docblocks and thinks that phpdoc tags like @access is a class and therefore shows an error that access is not a classlike defined or imported anywhere. Even PHP function as \array_merge get linted as "it doesn't exist".

Moreover @param doc blocks gets strictly compared with the function signature, as the default value has to be now in the @param tag. This was before not the behaviour. For example

\React\EventLoop\LoopInterface $loop = null

doesn't work together with

* @param \React\EventLoop\LoopInterface   $loop

on PHP Integrator 3.1, but worked previously.

Using PHP Integrator 3.1.0, with PHP 7.1.11 x86 and Atom 1.21.1 on Windows 7 x64 Professional.

@Gert-dev
Copy link
Owner

Hello.

There are a couple of things to address here, I'll handle them one by one.

Firstly, the @access tag: the reason that it is being linted as unknown classlike is because the core has a static list of tags it recognizes. This list includes the tags contained in phpDocumentor's documentation, but @access is not a tag that is mentioned in it.

When a tag is not in the set of recognized tags, the core assumes that this tag must be an annotation, such as a Doctrine annotation, which are actually classes themselves, hence this error.

In any case, it is likely that docblock tag linting will get removed at some point, although I'd need to either also disable class annotation linting as well, or make assumptions about what constitutes a docblock tag and a class annotation.

It is also strange that you did not get this error before, as this behavior and support for class annotations has been in the core for quite some time now.

Secondly, the @param tag linting in this case is correct. By setting the optional value null, you effectively allow null in your type and have now made your type implicitly nullable, which should be denoted explicitly in your @param tag. It may be the case that this was not linted as such before, but in that case it was a bug in the core.

In other words, all of these are equivalent and their docblock type should be LoopInterface|null:

function (LoopInterface $loop = null)
function (?LoopInterface $loop = null)
function (?LoopInterface $loop)

To mention just LoopInterface would be to misrepresent the parameter type as users of the function will not know that passing null is an option without it, judging solely by the docblock.

Finally, the error about functions such as array_merge not being found is likely the same problem as described in #314. Please take a look there to see if you are in a similar situation. If it's a bug, your input may help as I've not been able to reproduce this myself.

As point #1 is already handled in a ticket, #2 is not a bug and #3 is also handled by another ticket, I'll close this. If you have any further questions, I'll continue to answer them, of course.

@frdteknikelektro
Copy link

Seem like docblock linting is already removed on last release.
So sad. 😢

@ThomasLandauer
Copy link

I've posted a workaround for getting rid of the error on a custom annotation like @access: https://stackoverflow.com/q/56005296/1668200

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants