Skip to content

Commit 65af447

Browse files
committed
Fix php-cs-fixer warnings
1 parent 08f6e10 commit 65af447

File tree

3 files changed

+99
-99
lines changed

3 files changed

+99
-99
lines changed

src/PreRelease.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ public function increment(): PreRelease
6060
}
6161

6262
if (-1 != $lastNumericIndex) {
63-
$result->preReleaseParts[$lastNumericIndex] =
64-
(string) (intval($result->preReleaseParts[$lastNumericIndex]) + 1);
63+
$result->preReleaseParts[$lastNumericIndex]
64+
= (string) (intval($result->preReleaseParts[$lastNumericIndex]) + 1);
6565
} else {
6666
$result->preReleaseParts[] = '0';
6767
}

tests/ConstraintTest.php

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -29,53 +29,6 @@ public function testInvalidConstraintsNull(string $constraint)
2929
$this->assertNull(Constraint::parseOrNull($constraint));
3030
}
3131

32-
/**
33-
* @dataProvider dataSatisfies
34-
*/
35-
public function testSatisfies(string $constraint, string $version)
36-
{
37-
$this->assertTrue(Version::satisfies($version, $constraint));
38-
}
39-
40-
/**
41-
* @dataProvider dataNotSatisfies
42-
*/
43-
public function testNotSatisfies(string $constraint, string $version)
44-
{
45-
$this->assertFalse(Version::satisfies($version, $constraint));
46-
}
47-
48-
/**
49-
* @dataProvider dataParse
50-
*/
51-
public function testParse(string $constraint, string $parsed)
52-
{
53-
$this->assertEquals($parsed, (string) Constraint::parse($constraint));
54-
}
55-
56-
public function testConditions()
57-
{
58-
$version = Version::parse('1.0.0');
59-
$this->assertEquals('!=1.0.0', (new Condition(Op::EQUAL, $version))->opposite());
60-
$this->assertEquals('=1.0.0', (new Condition(Op::NOT_EQUAL, $version))->opposite());
61-
$this->assertEquals('>=1.0.0', (new Condition(Op::LESS_THAN, $version))->opposite());
62-
$this->assertEquals('>1.0.0', (new Condition(Op::LESS_THAN_OR_EQUAL, $version))->opposite());
63-
$this->assertEquals('<=1.0.0', (new Condition(Op::GREATER_THAN, $version))->opposite());
64-
$this->assertEquals('<1.0.0', (new Condition(Op::GREATER_THAN_OR_EQUAL, $version))->opposite());
65-
}
66-
67-
public function testRanges()
68-
{
69-
$start = new Condition(Op::GREATER_THAN, Version::parse('1.0.0'));
70-
$end = new Condition(Op::LESS_THAN, Version::parse('1.1.0'));
71-
$this->assertEquals('<=1.0.0 || >=1.1.0', (new Range($start, $end, Op::EQUAL))->opposite());
72-
$this->assertEquals('>1.0.0 <1.1.0', (new Range($start, $end, Op::NOT_EQUAL))->opposite());
73-
$this->assertEquals('>1.0.0', (new Range($start, $end, Op::LESS_THAN))->opposite());
74-
$this->assertEquals('>=1.1.0', (new Range($start, $end, Op::LESS_THAN_OR_EQUAL))->opposite());
75-
$this->assertEquals('<1.1.0', (new Range($start, $end, Op::GREATER_THAN))->opposite());
76-
$this->assertEquals('<=1.0.0', (new Range($start, $end, Op::GREATER_THAN_OR_EQUAL))->opposite());
77-
}
78-
7932
public static function dataInvalid(): array
8033
{
8134
return [
@@ -89,6 +42,14 @@ public static function dataInvalid(): array
8942
];
9043
}
9144

45+
/**
46+
* @dataProvider dataSatisfies
47+
*/
48+
public function testSatisfies(string $constraint, string $version)
49+
{
50+
$this->assertTrue(Version::satisfies($version, $constraint));
51+
}
52+
9253
public static function dataSatisfies(): array
9354
{
9455
return [
@@ -263,6 +224,14 @@ public static function dataSatisfies(): array
263224
];
264225
}
265226

227+
/**
228+
* @dataProvider dataNotSatisfies
229+
*/
230+
public function testNotSatisfies(string $constraint, string $version)
231+
{
232+
$this->assertFalse(Version::satisfies($version, $constraint));
233+
}
234+
266235
public static function dataNotSatisfies(): array
267236
{
268237
return [
@@ -443,6 +412,14 @@ public static function dataNotSatisfies(): array
443412
];
444413
}
445414

415+
/**
416+
* @dataProvider dataParse
417+
*/
418+
public function testParse(string $constraint, string $parsed)
419+
{
420+
$this->assertEquals($parsed, (string) Constraint::parse($constraint));
421+
}
422+
446423
public static function dataParse(): array
447424
{
448425
return [
@@ -683,4 +660,27 @@ public static function dataParse(): array
683660
['^7|^8', '>=7.0.0 <8.0.0-0 || >=8.0.0 <9.0.0-0'],
684661
];
685662
}
663+
664+
public function testConditions()
665+
{
666+
$version = Version::parse('1.0.0');
667+
$this->assertEquals('!=1.0.0', (new Condition(Op::EQUAL, $version))->opposite());
668+
$this->assertEquals('=1.0.0', (new Condition(Op::NOT_EQUAL, $version))->opposite());
669+
$this->assertEquals('>=1.0.0', (new Condition(Op::LESS_THAN, $version))->opposite());
670+
$this->assertEquals('>1.0.0', (new Condition(Op::LESS_THAN_OR_EQUAL, $version))->opposite());
671+
$this->assertEquals('<=1.0.0', (new Condition(Op::GREATER_THAN, $version))->opposite());
672+
$this->assertEquals('<1.0.0', (new Condition(Op::GREATER_THAN_OR_EQUAL, $version))->opposite());
673+
}
674+
675+
public function testRanges()
676+
{
677+
$start = new Condition(Op::GREATER_THAN, Version::parse('1.0.0'));
678+
$end = new Condition(Op::LESS_THAN, Version::parse('1.1.0'));
679+
$this->assertEquals('<=1.0.0 || >=1.1.0', (new Range($start, $end, Op::EQUAL))->opposite());
680+
$this->assertEquals('>1.0.0 <1.1.0', (new Range($start, $end, Op::NOT_EQUAL))->opposite());
681+
$this->assertEquals('>1.0.0', (new Range($start, $end, Op::LESS_THAN))->opposite());
682+
$this->assertEquals('>=1.1.0', (new Range($start, $end, Op::LESS_THAN_OR_EQUAL))->opposite());
683+
$this->assertEquals('<1.1.0', (new Range($start, $end, Op::GREATER_THAN))->opposite());
684+
$this->assertEquals('<=1.0.0', (new Range($start, $end, Op::GREATER_THAN_OR_EQUAL))->opposite());
685+
}
686686
}

tests/ParseTest.php

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,24 @@ public function testNullParse(string $version)
2525
$this->assertNull(Version::parseOrNull($version));
2626
}
2727

28+
public static function invalidData(): array
29+
{
30+
return [
31+
['-1.0.0'],
32+
['1.-1.0'],
33+
['0.0.-1'],
34+
['1'],
35+
[''],
36+
['1.0'],
37+
['1.0-alpha'],
38+
['1.0-alpha.01'],
39+
['a1.0.0'],
40+
['1.a0.0'],
41+
['1.0.a0'],
42+
['v1.0.0'],
43+
];
44+
}
45+
2846
/**
2947
* @dataProvider validData
3048
*/
@@ -33,6 +51,18 @@ public function testValid(string $version, bool $strict)
3351
$this->assertNotNull(Version::parseOrNull($version, $strict));
3452
}
3553

54+
public static function validData(): array
55+
{
56+
return [
57+
['0.0.0', true],
58+
['1.2.3-alpha.1+build', true],
59+
['v1.0.0', false],
60+
['1.0', false],
61+
['v1', false],
62+
['1', false],
63+
];
64+
}
65+
3666
/**
3767
* @dataProvider toStringData
3868
*/
@@ -41,6 +71,26 @@ public function testToString(string $expected, string $version, bool $strict)
4171
$this->assertEquals($expected, (string) Version::parseOrNull($version, $strict));
4272
}
4373

74+
public static function toStringData(): array
75+
{
76+
return [
77+
['1.2.3', '1.2.3', true],
78+
['1.2.3-alpha.b.3', '1.2.3-alpha.b.3', true],
79+
['1.2.3-alpha+build', '1.2.3-alpha+build', true],
80+
['1.2.3+build', '1.2.3+build', true],
81+
['1.2.3', 'v1.2.3', false],
82+
['1.0.0', 'v1', false],
83+
['1.0.0', '1', false],
84+
['1.2.0', '1.2', false],
85+
['1.2.0', 'v1.2', false],
86+
['1.2.3-alpha+build', 'v1.2.3-alpha+build', false],
87+
['1.0.0-alpha+build', 'v1-alpha+build', false],
88+
['1.0.0-alpha+build', '1-alpha+build', false],
89+
['1.2.0-alpha+build', '1.2-alpha+build', false],
90+
['1.2.0-alpha+build', 'v1.2-alpha+build', false],
91+
];
92+
}
93+
4494
public function testValidStable()
4595
{
4696
$version = Version::parse('1.2.3');
@@ -109,54 +159,4 @@ public function testIsStable()
109159
$this->assertFalse(Version::parse('1.1.0-prerelease')->isStable());
110160
$this->assertTrue(Version::parse('1.1.0')->isStable());
111161
}
112-
113-
public static function invalidData(): array
114-
{
115-
return [
116-
['-1.0.0'],
117-
['1.-1.0'],
118-
['0.0.-1'],
119-
['1'],
120-
[''],
121-
['1.0'],
122-
['1.0-alpha'],
123-
['1.0-alpha.01'],
124-
['a1.0.0'],
125-
['1.a0.0'],
126-
['1.0.a0'],
127-
['v1.0.0'],
128-
];
129-
}
130-
131-
public static function validData(): array
132-
{
133-
return [
134-
['0.0.0', true],
135-
['1.2.3-alpha.1+build', true],
136-
['v1.0.0', false],
137-
['1.0', false],
138-
['v1', false],
139-
['1', false],
140-
];
141-
}
142-
143-
public static function toStringData(): array
144-
{
145-
return [
146-
['1.2.3', '1.2.3', true],
147-
['1.2.3-alpha.b.3', '1.2.3-alpha.b.3', true],
148-
['1.2.3-alpha+build', '1.2.3-alpha+build', true],
149-
['1.2.3+build', '1.2.3+build', true],
150-
['1.2.3', 'v1.2.3', false],
151-
['1.0.0', 'v1', false],
152-
['1.0.0', '1', false],
153-
['1.2.0', '1.2', false],
154-
['1.2.0', 'v1.2', false],
155-
['1.2.3-alpha+build', 'v1.2.3-alpha+build', false],
156-
['1.0.0-alpha+build', 'v1-alpha+build', false],
157-
['1.0.0-alpha+build', '1-alpha+build', false],
158-
['1.2.0-alpha+build', '1.2-alpha+build', false],
159-
['1.2.0-alpha+build', 'v1.2-alpha+build', false],
160-
];
161-
}
162162
}

0 commit comments

Comments
 (0)