Skip to content

Conversation

GrahamCampbell
Copy link
Contributor

No description provided.

@GrahamCampbell
Copy link
Contributor Author

Unrelated, but is there a reason it was called getArguments instead of getParameters?

@jaapio
Copy link
Member

jaapio commented Dec 27, 2017

I don't know why this was called originally arguments but it is the term using in all phpdocumentor packages.

For some reason phpstan thinks your change isn't correct. And it needs to be swiched back to string[] maybe because it is an multi-dimensional array. string[][] it should be, I think. Need to check that.

@GrahamCampbell
Copy link
Contributor Author

It's not of type string[][], because, [$i]['type'] is of type Type.

@GrahamCampbell
Copy link
Contributor Author

It really is array[]. Not sure why phpstan can't agree.

@GrahamCampbell
Copy link
Contributor Author

GrahamCampbell commented Dec 27, 2017

Oh, i see why it inferred that now, it's because the only assignment to it happens to start off life as string[] from one branch. But that inference is incorrect, because it changes type before assignment.

@jaapio
Copy link
Member

jaapio commented Dec 27, 2017

@ondrejmirtes can you help us here, is this a false report by phpstan?

@ondrejmirtes
Copy link

@jaapio If you write array[], that is translated to mixed[][]... Since private $arguments = []; is string[] then these two do not match and something is wrong here...

@jaapio
Copy link
Member

jaapio commented Dec 27, 2017

Thanks for the quick response @ondrejmirtes!

@ondrejmirtes
Copy link

So I'm not sure what you need here, probably just @return array which gets translated into mixed[]?

@GrahamCampbell
Copy link
Contributor Author

The actual return type is array[] though. It just happens to be that variables that are later assigned to this property have other types in their life before assignment.

@jaapio
Copy link
Member

jaapio commented Dec 27, 2017

The array has 2 dimensions. where the second dimension is string|Type. Think from a documentation perspective this is not possible yet to define. Cannot find anything in the draft of psr-5.
Keys are even known name|type.

@GrahamCampbell
Copy link
Contributor Author

The array has 2 dimensions. where the second dimension is string|Type.

Yeh, so the best we can do it say it has type array[], which is the same as mixed[][]?

@jaapio
Copy link
Member

jaapio commented Dec 27, 2017

Would accept that for now.
A big plus when you even add a proper description ;-)

@GrahamCampbell
Copy link
Contributor Author

Ha, sorry. :)

@GrahamCampbell
Copy link
Contributor Author

Could this syntax be what we want: https://github.com/phpDocumentor/TypeResolver/blob/master/tests/unit/TypeResolverTest.php#L376. Does that mean an array of either of those types, but exactly one, or does it mean an array of either of them, if you see what I mean?

@ondrejmirtes
Copy link

ondrejmirtes commented Dec 28, 2017 via email

@jaapio
Copy link
Member

jaapio commented Jan 27, 2018

Closing because of changed made in #147.

@jaapio jaapio closed this Jan 27, 2018
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 this pull request may close these issues.

3 participants