dereuromark / cakephp-ide-helper

IDE Helper plugin for CakePHP
MIT License
186 stars 39 forks source link

Annotate templates is adding phpdoc for variable even when it already exists #343

Closed Harfusha closed 9 months ago

Harfusha commented 9 months ago

image

When variable have complex type like $args in screenshot then command bin/cake annotate templates is adding duplicated entry

dereuromark commented 9 months ago

Array shape isnt fully supperted yet afaik But it should still work and not create a 2nd line for the same variable.

What version of the plugin are you using? And what is the code for $args here?

dereuromark commented 9 months ago

I wonder which part adds the extra line I made a test case https://github.com/dereuromark/cakephp-ide-helper/pull/344 and it seems to pass, so I cannot find an issue here.

We need to check your concrete code snippet.

dereuromark commented 9 months ago

Ah, look at that: https://github.com/dereuromark/cakephp-ide-helper/pull/344/commits/587ea0dec2b86f25ce0404ae01193d53417e50d6 Adding a more complex type inside the shape and things start to fail..

So thats the part that isnt yet supported, primitive ones currently already work.

$content = mb_substr($content, mb_strlen($typeString) + 1);

seems to be the problem, in this case making it

  (int) 3 => object(IdeHelper\Annotation\VariableAnnotation) id:3 {
    protected variable => 'haped'
    protected description => ''
    protected guessed => false
    protected type => 'array{a: int, b: (string|null)}|null'
    protected index => (int) 29
    protected isInUse => false
  }

cutting of the variable

Quick for now is to use normalized form

array{h: (string|int|null)]|null $args

the phpdoc tool returns after parsing.

dereuromark commented 9 months ago

I fixed up the PR, please let me know if this fixes it for you.

dereuromark commented 9 months ago

https://github.com/dereuromark/cakephp-ide-helper/releases/tag/2.2.1