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

fix: strengthen type tokens extraction #504

Merged
merged 1 commit into from
Mar 27, 2024

Conversation

romm
Copy link
Member

@romm romm commented Mar 27, 2024

This commit refactors the way tokens are extracted from a raw type string, by using a better approach that consists in splitting first into tokens, and then detecting texts (aka string values).

This aims to fix edge cases like the following example, where the $bar annotation would previously have confused the lexer, leading to the type of $foo being used for $bar as well.

final class SomeClass
{
    /**
      * @param non-empty-string $foo Some description containing $bar
      *      which is the next parameter name
      */
     public function __construct(
         public string $foo,
         public int $bar,
     ) {}
}

Fixes #494

This commit refactors the way tokens are extracted from a raw type
string, by using a better approach that consists in splitting first into
tokens, and then detecting texts (aka string values).

This aims to fix edge cases like the following example, where the `$bar`
annotation would previously have confused the lexer, leading to the type
of `$foo` being used for `$bar` as well.

```php
final class SomeClass
{
    /**
      * @param non-empty-string $foo Some description containing $bar
      *      which is the next parameter name
      */
     public function __construct(
         public string $foo,
         public int $bar,
     ) {}
}
```
@romm romm force-pushed the fix/parameter-name-in-docblock-description branch from 4a149f4 to 5c49ff7 Compare March 27, 2024 12:59
@romm romm merged commit c9dc975 into CuyZ:master Mar 27, 2024
11 checks passed
@romm romm deleted the fix/parameter-name-in-docblock-description branch March 27, 2024 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant