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
Add SplObjectStorage stub #301
Conversation
33b89cb
to
385bb2f
Compare
Hi, you don't "need" this stub for phpstan/phpstan-symfony#92, you can go on and use just |
And fix the stub by looking at the build log :) |
Currently it's only possible to set the keys, not the values.
When using A BC way would be to allow Why target 1.0 ? Breaking changes are allowed in a 0.x version. It could be
Sure, but the errors are not really clear to me. |
385bb2f
to
ef2db18
Compare
The next major is going to be 1.0, not 0.13 :) It's a BC break because on level 6 there's going to be a new error message because SplObjectStorage becomes generic. |
Ok ! Any idea about the build failure ? |
interface does not implement other interfaces, it extends them. You can also run |
ef2db18
to
8d2dbd7
Compare
stubs/ArrayObject.stub
Outdated
@@ -105,3 +105,66 @@ class SplFixedArray implements Iterator, ArrayAccess, Countable | |||
*/ | |||
public function toArray(): array { } | |||
} | |||
|
|||
/** | |||
* @template TKey of object |
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.
You understand how SplObjectStorage works wrong. The user cannot influence the iterable key, it's always int: https://3v4l.org/J4M0N
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.
Ok, but the ArrayAccess Key is an objet: https://3v4l.org/DsUbK
So it would be
@template-implements Iterator<int, TKey>
@template-implements ArrayAccess<TKey, TValue>
?
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.
Yeah but it'd make more sense to rename them to TObject
and TData
.
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.
Done ! I have only 3 build failures. It's for php 8 so I assume it's normal.
8d2dbd7
to
a9145fb
Compare
1871b5a
to
afaeb6e
Compare
Sure, thanks. I'll make a note to merge this once 1.0-dev is opened. |
I'm curious, any release-goal for the 1.0 version ? |
Do you mean a date? Winter 2020-21. So in around 6 months. |
I thought about this. The following class could be generics: SplPriorityQueue, SplMinHeap, SplMaxHeap, SplHeap, SplQueue, SplStack, SplDoublyLinkedList. I'm sure there is (lot of) others. What is the name of the rule which will fail ? When you introduce a generic, you'll had to the exclude list
And then, in the next major, you remove it from the exclude list. WDYT ? |
I've thought about this - we could add these new stubs in |
528d60b
to
3bdfa2e
Compare
@@ -0,0 +1,62 @@ | |||
/** |
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.
This can't work without the opening <?php
tag.
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.
Fixed. But some tests are still failing for memory reason 😕
9d8e041
to
5ab4973
Compare
5ab4973
to
9e0c2bd
Compare
Thank you! |
I'm trying to close phpstan/phpstan#3111
This will be a BC-break I think, because before we could write
SplObjectStorage<object>
and now it will beSplObjectStorage<object, mixed>
.Maybe I'm wrong and I can avoid this BC-break @ondrejmirtes ?