-
-
Notifications
You must be signed in to change notification settings - Fork 67
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
[Type] replace Type\arr
by Type\{mutable_}map
and Type\{mutable_}vector
#101
Conversation
Pull Request Test Coverage Report for Build 737
💛 - Coveralls |
181b65f
to
39f9782
Compare
Was thinking : does it make sense to remove the array type altogether? In some situations in which you dont have that much control over de source data, you might be ok with having a very loose regular |
bf178d7
to
31a7eb3
Compare
31a7eb3
to
5d30586
Compare
0c6aef0
to
9725ce5
Compare
tests/Psl/Json/TypedTest.php
Outdated
/** @var MapInterface $actual */ | ||
$actual = Json\typed( | ||
'["php", "std", "stdlib", "utility", "psl"]', | ||
Type\vector(Type\string()) | ||
); | ||
|
||
static::assertInstanceOf(VectorInterface::class, $actual); | ||
static::assertSame(['php', 'std', 'stdlib', 'utility', 'psl'], $actual->toArray()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @veewee 😉
9725ce5
to
ea8c6e2
Compare
Type\arr
by Type\{mutable_}map
and Type\{mutable_}vector
that is just |
but i think we can add |
Sure, Will see what I can do. Hopefully at the end of the week :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Added a small remark / question.
Gonna try to open up a PR for maing the type layer pure as well. Still got some issues there.
} | ||
|
||
/** @psalm-var Iter\Iterator<Tk, Tv> $iterator */ | ||
$iterator = Iter\from_entries($entries); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense not to use entries but build the map up from the foreach directly? This would allow for pure / immutable type classes (since from_entries($iterable)
is not pure)
(same goes for the other usages of entries)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it woudln't make any differencce here, since coerce accepts any iterable, and does a foreach on it, meaning it can never be pure. as that iterable we are doing foreach on isn't really immutable.
not sure if that's possible, but we will see, i'm merging this as-is for now. |
Put some more time in it and it turns out it is not possible ... |
closes #100