Skip to content

Commit 4ae413e

Browse files
committed
Migrated codebase to php 8.0
1 parent a38f5ce commit 4ae413e

File tree

7 files changed

+70
-187
lines changed

7 files changed

+70
-187
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
.idea
22
composer.lock
33
vendor
4+
.phpunit.result.cache
5+
phpunit.xml.dist.bak

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
2323

2424
### Changeed
2525

26+
## [2.1.0](https://github.com/bazzline/php_component_cli_argument/tree/2.1.0) - released at 2022-11-23
27+
28+
### Changeed
29+
30+
* Raised minimum php version requirement from `7.0` to `8.0`
31+
* Updated development requirement from phpunit 6.0 to 8.0
32+
* Migrated phpunit xml
33+
* Migrated code base to php 8.0
34+
2635
## [2.0.0](https://github.com/bazzline/php_component_cli_argument/tree/2.0.0) - released at 2018-01-12
2736

2837
### Changed

Example/run.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
* @since: 2015-04-16
55
*/
66

7+
use Net\Bazzline\Component\Cli\Arguments\Arguments;
8+
79
require_once __DIR__ . '/../vendor/autoload.php';
810

9-
$arguments = new \Net\Bazzline\Component\Cli\Arguments\Arguments($argv);
11+
$arguments = new Arguments($argv);
1012

1113
if ($arguments->hasArguments()) {
1214
echo $arguments->getNumberOfArguments() . ' arguments provided:' . PHP_EOL;

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
"type": "library",
1919
"minimum-stability": "dev",
2020
"require": {
21-
"php": "~7.0"
21+
"php": "~8.0"
2222
},
2323
"require-dev": {
24-
"phpunit/phpunit": "~6.0"
24+
"phpunit/phpunit": "~9.0"
2525
},
2626
"license": "LGPL-3.0-only",
2727
"authors": [

phpunit.xml.dist

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
1-
<phpunit bootstrap="test/bootstrap.php"
2-
cacheTokens="false"
3-
colors="true"
4-
convertErrorsToExceptions="true"
5-
convertNoticesToExceptions="true"
6-
convertWarningsToExceptions="true"
7-
stopOnError="false"
8-
stopOnFailure="false"
9-
stopOnIncomplete="false"
10-
stopOnSkipped="false">
11-
12-
<testsuites>
13-
<testsuite name="Test Suite">
14-
<directory>test/</directory>
15-
</testsuite>
16-
</testsuites>
1+
<?xml version="1.0"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="test/bootstrap.php" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" stopOnError="false" stopOnFailure="false" stopOnIncomplete="false" stopOnSkipped="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
3+
<coverage/>
4+
<testsuites>
5+
<testsuite name="Test Suite">
6+
<directory>test/</directory>
7+
</testsuite>
8+
</testsuites>
179
</phpunit>

source/Arguments.php

Lines changed: 26 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,13 @@
88

99
class Arguments
1010
{
11-
/** @var array */
12-
private $arguments;
11+
private array $arguments;
12+
private array $flags;
13+
private array $lists;
14+
private Parser $parser;
15+
private array $values;
1316

14-
/** @var array */
15-
private $flags;
16-
17-
/** @var array */
18-
private $lists;
19-
20-
/** @var Parser */
21-
private $parser;
22-
23-
/** @var array */
24-
private $values;
25-
26-
/**
27-
* @param null|array $argv
28-
* @param boolean $removeFirstArgument
29-
*/
30-
public function __construct($argv = null, $removeFirstArgument = true)
17+
public function __construct(array $argv = null, bool $removeFirstArgument = true)
3118
{
3219
$this->parser = new Parser();
3320

@@ -38,137 +25,84 @@ public function __construct($argv = null, $removeFirstArgument = true)
3825
}
3926
}
4027

41-
/**
42-
* @return array
43-
*/
44-
public function getArguments()
28+
public function getArguments(): array
4529
{
4630
return $this->arguments;
4731
}
4832

49-
/**
50-
* @return array
51-
*/
52-
public function getFlags()
33+
public function getFlags(): array
5334
{
5435
return $this->flags;
5536
}
5637

57-
/**
58-
* @param string $name
59-
* @return null|array
60-
*/
61-
public function getList($name)
38+
public function getList(string $name): null|array
6239
{
6340
return (isset($this->lists[$name]))
6441
? $this->lists[$name]
6542
: null;
6643
}
6744

68-
/**
69-
* @return int
70-
*/
71-
public function getNumberOfArguments()
45+
public function getNumberOfArguments(): int
7246
{
7347
return (count($this->arguments));
7448
}
7549

76-
/**
77-
* @return int
78-
*/
79-
public function getNumberOfFlags()
50+
public function getNumberOfFlags(): int
8051
{
8152
return (count($this->flags));
8253
}
8354

84-
/**
85-
* @return int
86-
*/
87-
public function getNumberOfLists()
55+
public function getNumberOfLists(): int
8856
{
8957
return (count($this->lists));
9058
}
9159

92-
/**
93-
* @return int
94-
*/
95-
public function getNumberOfValues()
60+
public function getNumberOfValues(): int
9661
{
9762
return (count($this->values));
9863
}
9964

100-
/**
101-
* @return array
102-
*/
103-
public function getLists()
65+
public function getLists(): array
10466
{
10567
return $this->lists;
10668
}
10769

108-
/**
109-
* @return array
110-
*/
111-
public function getValues()
70+
public function getValues(): array
11271
{
11372
return $this->values;
11473
}
11574

116-
/**
117-
* @return bool
118-
*/
119-
public function hasArguments()
75+
public function hasArguments(): bool
12076
{
12177
return (!empty($this->arguments));
12278
}
12379

124-
/**
125-
* @param string $name
126-
* @return bool
127-
*/
128-
public function hasFlag($name)
80+
public function hasFlag(string $name): bool
12981
{
13082
return (in_array($name, $this->flags));
13183
}
13284

133-
/**
134-
* @return bool
135-
*/
136-
public function hasFlags()
85+
public function hasFlags(): bool
13786
{
13887
return (!empty($this->flags));
13988
}
14089

141-
/**
142-
* @param string $name
143-
* @return bool
144-
*/
145-
public function hasList($name)
90+
public function hasList(string $name): bool
14691
{
14792
return (isset($this->lists[$name]));
14893
}
14994

150-
/**
151-
* @return bool
152-
*/
153-
public function hasLists()
95+
public function hasLists(): bool
15496
{
15597
return (!empty($this->lists));
15698
}
15799

158-
/**
159-
* @return bool
160-
*/
161-
public function hasValues()
100+
public function hasValues(): bool
162101
{
163102
return (!empty($this->values));
164103
}
165104

166-
/**
167-
* @param array $argv
168-
* @param boolean $removeFirstArgument
169-
* @return $this
170-
*/
171-
public function parseArguments(array $argv, $removeFirstArgument = true)
105+
public function parseArguments(array $argv, bool $removeFirstArgument = true): self
172106
{
173107
if ($removeFirstArgument) {
174108
array_shift($argv);
@@ -181,34 +115,22 @@ public function parseArguments(array $argv, $removeFirstArgument = true)
181115
return $this;
182116
}
183117

184-
/**
185-
* @return array
186-
*/
187-
public function convertToArray()
118+
public function convertToArray(): array
188119
{
189120
return $this->getArguments();
190121
}
191122

192-
/**
193-
* @return string
194-
*/
195-
public function convertToString()
123+
public function convertToString(): string
196124
{
197125
return implode(' ', $this->convertToArray());
198126
}
199127

200-
/**
201-
* @return string
202-
*/
203-
public function __toString()
128+
public function __toString(): string
204129
{
205130
return $this->convertToString();
206131
}
207132

208-
/**
209-
* @param Parser $parser
210-
*/
211-
private function setArgumentsFromParser(Parser $parser)
133+
private function setArgumentsFromParser(Parser $parser): void
212134
{
213135
$this->flags = $parser->getFlags();
214136
$this->lists = $parser->getLists();

0 commit comments

Comments
 (0)