Skip to content

Fix: An array can have only integers or strings as keys #132

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

Merged
merged 4 commits into from
Oct 2, 2021

Conversation

voku
Copy link
Contributor

@voku voku commented Oct 1, 2021

We should allow all kind of string types here. We currently do not have an array-key interface or something like that, so I added the new type into the check.

@voku voku changed the title FP: An array can have only integers or strings as keys Fix: An array can have only integers or strings as keys Oct 1, 2021
Copy link
Member

@jaapio jaapio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this improvement, it would be nice if you can update the PR with my requested change.

After that, this should be ready to merge.


/**
* Value Object representing the type 'string'.
*
* @psalm-immutable
*/
final class ClassString implements Type
final class ClassString extends String_
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we forgot this one when introducing the PseudoType interface, Could you please add that as well here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

{
public function __construct()
{
parent::__construct([new String_(), new Integer()], '|');
}

public function underlyingType(): Type
{
return new String_();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems incorrect to me, this type is not a string, it should return a Compound with the types String_ and Integer. ArrayKey is an alternative notation for String|Int, not just String

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Copy link
Member

@jaapio jaapio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for yet another nice contribution!

@jaapio jaapio merged commit a12f7e3 into phpDocumentor:1.x Oct 2, 2021
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.

2 participants