Closed ryok90 closed 2 years ago
I just saw that there is the magic method __set in the abstraction. Would it be possible to add @method annotations for them?
Not sure I understand exactly how this would look like.
I just saw that there is the magic method __set in the abstraction.
This is for properties and these are declared by @property
annotations.
Would it be possible to add
@method
annotations for them?
Would be possible to implement this via __call() and @method
annotations.
// current ways of creating elements
$pathItem = new PathItem();
$post = new Operation();
$pathItem->post = $post;
// alternatively:
$post = new Operation();
$pathItem = new PathItem([
'post' => $post,
]);
// or
$pathItem = new PathItem([
'post' => new Operation([
// ...
]),
]);
// so what you propose would be like this?
$pathItem = new PathItem();
$post = new Operation();
$pathItem->setPost($post);
what additional value does it bring compared to the already existing options?
I actually don't know if my editor (VSCode) is not well configured for this but with the annotations it doesn't point type errors.
The only additional value I seek is the type checking for new developers to have a more 'safe' and 'fluid' documentation development.
@property
annotations come with a type so adding methods does not add any additional way of type checking. Tools like PHPStan should be able to detect this.
Hello! I was messing with an implementation of this package and came across this situation. I wonder if it would be possible to add typed setters for some properties, like Paths have with addPath. Just to have more fluid and intuitive implementation. If yes, would be willing to accept pull request with these kind of modifications?
Something like:
I used a typescript documentation package that made a little bit easier to write. That's where my idea comes from.