Skip to content

Commit 73e22ad

Browse files
committed
PHP 8 and PHPStan level 8
1 parent 5033876 commit 73e22ad

31 files changed

+731
-817
lines changed

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
/.* export-ignore
33
/phpcs.xml.dist export-ignore
44
/phpunit.xml.dist export-ignore
5+
/phpstan.neon.dist export-ignore

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Features:
1212
Requirements
1313
------------
1414

15-
- PHP 7.1+
15+
- PHP 8.0+
1616
- [php-ffmpeg/php-ffmpeg](https://packagist.org/packages/php-ffmpeg/php-ffmpeg) for extracting media profile directly from the media file.
1717

1818
Installation

composer.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@
1313
}
1414
],
1515
"require": {
16-
"php": ">=7.1",
16+
"php": ">=8.0",
1717
"php-ffmpeg/php-ffmpeg": ">=0.7"
1818
},
1919
"require-dev": {
20-
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.0",
20+
"phpstan/phpstan": "^0.12.84",
21+
"phpunit/phpunit": "^9.3",
2122
"squizlabs/php_codesniffer": "3.5.*",
2223
"swivl/php-coding-standard": "^1.0"
2324
},
@@ -33,7 +34,7 @@
3334
},
3435
"extra": {
3536
"branch-alias": {
36-
"dev-master": "1.2.x-dev"
37+
"dev-master": "1.3.x-dev"
3738
}
3839
}
3940
}

phpstan.neon.dist

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
parameters:
2+
level: 8
3+
paths:
4+
- src
5+
- tests

src/BuilderInterface.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ interface BuilderInterface
1212
/**
1313
* Build command.
1414
*
15-
* @return array
15+
* @return array<int, string>
1616
*/
1717
public function build(): array;
1818

src/Command/Command.php

+25-25
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,27 @@ class Command implements CommandInterface
1616
/**
1717
* @var string[]
1818
*/
19-
protected $options = [];
19+
protected array $options = [];
2020

2121
/**
2222
* @var FileInterface[]
2323
*/
24-
protected $inputFiles = [];
24+
protected array $inputFiles = [];
2525

2626
/**
2727
* @var FileInterface[]
2828
*/
29-
protected $outputFiles = [];
29+
protected array $outputFiles = [];
3030

3131
/**
3232
* Add an option.
3333
*
3434
* @param string $name
3535
* @param string $argument
3636
*
37-
* @return CommandInterface
37+
* @return static
3838
*/
39-
public function addOption(string $name, string $argument = ''): CommandInterface
39+
public function addOption(string $name, string $argument = ''): static
4040
{
4141
$this->options[] = $name;
4242

@@ -50,7 +50,7 @@ public function addOption(string $name, string $argument = ''): CommandInterface
5050
/**
5151
* Build command.
5252
*
53-
* @return array
53+
* @return array<int, string>
5454
*
5555
* @throws LogicException
5656
*/
@@ -102,9 +102,9 @@ public function __clone()
102102
*
103103
* @param string $logLevel
104104
*
105-
* @return CommandInterface
105+
* @return static
106106
*/
107-
public function logLevel(string $logLevel): CommandInterface
107+
public function logLevel(string $logLevel): static
108108
{
109109
return $this->addOption('-v', $logLevel);
110110
}
@@ -114,11 +114,11 @@ public function logLevel(string $logLevel): CommandInterface
114114
*
115115
* @param boolean $flag
116116
*
117-
* @return CommandInterface
117+
* @return static
118118
*/
119-
public function overwriteOutputFiles(bool $flag = true): CommandInterface
119+
public function overwriteOutputFiles(bool $flag = true): static
120120
{
121-
if (($optIndex = array_search($flag ? '-n' : '-y', $this->options)) !== false) {
121+
if (($optIndex = array_search($flag ? '-n' : '-y', $this->options, true)) !== false) {
122122
unset($this->options[$optIndex]);
123123
}
124124

@@ -128,19 +128,19 @@ public function overwriteOutputFiles(bool $flag = true): CommandInterface
128128
/**
129129
* Ignore unknown stream types.
130130
*
131-
* @return CommandInterface
131+
* @return static
132132
*/
133-
public function ignoreUnknownStreamTypes(): CommandInterface
133+
public function ignoreUnknownStreamTypes(): static
134134
{
135135
return $this->addOption('-ignore_unknown');
136136
}
137137

138138
/**
139139
* Print progress report.
140140
*
141-
* @return CommandInterface
141+
* @return static
142142
*/
143-
public function printProgressReport(): CommandInterface
143+
public function printProgressReport(): static
144144
{
145145
return $this->addOption('-stats');
146146
}
@@ -150,35 +150,35 @@ public function printProgressReport(): CommandInterface
150150
*
151151
* @param float $ratio
152152
*
153-
* @return CommandInterface
153+
* @return static
154154
*/
155-
public function maxErrorRate(float $ratio): CommandInterface
155+
public function maxErrorRate(float $ratio): static
156156
{
157-
return $this->addOption('-max_error_rate', $ratio);
157+
return $this->addOption('-max_error_rate', (string) $ratio);
158158
}
159159

160160
/**
161161
* Bits per raw sample.
162162
*
163163
* @param integer $number
164164
*
165-
* @return CommandInterface
165+
* @return static
166166
*/
167-
public function bitsPerRawSample(int $number): CommandInterface
167+
public function bitsPerRawSample(int $number): static
168168
{
169-
return $this->addOption('-bits_per_raw_sample', $number);
169+
return $this->addOption('-bits_per_raw_sample', (string) $number);
170170
}
171171

172172
/**
173173
* Volume.
174174
*
175175
* @param integer $volume
176176
*
177-
* @return CommandInterface
177+
* @return static
178178
*/
179-
public function volume(int $volume): CommandInterface
179+
public function volume(int $volume): static
180180
{
181-
return $this->addOption('-vol', $volume);
181+
return $this->addOption('-vol', (string) $volume);
182182
}
183183

184184
/**
@@ -190,7 +190,7 @@ public function volume(int $volume): CommandInterface
190190
*/
191191
public function addInput(string $filename): FileInterface
192192
{
193-
$file = new File($this, $filename, count($this->inputFiles), true);
193+
$file = new File($this, $filename, (string) count($this->inputFiles), true);
194194

195195
$this->inputFiles[] = $file;
196196

src/Command/CommandInterface.php

+16-16
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ interface CommandInterface extends BuilderInterface
1919
*
2020
* @param string $logLevel
2121
*
22-
* @return CommandInterface
22+
* @return static
2323
*/
24-
public function logLevel(string $logLevel): CommandInterface;
24+
public function logLevel(string $logLevel): static;
2525

2626
/**
2727
* Overwrite output files.
@@ -30,27 +30,27 @@ public function logLevel(string $logLevel): CommandInterface;
3030
*
3131
* @param boolean $flag
3232
*
33-
* @return CommandInterface
33+
* @return static
3434
*/
35-
public function overwriteOutputFiles(bool $flag = true): CommandInterface;
35+
public function overwriteOutputFiles(bool $flag = true): static;
3636

3737
/**
3838
* Ignore unknown stream types.
3939
*
4040
* Option: -ignore_unknown
4141
*
42-
* @return CommandInterface
42+
* @return static
4343
*/
44-
public function ignoreUnknownStreamTypes(): CommandInterface;
44+
public function ignoreUnknownStreamTypes(): static;
4545

4646
/**
4747
* Print progress report.
4848
*
4949
* Option: -stats
5050
*
51-
* @return CommandInterface
51+
* @return static
5252
*/
53-
public function printProgressReport(): CommandInterface;
53+
public function printProgressReport(): static;
5454

5555
/**
5656
* Max error rate.
@@ -59,9 +59,9 @@ public function printProgressReport(): CommandInterface;
5959
*
6060
* @param float $ratio
6161
*
62-
* @return CommandInterface
62+
* @return static
6363
*/
64-
public function maxErrorRate(float $ratio): CommandInterface;
64+
public function maxErrorRate(float $ratio): static;
6565

6666
/**
6767
* Bits per raw sample.
@@ -70,9 +70,9 @@ public function maxErrorRate(float $ratio): CommandInterface;
7070
*
7171
* @param integer $number
7272
*
73-
* @return CommandInterface
73+
* @return static
7474
*/
75-
public function bitsPerRawSample(int $number): CommandInterface;
75+
public function bitsPerRawSample(int $number): static;
7676

7777
/**
7878
* Volume.
@@ -81,9 +81,9 @@ public function bitsPerRawSample(int $number): CommandInterface;
8181
*
8282
* @param integer $volume
8383
*
84-
* @return CommandInterface
84+
* @return static
8585
*/
86-
public function volume(int $volume): CommandInterface;
86+
public function volume(int $volume): static;
8787

8888
/**
8989
* Add input file.
@@ -139,7 +139,7 @@ public function generateVideoFromPicture(string $filename, float $duration): Fil
139139
* @param string $name
140140
* @param string $argument
141141
*
142-
* @return CommandInterface
142+
* @return static
143143
*/
144-
public function addOption(string $name, string $argument = ''): CommandInterface;
144+
public function addOption(string $name, string $argument = ''): static;
145145
}

0 commit comments

Comments
 (0)