TypeResolver icon indicating copy to clipboard operation
TypeResolver copied to clipboard

Add new types

Open ahjdev opened this issue 1 year ago • 9 comments

I tried to add new types except class-string-map<T of Foo, T> which is not handled by phpstan I also want to resolve template tags (which is I am wonder how?)

ahjdev avatar Jul 20 '24 17:07 ahjdev

Thanks for your pr, it would be useful to split this PR into several smaller PRS. so we can discuss the individual additions you did. Some of them can be merged right away or with a few small changes. Other changes might need more discussion.

A good starting point could be the commits you did in separate prs?

A first comment regarding the changes you did. The pseudotypes should extend the underlying type. I see that this wasn't properly applied to all pseudotypes. If the original class is final we can remove the final keyword. So for example the OpenResource type extends the Resource type. And implements the pseudo type.

I think the condional type should extend the mixed type. Or maybe a union type? This would make it easier for consuming libraries to ignore the condition. And it will still reflect something useful?

jaapio avatar Jul 22 '24 08:07 jaapio

Well I did not know about extending underlying type (Which is will be my next commit)

If the original class is final we can remove the final keyword. So for example the OpenResource type extends the Resource type. And implements the pseudo type.

About that, well I did not get it. For example you mean OpenResource must not be final?

ahjdev avatar Jul 23 '24 14:07 ahjdev

https://github.com/phpDocumentor/TypeResolver/blob/1.x/src/PseudoTypes/FloatValue.php

Take a look. it did not extend too.

ahjdev avatar Jul 23 '24 14:07 ahjdev

Also I think I should just remove AggregatedPseudoType and extend IntMask and IntMaskOf from AggregatedType. (Well I just think ArrayShape need to review too)

ahjdev avatar Jul 23 '24 14:07 ahjdev

I get your confusion. And when looking for an example I discovered that I didn't do this myself correctly in the past. The pseudotypes were introduced with the True and False class. You can use those as an example.

jaapio avatar Jul 23 '24 15:07 jaapio

I would appreciate if you start workflow for my last commit

ahjdev avatar Jul 24 '24 06:07 ahjdev

I was checking classes and I noticed it is impossible to a property with type of ?Type became null. Because createType method will return Mixed_ class for null

ahjdev avatar Jul 27 '24 21:07 ahjdev

Reason to never use null is because everything has a type. I do see Mixed_ as an unknown or undefined type. Where php does have null as possible types in this library we do wrap nullable types in Nullable

What blocks me from merging this PR is that we really need tests. You did introduce quite a number of new types which is very nice and I'm grateful you did that. But without tests I cannot pass this.

Apart from that, thank you very much for all the work you already did.

jaapio avatar Aug 14 '24 19:08 jaapio

I can covert tests too. just how?

ahjdev avatar Aug 16 '24 11:08 ahjdev

I am still waiting for merge this pr. Also why ReflectionDocBlock doesn't use latest version of TypeResolver?

ahjdev avatar Nov 22 '24 10:11 ahjdev

I'm missing tests for the added types, to move forward faster I think it's better to split this pr in to several smaller ones, so I can merge and review the types individual. Right now this is a very big change without tests. That's what holding me back.

Based on your last comment I expected you were still working on this.

ReflectionDocBlock is able to work with newer and older versions of this library, so that's why it hasn't been changed

jaapio avatar Nov 22 '24 10:11 jaapio