From 8ec035c2cea3ef0f0dc69fe64c08edbe2aa747a4 Mon Sep 17 00:00:00 2001 From: Matthew Baggett Date: Mon, 31 Aug 2020 20:57:20 +0200 Subject: [PATCH] Make phpstan happier --- src/Controllers/Controller.php | 8 ++++---- src/Services/ConfigurationService.php | 14 ++++++++------ src/Workers/WorkerWorkItem.php | 4 ++-- tests/BaseTestCase.php | 16 +--------------- 4 files changed, 15 insertions(+), 27 deletions(-) diff --git a/src/Controllers/Controller.php b/src/Controllers/Controller.php index 560643a..0a082a1 100644 --- a/src/Controllers/Controller.php +++ b/src/Controllers/Controller.php @@ -4,7 +4,7 @@ namespace Benzine\Controllers; use Benzine\Controllers\Filters\Filter; use Benzine\Exceptions\FilterDecodeException; -use Benzine\ORM\Abstracts\Service; +use Benzine\ORM\Abstracts\AbstractService; use Monolog\Logger; use Slim\Psr7\Request; use Slim\Psr7\Response; @@ -12,7 +12,7 @@ use Slim\Psr7\Response; abstract class Controller { protected Logger $logger; - protected Service $service; + protected AbstractService $service; protected bool $apiExplorerEnabled = true; public function __construct(Logger $logger) @@ -21,12 +21,12 @@ abstract class Controller $this->logger->debug(sprintf('Entered Controller in %sms', number_format((microtime(true) - $_SERVER['REQUEST_TIME_FLOAT']) * 1000, 2))); } - public function getService(): Service + public function getService(): AbstractService { return $this->service; } - public function setService(Service $service): self + public function setService(AbstractService $service): self { $this->service = $service; diff --git a/src/Services/ConfigurationService.php b/src/Services/ConfigurationService.php index 752c6bc..906d7a6 100644 --- a/src/Services/ConfigurationService.php +++ b/src/Services/ConfigurationService.php @@ -83,13 +83,15 @@ class ConfigurationService protected function setupDefines(): void { - if (defined('APP_ROOT')) { - return; + if (!defined('APP_ROOT')) { + define('APP_ROOT', $this->appRoot); + } + if (!defined('APP_NAME')) { + define('APP_NAME', $this->get('application/name')); + } + if (!defined('APP_START')) { + define('APP_START', microtime(true)); } - - define('APP_ROOT', $this->appRoot); - define('APP_NAME', $this->get('application/name')); - define('APP_START', microtime(true)); } /** diff --git a/src/Workers/WorkerWorkItem.php b/src/Workers/WorkerWorkItem.php index 5dd3007..b2acb5c 100644 --- a/src/Workers/WorkerWorkItem.php +++ b/src/Workers/WorkerWorkItem.php @@ -2,7 +2,7 @@ namespace Benzine\Workers; -use Benzine\ORM\Abstracts\Model; +use Benzine\ORM\Abstracts\AbstractModel; class WorkerWorkItem { @@ -67,7 +67,7 @@ class WorkerWorkItem public function getKey(string $key) { - if ($this->data[$key] instanceof Model) { + if ($this->data[$key] instanceof AbstractModel) { $this->data[$key]->__setUp(); } diff --git a/tests/BaseTestCase.php b/tests/BaseTestCase.php index 22a66a3..8d9fb0c 100644 --- a/tests/BaseTestCase.php +++ b/tests/BaseTestCase.php @@ -11,26 +11,12 @@ abstract class BaseTestCase extends TestCase { // Set this to true if you want to see whats going on inside some unit tests.. public const DEBUG_MODE = false; - /** - * @see https://github.com/fzaninotto/Faker - * - * @var Generator - */ - private static $faker; - private $app; - - private $container; - - private $singleTestTime; - - private $waypoint_count; - private $waypoint_last_time; + private static Generator $faker; public function __construct($name = null, array $data = [], $dataName = '') { parent::__construct($name, $data, $dataName); - // @var \Slim\App $app // Force Kint into CLI mode. \Kint::$mode_default = \Kint::MODE_CLI;