Skip to content

Commit

Permalink
Fix code inspections
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin de Keijzer committed Mar 3, 2022
1 parent 18e9994 commit 8bb01f5
Show file tree
Hide file tree
Showing 71 changed files with 264 additions and 279 deletions.
34 changes: 17 additions & 17 deletions Broadcaster/AbstractSchedulerCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,24 @@ abstract class AbstractSchedulerCommands implements SchedulerCommandsInterface
*
* @var string|null
*/
protected $kernelEnvironment;
protected ?string $kernelEnvironment;

/**
* Directory to store FFMpeg logs
*
* @var string
*/
protected $logDirectoryFFMpeg = '';
protected string $logDirectoryFFMpeg = '';

/**
* @var bool Can the input be looped
*/
protected $looping = false;
protected bool $looping = false;

/**
* @var string
*/
protected $rootDir;
protected string $rootDir;

/**
* SchedulerCommands constructor.
Expand All @@ -60,7 +60,7 @@ public function __construct(Kernel $kernel)
*
* @throws \Exception
*/
public function startProcess($input, $output, $metadata): string
public function startProcess(string $input, string $output, array $metadata): string
{
$meta = '';
$metadata['env'] = $this->getKernelEnvironment();
Expand All @@ -76,7 +76,7 @@ public function startProcess($input, $output, $metadata): string
* {@inheritdoc}
* @throws LiveBroadcastException
*/
public function stopProcess($pid): string
public function stopProcess(int $pid): string
{
throw new LiveBroadcastException('stopProcess Cannot be called on the abstract class');
}
Expand All @@ -93,7 +93,7 @@ public function getRunningProcesses(): array
/**
* {@inheritdoc}
*/
public function getProcessId($processString): ?int
public function getProcessId(string $processString): ?int
{
$pid = [];
preg_match('/^\s*([\d]+)/', $processString, $pid);
Expand All @@ -107,7 +107,7 @@ public function getProcessId($processString): ?int
/**
* {@inheritdoc}
*/
public function getBroadcastId($processString): ?int
public function getBroadcastId(string $processString): ?int
{
$value = $this->getMetadataValue($processString, self::METADATA_BROADCAST);

Expand All @@ -117,7 +117,7 @@ public function getBroadcastId($processString): ?int
/**
* {@inheritdoc}
*/
public function getChannelId($processString): ?int
public function getChannelId(string $processString): ?int
{
$value = $this->getMetadataValue($processString, self::METADATA_CHANNEL);

Expand All @@ -127,7 +127,7 @@ public function getChannelId($processString): ?int
/**
* {@inheritdoc}
*/
public function getEnvironment($processString): ?string
public function getEnvironment(string $processString): ?string
{
return $this->getMetadataValue($processString, self::METADATA_ENVIRONMENT);
}
Expand All @@ -143,9 +143,9 @@ public function getKernelEnvironment(): ?string
/**
* @param string $directory
*/
public function setFFMpegLogDirectory($directory): void
public function setFFMpegLogDirectory(string $directory): void
{
if (null === $directory || !is_writable($directory)) {
if (!is_writable($directory)) {
return;
}

Expand All @@ -155,9 +155,9 @@ public function setFFMpegLogDirectory($directory): void
/**
* @param bool $looping
*/
public function setLooping($looping): void
public function setLooping(bool $looping): void
{
$this->looping = (bool) $looping;
$this->looping = $looping;
}

/**
Expand All @@ -179,7 +179,7 @@ public function isLooping(): bool
*
* @throws \Exception
*/
protected function execStreamCommand($input, $output, $meta): string
protected function execStreamCommand(string $input, string $output, string $meta): string
{
$logFile = '/dev/null';
$loop = '';
Expand All @@ -205,7 +205,7 @@ protected function execStreamCommand($input, $output, $meta): string
*
* @return array
*/
protected function readMetadata($processString): array
protected function readMetadata(string $processString): array
{
$metadata = [];
$processMetadata = [];
Expand All @@ -227,7 +227,7 @@ protected function readMetadata($processString): array
*
* @return mixed
*/
private function getMetadataValue($processString, $metadataKey)
private function getMetadataValue(string $processString, string $metadataKey)
{
$metadata = $this->readMetadata($processString);

Expand Down
2 changes: 1 addition & 1 deletion Broadcaster/Linux/SchedulerCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class SchedulerCommands extends AbstractSchedulerCommands
/**
* {@inheritdoc}
*/
public function stopProcess($pid): string
public function stopProcess(int $pid): string
{
return exec(sprintf('kill %d', $pid));
}
Expand Down
20 changes: 10 additions & 10 deletions Broadcaster/RunningBroadcast.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,22 @@ class RunningBroadcast
/**
* @var int
*/
private $broadcastId;
private int $broadcastId;

/**
* @var int
*/
private $processId;
private int $processId;

/**
* @var int
*/
private $channelId;
private int $channelId;

/**
* @var string
*/
private $environment;
private string $environment;

/**
* RunningBroadcast constructor.
Expand All @@ -43,12 +43,12 @@ class RunningBroadcast
* @param int $channelId
* @param string $environment
*/
public function __construct($broadcastId, $processId, $channelId, $environment)
public function __construct(int $broadcastId, int $processId, int $channelId, string $environment)
{
$this->broadcastId = (int) $broadcastId;
$this->processId = (int) $processId;
$this->channelId = (int) $channelId;
$this->environment = (string) $environment;
$this->broadcastId = $broadcastId;
$this->processId = $processId;
$this->channelId = $channelId;
$this->environment = $environment;
}

/**
Expand Down Expand Up @@ -99,7 +99,7 @@ public function isBroadcasting(LiveBroadcast $broadcast, AbstractChannel $channe
*
* @return bool
*/
public function isValid($kernelEnvironment): bool
public function isValid(string $kernelEnvironment): bool
{
return ($kernelEnvironment === $this->getEnvironment()) &&
($this->getProcessId() !== 0) &&
Expand Down
12 changes: 6 additions & 6 deletions Broadcaster/Scheduler.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,27 @@ class Scheduler
/**
* @var ChannelValidatorService
*/
protected $validator;
protected ChannelValidatorService $validator;

/**
* @var BroadcastStarter
*/
protected $starter;
protected BroadcastStarter $starter;

/**
* @var BroadcastManager
*/
protected $broadcastManager;
protected BroadcastManager $broadcastManager;

/**
* @var SchedulerCommandsInterface
*/
protected $schedulerCommands;
protected SchedulerCommandsInterface $schedulerCommands;

/**
* @var LoggerInterface
*/
protected $logger;
protected LoggerInterface $logger;

/**
* Scheduler constructor
Expand Down Expand Up @@ -211,7 +211,7 @@ protected function getRunningBroadcasts(): array
}

/**
* Send end signals to channels where broadcasts ended
* Send end signals to the channels where broadcasts ended
*
* @throws LiveBroadcastException
* @throws \Exception
Expand Down
2 changes: 1 addition & 1 deletion Broadcaster/SchedulerCommandsDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class SchedulerCommandsDetector
*
* @return SchedulerCommandsInterface
*/
public static function createSchedulerCommands(Kernel $kernel, $ffmpegLogDirectory = null): SchedulerCommandsInterface
public static function createSchedulerCommands(Kernel $kernel, ?string $ffmpegLogDirectory = null): SchedulerCommandsInterface
{
$osCode = strtoupper(substr(PHP_OS, 0, 3));

Expand Down
16 changes: 8 additions & 8 deletions Broadcaster/SchedulerCommandsInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ interface SchedulerCommandsInterface
*
* @return string
*/
public function startProcess($input, $output, $metadata): string;
public function startProcess(string $input, string $output, array $metadata): string;

/**
* @param int $pid
*
* @return string
*/
public function stopProcess($pid): string;
public function stopProcess(int $pid): string;

/**
* @return array
Expand All @@ -38,28 +38,28 @@ public function getRunningProcesses(): array;
*
* @return int|null
*/
public function getProcessId($processString): ?int;
public function getProcessId(string $processString): ?int;

/**
* @param string $processString
*
* @return int|null
*/
public function getBroadcastId($processString): ?int;
public function getBroadcastId(string $processString): ?int;

/**
* @param string $processString
*
* @return int|null
*/
public function getChannelId($processString): ?int;
public function getChannelId(string $processString): ?int;

/**
* @param string $processString
*
* @return string|null
*/
public function getEnvironment($processString): ?string;
public function getEnvironment(string $processString): ?string;

/**
* @return string|null
Expand All @@ -69,10 +69,10 @@ public function getKernelEnvironment(): ?string;
/**
* @param string $directory
*/
public function setFFMpegLogDirectory($directory);
public function setFFMpegLogDirectory(string $directory);

/**
* @param bool $looping
*/
public function setLooping($looping);
public function setLooping(bool $looping);
}
4 changes: 2 additions & 2 deletions Broadcaster/Windows/SchedulerCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class SchedulerCommands extends AbstractSchedulerCommands
/**
* {@inheritdoc}
*/
public function stopProcess($pid): string
public function stopProcess(int $pid): string
{
return exec(sprintf('START /B TASKKILL /PID %d /T', $pid));
}
Expand All @@ -41,7 +41,7 @@ public function getRunningProcesses(): array
*
* @return string
*/
protected function execStreamCommand($input, $output, $meta): string
protected function execStreamCommand(string $input, string $output, string $meta): string
{
$loop = '';

Expand Down
12 changes: 6 additions & 6 deletions Entity/Channel/AbstractChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ abstract class AbstractChannel
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
protected $channelId;
protected ?int $channelId = null;

/**
* @var string|null
Expand All @@ -39,14 +39,14 @@ abstract class AbstractChannel
*
* @Assert\NotBlank
*/
protected $channelName;
protected ?string $channelName = null;

/**
* @var bool
*
* @ORM\Column(name="is_healthy", type="boolean", options={"default": 0})
*/
protected $isHealthy = false;
protected bool $isHealthy = false;

/**
* @return int|null
Expand All @@ -65,11 +65,11 @@ public function getChannelName(): ?string
}

/**
* @param string $channelName
* @param string|null $channelName
*
* @return $this
*/
public function setChannelName($channelName): self
public function setChannelName(?string $channelName): self
{
$this->channelName = $channelName;

Expand Down Expand Up @@ -107,7 +107,7 @@ public static function isEntityConfigured($configuration): bool
return true;
}

return true;
return false;
}

/**
Expand Down
Loading

0 comments on commit 8bb01f5

Please sign in to comment.