Skip to content
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

Merged
merged 1 commit into from
Sep 13, 2017
Merged

Refactored away HashArray #702

merged 1 commit into from
Sep 13, 2017

Conversation

JeroenDeDauw
Copy link
Contributor

@JeroenDeDauw JeroenDeDauw commented Jan 5, 2017

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
  • ...

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).

Copy link
Contributor

@thiemowmde thiemowmde left a 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:

*
* @throws InvalidArgumentException
*/
public function __construct( $input = null, $flags = 0, $iteratorClass = 'ArrayIterator' ) {
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

public function __construct( $input = null, $flags = 0, $iteratorClass = 'ArrayIterator' ) {
parent::__construct( [], $flags, $iteratorClass );

if ( $input !== null ) {
Copy link
Contributor

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.

@JeroenDeDauw
Copy link
Contributor Author

Merge conflict as well

@thiemowmde
Copy link
Contributor

I will happily rebase this patch here when the other patches are merged.

@thiemowmde thiemowmde force-pushed the rm-hasharray branch 2 times, most recently from fa3d039 to 016649e Compare January 11, 2017 14:15
@JeroenDeDauw
Copy link
Contributor Author

Merge?

@thiemowmde
Copy link
Contributor

#702 (review)?

return false;
}

if ( $hasHash ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is now dead code. See #712, where I remove this entire feature from the base class. As before I will happily rebase this patch when #712 is merged.

* @see GenericArrayObject::getObjectType
* Maps snak hashes to their offsets.
*
* @var array [ snak hash (string) => array [ snak offset (string|int) ] | snak offset (string|int) ]
Copy link
Contributor

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.

@thiemowmde
Copy link
Contributor

thiemowmde commented Jan 13, 2017

Rebased. I also inlined what was formerly a protected preSetElement method. This patch is now much closer to being mergable, I believe. Still to do:

  • Some @since tags are missing.
  • Make sure the test cases cover everything we want them to cover.
  • Rework the constructor. However, we can do this later, but before doing a release.
  • The method name removeSnakHash is new. It's a bit awkward. Suggestion: removeSnakByHash.
  • Check if all non-private methods are really needed. Some appear to be duplicates.

@JeroenDeDauw
Copy link
Contributor Author

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.

@thiemowmde
Copy link
Contributor

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.

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
* ...
@JeroenDeDauw JeroenDeDauw modified the milestones: 8.0.0, 7.0.0 Sep 13, 2017
@JeroenDeDauw
Copy link
Contributor Author

JeroenDeDauw commented Sep 13, 2017

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

@JeroenDeDauw JeroenDeDauw merged commit 0460d67 into master Sep 13, 2017
@JeroenDeDauw JeroenDeDauw deleted the rm-hasharray branch September 13, 2017 07:59
@thiemowmde
Copy link
Contributor

Thanks. I updated the release notes in 16f54e9. I used reflection to compile a list of methods SnakList does not support any more.

@JeroenDeDauw
Copy link
Contributor Author

Thanks for updating the release notes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

None yet

2 participants