-
Notifications
You must be signed in to change notification settings - Fork 17
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
Refactored away HashArray #702
Conversation
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.
I don't feel like this patch can be merged as it is, because it is so big and potentially causes unwanted side effects. I suggest a series of smaller steps before we do this big change:
Let's drop as much unused code as we can first. See Drop unused HashArray::removeDuplicates #710, Remove unused HashArray::rebuildIndices and indicesAreUpToDate #711 and Drop "accept duplicates" feature from HashArray #712.Add a constructor in a separate patch, see Add SnakList constructor #439.- Make sure SnakListTest covers everything we want it to cover.
src/Snak/SnakList.php
Outdated
* | ||
* @throws InvalidArgumentException | ||
*/ | ||
public function __construct( $input = null, $flags = 0, $iteratorClass = 'ArrayIterator' ) { |
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.
In my opinion this constructor is exposing to much (undocumented) complexity that is not needed by users of the SnakList
class. Please tell me if I miss something. Otherwise I suggest to merge #439 first and rebase this patch.
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.
I did not touch this in this PR and don't want to add additional changes to it.
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.
I consider the $flags
and $iteratorClass
parameters implementation details from the ArrayObject
class. These parameters where never documented for the SnakList
class, and never used, and should not be copy pasted over here in my opinion. As said I would like to merge #439 first.
src/Snak/SnakList.php
Outdated
public function __construct( $input = null, $flags = 0, $iteratorClass = 'ArrayIterator' ) { | ||
parent::__construct( [], $flags, $iteratorClass ); | ||
|
||
if ( $input !== null ) { |
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 will not be necessary any more with #439.
Merge conflict as well |
I will happily rebase this patch here when the other patches are merged. |
fa3d039
to
016649e
Compare
Merge? |
src/Snak/SnakList.php
Outdated
return false; | ||
} | ||
|
||
if ( $hasHash ) { |
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.
src/Snak/SnakList.php
Outdated
* @see GenericArrayObject::getObjectType | ||
* Maps snak hashes to their offsets. | ||
* | ||
* @var array [ snak hash (string) => array [ snak offset (string|int) ] | snak offset (string|int) ] |
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 not be an array of arrays any more. Multiple is_array
checks below are not needed any more. See #712.
016649e
to
666d9f3
Compare
Rebased. I also inlined what was formerly a protected
|
I do not like this "everything needs to be done before this is merged" approach. Not saying it is bad. I find it unpleasant and think its not efficient. I do not want discuss this with you, and I no longer feel like following up on this change either, it's just not fun. |
Sorry to hear that. All I wanted was a series of smaller patches that are easier to follow, easier to understand and easier to review. Thanks for merging the patches I did so far. |
666d9f3
to
4cca1e5
Compare
9050061
to
ce1b72c
Compare
ce1b72c
to
75dec09
Compare
75dec09
to
40b5123
Compare
Removed a bunch of unused code and made SnakList simpler. SnakList can be improved further in follow ups: * Constructor can hide extending of ArrayObject * Perhaps can use composition of ArrayObject instead of inheritance * removeSnakHash -> removeSnakByHash * ...
40b5123
to
e23e3c0
Compare
Just noticed this HasArray thing still exists, went looking for a PR that removes it, found this one, and went faceplam. Forgetti much Since mawster is at 8.0-alpha anyway, I suppose this can be merged right away Edit: well since it is approved and the reason to not merge it right away is gone, I can just merge it myself |
Thanks. I updated the release notes in 16f54e9. I used reflection to compile a list of methods SnakList does not support any more. |
Thanks for updating the release notes |
Removed a bunch of unused code and made SnakList simpler.
SnakList can be improved further in follow ups:
The changes made so far should not break anything in Wikibase.git, though clearly there are some breaking changes (public methods no longer there and no more HashArray).