Skip to content

Commit

Permalink
[minor] add native return types (#269)
Browse files Browse the repository at this point in the history
  • Loading branch information
mremi authored Dec 23, 2021
1 parent 906c9e0 commit 67fdfd8
Show file tree
Hide file tree
Showing 61 changed files with 260 additions and 215 deletions.
12 changes: 8 additions & 4 deletions Check/CustomErrorPages.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Laminas\Diagnostics\Check\CheckInterface;
use Laminas\Diagnostics\Result\Failure;
use Laminas\Diagnostics\Result\ResultInterface;
use Laminas\Diagnostics\Result\Success;

/**
Expand Down Expand Up @@ -35,6 +36,9 @@ public function __construct(array $errorCodes, $path, $projectDir)
$this->projectDir = $projectDir;
}

/**
* @return ResultInterface
*/
public function check()
{
$dir = $this->getCustomTemplateDirectory();
Expand All @@ -55,15 +59,15 @@ public function check()
return new Success();
}

/**
* @return string
*/
public function getLabel()
{
return 'Custom error pages';
}

/**
* @return string
*/
private function getCustomTemplateDirectory()
private function getCustomTemplateDirectory(): string
{
if ($this->projectDir !== $this->path) {
return $this->path; // using custom directory
Expand Down
4 changes: 4 additions & 0 deletions Check/DoctrineDbal.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Doctrine\Persistence\ConnectionRegistry;
use Laminas\Diagnostics\Check\AbstractCheck;
use Laminas\Diagnostics\Result\ResultInterface;
use Laminas\Diagnostics\Result\Success;

class DoctrineDbal extends AbstractCheck
Expand All @@ -17,6 +18,9 @@ public function __construct(ConnectionRegistry $registry, $connectionName = null
$this->connectionName = $connectionName;
}

/**
* @return ResultInterface
*/
public function check()
{
$connection = $this->manager->getConnection($this->connectionName);
Expand Down
3 changes: 3 additions & 0 deletions Check/DoctrineDbalCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ public function __construct(ConnectionRegistry $manager, $connections)
}
}

/**
* @return array|\Traversable
*/
public function getChecks()
{
return $this->checks;
Expand Down
3 changes: 3 additions & 0 deletions Check/DoctrineMigrationsCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ public function __construct(
$this->migrations = $migrations;
}

/**
* @return array|\Traversable
*/
public function getChecks()
{
if (null === $this->checks) {
Expand Down
4 changes: 4 additions & 0 deletions Check/DoctrineMongoDb.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Doctrine\Bundle\MongoDBBundle\ManagerRegistry;
use Laminas\Diagnostics\Check\AbstractCheck;
use Laminas\Diagnostics\Result\Failure;
use Laminas\Diagnostics\Result\ResultInterface;
use Laminas\Diagnostics\Result\Success;
use MongoDB\Driver\Command;
use MongoDB\Driver\Exception\ConnectionException;
Expand All @@ -20,6 +21,9 @@ public function __construct(ManagerRegistry $registry, $connectionName = null)
$this->connectionName = $connectionName;
}

/**
* @return ResultInterface
*/
public function check()
{
$connection = $this->manager->getConnection($this->connectionName);
Expand Down
3 changes: 3 additions & 0 deletions Check/DoctrineMongoDbCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ public function __construct(ConnectionRegistry $manager, $connections)
}
}

/**
* @return array|\Traversable
*/
public function getChecks()
{
return $this->checks;
Expand Down
9 changes: 8 additions & 1 deletion Check/Expression.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Laminas\Diagnostics\Check\CheckInterface;
use Laminas\Diagnostics\Result\Failure;
use Laminas\Diagnostics\Result\ResultInterface;
use Laminas\Diagnostics\Result\Success;
use Laminas\Diagnostics\Result\Warning;
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
Expand Down Expand Up @@ -36,6 +37,9 @@ public function __construct($label, $warningCheck = null, $criticalCheck = null,
$this->criticalMessage = $criticalMessage;
}

/**
* @return ResultInterface
*/
public function check()
{
$language = $this->getExpressionLanguage();
Expand All @@ -51,12 +55,15 @@ public function check()
return new Success();
}

/**
* @return string
*/
public function getLabel()
{
return $this->label;
}

protected function getExpressionLanguage()
protected function getExpressionLanguage(): ExpressionLanguage
{
$language = new ExpressionLanguage();
$language->register(
Expand Down
3 changes: 3 additions & 0 deletions Check/ExpressionCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ public function __construct(array $configs)
}
}

/**
* @return array|\Traversable
*/
public function getChecks()
{
return $this->checks;
Expand Down
3 changes: 3 additions & 0 deletions Check/GuzzleHttpServiceCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ public function __construct(array $configs)
}
}

/**
* @return array|\Traversable
*/
public function getChecks()
{
return $this->checks;
Expand Down
3 changes: 3 additions & 0 deletions Check/HttpServiceCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public function __construct(array $configs)
}
}

/**
* @return array|\Traversable
*/
public function getChecks()
{
return $this->checks;
Expand Down
3 changes: 3 additions & 0 deletions Check/MemcacheCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public function __construct(array $configs)
}
}

/**
* @return array|\Traversable
*/
public function getChecks()
{
return $this->checks;
Expand Down
3 changes: 3 additions & 0 deletions Check/MemcachedCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public function __construct(array $configs)
}
}

/**
* @return array|\Traversable
*/
public function getChecks()
{
return $this->checks;
Expand Down
3 changes: 3 additions & 0 deletions Check/PdoConnectionCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ public function __construct(array $connections)
}
}

/**
* @return array|\Traversable
*/
public function getChecks()
{
return $this->checks;
Expand Down
3 changes: 3 additions & 0 deletions Check/PhpFlagsCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public function __construct(array $configs)
}
}

/**
* @return array|\Traversable
*/
public function getChecks()
{
return $this->checks;
Expand Down
3 changes: 3 additions & 0 deletions Check/PhpVersionCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public function __construct(array $configs)
}
}

/**
* @return array|\Traversable
*/
public function getChecks()
{
return $this->checks;
Expand Down
3 changes: 3 additions & 0 deletions Check/ProcessRunningCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ public function __construct($processes)
}
}

/**
* @return array|\Traversable
*/
public function getChecks()
{
return $this->checks;
Expand Down
3 changes: 3 additions & 0 deletions Check/RabbitMQCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ public function __construct(array $configs)
}
}

/**
* @return array|\Traversable
*/
public function getChecks()
{
return $this->checks;
Expand Down
5 changes: 4 additions & 1 deletion Check/RedisCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function __construct(array $configs)
}
}

private function parseDsn(array &$config)
private function parseDsn(array &$config): void
{
$config = \array_merge($config, \parse_url($config['dsn']));

Expand All @@ -45,6 +45,9 @@ private function parseDsn(array &$config)
}
}

/**
* @return array|\Traversable
*/
public function getChecks()
{
return $this->checks;
Expand Down
7 changes: 7 additions & 0 deletions Check/SymfonyRequirements.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Laminas\Diagnostics\Check\CheckInterface;
use Laminas\Diagnostics\Result\Failure;
use Laminas\Diagnostics\Result\ResultInterface;
use Laminas\Diagnostics\Result\Success;
use Laminas\Diagnostics\Result\Warning;

Expand All @@ -21,6 +22,9 @@ public function __construct($file)
require $file;
}

/**
* @return ResultInterface
*/
public function check()
{
$symfonyRequirements = new \SymfonyRequirements();
Expand All @@ -36,6 +40,9 @@ public function check()
return new Success();
}

/**
* @return string
*/
public function getLabel()
{
return 'Symfony2 Requirements';
Expand Down
17 changes: 10 additions & 7 deletions Check/SymfonyVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Laminas\Diagnostics\Check\CheckInterface;
use Laminas\Diagnostics\Result\Failure;
use Laminas\Diagnostics\Result\ResultInterface;
use Laminas\Diagnostics\Result\Success;
use Laminas\Diagnostics\Result\Warning;
use Symfony\Component\HttpClient\HttpClient;
Expand All @@ -20,6 +21,9 @@ class SymfonyVersion implements CheckInterface
const PACKAGIST_URL = 'https://packagist.org/packages/symfony/symfony.json';
const VERSION_CHECK_URL = 'https://symfony.com/releases/%s.json';

/**
* @return ResultInterface
*/
public function check()
{
$currentBranch = Kernel::MAJOR_VERSION.'.'.Kernel::MINOR_VERSION;
Expand Down Expand Up @@ -47,6 +51,9 @@ public function check()
return new Success(sprintf('Your current Symfony branch reaches it\'s end of life in %s.', $endOfLife));
}

/**
* @return string
*/
public function getLabel()
{
return 'Symfony version';
Expand All @@ -55,11 +62,9 @@ public function getLabel()
/**
* @param string $branch
*
* @return string
*
* @throws \Exception
*/
private function getLatestVersion($branch)
private function getLatestVersion($branch): string
{
$response = $this->getResponseAndDecode(self::PACKAGIST_URL);

Expand Down Expand Up @@ -96,13 +101,11 @@ function ($value) use ($branch) {
}

/**
* @param $url
*
* @return array
* @param string $url
*
* @throws \Exception
*/
private function getResponseAndDecode($url)
private function getResponseAndDecode($url): array
{
if (class_exists(HttpClient::class)) {
return HttpClient::create()->request('GET', $url)->toArray();
Expand Down
7 changes: 2 additions & 5 deletions Command/HealthCheckCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function __construct(ConsoleReporter $reporter, RawConsoleReporter $rawRe
parent::__construct($name);
}

protected function configure()
protected function configure(): void
{
$this
->setName('monitor:health')
Expand All @@ -53,10 +53,7 @@ protected function configure()
;
}

/**
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$failureCount = 0;

Expand Down
Loading

0 comments on commit 67fdfd8

Please sign in to comment.