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

(int|string)[] is unextractable #2008

Closed
mvangeest opened this issue Sep 28, 2018 · 2 comments
Closed

(int|string)[] is unextractable #2008

mvangeest opened this issue Sep 28, 2018 · 2 comments
Labels
enhancement This improves the quality of Phan's analysis of a codebase

Comments

@mvangeest
Copy link

The README states:

Phan supports (int|string)[] style annotations, and represents them internally as int[]|string[] (Both annotations are treated like array which may have integers and/or strings).

However, when I run Phan (master) on the following...

<?php

/**
 * @return (int|string)[]
 */
function intsAndStrings()
{
    return [1, 'two', 3];
}

... it tells me the annotation is no good:

test.php:4 PhanUnextractableAnnotation Saw unextractable annotation for comment '* @return (int|string)[]'

I think there are two good reasons to support (int|string)[]:

  1. its equivalent array<int|string> is supported
  2. phpDocumentor likes it, although it warns that it might not be supported

If this issue is fixed, I also suggest changing the BNF on About Union Types to show that ARRAY_TYPE is allowed to contain a UNION_TYPE wrapped in parentheses.

@TysonAndre TysonAndre added the enhancement This improves the quality of Phan's analysis of a codebase label Sep 28, 2018
@TysonAndre
Copy link
Member

I agree that it should be added. I was having some problems with type_regex the last time I tried supporting this.

@TysonAndre
Copy link
Member

Or it may have broken in an earlier refactoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This improves the quality of Phan's analysis of a codebase
Projects
None yet
Development

No branches or pull requests

2 participants