-
Notifications
You must be signed in to change notification settings - Fork 7
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
Issue/91. Handle patch correctly. #98
Conversation
…h has the highest rank
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.
Overall looking good, but we need checks among -p1
, -p2
and -p3
.
@nikolaposa you might be interested in this sort of patch too 👍
} | ||
|
||
/** | ||
* @return mixed |
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 js an array<string, array<int, string|array<string, array<string, array<string>>>>
or such 😵😵😵
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 know how to correct this 😓
Is @return mixed
okay ?
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's a test data provider: we're good for now 👍
complex than I expected. Apart from designating Flag class for all the logic, spaceship operator logic was ditched — it became too complex so insted we just use boolean. PRIORITY map in Flag class contains null, looks ugly, but allowed to throw away lots of checks and makes flag comparison more obvious and "natural" I would say.
Thanks for the ping @Ocramius. 👍 On a different note, these days I'm working on Version 4.0.0, lots of backward-incompatible improvements in it (https://github.com/nikolaposa/version/blob/master/CHANGELOG.md#unreleased). 😒 BackwardCompatibilityCheck library is by far the biggest dependent so I'll help you with migrating, expect a PR soon! |
private const PRIORITY = [ | ||
'patch' => 5, | ||
'p' => 5, | ||
null => 4, // special case of clean version, e.g. 1.2.3 |
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 guess it looks a bit ugly, but when I added this null
in the map, it helped to ditch so many useless checks.
So I think it is ugly and... elegant at the same time 😅
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.
null
is not a valid array key. This is probably adding the empty string instead.
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'd say it actually is a valid key, at least I'm being able to get value from array by null
But you got me thinking, and yes null
is not very good key. I'm going to change it to string value with some meaning attached.
Thanks!
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 the end empty string was the best variant. I did push update.
{ | ||
$this->versionNumbers = self::removeTrailingZeroes(...array_map('intval', explode('.', $matches['version']))); |
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.
just moved this logic from fromString
static method to unload it a little bit
} | ||
|
||
public function equalTo(self $other) : bool | ||
{ | ||
return $other->versionNumbers === $this->versionNumbers && | ||
$this->stabilityEqualTo($other); | ||
return $other->versionNumbers === $this->versionNumbers |
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.
simplified logic, no need for stabilityEqualTo
// compare with version lower | ||
['2.3.2-p2', '2.3.1', true, false], | ||
// compare two patches but with additional stability versions like 1-p1 and 1-p2 so the p2 will be greater | ||
['2.3.2-p1', '2.3.2-p2', false, true], |
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.
@Ocramius I do this p1
vs p2
comparison here.
Also I have to admit it starts to get out of hand, data providers grow and it is a bit hard to navigate.
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 that's combinatory logic with edge cases 🤷♀️
The good thing is that I'm not (currently) aware of further edge cases
It is ready for review 🤞 |
… php casts null to empty string anyway
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.
LGTM, excellent work @slash3b!
@Ocramius thank you! |
Seems fixed downstream 💃 Roave/SecurityAdvisories@72ffba7#diff-b5d0ee8c97c7abd7e3fa29b9a27d1780R78 |
@slash3b What does
|
|
Oh no. |
TLDR: priority fix and added some more tests
Fixed major flaw — turned out within extent of same version
patch
flag is of the highest priority.Priority sequence should be the following:
diff between old version and fixed one: