support for class-string-map<T of Foo>

Open
#281 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
php
Domain
devtools

Research direction

Start by reviewing issue #246, PHPStan issue #9521, and the linked phpDocumentor TypeResolver issue to understand the proposed class-string-map syntax. Then examine how GenericType represents bounds and how the parser handles this syntax; done means an agreed representation and parser support that avoids a crash.

Written by the indexing model from the issue text.

Description

I was investigating the option to add support for class-string-map<T of Foo> and found #246, and also https://github.com/phpstan/phpstan/issues/9521. According to @ondrejmirtes in #246 this syntax should already be supported by this library. But is it not.

I'm wondering if we should introduce the syntax, and how this would look like. I can help with the implementation in the parser. But not without an agreement on how this would work on the GenericType.

I would suggest to add a $bound type on the GenericType which is equal to the behavior on @template

This is needed to the mentioned change in phpstan and https://github.com/phpDocumentor/TypeResolver/issues/266. Support in the parser would at least prevent a crash in the parser.

Thanks for this library! 🎉

Dominant language
PHP
Stars
1.5k
Forks
78
Avg merge
9h 5m
Merged PRs (30d)
5

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from phpstan/phpdoc-parser

All issues in phpstan/phpdoc-parser

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.