-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[PropertyInfo] Extract the logic converting a php doc to a Type #19484
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
Conversation
I got the use case and it is legitimate, but what do you think about creating a new utility class instead of a trait? It would be easier to test and a cleaner design IMO. |
@dunglas looks good to me as well :) |
Last nitpicking (I hope): why using static methods here? A typical class would be cleaner IMO (even if it has no state). |
@dunglas I made it static because it is very unlikely to change and to be extended but a typical class is fine for me as well :) |
* | ||
* @return Type|null | ||
*/ | ||
private static function createType($docType, $nullable) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we let static
the private
methods?
@Ener-Getick a static API creates hard coupling, and is harder to evolve in the future because of that. So I would prefer using a normal class here |
@stof that's already the case except for the |
/** | ||
* Creates a {@see Type} from a PHPDoc tag. | ||
* | ||
* @param Var_|Return_|Param $tag |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than such mixed argument, used only to get its type, I would take the phpDocumentor\Reflection\Type
directly as argument
in PhpDocTypeHelperTrait
Thank you @Ener-Getick. |
…to a Type (Ener-Getick) This PR was merged into the 3.2-dev branch. Discussion ---------- [PropertyInfo] Extract the logic converting a php doc to a Type | Q | A | ------------- | --- | Branch? | "master" | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | This PR creates a new trait `PhpDocTypeHelperTrait` extracting some logic of the `PhpDocExtractor`. I would like to detect the return type of some methods but this is not easily doable as I have to transform the doc types to a ``Type`` instance. Is this ok for you ? Commits ------- d6e93d8 [PropertyInfo] Extract the logic converting a php doc to a Type in PhpDocTypeHelperTrait
This PR creates a new trait
PhpDocTypeHelperTrait
extracting some logic of thePhpDocExtractor
.I would like to detect the return type of some methods but this is not easily doable as I have to transform the doc types to a
Type
instance.Is this ok for you ?