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

Generics support #92

Closed
kubk opened this issue Jul 24, 2023 · 0 comments · Fixed by #94
Closed

Generics support #92

kubk opened this issue Jul 24, 2023 · 0 comments · Fixed by #94

Comments

@kubk
Copy link
Collaborator

kubk commented Jul 24, 2023

https://phpstan.org/r/057a248b-07fc-4317-954e-5986b19c4760

How to include stub file:

parameters:
    stubFiles:
        - ./vendor/riverwaysoft/php-converter/JsonResponse.stub
  • Check that it works both with and without PHPStan.

    /** @return JsonResponse<MyCollection<string>> */
    #[DtoEndpoint]
    #[Route('/api/test', methods: ['GET'])]
    public function customGenericEndpoint()
    {
        $result = new JsonResponse(new MyCollection('test', 100));
        return $result;
    }
<?php

namespace App\Domain\Food\Controller;

/**
* @template T
*/
class MyCollection
{
   /**
    * @param T $data
    */
   public function __construct(
       public $data,
       public int $total,
   ) {
   }
}
   $ecsConfig->rules([
       RequireAttributeAfterDocCommentSniff::class,
   ]);
@kubk kubk mentioned this issue Jul 24, 2023
@kubk kubk changed the title Describe how to use generics Generics support Jul 24, 2023
@kubk kubk closed this as completed in #94 Jul 27, 2023
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 a pull request may close this issue.

1 participant