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

Add new tags #373

Merged
merged 11 commits into from
Aug 14, 2024
Merged

Add new tags #373

merged 11 commits into from
Aug 14, 2024

Conversation

ahjdev
Copy link
Contributor

@ahjdev ahjdev commented Jul 16, 2024

This is a beta pr for checking my code.
I will add template tag for sure.

But what about psalm, phan, phpstan tags? Should I handle them too?

@ahjdev
Copy link
Contributor Author

ahjdev commented Jul 16, 2024

I also thinks I should open a pr for type resolver repository beacuse of this classes not handled:

ConditionalTypeNode
ConditionalTypeForParameterNode
OffsetAccessTypeNode
ObjectShapeNode

@jaapio
Copy link
Member

jaapio commented Jul 17, 2024

Right now we do not focus on the prefixed tags used by psalm and phpstan. Integrations do have the option to add new tags and register a factory twice to handle tags. I don't thing we should support this out of the box. The tags are mend to use by these tools. And are not general purpose tags.

Regarding the extra types, it would be nice to support them. But I'm wondering if we should add them to the type resolver and how. As users of the type resolver will assume that they get clear types and apart from the objectshape they are all fuzzy. Maybe we should introduce them as PseudoType of Mixed? This would allow other libraries to get the information they need but if they do not support they could interpret it as mixed?

@ahjdev
Copy link
Contributor Author

ahjdev commented Jul 17, 2024

Well I add them to PseudoType of Mixed last night (In Type Resolver). As far I checked the psalm etc they have extra types e.g:
key-of and value-of.
I will add them too.

About prefixed tags, I was thinking at least add some important of them. (lots of them will be generics and no need to new classes)

Copy link
Member

@jaapio jaapio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, if you could have a look at the phpstan issue. (Missing return in the static factory) You can just return null.

And run make code-style to see the code style issues we can merge this right away.

Thank you very much for your help

@ahjdev
Copy link
Contributor Author

ahjdev commented Jul 23, 2024

This looks good, if you could have a look at the phpstan issue. (Missing return in the static factory) You can just return null.

And run make code-style to see the code style issues we can merge this right away.

Thank you very much for your help

Ok I will fix them tommorow

@ahjdev
Copy link
Contributor Author

ahjdev commented Jul 24, 2024

I guess I'm done except I did not found (Missing return in the static factory).

@ahjdev ahjdev requested a review from jaapio July 24, 2024 08:45
Copy link
Member

@jaapio jaapio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry, I must have overlooked the things I commented on in this review. It's a bit hard to review this while I'm just on a mobile phone as I'm on holiday right now. But I didn't want to let you wait for another 3 weeks.

It's ok if you can answer my questions. We can always fix some things after this has been merged. I will not do a release before I'm able to do some tests myself, just to be sure we do not overlook things.

$description = $tagValue->description;
}

$class = $node->name === '@implements' ? Implements_::class : TemplateImplements::class;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would you combine these tags in 1 factory? I think it's wise to keep them separate. Maybe with a base class. A factory should always return a single type in my opinion. Otherwise this is an abstract factory

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well I just think avoid duplicate codes.
it will be easy for me to seprate them

/**
* Reflection class for a {@}template-extends tag in a Docblock.
*/
final class TemplateExtends extends Extends_
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is Template extends a decorator on extends? And could you replace template-extends with extends? Because that's what it means when you extend a tag this way. I'm not sure that's what you intended to do.

In this project we chose often to duplicate code because tags are not the same and cannot be interchanged. If we want to share code between tags we chose to create a base class.

I'm not aware of what template-extends does. And I couldn't find it in the phpstan documentation. So it could be that you are fully correct here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well read this

{
$this->name = 'template';
$this->templateName = $templateName;
$this->bound = $bound;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the bound property? I don't know what it means in this context. Can we clarify that by renaming the property or add some docblock that explains the value?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just copied property name from phpstan but as far I know:
template T of int
int is bound

@ahjdev ahjdev requested a review from jaapio July 27, 2024 14:39
@ahjdev
Copy link
Contributor Author

ahjdev commented Jul 27, 2024

I fix these things but why for god sake there is not a script in composer.json for phpcs-fixer

@jaapio
Copy link
Member

jaapio commented Jul 27, 2024

We are using php-code-sniffer, there is a target in the make file named "code-style" to run it.

For historical reasons this project didn't have dev dependencies. Especially when phpunit had a direct dependency this was problematic. We could never build on a new major version without a version issue on phpunit.
I think it would be possible now to add php-code-sniffer as a normal dev dependency. If you want to do that, please do that in a separate pr.

@jaapio
Copy link
Member

jaapio commented Jul 28, 2024

When I'm back I will merge this and add some more tests to cover this new behavior.

Thanks for your efforts

@jaapio jaapio merged commit bd5b5a8 into phpDocumentor:5.x Aug 14, 2024
19 of 22 checks passed
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

Successfully merging this pull request may close these issues.

2 participants