From 3ebd91d2ef6b3b369e4f2f92ee7d46055e58242f Mon Sep 17 00:00:00 2001 From: Abel Hoogeveen Date: Fri, 31 Jul 2020 14:29:37 +0200 Subject: [PATCH 1/4] Updated PHPUnit to ^9 and vfsStream to ~1.6.0. - This resulted in some changes needing to be made in the test folder. All tests have been updated to work with these updated dependencies. - Also, PHP 7.1 is no longer supported. - psr/log is no longer a dependency of Core --- composer.json | 7 ++--- test/autoload.php | 4 +-- test/bootstrap.php | 5 ++- test/core/abstract.coreTestAbstract.php | 5 ++- test/core/core_configTest.php | 7 +++-- test/core/core_configuratorTest.php | 19 +++++------ test/core/core_eventsTest.php | 13 ++++---- test/core/core_exceptionTest.php | 42 +++++++------------------ test/core/core_factoryTest.php | 14 ++++----- test/core/core_helperTest.php | 4 +-- test/core/core_libraryTest.php | 17 +++++----- test/core/core_loggerTest.php | 6 ++-- test/core/core_pluginsTest.php | 21 +++++++------ test/phpunit.xml | 7 ----- 14 files changed, 72 insertions(+), 99 deletions(-) diff --git a/composer.json b/composer.json index a505137..d2aa1b5 100644 --- a/composer.json +++ b/composer.json @@ -14,12 +14,11 @@ } ], "require": { - "php": ">=7.1.0", - "psr/log": "~1.1.0" + "php": ">=7.2.0" }, "require-dev": { - "phpunit/phpunit": "^7", - "mikey179/vfsstream": "1.1.*" + "phpunit/phpunit": "^9", + "mikey179/vfsstream": "~1.6.0" }, "autoload": { "psr-4": { diff --git a/test/autoload.php b/test/autoload.php index 0002526..859a051 100644 --- a/test/autoload.php +++ b/test/autoload.php @@ -31,11 +31,9 @@ * @link http://techfuze.net/fuzeworks * @since Version 0.0.1 * - * @version Version 1.2.0 + * @version Version 1.3.0 */ -use FuzeWorks\Config; -use FuzeWorks\Core; use FuzeWorks\Logger; // First set the working directory diff --git a/test/bootstrap.php b/test/bootstrap.php index 0ef3c1c..d5f961d 100644 --- a/test/bootstrap.php +++ b/test/bootstrap.php @@ -31,7 +31,7 @@ * @link http://techfuze.net/fuzeworks * @since Version 1.2.0 * - * @version Version 1.2.0 + * @version Version 1.3.0 */ require_once(dirname(__DIR__) . '/vendor/autoload.php'); @@ -45,9 +45,8 @@ $configurator->setLogDirectory(__DIR__ . '/temp'); $configurator->setTimeZone('Europe/Amsterdam'); // Debug related -$configurator->enableDebugMode(true); +$configurator->enableDebugMode(); $configurator->setDebugAddress('ALL'); -//$configurator->setDebugEmail('example@mail.com'); $container = $configurator->createContainer(); return $container; diff --git a/test/core/abstract.coreTestAbstract.php b/test/core/abstract.coreTestAbstract.php index af4db16..f9901cd 100644 --- a/test/core/abstract.coreTestAbstract.php +++ b/test/core/abstract.coreTestAbstract.php @@ -31,14 +31,13 @@ * @link http://techfuze.net/fuzeworks * @since Version 0.0.1 * - * @version Version 1.2.0 + * @version Version 1.3.0 */ use PHPUnit\Framework\TestCase; use FuzeWorks\Events; use FuzeWorks\Factory; use FuzeWorks\Core; use FuzeWorks\Config; -use FuzeWorks\LoggerTracyBridge; /** * Class CoreTestAbstract. @@ -50,7 +49,7 @@ abstract class CoreTestAbstract extends TestCase /** * Reset multiple components to their original state before running the next test */ - public function tearDown() + public function tearDown(): void { // Clear all events created by tests Events::$listeners = []; diff --git a/test/core/core_configTest.php b/test/core/core_configTest.php index 83003cb..034414e 100644 --- a/test/core/core_configTest.php +++ b/test/core/core_configTest.php @@ -31,11 +31,12 @@ * @link http://techfuze.net/fuzeworks * @since Version 0.0.1 * - * @version Version 1.2.0 + * @version Version 1.3.0 */ use FuzeWorks\Config; use FuzeWorks\Event\ConfigGetEvent; +use FuzeWorks\Exception\ConfigException; use FuzeWorks\Priority; use FuzeWorks\Events; @@ -53,7 +54,7 @@ class configTest extends CoreTestAbstract */ protected $config; - public function setUp() + public function setUp(): void { $this->config = new Config(); } @@ -90,10 +91,10 @@ class configTest extends CoreTestAbstract /** * @depends testLoadConfig * @covers ::loadConfigFile - * @expectedException FuzeWorks\Exception\ConfigException */ public function testFileNotFound() { + $this->expectException(ConfigException::class); $this->config->getConfig('notFound'); } diff --git a/test/core/core_configuratorTest.php b/test/core/core_configuratorTest.php index 3ec6063..53a55c8 100644 --- a/test/core/core_configuratorTest.php +++ b/test/core/core_configuratorTest.php @@ -31,11 +31,12 @@ * @link http://techfuze.net/fuzeworks * @since Version 1.2.0 * - * @version Version 1.2.0 + * @version Version 1.3.0 */ use FuzeWorks\Configurator; use FuzeWorks\Core; +use FuzeWorks\Exception\ConfiguratorException; use FuzeWorks\Factory; use FuzeWorks\iComponent; use FuzeWorks\Logger; @@ -54,7 +55,7 @@ class configuratorTest extends CoreTestAbstract */ protected $configurator; - public function setUp() + public function setUp(): void { $this->configurator = new Configurator; $this->configurator->setTempDirectory(dirname(__DIR__) . '/temp'); @@ -62,7 +63,7 @@ class configuratorTest extends CoreTestAbstract $this->configurator->setTimeZone('Europe/Amsterdam'); } - public function tearDown() + public function tearDown(): void { parent::tearDown(); @@ -132,7 +133,6 @@ class configuratorTest extends CoreTestAbstract * @depends testAddComponent * @covers ::addComponent * @covers ::createContainer - * @expectedException FuzeWorks\Exception\ConfiguratorException */ public function testAddComponentFail() { @@ -142,6 +142,7 @@ class configuratorTest extends CoreTestAbstract $this->configurator->addComponent($component); // Create container and fail + $this->expectException(ConfiguratorException::class); $this->configurator->createContainer(); } @@ -175,11 +176,11 @@ class configuratorTest extends CoreTestAbstract /** * @depends testSetLogDirectory * @covers ::setLogDirectory - * @expectedException \FuzeWorks\Exception\InvalidArgumentException */ public function testSetLogDirectoryNotDirectory() { // Set the directory + $this->expectException(\FuzeWorks\Exception\InvalidArgumentException::class); $this->configurator->setLogDirectory('not_exist'); } @@ -204,11 +205,11 @@ class configuratorTest extends CoreTestAbstract /** * @depends testSetTempDirectory * @covers ::setTempDirectory - * @expectedException \FuzeWorks\Exception\InvalidArgumentException */ public function testSetTempDirectoryNotDirectory() { // Set the directory + $this->expectException(\FuzeWorks\Exception\InvalidArgumentException::class); $this->configurator->setTempDirectory('not_exist'); } @@ -245,10 +246,10 @@ class configuratorTest extends CoreTestAbstract /** * @depends testAddComponentDirectory * @covers ::addDirectory - * @expectedException \FuzeWorks\Exception\InvalidArgumentException */ public function testAddComponentDirectoryNotExist() { + $this->expectException(\FuzeWorks\Exception\InvalidArgumentException::class); $this->configurator->addDirectory('not_exist', 'irrelevant'); } @@ -342,11 +343,11 @@ class configuratorTest extends CoreTestAbstract /** * @depends testSetTimezone - * @expectedException \FuzeWorks\Exception\InvalidArgumentException * @covers ::setTimeZone */ public function testSetTimezoneInvalid() { + $this->expectException(\FuzeWorks\Exception\InvalidArgumentException::class); $this->configurator->setTimeZone('Europe/Amsterdamned'); } @@ -472,10 +473,10 @@ class configuratorTest extends CoreTestAbstract /** * @depends testEnableDebugMode * @covers ::setDebugAddress - * @expectedException \FuzeWorks\Exception\InvalidArgumentException */ public function testSetDebugAddressInvalidArgument() { + $this->expectException(\FuzeWorks\Exception\InvalidArgumentException::class); $this->configurator->setDebugAddress(null); } } diff --git a/test/core/core_eventsTest.php b/test/core/core_eventsTest.php index c9d1903..f29f2ed 100644 --- a/test/core/core_eventsTest.php +++ b/test/core/core_eventsTest.php @@ -31,11 +31,12 @@ * @link http://techfuze.net/fuzeworks * @since Version 0.0.1 * - * @version Version 1.2.0 + * @version Version 1.3.0 */ use FuzeWorks\Event; use FuzeWorks\Events; +use FuzeWorks\Exception\EventException; use FuzeWorks\Priority; /** @@ -145,21 +146,21 @@ class eventsTest extends CoreTestAbstract /** * @depends testFireEvent - * @expectedException FuzeWorks\Exception\EventException * @covers ::fireEvent */ public function testInvalidTypeEvent() { + $this->expectException(EventException::class); Events::fireEvent(array('x', 'y', 'z')); } /** * @depends testFireEvent * @covers ::fireEvent - * @expectedException FuzeWorks\Exception\EventException */ public function testInvalidClassEvent() { + $this->expectException(EventException::class); Events::fireEvent('nonExistingEvent', 'x', 'y', 'z'); } @@ -185,30 +186,30 @@ class eventsTest extends CoreTestAbstract /** * @depends testAddAndRemoveListener * @covers ::addListener - * @expectedException FuzeWorks\Exception\EventException */ public function testAddInvalidPriorityListener() { + $this->expectException(EventException::class); Events::addListener(function($event){}, 'mockEvent', 99); } /** * @depends testAddAndRemoveListener * @covers ::addListener - * @expectedException FuzeWorks\Exception\EventException */ public function testAddInvalidNameListener() { + $this->expectException(EventException::class); Events::addListener(function($e) {}, '', Priority::NORMAL); } /** * @depends testAddAndRemoveListener * @covers ::removeListener - * @expectedException FuzeWorks\Exception\EventException */ public function testRemoveInvalidPriorityListener() { + $this->expectException(EventException::class); Events::removeListener(function($event){}, 'mockEvent', 99); } diff --git a/test/core/core_exceptionTest.php b/test/core/core_exceptionTest.php index f09786c..e99fc3d 100644 --- a/test/core/core_exceptionTest.php +++ b/test/core/core_exceptionTest.php @@ -31,7 +31,7 @@ * @link http://techfuze.net/fuzeworks * @since Version 0.0.1 * - * @version Version 1.2.0 + * @version Version 1.3.0 */ use FuzeWorks\Exception\Exception; @@ -53,83 +53,63 @@ use FuzeWorks\Exception\ConfiguratorException; class exceptionTestTest extends CoreTestAbstract { - /** - * @expectedException FuzeWorks\Exception\Exception - */ public function testException() { + $this->expectException(Exception::class); throw new Exception("Exception Test Run", 1); } - /** - * @expectedException FuzeWorks\Exception\CoreException - */ public function testCoreException() { + $this->expectException(CoreException::class); throw new CoreException("Exception Test Run", 1); } - /** - * @expectedException FuzeWorks\Exception\ConfigException - */ public function testConfigException() { + $this->expectException(ConfigException::class); throw new ConfigException("Exception Test Run", 1); } - /** - * @expectedException FuzeWorks\Exception\EventException - */ public function testEventException() { + $this->expectException(EventException::class); throw new EventException("Exception Test Run", 1); } - /** - * @expectedException FuzeWorks\Exception\FactoryException - */ public function testFactoryException() { + $this->expectException(FactoryException::class); throw new FactoryException("Exception Test Run", 1); } - /** - * @expectedException FuzeWorks\Exception\HelperException - */ public function testHelperException() { + $this->expectException(HelperException::class); throw new HelperException("Exception Test Run", 1); } - /** - * @expectedException FuzeWorks\Exception\InvalidArgumentException - */ public function testInvalidArgumentException() { + $this->expectException(InvalidArgumentException::class); throw new InvalidArgumentException("Exception Test Run", 1); } - /** - * @expectedException FuzeWorks\Exception\LibraryException - */ public function testLibraryException() { + $this->expectException(LibraryException::class); throw new LibraryException("Exception Test Run", 1); } - /** - * @expectedException FuzeWorks\Exception\LoggerException - */ public function testLoggerException() { + $this->expectException(LoggerException::class); throw new LoggerException("Exception Test Run", 1); } - /** - * @expectedException FuzeWorks\Exception\ConfiguratorException - */ public function testConfiguratorException() { + $this->expectException(ConfiguratorException::class); throw new ConfiguratorException("Exception Test Run", 1); } diff --git a/test/core/core_factoryTest.php b/test/core/core_factoryTest.php index df25b51..2febdc1 100644 --- a/test/core/core_factoryTest.php +++ b/test/core/core_factoryTest.php @@ -31,7 +31,7 @@ * @link http://techfuze.net/fuzeworks * @since Version 0.0.1 * - * @version Version 1.2.0 + * @version Version 1.3.0 */ use FuzeWorks\Factory; @@ -73,10 +73,10 @@ class factoryTest extends CoreTestAbstract /** * @depends testGetInstance * @covers ::getInstance - * @expectedException \FuzeWorks\Exception\FactoryException */ public function testGetInstanceNotFound() { + $this->expectException(FactoryException::class); Factory::getInstance('NotFound'); } @@ -183,7 +183,6 @@ class factoryTest extends CoreTestAbstract /** * @depends testCanLoadFactory * @covers ::cloneInstance - * @expectedException FuzeWorks\Exception\FactoryException */ public function testCloneInstanceWrongClassname() { @@ -191,6 +190,7 @@ class factoryTest extends CoreTestAbstract $factory = new Factory; // Attempt + $this->expectException(FactoryException::class); $factory->cloneInstance('fake'); } @@ -223,7 +223,6 @@ class factoryTest extends CoreTestAbstract /** * @depends testNewFactoryInstance * @covers ::newInstance - * @expectedException FuzeWorks\Exception\FactoryException */ public function testFactoryNewInstanceNotExist() { @@ -231,13 +230,13 @@ class factoryTest extends CoreTestAbstract $factory = new Factory; // First, it does not exist + $this->expectException(FactoryException::class); $factory->newInstance('fake'); } /** * @depends testNewFactoryInstance * @covers ::newInstance - * @expectedException FuzeWorks\Exception\FactoryException */ public function testFactoryNewInstanceWrongNamespace() { @@ -245,6 +244,7 @@ class factoryTest extends CoreTestAbstract $factory = new Factory; // Second, it just fails + $this->expectException(FactoryException::class); $factory->newInstance('helpers', 'Test\\'); } @@ -278,7 +278,6 @@ class factoryTest extends CoreTestAbstract /** * @depends testRemoveInstance * @covers ::removeInstance - * @expectedException FuzeWorks\Exception\FactoryException */ public function testRemoveInstanceNotExist() { @@ -286,6 +285,7 @@ class factoryTest extends CoreTestAbstract $factory = new Factory; // Test + $this->expectException(FactoryException::class); $factory->removeInstance('fake'); } @@ -308,7 +308,7 @@ class factoryTest extends CoreTestAbstract $this->assertEquals(5, $factory->test); } - public function tearDown() + public function tearDown(): void { parent::tearDown(); diff --git a/test/core/core_helperTest.php b/test/core/core_helperTest.php index a86a64c..10c3a91 100644 --- a/test/core/core_helperTest.php +++ b/test/core/core_helperTest.php @@ -31,7 +31,7 @@ * @link http://techfuze.net/fuzeworks * @since Version 0.0.1 * - * @version Version 1.2.0 + * @version Version 1.3.0 */ use FuzeWorks\Priority; @@ -52,7 +52,7 @@ class helperTest extends CoreTestAbstract */ protected $helpers; - public function setUp() + public function setUp(): void { // Prepare class $this->helpers = new Helpers(); diff --git a/test/core/core_libraryTest.php b/test/core/core_libraryTest.php index 123513e..6eb12e1 100644 --- a/test/core/core_libraryTest.php +++ b/test/core/core_libraryTest.php @@ -31,10 +31,11 @@ * @link http://techfuze.net/fuzeworks * @since Version 0.0.1 * - * @version Version 1.2.0 + * @version Version 1.3.0 */ use FuzeWorks\Core; +use FuzeWorks\Exception\LibraryException; use FuzeWorks\Factory; use FuzeWorks\Libraries; @@ -52,7 +53,7 @@ class libraryTest extends CoreTestAbstract */ protected $libraries; - public function setUp() + public function setUp(): void { // Load new libraries class $this->libraries = new Libraries(); @@ -110,10 +111,10 @@ class libraryTest extends CoreTestAbstract * @depends testGetLibraryFromDirectory * @covers ::get * @covers ::initLibrary - * @expectedException FuzeWorks\Exception\LibraryException */ public function testGetLibraryFail() { + $this->expectException(LibraryException::class); $this->libraries->get('FailLoadLibrary'); } @@ -121,10 +122,10 @@ class libraryTest extends CoreTestAbstract * @depends testGetLibraryFromDirectory * @covers ::get * @covers ::initLibrary - * @expectedException FuzeWorks\Exception\LibraryException */ public function testGetLibraryNoName() { + $this->expectException(LibraryException::class); $this->libraries->get(''); } @@ -132,10 +133,10 @@ class libraryTest extends CoreTestAbstract * @depends testGetLibraryFromDirectory * @covers ::get * @covers ::initLibrary - * @expectedException FuzeWorks\Exception\LibraryException */ public function testGetLibraryNoClass() { + $this->expectException(LibraryException::class); $this->libraries->get('TestGetLibraryNoClass'); } @@ -188,10 +189,10 @@ class libraryTest extends CoreTestAbstract /** * @depends testAddLibraryClass * @covers ::addLibraryClass - * @expectedException \FuzeWorks\Exception\LibraryException */ public function testAddLibraryClassFail() { + $this->expectException(LibraryException::class); $this->libraries->addLibraryClass('LibraryClassFail', '\Case\Not\Exist'); } @@ -214,14 +215,14 @@ class libraryTest extends CoreTestAbstract /** * @depends testAddLibraryWithAutoloader * @covers ::initLibrary - * @expectedException \FuzeWorks\Exception\LibraryException */ public function testAddBadAutoloader() { + $this->expectException(LibraryException::class); $this->assertInstanceOf('Application\Library\TestAddBadAutoloader', $this->libraries->get('TestAddBadAutoloader')); } - public function tearDown() + public function tearDown(): void { parent::tearDown(); diff --git a/test/core/core_loggerTest.php b/test/core/core_loggerTest.php index 69f9577..25023d8 100644 --- a/test/core/core_loggerTest.php +++ b/test/core/core_loggerTest.php @@ -31,7 +31,7 @@ * @link http://techfuze.net/fuzeworks * @since Version 0.0.1 * - * @version Version 1.2.0 + * @version Version 1.3.0 */ use FuzeWorks\Events; @@ -51,7 +51,7 @@ class loggerTest extends CoreTestAbstract protected $output; - public function setUp() + public function setUp(): void { Factory::getInstance()->config->get('error')->fuzeworks_error_reporting = false; Logger::$logs = array(); @@ -211,7 +211,7 @@ class loggerTest extends CoreTestAbstract $this->assertFalse(Logger::isEnabled()); } - public function tearDown() + public function tearDown(): void { parent::tearDown(); diff --git a/test/core/core_pluginsTest.php b/test/core/core_pluginsTest.php index 29beb1a..6c3fd19 100644 --- a/test/core/core_pluginsTest.php +++ b/test/core/core_pluginsTest.php @@ -31,10 +31,11 @@ * @link http://techfuze.net/fuzeworks * @since Version 1.1.4 * - * @version Version 1.2.0 + * @version Version 1.3.0 */ use FuzeWorks\Core; +use FuzeWorks\Exception\PluginException; use FuzeWorks\Factory; use FuzeWorks\Plugins; @@ -52,7 +53,7 @@ class pluginTest extends CoreTestAbstract */ protected $plugins; - public function setUp() + public function setUp(): void { $this->plugins = new Plugins(); $this->plugins->init(); @@ -106,10 +107,10 @@ class pluginTest extends CoreTestAbstract /** * @depends testLoadPlugin * @covers ::get - * @expectedException FuzeWorks\Exception\PluginException */ public function testMissingHeader() { + $this->expectException(PluginException::class); $this->plugins->get('testMissingHeader'); } @@ -134,39 +135,39 @@ class pluginTest extends CoreTestAbstract /** * @depends testLoadPlugin * @covers ::get - * @expectedException FuzeWorks\Exception\PluginException */ public function testMissingPlugin() { + $this->expectException(PluginException::class); $this->plugins->get('testMissingPlugin'); } /** * @depends testMissingPlugin * @covers ::get - * @expectedException FuzeWorks\Exception\PluginException */ public function testLoadHeaderNotIPluginHeader() { + $this->expectException(PluginException::class); $this->plugins->get('TestLoadHeaderNotIPluginHeader'); } /** * @depends testLoadPlugin * @covers ::get - * @expectedException FuzeWorks\Exception\PluginException */ public function testInvalidClass() { + $this->expectException(PluginException::class); $this->plugins->get('testInvalidClass'); } /** * @covers ::get - * @expectedException FuzeWorks\Exception\PluginException */ public function testGetMissingName() { + $this->expectException(PluginException::class); $this->plugins->get(''); } @@ -174,12 +175,12 @@ class pluginTest extends CoreTestAbstract * @depends testLoadPlugin * @covers ::get * @covers ::loadHeadersFromPluginPaths - * @expectedException FuzeWorks\Exception\PluginException */ public function testDisabledPlugin() { Factory::getInstance()->config->plugins->disabled_plugins = array('TestDisabledPlugin'); $this->plugins->loadHeadersFromPluginPaths(); + $this->expectException(PluginException::class); $this->plugins->get('testDisabledPlugin'); } @@ -187,16 +188,16 @@ class pluginTest extends CoreTestAbstract * @depends testLoadPlugin * @covers ::get * @covers ::loadHeadersFromPluginPaths - * @expectedException FuzeWorks\Exception\PluginException */ public function testRunInvalidDirectory() { $this->plugins->addComponentPath('exists_not'); $this->plugins->loadHeadersFromPluginPaths(); + $this->expectException(PluginException::class); $this->plugins->get('testRunInvalidDirectory'); } - public function tearDown() + public function tearDown(): void { parent::tearDown(); diff --git a/test/phpunit.xml b/test/phpunit.xml index 14749cd..5a152b6 100644 --- a/test/phpunit.xml +++ b/test/phpunit.xml @@ -15,13 +15,6 @@ - - - - - - - ../ From 8ce3630714267cd2766783e258cf0f85fea31be3 Mon Sep 17 00:00:00 2001 From: Abel Hoogeveen Date: Wed, 24 Nov 2021 17:43:00 +0100 Subject: [PATCH 2/4] PHP 8.0 compatibility update --- composer.json | 12 ++++------- src/FuzeWorks/Configurator.php | 4 ++-- src/FuzeWorks/Factory.php | 5 ++++- test/phpunit.xml | 38 +++++++++++++--------------------- 4 files changed, 24 insertions(+), 35 deletions(-) diff --git a/composer.json b/composer.json index d2aa1b5..e8c9b82 100644 --- a/composer.json +++ b/composer.json @@ -1,20 +1,16 @@ { "name": "fuzeworks/core", "description": "FuzeWorks Framework Core", - "homepage": "https://techfuze.net/fuzeworks", + "homepage": "https://i15.nl/fuzeworks", "license": ["MIT"], "authors": [ { - "name": "TechFuze", - "homepage": "https://techfuze.net" - }, - { - "name": "FuzeWorks Community", - "homepage": "https://techfuze.net/fuzeworks/contributors" + "name": "Abel Hoogeveen", + "homepage": "https://i15.nl" } ], "require": { - "php": ">=7.2.0" + "php": ">=7.4.0" }, "require-dev": { "phpunit/phpunit": "^9", diff --git a/src/FuzeWorks/Configurator.php b/src/FuzeWorks/Configurator.php index 9e72214..90e6640 100644 --- a/src/FuzeWorks/Configurator.php +++ b/src/FuzeWorks/Configurator.php @@ -31,7 +31,7 @@ * @link http://techfuze.net/fuzeworks * @since Version 0.0.1 * - * @version Version 1.2.0 + * @version Version 1.3.0 */ namespace FuzeWorks; @@ -345,7 +345,7 @@ class Configurator Core::$logDir = $this->parameters['logDir']; // Then prepare the debugger - $debug = ($this->parameters['debugEnabled'] && $this->parameters['debugMatch'] ? true : false); + $debug = $this->parameters['debugEnabled'] && $this->parameters['debugMatch']; // Then load the framework $container = Core::init(); diff --git a/src/FuzeWorks/Factory.php b/src/FuzeWorks/Factory.php index 37e1892..25b6526 100644 --- a/src/FuzeWorks/Factory.php +++ b/src/FuzeWorks/Factory.php @@ -31,7 +31,7 @@ * @link http://techfuze.net/fuzeworks * @since Version 0.0.1 * - * @version Version 1.2.0 + * @version Version 1.3.0 */ namespace FuzeWorks; @@ -173,6 +173,9 @@ class Factory // Initialize all components foreach ($this as $component) { + if (!is_object($component)) + continue; + if (method_exists($component, 'init')) $component->init(); } diff --git a/test/phpunit.xml b/test/phpunit.xml index 5a152b6..d37cfe4 100644 --- a/test/phpunit.xml +++ b/test/phpunit.xml @@ -1,29 +1,19 @@ - - + + + + + ../ + + + ../vendor/ + ../test/ + ../src/Layout/ + ../src/Config/ + + - + ./ - - - - ../ - - ../vendor/ - ../test/ - ../src/Layout/ - ../src/Config/ - - - \ No newline at end of file From 32420e4681fb7104c9f837b7b70d26236252095f Mon Sep 17 00:00:00 2001 From: Abel Hoogeveen Date: Wed, 24 Nov 2021 17:49:20 +0100 Subject: [PATCH 3/4] Updated drone to perform tests for PHP 7.4 and 8.0. --- .drone.yml | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/.drone.yml b/.drone.yml index a4fe468..ec6e2a6 100644 --- a/.drone.yml +++ b/.drone.yml @@ -8,12 +8,23 @@ steps: commands: - composer install - - name: phpunit - image: phpunit:7.3 + - name: php74test + image: registry.i15.nl/i15/fuzephp:7.4-alpine commands: + - docker-php-ext-enable xdebug + - vendor/bin/phpunit -c test/phpunit.xml + + - name: php80test + image: registry.i15.nl/i15/fuzephp:8.0-alpine + commands: + - docker-php-ext-enable xdebug - vendor/bin/phpunit -c test/phpunit.xml - name: coverage - image: phpunit:7.3 + image: registry.i15.nl/i15/fuzephp:8.0-alpine commands: - - vendor/bin/phpunit -c test/phpunit.xml --coverage-text \ No newline at end of file + - docker-php-ext-enable xdebug + - vendor/bin/phpunit -c test/phpunit.xml --coverage-text + +image_pull_secrets: + - dockerconfig \ No newline at end of file From 440964b375305f3a1933cddadf4897411b6abe4a Mon Sep 17 00:00:00 2001 From: Abel Hoogeveen Date: Wed, 24 Nov 2021 18:56:36 +0100 Subject: [PATCH 4/4] Resolved problems brought up by PhpStorm. Includes problems such as: - Grammar errors - Type, argument and return declarations - Redundant argument removal --- README.md | 2 +- src/FuzeWorks/ComponentPathsTrait.php | 12 +- src/FuzeWorks/Config.php | 12 +- src/FuzeWorks/ConfigORM/ConfigORM.php | 4 +- src/FuzeWorks/ConfigORM/ConfigORMAbstract.php | 20 +-- src/FuzeWorks/Configurator.php | 26 ++-- src/FuzeWorks/Core.php | 25 ++-- src/FuzeWorks/DeferredComponentClass.php | 10 +- src/FuzeWorks/Event.php | 6 +- src/FuzeWorks/Event/ConfigGetEvent.php | 6 +- src/FuzeWorks/Event/HaltExecutionEvent.php | 4 +- src/FuzeWorks/Event/HelperLoadEvent.php | 6 +- src/FuzeWorks/Event/PluginGetEvent.php | 14 +- src/FuzeWorks/Events.php | 10 +- src/FuzeWorks/Factory.php | 32 ++-- src/FuzeWorks/Helpers.php | 12 +- src/FuzeWorks/Libraries.php | 11 +- src/FuzeWorks/Logger.php | 139 ++++++++---------- src/FuzeWorks/Plugins.php | 20 +-- src/FuzeWorks/Priority.php | 10 +- src/Layout/layout.logger_cli.php | 5 +- test/bootstrap.php | 4 +- .../TestAddComponent/TestAddComponent.php | 6 +- .../TestAddComponentDirectory.php | 8 +- .../TestAddComponentFail.php | 6 +- test/core/core_configTest.php | 6 +- test/core/core_configuratorTest.php | 7 +- test/core/core_eventTest.php | 3 +- test/core/core_eventsTest.php | 2 +- test/core/core_helperTest.php | 2 +- test/core/core_libraryTest.php | 8 +- test/core/core_loggerTest.php | 6 +- test/core/core_pluginsTest.php | 3 +- test/core/core_priorityTest.php | 18 +-- test/events/event_pluginGetEventTest.php | 9 +- .../TestCancelLoadHelper.php | 4 +- test/helpers/TestGetHelper/TestGetHelper.php | 4 +- .../helpers/TestLoadHelper/TestLoadHelper.php | 6 +- .../TestLoadHelperWithAltDirectory.php | 4 +- .../TestLoadHelperWithoutSubdirectory.php | 4 +- .../TestReloadHelper/TestReloadHelper.php | 4 +- test/plugins/TestGetPluginMethod/header.php | 6 +- 42 files changed, 239 insertions(+), 267 deletions(-) diff --git a/README.md b/README.md index 06664c5..225116d 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ https://techfuze.net/fuzeworks Summary ------- -FuzeWorks is a flexible PHP Framework made for the requirements of todays web. +FuzeWorks is a flexible PHP Framework made for the requirements of today's web. For a summary of features, list of requirements, and installation instructions, please see the documentation in the ./doc/ folder or at http://techfuze.net/fuzeworks diff --git a/src/FuzeWorks/ComponentPathsTrait.php b/src/FuzeWorks/ComponentPathsTrait.php index 18ed6c6..243fc9e 100644 --- a/src/FuzeWorks/ComponentPathsTrait.php +++ b/src/FuzeWorks/ComponentPathsTrait.php @@ -31,7 +31,7 @@ * @link http://techfuze.net/fuzeworks * @since Version 1.2.0 * - * @version Version 1.2.0 + * @version Version 1.3.0 */ namespace FuzeWorks; @@ -45,7 +45,7 @@ trait ComponentPathsTrait * * @var array $componentPaths */ - protected $componentPaths = []; + protected array $componentPaths = []; /** * Set the directories. Automatically gets invoked if componentPaths are added by FuzeWorks\Configurator. @@ -63,7 +63,7 @@ trait ComponentPathsTrait * @param string $componentPath * @param int $priority */ - public function addComponentPath($componentPath, $priority = Priority::NORMAL) + public function addComponentPath(string $componentPath, int $priority = Priority::NORMAL) { if (!isset($this->componentPaths[$priority])) $this->componentPaths[$priority] = []; @@ -78,7 +78,7 @@ trait ComponentPathsTrait * @param string $componentPath * @param int $priority */ - public function removeComponentPath($componentPath, $priority = Priority::NORMAL) + public function removeComponentPath(string $componentPath, int $priority = Priority::NORMAL) { if (!isset($this->componentPaths[$priority])) return; @@ -93,8 +93,8 @@ trait ComponentPathsTrait * @param int $priority * @return array of paths where objects for this component can be found */ - public function getComponentPaths($priority = Priority::NORMAL): array + public function getComponentPaths(int $priority = Priority::NORMAL): array { - return (isset($this->componentPaths[$priority]) ? $this->componentPaths[$priority] : []); + return $this->componentPaths[$priority] ?? []; } } \ No newline at end of file diff --git a/src/FuzeWorks/Config.php b/src/FuzeWorks/Config.php index 7ced647..cd5c611 100644 --- a/src/FuzeWorks/Config.php +++ b/src/FuzeWorks/Config.php @@ -31,7 +31,7 @@ * @link http://techfuze.net/fuzeworks * @since Version 0.0.1 * - * @version Version 1.2.0 + * @version Version 1.3.0 */ namespace FuzeWorks; @@ -57,19 +57,19 @@ class Config * * @var array Array of all loaded config file ORM's */ - protected $cfg = []; + protected array $cfg = []; /** * Array of config values that will be overridden * * @var array of config values */ - public static $configOverrides = []; + public static array $configOverrides = []; /** * Retrieve a config file object * - * @param string $configName Name of the config file. Eg. 'main' + * @param string $configName Name of the config file. E.g. 'main' * @param array $configPaths Optional array of where to look for the config files * @return ConfigORM of the config file. Allows for easy reading and editing of the file * @throws ConfigException @@ -92,7 +92,7 @@ class Config else $paths = $this->componentPaths; - // Otherwise try and load a new one + // Otherwise, try and load a new one $this->cfg[$configName] = $this->loadConfigFile($configName, $paths); return $this->cfg[$configName]; } @@ -128,7 +128,7 @@ class Config /** * Determine whether the file exists and, if so, load the ConfigORM * - * @param string $configName Name of the config file. Eg. 'main' + * @param string $configName Name of the config file. E.g. 'main' * @param array $configPaths Required array of where to look for the config files * @return ConfigORM of the config file. Allows for easy reading and editing of the file * @throws ConfigException diff --git a/src/FuzeWorks/ConfigORM/ConfigORM.php b/src/FuzeWorks/ConfigORM/ConfigORM.php index 1005082..f9568fd 100644 --- a/src/FuzeWorks/ConfigORM/ConfigORM.php +++ b/src/FuzeWorks/ConfigORM/ConfigORM.php @@ -31,7 +31,7 @@ * @link http://techfuze.net/fuzeworks * @since Version 0.0.1 * - * @version Version 1.2.0 + * @version Version 1.3.0 */ namespace FuzeWorks\ConfigORM; @@ -52,7 +52,7 @@ class ConfigORM extends ConfigORMAbstract * * @var string filename */ - private $file; + private string $file; /** * Load the ConfigORM file. diff --git a/src/FuzeWorks/ConfigORM/ConfigORMAbstract.php b/src/FuzeWorks/ConfigORM/ConfigORMAbstract.php index c4c7070..6b62031 100644 --- a/src/FuzeWorks/ConfigORM/ConfigORMAbstract.php +++ b/src/FuzeWorks/ConfigORM/ConfigORMAbstract.php @@ -31,7 +31,7 @@ * @link http://techfuze.net/fuzeworks * @since Version 0.0.1 * - * @version Version 1.2.0 + * @version Version 1.3.0 */ namespace FuzeWorks\ConfigORM; @@ -53,14 +53,14 @@ abstract class ConfigORMAbstract implements Iterator * * @var array Config file */ - protected $originalCfg = []; + protected array $originalCfg = []; /** * The current state of a config file. * * @var array Config file */ - protected $cfg = []; + protected array $cfg = []; /** * Revert to the original conditions of the config file. @@ -98,7 +98,7 @@ abstract class ConfigORMAbstract implements Iterator * @return bool true on isset, false on not * @codeCoverageIgnore */ - public function __isset($name) + public function __isset(string $name) { return isset($this->cfg[$name]); } @@ -110,7 +110,7 @@ abstract class ConfigORMAbstract implements Iterator * @return mixed Value of the requested entry * @codeCoverageIgnore */ - public function __get($name) + public function __get(string $name) { return $this->cfg[$name]; } @@ -122,7 +122,7 @@ abstract class ConfigORMAbstract implements Iterator * @return mixed Value of the requested entry * @codeCoverageIgnore */ - public function get($name) + public function get(string $name) { return $this->cfg[$name]; } @@ -134,7 +134,7 @@ abstract class ConfigORMAbstract implements Iterator * @param mixed $value Value of the entry * @codeCoverageIgnore */ - public function __set($name, $value) + public function __set(string $name, $value) { $this->cfg[$name] = $value; } @@ -146,7 +146,7 @@ abstract class ConfigORMAbstract implements Iterator * @param mixed $value Value of the entry * @codeCoverageIgnore */ - public function set($name, $value) + public function set(string $name, $value) { $this->cfg[$name] = $value; } @@ -202,7 +202,7 @@ abstract class ConfigORMAbstract implements Iterator * Iterator method. * @codeCoverageIgnore */ - public function valid() + public function valid(): bool { return key($this->cfg) !== null; } @@ -212,7 +212,7 @@ abstract class ConfigORMAbstract implements Iterator * * @return array Config file */ - public function toArray() + public function toArray(): array { return $this->cfg; } diff --git a/src/FuzeWorks/Configurator.php b/src/FuzeWorks/Configurator.php index 90e6640..13a7825 100644 --- a/src/FuzeWorks/Configurator.php +++ b/src/FuzeWorks/Configurator.php @@ -35,6 +35,7 @@ */ namespace FuzeWorks; +use Exception; use FuzeWorks\Exception\ConfiguratorException; use FuzeWorks\Exception\InvalidArgumentException; @@ -58,14 +59,14 @@ class Configurator * * @var array */ - protected $parameters = ['debugEnabled' => false]; + protected array $parameters = ['debugEnabled' => false]; /** * Components that have been added to FuzeWorks * * @var iComponent[] */ - protected $components = []; + protected array $components = []; /** * Directories that will be passed to FuzeWorks components. @@ -74,14 +75,14 @@ class Configurator * * @var array of directories */ - protected $directories = []; + protected array $directories = []; /** * Array of ComponentClass methods to be invoked once ComponentClass is loaded * * @var DeferredComponentClass[] */ - protected $deferredComponentClassMethods = []; + protected array $deferredComponentClassMethods = []; const COOKIE_SECRET = 'fuzeworks-debug'; @@ -128,7 +129,7 @@ class Configurator * @return $this * @throws InvalidArgumentException */ - public function addDirectory(string $directory, string $category, $priority = Priority::NORMAL): Configurator + public function addDirectory(string $directory, string $category, int $priority = Priority::NORMAL): Configurator { if (!file_exists($directory)) throw new InvalidArgumentException("Could not add directory. Directory does not exist."); @@ -172,7 +173,7 @@ class Configurator * @param mixed $parameters,... Parameters for the method to be invoked * @return DeferredComponentClass */ - public function deferComponentClassMethod(string $componentClass, string $method, callable $callable = null) + public function deferComponentClassMethod(string $componentClass, string $method, callable $callable = null): DeferredComponentClass { // Retrieve arguments $arguments = (func_num_args() > 3 ? array_slice(func_get_args(), 3) : []); @@ -195,7 +196,7 @@ class Configurator * @return DeferredComponentClass * @codeCoverageIgnore */ - public function call(string $componentClass, string $method, callable $callable = null) + public function call(string $componentClass, string $method, callable $callable = null): DeferredComponentClass { return call_user_func_array([$this, 'deferComponentClassMethod'], func_get_args()); } @@ -270,8 +271,7 @@ class Configurator public function enableDebugMode(): Configurator { $this->parameters['debugEnabled'] = true; - $this->parameters['debugMatch'] = (isset($this->parameters['debugMatch']) ? $this->parameters['debugMatch'] : true); - + $this->parameters['debugMatch'] = $this->parameters['debugMatch'] ?? true; return $this; } @@ -301,13 +301,11 @@ class Configurator return $this; } - // Otherwise we run the regular detectDebugMode from Tracy + // Otherwise, we run the regular detectDebugMode from Tracy $list = is_string($address) ? preg_split('#[,\s]+#', $address) : (array) $address; - $addr = isset($_SERVER['REMOTE_ADDR']) - ? $_SERVER['REMOTE_ADDR'] - : php_uname('n'); + $addr = $_SERVER['REMOTE_ADDR'] ?? php_uname('n'); $secret = isset($_COOKIE[self::COOKIE_SECRET]) && is_string($_COOKIE[self::COOKIE_SECRET]) ? $_COOKIE[self::COOKIE_SECRET] : NULL; @@ -336,7 +334,7 @@ class Configurator * When issue #101 is completed, this should be resolved. * * @return Factory - * @throws \Exception + * @throws Exception */ public function createContainer(): Factory { diff --git a/src/FuzeWorks/Core.php b/src/FuzeWorks/Core.php index 3c9b7bf..6eb00b9 100644 --- a/src/FuzeWorks/Core.php +++ b/src/FuzeWorks/Core.php @@ -31,11 +31,12 @@ * @link http://techfuze.net/fuzeworks * @since Version 0.0.1 * - * @version Version 1.2.0 + * @version Version 1.3.0 */ namespace FuzeWorks; +use Exception; use FuzeWorks\Exception\CoreException; use FuzeWorks\Exception\EventException; @@ -55,7 +56,7 @@ class Core * * @var string Framework version */ - public static $version = '1.2.0'; + public static string $version = '1.2.0'; /** * Working directory of the Framework. @@ -64,39 +65,39 @@ class Core * * @var string */ - public static $cwd; + public static string $cwd; - public static $coreDir; + public static string $coreDir; - public static $tempDir; + public static string $tempDir; - public static $logDir; + public static string $logDir; /** * Array of exception handlers, sorted by priority * * @var array */ - protected static $exceptionHandlers = []; + protected static array $exceptionHandlers = []; /** * Array of error handlers, sorted by priority * * @var array */ - protected static $errorHandlers = []; + protected static array $errorHandlers = []; /** * Array of all classMaps which can be autoloaded. * * @var array */ - protected static $autoloadMap = []; + protected static array $autoloadMap = []; /** * Initializes the core. * - * @throws \Exception + * @throws Exception */ public static function init(): Factory { @@ -153,7 +154,7 @@ class Core * * @param string $varName * @param string|null $default - * @return mixed + * @return array|string|null */ public static function getEnv(string $varName, string $default = null) { @@ -164,7 +165,7 @@ class Core if ($var === FALSE) return $default; - // Otherwise return the variable itself + // Otherwise, return the variable itself return $var; } diff --git a/src/FuzeWorks/DeferredComponentClass.php b/src/FuzeWorks/DeferredComponentClass.php index abff4c2..edb4d73 100644 --- a/src/FuzeWorks/DeferredComponentClass.php +++ b/src/FuzeWorks/DeferredComponentClass.php @@ -31,7 +31,7 @@ * @link http://techfuze.net/fuzeworks * @since Version 0.0.1 * - * @version Version 1.2.0 + * @version Version 1.3.0 */ namespace FuzeWorks; @@ -42,17 +42,17 @@ class DeferredComponentClass /** * @var string Name of the class to be invoked */ - public $componentClass; + public string $componentClass; /** * @var string name of the method to be invoked */ - public $method; + public string $method; /** * @var array arguments to invoke the method with */ - public $arguments = []; + public array $arguments = []; /** * @var mixed return from the invoked method @@ -62,7 +62,7 @@ class DeferredComponentClass /** * @var bool Whether the method has been invoked */ - protected $invoked = false; + protected bool $invoked = false; /** * @var callable A callback to call when method has been invoked. diff --git a/src/FuzeWorks/Event.php b/src/FuzeWorks/Event.php index 0d73ce7..274d633 100644 --- a/src/FuzeWorks/Event.php +++ b/src/FuzeWorks/Event.php @@ -31,7 +31,7 @@ * @link http://techfuze.net/fuzeworks * @since Version 0.0.1 * - * @version Version 1.2.0 + * @version Version 1.3.0 */ namespace FuzeWorks; @@ -46,7 +46,7 @@ namespace FuzeWorks; */ class Event { - private $cancelled = false; + private bool $cancelled = false; /** * @return bool True if the event is cancelled, false if the event is not cancelled @@ -59,7 +59,7 @@ class Event /** * @param bool $cancelled True if the event is cancelled, false if the event is not cancelled */ - public function setCancelled($cancelled) + public function setCancelled(bool $cancelled) { if ($cancelled == true) { $this->cancelled = true; diff --git a/src/FuzeWorks/Event/ConfigGetEvent.php b/src/FuzeWorks/Event/ConfigGetEvent.php index 434ab81..eb89ceb 100644 --- a/src/FuzeWorks/Event/ConfigGetEvent.php +++ b/src/FuzeWorks/Event/ConfigGetEvent.php @@ -31,7 +31,7 @@ * @link http://techfuze.net/fuzeworks * @since Version 0.0.1 * - * @version Version 1.2.0 + * @version Version 1.3.0 */ namespace FuzeWorks\Event; @@ -54,14 +54,14 @@ class ConfigGetEvent extends Event * * @var string */ - public $configName; + public string $configName; /** * The directories the config might be found in * * @var array */ - public $configPaths; + public array $configPaths; public function init(string $configName, array $configPaths) diff --git a/src/FuzeWorks/Event/HaltExecutionEvent.php b/src/FuzeWorks/Event/HaltExecutionEvent.php index 8c06e07..c1d4f19 100644 --- a/src/FuzeWorks/Event/HaltExecutionEvent.php +++ b/src/FuzeWorks/Event/HaltExecutionEvent.php @@ -31,7 +31,7 @@ * @link http://techfuze.net/fuzeworks * @since Version 1.2.0 * - * @version Version 1.2.0 + * @version Version 1.3.0 */ namespace FuzeWorks\Event; @@ -51,7 +51,7 @@ class HaltExecutionEvent extends Event /** * @var array Log */ - public $log; + public array $log; public function init(array $log) { diff --git a/src/FuzeWorks/Event/HelperLoadEvent.php b/src/FuzeWorks/Event/HelperLoadEvent.php index 48bf628..7fa5f83 100644 --- a/src/FuzeWorks/Event/HelperLoadEvent.php +++ b/src/FuzeWorks/Event/HelperLoadEvent.php @@ -31,7 +31,7 @@ * @link http://techfuze.net/fuzeworks * @since Version 0.0.1 * - * @version Version 1.2.0 + * @version Version 1.3.0 */ namespace FuzeWorks\Event; @@ -54,14 +54,14 @@ class HelperLoadEvent extends Event * * @var string */ - public $helperName; + public string $helperName; /** * The directory of the helper that gets loaded * * @var array */ - public $helperPaths; + public array $helperPaths; public function init(string $helperName, array $helperPaths) diff --git a/src/FuzeWorks/Event/PluginGetEvent.php b/src/FuzeWorks/Event/PluginGetEvent.php index 2b6e415..e9f7fdb 100644 --- a/src/FuzeWorks/Event/PluginGetEvent.php +++ b/src/FuzeWorks/Event/PluginGetEvent.php @@ -31,7 +31,7 @@ * @link http://techfuze.net/fuzeworks * @since Version 1.1.4 * - * @version Version 1.2.0 + * @version Version 1.3.0 */ namespace FuzeWorks\Event; @@ -51,14 +51,14 @@ class PluginGetEvent extends Event * * @var string */ - public $pluginName; + public string $pluginName; /** * Potential plugin to return instead. If set, the plugins class will return this object * - * @var object + * @var object|null */ - public $plugin = null; + public ?object $plugin = null; public function init($pluginName) { @@ -70,7 +70,7 @@ class PluginGetEvent extends Event * * @param object $plugin */ - public function setPlugin($plugin) + public function setPlugin(object $plugin) { $this->plugin = $plugin; } @@ -80,8 +80,8 @@ class PluginGetEvent extends Event * * @return object|null $plugin */ - public function getPlugin() - { + public function getPlugin(): ?object + { return $this->plugin; } } diff --git a/src/FuzeWorks/Events.php b/src/FuzeWorks/Events.php index 50876a6..d602f39 100644 --- a/src/FuzeWorks/Events.php +++ b/src/FuzeWorks/Events.php @@ -31,7 +31,7 @@ * @link http://techfuze.net/fuzeworks * @since Version 0.0.1 * - * @version Version 1.2.0 + * @version Version 1.3.0 */ namespace FuzeWorks; @@ -66,7 +66,7 @@ class Events * * @var array */ - public static $listeners = array(); + public static array $listeners = array(); /** * Whether the event system is enabled or not. @@ -123,13 +123,13 @@ class Events * * @param mixed callback The callback when the events get fired, see {@link http://php.net/manual/en/language.types.callable.php PHP.net} * @param string $eventName The name of the event - * @param int $priority The priority, even though integers are valid, please use Priority (for example Priority::Lowest) + * @param int $priority The priority, even though integers are valid, please use Priority (for example Priority::Lowest) * * @see Priority * * @throws EventException */ - public static function removeListener(callable $callback, string $eventName, $priority = Priority::NORMAL) + public static function removeListener(callable $callback, string $eventName, int $priority = Priority::NORMAL) { if (Priority::getPriority($priority) == false) { throw new EventException('Unknown priority '.$priority); @@ -169,7 +169,7 @@ class Events $eventName = end($eventName); $event = $input; } - // Otherwise try to load an event based on the input string + // Otherwise, try to load an event based on the input string elseif (is_string($input)) { $eventClass = ucfirst($input); diff --git a/src/FuzeWorks/Factory.php b/src/FuzeWorks/Factory.php index 25b6526..455c9b6 100644 --- a/src/FuzeWorks/Factory.php +++ b/src/FuzeWorks/Factory.php @@ -67,56 +67,55 @@ class Factory /** * The Factory instance that is shared by default when calling Factory::getInstance(); * - * @var Factory Default shared instance + * @var Factory|null Default shared instance */ - private static $sharedFactoryInstance; + private static ?Factory $sharedFactoryInstance = null; /** * Whether the Factory has been initialized or not * * @var bool $initialized */ - private $initialized = false; + private bool $initialized = false; /** * Config Object * @var Config */ - public $config; + public Config $config; /** * Logger Object * @var Logger */ - public $logger; + public Logger $logger; /** * Events Object * @var Events */ - public $events; + public Events $events; /** * Libraries Object * @var Libraries */ - public $libraries; + public Libraries $libraries; /** * Helpers Object * @var Helpers */ - public $helpers; + public Helpers $helpers; /** * Plugins Object * @var Plugins */ - public $plugins; + public Plugins $plugins; /** * Factory instance constructor. Should only really be called once - * @throws ConfigException * @throws FactoryException */ public function __construct() @@ -140,12 +139,9 @@ class Factory // Otherwise, copy the existing instances $x = self::getInstance(); foreach ($x as $key => $value) - { $this->{$key} = $value; - } - return; - } + } /** * Finalizes the Factory and sends out a coreStartEvent @@ -226,7 +222,7 @@ class Factory * @return Factory Instance * @throws FactoryException */ - public function newInstance($className, $namespace = 'FuzeWorks\\'): self + public function newInstance(string $className, string $namespace = 'FuzeWorks\\'): self { // Determine the class to load $instanceName = strtolower($className); @@ -288,7 +284,7 @@ class Factory * @param mixed $object Object to replace the class with * @return Factory Instance */ - public function setInstance($objectName, $object): self + public function setInstance(string $objectName, $object): self { // Determine the instance name $instanceName = strtolower($objectName); @@ -308,7 +304,7 @@ class Factory * @return Factory Factory Instance * @throws FactoryException */ - public function removeInstance($className): self + public function removeInstance(string $className): self { // Determine the instance name $instanceName = strtolower($className); @@ -331,7 +327,7 @@ class Factory * @param $componentName * @return bool */ - public function instanceIsset($componentName) + public function instanceIsset($componentName): bool { return isset($this->{$componentName}); } diff --git a/src/FuzeWorks/Helpers.php b/src/FuzeWorks/Helpers.php index 82ef361..bcfb69c 100644 --- a/src/FuzeWorks/Helpers.php +++ b/src/FuzeWorks/Helpers.php @@ -31,7 +31,7 @@ * @link http://techfuze.net/fuzeworks * @since Version 0.0.1 * - * @version Version 1.2.0 + * @version Version 1.3.0 */ namespace FuzeWorks; @@ -49,7 +49,7 @@ use FuzeWorks\Exception\HelperException; * Text Helpers perform various text formatting routines, Cookie Helpers set and read cookies, * File Helpers help you deal with files, etc. * - * Unlike most other systems in FuzeWorks, Helpers are not written in an Object Oriented format. + * Unlike most other systems in FuzeWorks, Helpers are not written in an Object-Oriented format. * They are simple, procedural functions. Each helper function performs one specific task, with no dependence on other functions. * * FuzeWorks does not load Helper Files by default, so the first step in using a Helper is to load it. Once loaded, @@ -67,7 +67,7 @@ class Helpers * * @var array Array of loaded helperNames */ - protected $helpers = []; + protected array $helpers = []; /** * Load a helper. @@ -145,14 +145,14 @@ class Helpers /** * Alias for load - * @see load() for more details - * * @param string $helperName Name of the helper * @param array $helperPaths * @return bool Whether the helper was successfully loaded (true if yes) * @throws HelperException + *@see load() for more details + * */ - public function get($helperName, array $helperPaths = []): bool + public function get(string $helperName, array $helperPaths = []): bool { return $this->load($helperName, $helperPaths); } diff --git a/src/FuzeWorks/Libraries.php b/src/FuzeWorks/Libraries.php index ab6dcf6..fbd59b1 100644 --- a/src/FuzeWorks/Libraries.php +++ b/src/FuzeWorks/Libraries.php @@ -31,7 +31,7 @@ * @link http://techfuze.net/fuzeworks * @since Version 0.0.1 * - * @version Version 1.2.0 + * @version Version 1.3.0 */ namespace FuzeWorks; @@ -40,7 +40,6 @@ use FuzeWorks\Exception\ConfigException; use FuzeWorks\Exception\CoreException; use FuzeWorks\Exception\LibraryException; use ReflectionClass; -use ReflectionException; class Libraries { @@ -51,14 +50,14 @@ class Libraries * * @var array Library objects */ - protected $libraryObjects = []; + protected array $libraryObjects = []; /** * Array of libraries with their classnames, so they can be easily loaded * * @var array Library classes */ - protected $libraryClasses = []; + protected array $libraryClasses = []; /** * FuzeWorks Factory object. For internal use. @@ -83,7 +82,7 @@ class Libraries * @param string $libraryName * @param object $libraryObject */ - public function addLibraryObject(string $libraryName, $libraryObject) + public function addLibraryObject(string $libraryName, object $libraryObject) { $this->libraryObjects[strtolower($libraryName)] = $libraryObject; } @@ -213,8 +212,6 @@ class Libraries $prefix = $classObject->getClassesPrefix(); if (!is_null($filePath) && !is_null($prefix)) Core::addAutoloadMap($prefix, $filePath); - } catch (ReflectionException $e) { - throw new LibraryException("Could not initiate library. ReflectionClass threw exception."); } catch (CoreException $e) { throw new LibraryException("Could not initiate library. Failed to add to autoloader."); } diff --git a/src/FuzeWorks/Logger.php b/src/FuzeWorks/Logger.php index 9b03349..bc05eda 100644 --- a/src/FuzeWorks/Logger.php +++ b/src/FuzeWorks/Logger.php @@ -31,7 +31,7 @@ * @link http://techfuze.net/fuzeworks * @since Version 0.0.1 * - * @version Version 1.2.0 + * @version Version 1.3.0 */ namespace FuzeWorks; @@ -57,21 +57,21 @@ class Logger { * * @var array */ - public static $logs = []; + public static array $logs = []; /** * whether to output the log after FuzeWorks has run. * * @var bool */ - private static $print_to_screen = false; + private static bool $print_to_screen = false; /** * Whether the Logger has been enabled or not * * @var bool */ - private static $isEnabled = false; + private static bool $isEnabled = false; /** * whether to output the log of the last entire request to a file after FuzeWorks has run. @@ -92,21 +92,21 @@ class Logger { * * @var string Template name */ - private static $logger_template = 'logger_cli'; + private static string $logger_template = 'logger_cli'; /** * whether to output the log after FuzeWorks has run, regardless of conditions. * * @var bool */ - public static $debug = false; + public static bool $debug = false; /** * List of all benchmark markpoints. * * @var array */ - public static $markPoints = []; + public static array $markPoints = []; /** * Initiates the Logger. @@ -188,8 +188,8 @@ class Logger { */ public static function enableHandlers() { - Core::addErrorHandler(['\FuzeWorks\Logger', 'errorHandler'], Priority::NORMAL); - Core::addExceptionHandler(['\FuzeWorks\Logger', 'exceptionHandler'], Priority::NORMAL); + Core::addErrorHandler(['\FuzeWorks\Logger', 'errorHandler']); + Core::addExceptionHandler(['\FuzeWorks\Logger', 'exceptionHandler']); } /** @@ -200,8 +200,8 @@ class Logger { */ public static function disableHandlers() { - Core::removeErrorHandler(['\FuzeWorks\Logger', 'errorHandler'], Priority::NORMAL); - Core::removeExceptionHandler(['\FuzeWorks\Logger', 'exceptionHandler'], Priority::NORMAL); + Core::removeErrorHandler(['\FuzeWorks\Logger', 'errorHandler']); + Core::removeExceptionHandler(['\FuzeWorks\Logger', 'exceptionHandler']); } /** @@ -265,7 +265,7 @@ class Logger { * @param int Line. The line on which the error occured. * @param array context. Some of the error's relevant variables */ - public static function errorHandler($type = E_USER_NOTICE, $error = 'Undefined Error', $errFile = null, $errLine = null) + public static function errorHandler(int $type = E_USER_NOTICE, $error = 'Undefined Error', $errFile = null, $errLine = null) { // Check type $thisType = self::getType($type); @@ -285,7 +285,7 @@ class Logger { * @param Exception $exception The occured exception. * @param bool $haltExecution. Defaults to true */ - public static function exceptionHandler($exception, bool $haltExecution = true) + public static function exceptionHandler(Exception $exception, bool $haltExecution = true) { $LOG = array('type' => 'EXCEPTION', 'message' => $exception->getMessage(), @@ -372,10 +372,10 @@ class Logger { * Multiple calls to this function can be made so that several * execution points can be timed. * - * @param string $name Marker name + * @param string $name Marker name * @return void */ - public static function mark($name) + public static function mark(string $name) { $LOG = array('type' => 'BMARK', 'message' => (!is_null($name) ? $name : ''), @@ -388,30 +388,30 @@ class Logger { } /** - * Create a information log entry. + * Create an information log entry. * * @param string $msg The information to be logged - * @param string $mod The name of the module - * @param string $file The file where the log occurred - * @param int $line The line where the log occurred + * @param string|null $mod The name of the module + * @param string|null $file The file where the log occurred + * @param int|null $line The line where the log occurred */ - public static function log($msg, $mod = null, $file = null, $line = null) + public static function log(string $msg, string $mod = null, string $file = null, int $line = null) { self::logInfo($msg, $mod, $file, $line); } /** - * Create a information log entry. + * Create an information log entry. * * @param string $msg The information to be logged - * @param string $mod The name of the module - * @param string $file The file where the log occurred - * @param int $line The line where the log occurred + * @param string|null $mod The name of the module + * @param string|null $file The file where the log occurred + * @param int|null $line The line where the log occurred */ - public static function logInfo($msg, $mod = null, $file = null, $line = null) + public static function logInfo(string $msg, string $mod = null, string $file = null, int $line = null) { $LOG = array('type' => 'INFO', - 'message' => (!is_null($msg) ? $msg : ''), + 'message' => ($msg), 'logFile' => (!is_null($file) ? $file : ''), 'logLine' => (!is_null($line) ? $line : ''), 'context' => (!is_null($mod) ? $mod : ''), @@ -421,17 +421,17 @@ class Logger { } /** - * Create a information log entry. + * Create an information log entry. * * @param string $msg The information to be logged - * @param string $mod The name of the module - * @param string $file The file where the log occurred - * @param int $line The line where the log occurred + * @param string|null $mod The name of the module + * @param string|null $file The file where the log occurred + * @param int|null $line The line where the log occurred */ - public static function logDebug($msg, $mod = null, $file = null, $line = null) + public static function logDebug(string $msg, string $mod = null, string $file = null, int $line = null) { $LOG = array('type' => 'DEBUG', - 'message' => (!is_null($msg) ? $msg : ''), + 'message' => ($msg), 'logFile' => (!is_null($file) ? $file : ''), 'logLine' => (!is_null($line) ? $line : ''), 'context' => (!is_null($mod) ? $mod : ''), @@ -444,14 +444,14 @@ class Logger { * Create a error log entry. * * @param string $msg The information to be logged - * @param string $mod The name of the module - * @param string $file The file where the log occurred - * @param int $line The line where the log occurred + * @param string|null $mod The name of the module + * @param string|null $file The file where the log occurred + * @param int|null $line The line where the log occurred */ - public static function logError($msg, $mod = null, $file = null, $line = null) + public static function logError(string $msg, string $mod = null, string $file = null, int $line = null) { $LOG = array('type' => 'ERROR', - 'message' => (!is_null($msg) ? $msg : ''), + 'message' => ($msg), 'logFile' => (!is_null($file) ? $file : ''), 'logLine' => (!is_null($line) ? $line : ''), 'context' => (!is_null($mod) ? $mod : ''), @@ -464,14 +464,14 @@ class Logger { * Create a warning log entry. * * @param string $msg The information to be logged - * @param string $mod The name of the module - * @param string $file The file where the log occurred - * @param int $line The line where the log occurred + * @param string|null $mod The name of the module + * @param string|null $file The file where the log occurred + * @param int|null $line The line where the log occurred */ - public static function logWarning($msg, $mod = null, $file = null, $line = null) + public static function logWarning(string $msg, string $mod = null, string $file = null, int $line = null) { $LOG = array('type' => 'WARNING', - 'message' => (!is_null($msg) ? $msg : ''), + 'message' => ($msg), 'logFile' => (!is_null($file) ? $file : ''), 'logLine' => (!is_null($line) ? $line : ''), 'context' => (!is_null($mod) ? $mod : ''), @@ -484,14 +484,14 @@ class Logger { * Create a new Level log entry. Used to categorise logs. * * @param string $msg The name of the new level - * @param string $mod The name of the module - * @param string $file The file where the log occurred - * @param int $line The line where the log occurred + * @param string|null $mod The name of the module + * @param string|null $file The file where the log occurred + * @param int|null $line The line where the log occurred */ - public static function newLevel($msg, $mod = null, $file = null, $line = null) + public static function newLevel(string $msg, string $mod = null, string $file = null, int $line = null) { $LOG = array('type' => 'LEVEL_START', - 'message' => (!is_null($msg) ? $msg : ''), + 'message' => ($msg), 'logFile' => (!is_null($file) ? $file : ''), 'logLine' => (!is_null($line) ? $line : ''), 'context' => (!is_null($mod) ? $mod : ''), @@ -503,12 +503,12 @@ class Logger { /** * Create a stop Level log entry. Used to close log categories. * - * @param string $msg The name of the new level - * @param string $mod The name of the module - * @param string $file The file where the log occurred - * @param int $line The line where the log occurred + * @param string|null $msg The name of the new level + * @param string|null $mod The name of the module + * @param string|null $file The file where the log occurred + * @param int|null $line The line where the log occurred */ - public static function stopLevel($msg = null, $mod = null, $file = null, $line = null) + public static function stopLevel(string $msg = null, string $mod = null, string $file = null, int $line = null) { $LOG = array('type' => 'LEVEL_STOP', 'message' => (!is_null($msg) ? $msg : ''), @@ -530,42 +530,29 @@ class Logger { * * @return string String representation */ - public static function getType($type): string + public static function getType(int $type): string { switch ($type) { + case E_PARSE: + case E_CORE_ERROR: + case E_COMPILE_ERROR: + case E_USER_ERROR: + case E_STRICT: + case E_RECOVERABLE_ERROR: case E_ERROR: return 'ERROR'; - case E_WARNING: - return 'WARNING'; - case E_PARSE: - return 'ERROR'; case E_NOTICE: - return 'WARNING'; - case E_CORE_ERROR: - return 'ERROR'; case E_CORE_WARNING: - return 'WARNING'; - case E_COMPILE_ERROR: - return 'ERROR'; case E_COMPILE_WARNING: - return 'WARNING'; - case E_USER_ERROR: - return 'ERROR'; case E_USER_WARNING: - return 'WARNING'; case E_USER_NOTICE: - return 'WARNING'; case E_USER_DEPRECATED: - return 'WARNING'; - case E_STRICT: - return 'ERROR'; - case E_RECOVERABLE_ERROR: - return 'ERROR'; case E_DEPRECATED: + case E_WARNING: return 'WARNING'; } - return $type = 'Unknown error: ' . $type; + return 'Unknown error: ' . $type; } /** @@ -600,8 +587,6 @@ class Logger { private static function getRelativeTime(): float { $startTime = STARTTIME; - $time = microtime(true) - $startTime; - - return $time; + return microtime(true) - $startTime; } } \ No newline at end of file diff --git a/src/FuzeWorks/Plugins.php b/src/FuzeWorks/Plugins.php index 5799d54..c70886c 100644 --- a/src/FuzeWorks/Plugins.php +++ b/src/FuzeWorks/Plugins.php @@ -31,7 +31,7 @@ * @link http://techfuze.net/fuzeworks * @since Version 1.1.4 * - * @version Version 1.2.0 + * @version Version 1.3.0 */ namespace FuzeWorks; @@ -41,7 +41,6 @@ use FuzeWorks\Exception\CoreException; use FuzeWorks\Exception\FactoryException; use FuzeWorks\Exception\PluginException; use ReflectionClass; -use ReflectionException; /** * Plugins Class. @@ -72,7 +71,7 @@ class Plugins * * @var array Array of loaded plugins */ - protected $plugins = array(); + protected array $plugins = array(); /** * Array of plugin header classes. @@ -80,14 +79,14 @@ class Plugins * * @var array Array of loaded plugin header classes */ - protected $headers = array(); + protected array $headers = array(); /** * Config file for the plugin system * * @var ConfigORM */ - protected $cfg; + protected ConfigORM $cfg; /** * Called upon initialization of the Container @@ -142,11 +141,7 @@ class Plugins // Load the header $this->loadHeader($header); } - - // If it doesn't exist, skip it - continue; } - } } } @@ -197,13 +192,12 @@ class Plugins * Get a plugin. * * @param string $pluginName Name of the plugin - * @param array $parameters Parameters to send to the __construct() method + * @param array|null $parameters Parameters to send to the __construct() method * @return mixed Plugin on success, bool on cancellation * @throws Exception\EventException * @throws PluginException - * @throws ReflectionException */ - public function get($pluginName, array $parameters = null) + public function get(string $pluginName, array $parameters = null) { if (empty($pluginName)) throw new PluginException("Could not load plugin. No name provided", 1); @@ -219,7 +213,7 @@ class Plugins elseif ($event->getPlugin() != null) return $event->getPlugin(); - // Otherwise just set the variables + // Otherwise, just set the variables $pluginName = $event->pluginName; // Check if the plugin is already loaded and return directly diff --git a/src/FuzeWorks/Priority.php b/src/FuzeWorks/Priority.php index 26a0610..94e9961 100644 --- a/src/FuzeWorks/Priority.php +++ b/src/FuzeWorks/Priority.php @@ -31,7 +31,7 @@ * @link http://techfuze.net/fuzeworks * @since Version 0.0.1 * - * @version Version 1.2.0 + * @version Version 1.3.0 */ namespace FuzeWorks; @@ -90,22 +90,22 @@ abstract class Priority /** * Returns the highest priority - * This function is needed for executing in the right order,. + * This function is needed for executing in the right order. * * @return int */ - public static function getHighestPriority() + public static function getHighestPriority(): int { return self::MONITOR; } /** * Returns the lowest priority - * This function is needed for executing in the right order,. + * This function is needed for executing in the right order. * * @return int */ - public static function getLowestPriority() + public static function getLowestPriority(): int { return self::LOWEST; } diff --git a/src/Layout/layout.logger_cli.php b/src/Layout/layout.logger_cli.php index a5c3ff9..f9675e1 100644 --- a/src/Layout/layout.logger_cli.php +++ b/src/Layout/layout.logger_cli.php @@ -31,11 +31,12 @@ * @link http://techfuze.net/fuzeworks * @since Version 1.2.0 * - * @version Version 1.2.0 + * @version Version 1.3.0 */ if (!function_exists('getColoredString')) { - function getColoredString($string, $foreground_color, $background_color) { + function getColoredString($string, $foreground_color, $background_color): string + { // Determine the color system $foreground_colors = array(); diff --git a/test/bootstrap.php b/test/bootstrap.php index d5f961d..21d22e2 100644 --- a/test/bootstrap.php +++ b/test/bootstrap.php @@ -48,6 +48,4 @@ $configurator->setTimeZone('Europe/Amsterdam'); $configurator->enableDebugMode(); $configurator->setDebugAddress('ALL'); -$container = $configurator->createContainer(); -return $container; - +return $configurator->createContainer(); \ No newline at end of file diff --git a/test/components/TestAddComponent/TestAddComponent.php b/test/components/TestAddComponent/TestAddComponent.php index bb98164..45e2734 100644 --- a/test/components/TestAddComponent/TestAddComponent.php +++ b/test/components/TestAddComponent/TestAddComponent.php @@ -31,7 +31,7 @@ * @link http://techfuze.net/fuzeworks * @since Version 1.2.0 * - * @version Version 1.2.0 + * @version Version 1.3.0 */ namespace FuzeWorks\Component; use FuzeWorks\Configurator; @@ -56,7 +56,7 @@ class TestComponent implements iComponent return $configurator; } - public function onCreateContainer(Factory $container) + public function onCreateContainer(Factory $container): Factory { return $container; } @@ -64,5 +64,5 @@ class TestComponent implements iComponent class Test { - public $variable = 5; + public int $variable = 5; } \ No newline at end of file diff --git a/test/components/TestAddComponentDirectory/TestAddComponentDirectory.php b/test/components/TestAddComponentDirectory/TestAddComponentDirectory.php index 34a74b7..1c06fb3 100644 --- a/test/components/TestAddComponentDirectory/TestAddComponentDirectory.php +++ b/test/components/TestAddComponentDirectory/TestAddComponentDirectory.php @@ -31,7 +31,7 @@ * @link http://techfuze.net/fuzeworks * @since Version 1.2.0 * - * @version Version 1.2.0 + * @version Version 1.3.0 */ namespace FuzeWorks\Component; use FuzeWorks\ComponentPathsTrait; @@ -47,12 +47,12 @@ class TestAddComponentDirectoryComponent implements iComponent return ['testaddcomponentdirectory' => 'FuzeWorks\Component\TestAddComponentDirectory']; } - public function onAddComponent(Configurator $configurator) + public function onAddComponent(Configurator $configurator): Configurator { return $configurator; } - public function onCreateContainer(Factory $container) + public function onCreateContainer(Factory $container): Factory { return $container; } @@ -67,5 +67,5 @@ class TestAddComponentDirectory { use ComponentPathsTrait; - public $variable = 5; + public int $variable = 5; } \ No newline at end of file diff --git a/test/components/TestAddComponentFail/TestAddComponentFail.php b/test/components/TestAddComponentFail/TestAddComponentFail.php index 32716e3..038fa79 100644 --- a/test/components/TestAddComponentFail/TestAddComponentFail.php +++ b/test/components/TestAddComponentFail/TestAddComponentFail.php @@ -31,7 +31,7 @@ * @link http://techfuze.net/fuzeworks * @since Version 1.2.0 * - * @version Version 1.2.0 + * @version Version 1.3.0 */ namespace FuzeWorks\Component; use FuzeWorks\Configurator; @@ -56,7 +56,7 @@ class TestAddComponentFailComponent implements iComponent return $configurator; } - public function onCreateContainer(Factory $container) + public function onCreateContainer(Factory $container): Factory { return $container; } @@ -64,5 +64,5 @@ class TestAddComponentFailComponent implements iComponent class TestAddComponentFail { - public $variable = 5; + public int $variable = 5; } \ No newline at end of file diff --git a/test/core/core_configTest.php b/test/core/core_configTest.php index 034414e..04ec2fc 100644 --- a/test/core/core_configTest.php +++ b/test/core/core_configTest.php @@ -52,7 +52,7 @@ class configTest extends CoreTestAbstract /** * @var Config */ - protected $config; + protected Config $config; public function setUp(): void { @@ -184,11 +184,11 @@ class configTest extends CoreTestAbstract $this->assertSame($config, $config2); // First test the existing key - $this->assertEquals($config->key, 'value'); + $this->assertEquals('value', $config->key); // Change it and test if it's different now $config->key = 'other_value'; - $this->assertEquals($config2->key, 'other_value'); + $this->assertEquals('other_value', $config2->key); } /** diff --git a/test/core/core_configuratorTest.php b/test/core/core_configuratorTest.php index 53a55c8..b1de16c 100644 --- a/test/core/core_configuratorTest.php +++ b/test/core/core_configuratorTest.php @@ -34,6 +34,7 @@ * @version Version 1.3.0 */ +use FuzeWorks\Config; use FuzeWorks\Configurator; use FuzeWorks\Core; use FuzeWorks\Exception\ConfiguratorException; @@ -53,7 +54,7 @@ class configuratorTest extends CoreTestAbstract /** * @var Configurator */ - protected $configurator; + protected Configurator $configurator; public function setUp(): void { @@ -380,7 +381,7 @@ class configuratorTest extends CoreTestAbstract $this->configurator->createContainer(); // Verify that the variable is set in the Config class - $this->assertEquals(['test' => ['somekey' => 'somevalue']], \FuzeWorks\Config::$configOverrides); + $this->assertEquals(['test' => ['somekey' => 'somevalue']], Config::$configOverrides); } /* ---------------------------------- Debugging ------------------------------------------------- */ @@ -498,7 +499,7 @@ class MockComponent implements iComponent return $configurator; } - public function onCreateContainer(Factory $container) + public function onCreateContainer(Factory $container): Factory { return $container; } diff --git a/test/core/core_eventTest.php b/test/core/core_eventTest.php index 5cd839d..80d2ac2 100644 --- a/test/core/core_eventTest.php +++ b/test/core/core_eventTest.php @@ -31,10 +31,9 @@ * @link http://techfuze.net/fuzeworks * @since Version 1.0.4 * - * @version Version 1.2.0 + * @version Version 1.3.0 */ use FuzeWorks\Events; -use FuzeWorks\Event; use FuzeWorks\Priority; /** diff --git a/test/core/core_eventsTest.php b/test/core/core_eventsTest.php index f29f2ed..072a5e7 100644 --- a/test/core/core_eventsTest.php +++ b/test/core/core_eventsTest.php @@ -229,7 +229,7 @@ class eventsTest extends CoreTestAbstract public function testRemoveUnsetListener() { Events::addListener(function($e) {}, 'mockEvent', Priority::NORMAL); - $this->assertNull(Events::removeListener(function($x) {echo "Called"; }, 'mockEvent', Priority::NORMAL)); + $this->assertNull(Events::removeListener(function() {echo "Called"; }, 'mockEvent', Priority::NORMAL)); } /** diff --git a/test/core/core_helperTest.php b/test/core/core_helperTest.php index 10c3a91..fb56597 100644 --- a/test/core/core_helperTest.php +++ b/test/core/core_helperTest.php @@ -50,7 +50,7 @@ class helperTest extends CoreTestAbstract /** * @var Helpers */ - protected $helpers; + protected Helpers $helpers; public function setUp(): void { diff --git a/test/core/core_libraryTest.php b/test/core/core_libraryTest.php index 6eb12e1..8623a76 100644 --- a/test/core/core_libraryTest.php +++ b/test/core/core_libraryTest.php @@ -34,7 +34,6 @@ * @version Version 1.3.0 */ -use FuzeWorks\Core; use FuzeWorks\Exception\LibraryException; use FuzeWorks\Factory; use FuzeWorks\Libraries; @@ -51,7 +50,7 @@ class libraryTest extends CoreTestAbstract /** * @var Libraries */ - protected $libraries; + protected Libraries $libraries; public function setUp(): void { @@ -168,9 +167,10 @@ class libraryTest extends CoreTestAbstract */ public function testAddLibraryObject() { - $this->libraries->addLibraryObject('TestAddLibraryObject', 5); + $z = new stdClass(); + $this->libraries->addLibraryObject('TestAddLibraryObject', $z); - $this->assertEquals(5, $this->libraries->get('TestAddLibraryObject')); + $this->assertEquals($z, $this->libraries->get('TestAddLibraryObject')); } /** diff --git a/test/core/core_loggerTest.php b/test/core/core_loggerTest.php index 25023d8..c728465 100644 --- a/test/core/core_loggerTest.php +++ b/test/core/core_loggerTest.php @@ -47,9 +47,9 @@ use FuzeWorks\Exception\LoggerException; */ class loggerTest extends CoreTestAbstract { - protected $logger; + protected Logger $logger; - protected $output; + protected string $output; public function setUp(): void { @@ -105,7 +105,7 @@ class loggerTest extends CoreTestAbstract E_STRICT => 'ERROR', E_RECOVERABLE_ERROR => 'ERROR', E_DEPRECATED => 'WARNING', - 'UNKNOWN' => 'Unknown error: UNKNOWN' + 0 => 'Unknown error: 0' ); foreach ($types as $errorType => $output) { diff --git a/test/core/core_pluginsTest.php b/test/core/core_pluginsTest.php index 6c3fd19..38d8a46 100644 --- a/test/core/core_pluginsTest.php +++ b/test/core/core_pluginsTest.php @@ -34,7 +34,6 @@ * @version Version 1.3.0 */ -use FuzeWorks\Core; use FuzeWorks\Exception\PluginException; use FuzeWorks\Factory; use FuzeWorks\Plugins; @@ -51,7 +50,7 @@ class pluginTest extends CoreTestAbstract /** * @var FuzeWorks\Plugins */ - protected $plugins; + protected Plugins $plugins; public function setUp(): void { diff --git a/test/core/core_priorityTest.php b/test/core/core_priorityTest.php index 57ef1ab..0ba10fd 100644 --- a/test/core/core_priorityTest.php +++ b/test/core/core_priorityTest.php @@ -31,7 +31,7 @@ * @link http://techfuze.net/fuzeworks * @since Version 1.0.4 * - * @version Version 1.2.0 + * @version Version 1.3.0 */ use FuzeWorks\Priority; @@ -62,12 +62,12 @@ class priorityTest extends CoreTestAbstract */ public function testGetPriority() { - $this->assertEquals(Priority::getPriority(5), 'Priority::LOWEST'); - $this->assertEquals(Priority::getPriority(4), 'Priority::LOW'); - $this->assertEquals(Priority::getPriority(3), 'Priority::NORMAL'); - $this->assertEquals(Priority::getPriority(2), 'Priority::HIGH'); - $this->assertEquals(Priority::getPriority(1), 'Priority::HIGHEST'); - $this->assertEquals(Priority::getPriority(0), 'Priority::MONITOR'); + $this->assertEquals('Priority::LOWEST', Priority::getPriority(5)); + $this->assertEquals('Priority::LOW', Priority::getPriority(4)); + $this->assertEquals('Priority::NORMAL', Priority::getPriority(3)); + $this->assertEquals('Priority::HIGH', Priority::getPriority(2)); + $this->assertEquals('Priority::HIGHEST', Priority::getPriority(1)); + $this->assertEquals('Priority::MONITOR', Priority::getPriority(0)); } /** @@ -83,7 +83,7 @@ class priorityTest extends CoreTestAbstract */ public function testHighestPriority() { - $this->assertEquals(Priority::getHighestPriority(), Priority::MONITOR); + $this->assertEquals(Priority::MONITOR, Priority::getHighestPriority()); } /** @@ -91,7 +91,7 @@ class priorityTest extends CoreTestAbstract */ public function testLowestPriority() { - $this->assertEquals(Priority::getLowestPriority(), Priority::LOWEST); + $this->assertEquals(Priority::LOWEST, Priority::getLowestPriority()); } } diff --git a/test/events/event_pluginGetEventTest.php b/test/events/event_pluginGetEventTest.php index 49514df..5b664aa 100644 --- a/test/events/event_pluginGetEventTest.php +++ b/test/events/event_pluginGetEventTest.php @@ -31,7 +31,7 @@ * @link http://techfuze.net/fuzeworks * @since Version 1.1.4 * - * @version Version 1.2.0 + * @version Version 1.3.0 */ use FuzeWorks\Factory; use FuzeWorks\Events; @@ -64,11 +64,14 @@ class pluginGetEventTest extends CoreTestAbstract { // Create mock listener Events::addListener( - function($event){$event->setPlugin('test_string');return $event;}, + function($event){ + $z = new stdClass(); + $event->setPlugin($z);return $event; + }, 'pluginGetEvent', Priority::NORMAL); // And fire the event - $this->assertEquals('test_string', Factory::getInstance()->plugins->get('test')); + $this->assertInstanceOf('\stdClass', Factory::getInstance()->plugins->get('test')); } } \ No newline at end of file diff --git a/test/helpers/TestCancelLoadHelper/TestCancelLoadHelper.php b/test/helpers/TestCancelLoadHelper/TestCancelLoadHelper.php index cd65d15..a7ec689 100644 --- a/test/helpers/TestCancelLoadHelper/TestCancelLoadHelper.php +++ b/test/helpers/TestCancelLoadHelper/TestCancelLoadHelper.php @@ -31,13 +31,13 @@ * @link http://techfuze.net/fuzeworks * @since Version 0.0.1 * - * @version Version 1.2.0 + * @version Version 1.3.0 */ if ( ! function_exists('testCancelLoadHelper')) { - function testCancelLoadHelper($someParameter) + function testCancelLoadHelper(): string { return 'SomeResult'; } diff --git a/test/helpers/TestGetHelper/TestGetHelper.php b/test/helpers/TestGetHelper/TestGetHelper.php index 8df5e57..7898e49 100644 --- a/test/helpers/TestGetHelper/TestGetHelper.php +++ b/test/helpers/TestGetHelper/TestGetHelper.php @@ -31,13 +31,13 @@ * @link http://techfuze.net/fuzeworks * @since Version 0.0.1 * - * @version Version 1.2.0 + * @version Version 1.3.0 */ if ( ! function_exists('testGetHelper')) { - function testGetHelper($someParameter) + function testGetHelper(): string { return 'SomeResult'; } diff --git a/test/helpers/TestLoadHelper/TestLoadHelper.php b/test/helpers/TestLoadHelper/TestLoadHelper.php index 5f50b7b..e6d3a7f 100644 --- a/test/helpers/TestLoadHelper/TestLoadHelper.php +++ b/test/helpers/TestLoadHelper/TestLoadHelper.php @@ -31,13 +31,13 @@ * @link http://techfuze.net/fuzeworks * @since Version 1.2.0 * - * @version Version 1.2.0 + * @version Version 1.3.0 */ if ( ! function_exists('testHelperFunction')) { - function testHelperFunction($someParameter) - { + function testHelperFunction(): string + { return 'SomeResult'; } } \ No newline at end of file diff --git a/test/helpers/TestLoadHelperWithAltDirectory/SubDirectory/TestLoadHelperWithAltDirectory/TestLoadHelperWithAltDirectory.php b/test/helpers/TestLoadHelperWithAltDirectory/SubDirectory/TestLoadHelperWithAltDirectory/TestLoadHelperWithAltDirectory.php index b1fec73..f393dce 100644 --- a/test/helpers/TestLoadHelperWithAltDirectory/SubDirectory/TestLoadHelperWithAltDirectory/TestLoadHelperWithAltDirectory.php +++ b/test/helpers/TestLoadHelperWithAltDirectory/SubDirectory/TestLoadHelperWithAltDirectory/TestLoadHelperWithAltDirectory.php @@ -31,13 +31,13 @@ * @link http://techfuze.net/fuzeworks * @since Version 1.2.0 * - * @version Version 1.2.0 + * @version Version 1.3.0 */ if ( ! function_exists('testLoadHelperWithAltDirectory')) { - function testLoadHelperWithAltDirectory($someParameter) + function testLoadHelperWithAltDirectory(): string { return 'SomeResult'; } diff --git a/test/helpers/TestLoadHelperWithoutSubdirectory.php b/test/helpers/TestLoadHelperWithoutSubdirectory.php index 7aeefbd..cb0088b 100644 --- a/test/helpers/TestLoadHelperWithoutSubdirectory.php +++ b/test/helpers/TestLoadHelperWithoutSubdirectory.php @@ -31,13 +31,13 @@ * @link http://techfuze.net/fuzeworks * @since Version 0.0.1 * - * @version Version 1.2.0 + * @version Version 1.3.0 */ if ( ! function_exists('testLoadHelperWithoutSubdirectory')) { - function testLoadHelperWithoutSubdirectory($someParameter) + function testLoadHelperWithoutSubdirectory(): string { return 'SomeResult'; } diff --git a/test/helpers/TestReloadHelper/TestReloadHelper.php b/test/helpers/TestReloadHelper/TestReloadHelper.php index 24e318e..ab093a3 100644 --- a/test/helpers/TestReloadHelper/TestReloadHelper.php +++ b/test/helpers/TestReloadHelper/TestReloadHelper.php @@ -31,13 +31,13 @@ * @link http://techfuze.net/fuzeworks * @since Version 0.0.1 * - * @version Version 1.2.0 + * @version Version 1.3.0 */ if ( ! function_exists('testReloadHelper')) { - function testReloadHelper($someParameter) + function testReloadHelper(): string { return 'SomeResult'; } diff --git a/test/plugins/TestGetPluginMethod/header.php b/test/plugins/TestGetPluginMethod/header.php index 2b7b820..db65493 100644 --- a/test/plugins/TestGetPluginMethod/header.php +++ b/test/plugins/TestGetPluginMethod/header.php @@ -31,7 +31,7 @@ * @link http://techfuze.net/fuzeworks * @since Version 1.2.0 * - * @version Version 1.2.0 + * @version Version 1.3.0 */ namespace Application\Plugin; use FuzeWorks\iPluginHeader; @@ -48,8 +48,8 @@ class TestGetPluginMethodHeader implements iPluginHeader { } - public function getPlugin() - { + public function getPlugin(): string + { return 'test_string'; }