Skip to content

Commit 8bb01f5

Browse files
author
Martin de Keijzer
committed
Fix code inspections
1 parent 18e9994 commit 8bb01f5

File tree

71 files changed

+264
-279
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+264
-279
lines changed

Broadcaster/AbstractSchedulerCommands.php

+17-17
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,24 @@ abstract class AbstractSchedulerCommands implements SchedulerCommandsInterface
2525
*
2626
* @var string|null
2727
*/
28-
protected $kernelEnvironment;
28+
protected ?string $kernelEnvironment;
2929

3030
/**
3131
* Directory to store FFMpeg logs
3232
*
3333
* @var string
3434
*/
35-
protected $logDirectoryFFMpeg = '';
35+
protected string $logDirectoryFFMpeg = '';
3636

3737
/**
3838
* @var bool Can the input be looped
3939
*/
40-
protected $looping = false;
40+
protected bool $looping = false;
4141

4242
/**
4343
* @var string
4444
*/
45-
protected $rootDir;
45+
protected string $rootDir;
4646

4747
/**
4848
* SchedulerCommands constructor.
@@ -60,7 +60,7 @@ public function __construct(Kernel $kernel)
6060
*
6161
* @throws \Exception
6262
*/
63-
public function startProcess($input, $output, $metadata): string
63+
public function startProcess(string $input, string $output, array $metadata): string
6464
{
6565
$meta = '';
6666
$metadata['env'] = $this->getKernelEnvironment();
@@ -76,7 +76,7 @@ public function startProcess($input, $output, $metadata): string
7676
* {@inheritdoc}
7777
* @throws LiveBroadcastException
7878
*/
79-
public function stopProcess($pid): string
79+
public function stopProcess(int $pid): string
8080
{
8181
throw new LiveBroadcastException('stopProcess Cannot be called on the abstract class');
8282
}
@@ -93,7 +93,7 @@ public function getRunningProcesses(): array
9393
/**
9494
* {@inheritdoc}
9595
*/
96-
public function getProcessId($processString): ?int
96+
public function getProcessId(string $processString): ?int
9797
{
9898
$pid = [];
9999
preg_match('/^\s*([\d]+)/', $processString, $pid);
@@ -107,7 +107,7 @@ public function getProcessId($processString): ?int
107107
/**
108108
* {@inheritdoc}
109109
*/
110-
public function getBroadcastId($processString): ?int
110+
public function getBroadcastId(string $processString): ?int
111111
{
112112
$value = $this->getMetadataValue($processString, self::METADATA_BROADCAST);
113113

@@ -117,7 +117,7 @@ public function getBroadcastId($processString): ?int
117117
/**
118118
* {@inheritdoc}
119119
*/
120-
public function getChannelId($processString): ?int
120+
public function getChannelId(string $processString): ?int
121121
{
122122
$value = $this->getMetadataValue($processString, self::METADATA_CHANNEL);
123123

@@ -127,7 +127,7 @@ public function getChannelId($processString): ?int
127127
/**
128128
* {@inheritdoc}
129129
*/
130-
public function getEnvironment($processString): ?string
130+
public function getEnvironment(string $processString): ?string
131131
{
132132
return $this->getMetadataValue($processString, self::METADATA_ENVIRONMENT);
133133
}
@@ -143,9 +143,9 @@ public function getKernelEnvironment(): ?string
143143
/**
144144
* @param string $directory
145145
*/
146-
public function setFFMpegLogDirectory($directory): void
146+
public function setFFMpegLogDirectory(string $directory): void
147147
{
148-
if (null === $directory || !is_writable($directory)) {
148+
if (!is_writable($directory)) {
149149
return;
150150
}
151151

@@ -155,9 +155,9 @@ public function setFFMpegLogDirectory($directory): void
155155
/**
156156
* @param bool $looping
157157
*/
158-
public function setLooping($looping): void
158+
public function setLooping(bool $looping): void
159159
{
160-
$this->looping = (bool) $looping;
160+
$this->looping = $looping;
161161
}
162162

163163
/**
@@ -179,7 +179,7 @@ public function isLooping(): bool
179179
*
180180
* @throws \Exception
181181
*/
182-
protected function execStreamCommand($input, $output, $meta): string
182+
protected function execStreamCommand(string $input, string $output, string $meta): string
183183
{
184184
$logFile = '/dev/null';
185185
$loop = '';
@@ -205,7 +205,7 @@ protected function execStreamCommand($input, $output, $meta): string
205205
*
206206
* @return array
207207
*/
208-
protected function readMetadata($processString): array
208+
protected function readMetadata(string $processString): array
209209
{
210210
$metadata = [];
211211
$processMetadata = [];
@@ -227,7 +227,7 @@ protected function readMetadata($processString): array
227227
*
228228
* @return mixed
229229
*/
230-
private function getMetadataValue($processString, $metadataKey)
230+
private function getMetadataValue(string $processString, string $metadataKey)
231231
{
232232
$metadata = $this->readMetadata($processString);
233233

Broadcaster/Linux/SchedulerCommands.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class SchedulerCommands extends AbstractSchedulerCommands
1717
/**
1818
* {@inheritdoc}
1919
*/
20-
public function stopProcess($pid): string
20+
public function stopProcess(int $pid): string
2121
{
2222
return exec(sprintf('kill %d', $pid));
2323
}

Broadcaster/RunningBroadcast.php

+10-10
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,22 @@ class RunningBroadcast
1818
/**
1919
* @var int
2020
*/
21-
private $broadcastId;
21+
private int $broadcastId;
2222

2323
/**
2424
* @var int
2525
*/
26-
private $processId;
26+
private int $processId;
2727

2828
/**
2929
* @var int
3030
*/
31-
private $channelId;
31+
private int $channelId;
3232

3333
/**
3434
* @var string
3535
*/
36-
private $environment;
36+
private string $environment;
3737

3838
/**
3939
* RunningBroadcast constructor.
@@ -43,12 +43,12 @@ class RunningBroadcast
4343
* @param int $channelId
4444
* @param string $environment
4545
*/
46-
public function __construct($broadcastId, $processId, $channelId, $environment)
46+
public function __construct(int $broadcastId, int $processId, int $channelId, string $environment)
4747
{
48-
$this->broadcastId = (int) $broadcastId;
49-
$this->processId = (int) $processId;
50-
$this->channelId = (int) $channelId;
51-
$this->environment = (string) $environment;
48+
$this->broadcastId = $broadcastId;
49+
$this->processId = $processId;
50+
$this->channelId = $channelId;
51+
$this->environment = $environment;
5252
}
5353

5454
/**
@@ -99,7 +99,7 @@ public function isBroadcasting(LiveBroadcast $broadcast, AbstractChannel $channe
9999
*
100100
* @return bool
101101
*/
102-
public function isValid($kernelEnvironment): bool
102+
public function isValid(string $kernelEnvironment): bool
103103
{
104104
return ($kernelEnvironment === $this->getEnvironment()) &&
105105
($this->getProcessId() !== 0) &&

Broadcaster/Scheduler.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -24,27 +24,27 @@ class Scheduler
2424
/**
2525
* @var ChannelValidatorService
2626
*/
27-
protected $validator;
27+
protected ChannelValidatorService $validator;
2828

2929
/**
3030
* @var BroadcastStarter
3131
*/
32-
protected $starter;
32+
protected BroadcastStarter $starter;
3333

3434
/**
3535
* @var BroadcastManager
3636
*/
37-
protected $broadcastManager;
37+
protected BroadcastManager $broadcastManager;
3838

3939
/**
4040
* @var SchedulerCommandsInterface
4141
*/
42-
protected $schedulerCommands;
42+
protected SchedulerCommandsInterface $schedulerCommands;
4343

4444
/**
4545
* @var LoggerInterface
4646
*/
47-
protected $logger;
47+
protected LoggerInterface $logger;
4848

4949
/**
5050
* Scheduler constructor
@@ -211,7 +211,7 @@ protected function getRunningBroadcasts(): array
211211
}
212212

213213
/**
214-
* Send end signals to channels where broadcasts ended
214+
* Send end signals to the channels where broadcasts ended
215215
*
216216
* @throws LiveBroadcastException
217217
* @throws \Exception

Broadcaster/SchedulerCommandsDetector.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class SchedulerCommandsDetector
2525
*
2626
* @return SchedulerCommandsInterface
2727
*/
28-
public static function createSchedulerCommands(Kernel $kernel, $ffmpegLogDirectory = null): SchedulerCommandsInterface
28+
public static function createSchedulerCommands(Kernel $kernel, ?string $ffmpegLogDirectory = null): SchedulerCommandsInterface
2929
{
3030
$osCode = strtoupper(substr(PHP_OS, 0, 3));
3131

Broadcaster/SchedulerCommandsInterface.php

+8-8
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ interface SchedulerCommandsInterface
1919
*
2020
* @return string
2121
*/
22-
public function startProcess($input, $output, $metadata): string;
22+
public function startProcess(string $input, string $output, array $metadata): string;
2323

2424
/**
2525
* @param int $pid
2626
*
2727
* @return string
2828
*/
29-
public function stopProcess($pid): string;
29+
public function stopProcess(int $pid): string;
3030

3131
/**
3232
* @return array
@@ -38,28 +38,28 @@ public function getRunningProcesses(): array;
3838
*
3939
* @return int|null
4040
*/
41-
public function getProcessId($processString): ?int;
41+
public function getProcessId(string $processString): ?int;
4242

4343
/**
4444
* @param string $processString
4545
*
4646
* @return int|null
4747
*/
48-
public function getBroadcastId($processString): ?int;
48+
public function getBroadcastId(string $processString): ?int;
4949

5050
/**
5151
* @param string $processString
5252
*
5353
* @return int|null
5454
*/
55-
public function getChannelId($processString): ?int;
55+
public function getChannelId(string $processString): ?int;
5656

5757
/**
5858
* @param string $processString
5959
*
6060
* @return string|null
6161
*/
62-
public function getEnvironment($processString): ?string;
62+
public function getEnvironment(string $processString): ?string;
6363

6464
/**
6565
* @return string|null
@@ -69,10 +69,10 @@ public function getKernelEnvironment(): ?string;
6969
/**
7070
* @param string $directory
7171
*/
72-
public function setFFMpegLogDirectory($directory);
72+
public function setFFMpegLogDirectory(string $directory);
7373

7474
/**
7575
* @param bool $looping
7676
*/
77-
public function setLooping($looping);
77+
public function setLooping(bool $looping);
7878
}

Broadcaster/Windows/SchedulerCommands.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class SchedulerCommands extends AbstractSchedulerCommands
1717
/**
1818
* {@inheritdoc}
1919
*/
20-
public function stopProcess($pid): string
20+
public function stopProcess(int $pid): string
2121
{
2222
return exec(sprintf('START /B TASKKILL /PID %d /T', $pid));
2323
}
@@ -41,7 +41,7 @@ public function getRunningProcesses(): array
4141
*
4242
* @return string
4343
*/
44-
protected function execStreamCommand($input, $output, $meta): string
44+
protected function execStreamCommand(string $input, string $output, string $meta): string
4545
{
4646
$loop = '';
4747

Entity/Channel/AbstractChannel.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ abstract class AbstractChannel
3030
* @ORM\Id
3131
* @ORM\GeneratedValue(strategy="IDENTITY")
3232
*/
33-
protected $channelId;
33+
protected ?int $channelId = null;
3434

3535
/**
3636
* @var string|null
@@ -39,14 +39,14 @@ abstract class AbstractChannel
3939
*
4040
* @Assert\NotBlank
4141
*/
42-
protected $channelName;
42+
protected ?string $channelName = null;
4343

4444
/**
4545
* @var bool
4646
*
4747
* @ORM\Column(name="is_healthy", type="boolean", options={"default": 0})
4848
*/
49-
protected $isHealthy = false;
49+
protected bool $isHealthy = false;
5050

5151
/**
5252
* @return int|null
@@ -65,11 +65,11 @@ public function getChannelName(): ?string
6565
}
6666

6767
/**
68-
* @param string $channelName
68+
* @param string|null $channelName
6969
*
7070
* @return $this
7171
*/
72-
public function setChannelName($channelName): self
72+
public function setChannelName(?string $channelName): self
7373
{
7474
$this->channelName = $channelName;
7575

@@ -107,7 +107,7 @@ public static function isEntityConfigured($configuration): bool
107107
return true;
108108
}
109109

110-
return true;
110+
return false;
111111
}
112112

113113
/**

0 commit comments

Comments
 (0)