Compare commits
20 Commits
Author | SHA1 | Date | |
---|---|---|---|
ccb0564a14 | |||
ed0a82d68b | |||
0014c2d9f6 | |||
c1b734d084 | |||
44ae26404c | |||
46787aaa4e | |||
440964b375 | |||
32420e4681 | |||
8ce3630714 | |||
3ebd91d2ef | |||
fbc17a9519 | |||
a8e6c46bb1 | |||
7a899e33d7 | |||
eec9eda22d | |||
d4bf138533 | |||
6f2e941eb1 | |||
c74967f2a2 | |||
2ae192b286 | |||
051c64fdaa | |||
81125ae8b8 |
36
.drone.yml
Normal file
36
.drone.yml
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
kind: pipeline
|
||||||
|
type: docker
|
||||||
|
name: test
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: composer
|
||||||
|
image: composer:latest
|
||||||
|
commands:
|
||||||
|
- composer install
|
||||||
|
|
||||||
|
- 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: php81test
|
||||||
|
image: registry.i15.nl/i15/fuzephp:8.1-alpine
|
||||||
|
commands:
|
||||||
|
- docker-php-ext-enable xdebug
|
||||||
|
- vendor/bin/phpunit -c test/phpunit.xml
|
||||||
|
|
||||||
|
- name: coverage
|
||||||
|
image: registry.i15.nl/i15/fuzephp:8.0-alpine
|
||||||
|
commands:
|
||||||
|
- docker-php-ext-enable xdebug
|
||||||
|
- vendor/bin/phpunit -c test/phpunit.xml --coverage-text
|
||||||
|
|
||||||
|
image_pull_secrets:
|
||||||
|
- dockerconfig
|
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -3,3 +3,4 @@
|
|||||||
.gitlab-ci.yml export-ignore
|
.gitlab-ci.yml export-ignore
|
||||||
.travis.yml export-ignore
|
.travis.yml export-ignore
|
||||||
test/ export-ignore
|
test/ export-ignore
|
||||||
|
docs/ export-ignore
|
@ -1,82 +0,0 @@
|
|||||||
before_script:
|
|
||||||
# Install dependencies
|
|
||||||
- set -xe
|
|
||||||
- apt-get update -yqq
|
|
||||||
- apt-get install git zip unzip -yqq
|
|
||||||
|
|
||||||
stages:
|
|
||||||
- build
|
|
||||||
- test
|
|
||||||
- deploy
|
|
||||||
|
|
||||||
build:composer:
|
|
||||||
image: php:7.2
|
|
||||||
stage: build
|
|
||||||
script:
|
|
||||||
- curl -sS https://getcomposer.org/installer | php
|
|
||||||
- php composer.phar install
|
|
||||||
cache:
|
|
||||||
key: "$CI_BUILD_REF_$CI_BUILD_REF_NAME"
|
|
||||||
paths:
|
|
||||||
- vendor/
|
|
||||||
|
|
||||||
test:7.1:
|
|
||||||
stage: test
|
|
||||||
image: php:7.1
|
|
||||||
script:
|
|
||||||
- vendor/bin/phpunit -c test/phpunit.xml
|
|
||||||
cache:
|
|
||||||
key: "$CI_BUILD_REF_$CI_BUILD_REF_NAME"
|
|
||||||
paths:
|
|
||||||
- vendor
|
|
||||||
|
|
||||||
test:7.2:
|
|
||||||
stage: test
|
|
||||||
image: php:7.2
|
|
||||||
script:
|
|
||||||
- vendor/bin/phpunit -c test/phpunit.xml
|
|
||||||
cache:
|
|
||||||
key: "$CI_BUILD_REF_$CI_BUILD_REF_NAME"
|
|
||||||
paths:
|
|
||||||
- vendor/
|
|
||||||
|
|
||||||
test:7.3:
|
|
||||||
stage: test
|
|
||||||
image: php:7.3
|
|
||||||
script:
|
|
||||||
- vendor/bin/phpunit -c test/phpunit.xml
|
|
||||||
cache:
|
|
||||||
key: "$CI_BUILD_REF_$CI_BUILD_REF_NAME"
|
|
||||||
paths:
|
|
||||||
- vendor/
|
|
||||||
|
|
||||||
test:coverage:
|
|
||||||
stage: test
|
|
||||||
image: php:7.2
|
|
||||||
script:
|
|
||||||
- pecl install xdebug
|
|
||||||
- docker-php-ext-enable xdebug
|
|
||||||
- vendor/bin/phpunit -c test/phpunit.xml --coverage-text
|
|
||||||
cache:
|
|
||||||
key: "$CI_BUILD_REF_$CI_BUILD_REF_NAME"
|
|
||||||
paths:
|
|
||||||
- vendor/
|
|
||||||
|
|
||||||
release:
|
|
||||||
stage: deploy
|
|
||||||
image: php:7.2
|
|
||||||
only:
|
|
||||||
- master
|
|
||||||
script:
|
|
||||||
- pecl install xdebug
|
|
||||||
- docker-php-ext-enable xdebug
|
|
||||||
- vendor/bin/phpunit -c test/phpunit.xml --coverage-text
|
|
||||||
artifacts:
|
|
||||||
name: "${CI_BUILD_NAME}_${CI_BUILD_REF_NAME}"
|
|
||||||
paths:
|
|
||||||
- build/
|
|
||||||
expire_in: 3 weeks
|
|
||||||
cache:
|
|
||||||
key: "$CI_BUILD_REF_$CI_BUILD_REF_NAME"
|
|
||||||
paths:
|
|
||||||
- vendor/
|
|
12
.travis.yml
12
.travis.yml
@ -1,12 +0,0 @@
|
|||||||
language: php
|
|
||||||
|
|
||||||
php:
|
|
||||||
- 7.1
|
|
||||||
- 7.2
|
|
||||||
- 7.3
|
|
||||||
|
|
||||||
script:
|
|
||||||
- php vendor/bin/phpunit -v -c test/phpunit.xml --coverage-text
|
|
||||||
|
|
||||||
before_script:
|
|
||||||
- composer install
|
|
@ -10,7 +10,7 @@ https://techfuze.net/fuzeworks
|
|||||||
Summary
|
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,
|
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
|
please see the documentation in the ./doc/ folder or at http://techfuze.net/fuzeworks
|
||||||
|
|
||||||
|
@ -1,25 +1,20 @@
|
|||||||
{
|
{
|
||||||
"name": "fuzeworks/core",
|
"name": "fuzeworks/core",
|
||||||
"description": "FuzeWorks Framework Core",
|
"description": "FuzeWorks Framework Core",
|
||||||
"homepage": "https://techfuze.net/fuzeworks",
|
"homepage": "https://i15.nl/fuzeworks",
|
||||||
"license": ["MIT"],
|
"license": ["MIT"],
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
"name": "TechFuze",
|
"name": "Abel Hoogeveen",
|
||||||
"homepage": "https://techfuze.net"
|
"homepage": "https://i15.nl"
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "FuzeWorks Community",
|
|
||||||
"homepage": "https://techfuze.net/fuzeworks/contributors"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=7.1.0",
|
"php": ">=7.4.0"
|
||||||
"psr/log": "1.1.0"
|
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "^7",
|
"phpunit/phpunit": "^9",
|
||||||
"mikey179/vfsstream": "1.1.*"
|
"mikey179/vfsstream": "~1.6.0"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
|
27
docs/boot.txt
Normal file
27
docs/boot.txt
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
FuzeWorks boot process
|
||||||
|
|
||||||
|
1.
|
||||||
|
1.1 Temp/Log directory set
|
||||||
|
1.2 Debug parameters set
|
||||||
|
2.
|
||||||
|
2.1 Define ENVIRONMENT
|
||||||
|
2.2 Core::init()
|
||||||
|
2.2.1 CWD Set
|
||||||
|
2.2.2 CoreDir set
|
||||||
|
2.2.3 Constants defined
|
||||||
|
2.2.4 shutdown/error/exception handlers set
|
||||||
|
2.3 new Factory()
|
||||||
|
2.3.1 new Config, Logger, Events, Libraries, Helpers, Plugins
|
||||||
|
3.
|
||||||
|
3.1 Load Components
|
||||||
|
3.1.1 setInstance of component
|
||||||
|
3.1.2 run onCreateContainer()
|
||||||
|
3.2 Add directories by category
|
||||||
|
3.3 each component init()
|
||||||
|
3.4 deferComponentClass invoke
|
||||||
|
4.
|
||||||
|
4.1 Factory::initFactory()
|
||||||
|
4.1.1 enable/disable Events
|
||||||
|
4.1.2 Plugins::loadHeadersFromPluginPaths()
|
||||||
|
4.1.3 coreStartEvent()
|
||||||
|
5. Return container
|
@ -31,7 +31,7 @@
|
|||||||
* @link http://techfuze.net/fuzeworks
|
* @link http://techfuze.net/fuzeworks
|
||||||
* @since Version 1.2.0
|
* @since Version 1.2.0
|
||||||
*
|
*
|
||||||
* @version Version 1.2.0
|
* @version Version 1.3.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace FuzeWorks;
|
namespace FuzeWorks;
|
||||||
@ -45,7 +45,7 @@ trait ComponentPathsTrait
|
|||||||
*
|
*
|
||||||
* @var array $componentPaths
|
* @var array $componentPaths
|
||||||
*/
|
*/
|
||||||
protected $componentPaths = [];
|
protected array $componentPaths = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the directories. Automatically gets invoked if componentPaths are added by FuzeWorks\Configurator.
|
* Set the directories. Automatically gets invoked if componentPaths are added by FuzeWorks\Configurator.
|
||||||
@ -63,7 +63,7 @@ trait ComponentPathsTrait
|
|||||||
* @param string $componentPath
|
* @param string $componentPath
|
||||||
* @param int $priority
|
* @param int $priority
|
||||||
*/
|
*/
|
||||||
public function addComponentPath($componentPath, $priority = Priority::NORMAL)
|
public function addComponentPath(string $componentPath, int $priority = Priority::NORMAL)
|
||||||
{
|
{
|
||||||
if (!isset($this->componentPaths[$priority]))
|
if (!isset($this->componentPaths[$priority]))
|
||||||
$this->componentPaths[$priority] = [];
|
$this->componentPaths[$priority] = [];
|
||||||
@ -78,7 +78,7 @@ trait ComponentPathsTrait
|
|||||||
* @param string $componentPath
|
* @param string $componentPath
|
||||||
* @param int $priority
|
* @param int $priority
|
||||||
*/
|
*/
|
||||||
public function removeComponentPath($componentPath, $priority = Priority::NORMAL)
|
public function removeComponentPath(string $componentPath, int $priority = Priority::NORMAL)
|
||||||
{
|
{
|
||||||
if (!isset($this->componentPaths[$priority]))
|
if (!isset($this->componentPaths[$priority]))
|
||||||
return;
|
return;
|
||||||
@ -93,8 +93,8 @@ trait ComponentPathsTrait
|
|||||||
* @param int $priority
|
* @param int $priority
|
||||||
* @return array of paths where objects for this component can be found
|
* @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] ?? [];
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -31,7 +31,7 @@
|
|||||||
* @link http://techfuze.net/fuzeworks
|
* @link http://techfuze.net/fuzeworks
|
||||||
* @since Version 0.0.1
|
* @since Version 0.0.1
|
||||||
*
|
*
|
||||||
* @version Version 1.2.0
|
* @version Version 1.3.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace FuzeWorks;
|
namespace FuzeWorks;
|
||||||
@ -52,24 +52,28 @@ class Config
|
|||||||
{
|
{
|
||||||
use ComponentPathsTrait;
|
use ComponentPathsTrait;
|
||||||
|
|
||||||
|
public function __construct() {
|
||||||
|
$this->addComponentPath(Core::$coreDir . DS . 'Config', Priority::LOWEST);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Array where all config files are saved while FuzeWorks runs
|
* Array where all config files are saved while FuzeWorks runs
|
||||||
*
|
*
|
||||||
* @var array Array of all loaded config file ORM's
|
* @var array Array of all loaded config file ORM's
|
||||||
*/
|
*/
|
||||||
protected $cfg = [];
|
protected array $cfg = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Array of config values that will be overridden
|
* Array of config values that will be overridden
|
||||||
*
|
*
|
||||||
* @var array of config values
|
* @var array of config values
|
||||||
*/
|
*/
|
||||||
public static $configOverrides = [];
|
public static array $configOverrides = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve a config file object
|
* 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
|
* @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
|
* @return ConfigORM of the config file. Allows for easy reading and editing of the file
|
||||||
* @throws ConfigException
|
* @throws ConfigException
|
||||||
@ -92,7 +96,7 @@ class Config
|
|||||||
else
|
else
|
||||||
$paths = $this->componentPaths;
|
$paths = $this->componentPaths;
|
||||||
|
|
||||||
// Otherwise try and load a new one
|
// Otherwise, try and load a new one
|
||||||
$this->cfg[$configName] = $this->loadConfigFile($configName, $paths);
|
$this->cfg[$configName] = $this->loadConfigFile($configName, $paths);
|
||||||
return $this->cfg[$configName];
|
return $this->cfg[$configName];
|
||||||
}
|
}
|
||||||
@ -128,7 +132,7 @@ class Config
|
|||||||
/**
|
/**
|
||||||
* Determine whether the file exists and, if so, load the ConfigORM
|
* 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
|
* @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
|
* @return ConfigORM of the config file. Allows for easy reading and editing of the file
|
||||||
* @throws ConfigException
|
* @throws ConfigException
|
||||||
@ -150,6 +154,7 @@ class Config
|
|||||||
return new ConfigORM();
|
return new ConfigORM();
|
||||||
|
|
||||||
// Cycle through all priorities if they exist
|
// Cycle through all priorities if they exist
|
||||||
|
$configORM = new ConfigORM();
|
||||||
for ($i=Priority::getHighestPriority(); $i<=Priority::getLowestPriority(); $i++)
|
for ($i=Priority::getHighestPriority(); $i<=Priority::getLowestPriority(); $i++)
|
||||||
{
|
{
|
||||||
if (!isset($event->configPaths[$i]))
|
if (!isset($event->configPaths[$i]))
|
||||||
@ -161,9 +166,12 @@ class Config
|
|||||||
// If file exists, load it and break the loop
|
// If file exists, load it and break the loop
|
||||||
$file = $configPath . DS . 'config.'.strtolower($event->configName).'.php';
|
$file = $configPath . DS . 'config.'.strtolower($event->configName).'.php';
|
||||||
if (file_exists($file))
|
if (file_exists($file))
|
||||||
{
|
$configORM->addFile($i, $file);
|
||||||
// Load object
|
}
|
||||||
$configORM = (new ConfigORM())->load($file);
|
}
|
||||||
|
|
||||||
|
// And initialize the ORM
|
||||||
|
$configORM->init();
|
||||||
|
|
||||||
// Override config values if they exist
|
// Override config values if they exist
|
||||||
if (isset(self::$configOverrides[$event->configName]))
|
if (isset(self::$configOverrides[$event->configName]))
|
||||||
@ -172,29 +180,8 @@ class Config
|
|||||||
$configORM->{$configKey} = $configValue;
|
$configORM->{$configKey} = $configValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return object
|
if ($configORM->loaded)
|
||||||
return $configORM;
|
return $configORM;
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Try fallback
|
|
||||||
$file = Core::$coreDir . DS . 'Config' . DS . 'config.' . $event->configName . '.php';
|
|
||||||
if (file_exists($file))
|
|
||||||
{
|
|
||||||
// Load object
|
|
||||||
$configORM = (new ConfigORM())->load($file);
|
|
||||||
|
|
||||||
// Override config values if they exist
|
|
||||||
if (isset(self::$configOverrides[$event->configName]))
|
|
||||||
{
|
|
||||||
foreach (self::$configOverrides[$event->configName] as $configKey => $configValue)
|
|
||||||
$configORM->{$configKey} = $configValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return object
|
|
||||||
return $configORM;
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new ConfigException("Could not load config. File $event->configName not found", 1);
|
throw new ConfigException("Could not load config. File $event->configName not found", 1);
|
||||||
}
|
}
|
||||||
|
@ -31,11 +31,12 @@
|
|||||||
* @link http://techfuze.net/fuzeworks
|
* @link http://techfuze.net/fuzeworks
|
||||||
* @since Version 0.0.1
|
* @since Version 0.0.1
|
||||||
*
|
*
|
||||||
* @version Version 1.2.0
|
* @version Version 1.3.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace FuzeWorks\ConfigORM;
|
namespace FuzeWorks\ConfigORM;
|
||||||
use FuzeWorks\Exception\ConfigException;
|
use FuzeWorks\Exception\ConfigException;
|
||||||
|
use FuzeWorks\Priority;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ORM class for config files in PHP files.
|
* ORM class for config files in PHP files.
|
||||||
@ -48,37 +49,61 @@ use FuzeWorks\Exception\ConfigException;
|
|||||||
class ConfigORM extends ConfigORMAbstract
|
class ConfigORM extends ConfigORMAbstract
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The current filename.
|
* The path to the highest priority filename.
|
||||||
*
|
*
|
||||||
* @var string filename
|
* @var string filename
|
||||||
*/
|
*/
|
||||||
private $file;
|
protected string $file;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the ConfigORM file.
|
* Files the ConfigORM is built on
|
||||||
*
|
*
|
||||||
* @param string $file
|
* @var array files
|
||||||
* @return ConfigORM
|
|
||||||
* @throws ConfigException
|
|
||||||
*/
|
*/
|
||||||
public function load(string $file = ''): ConfigORM
|
protected array $files = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the ConfigORM is loaded or not.
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
public bool $loaded = false;
|
||||||
|
|
||||||
|
public function addFile(int $priority, string $file)
|
||||||
{
|
{
|
||||||
if (empty($file))
|
if (!isset($this->files[$priority]))
|
||||||
{
|
$this->files[$priority] = [];
|
||||||
throw new ConfigException('Could not load config file. No file provided', 1);
|
|
||||||
}
|
$this->files[$priority][] = $file;
|
||||||
elseif (file_exists($file))
|
|
||||||
{
|
|
||||||
$this->file = $file;
|
|
||||||
$this->cfg = (array) include $file;
|
|
||||||
$this->originalCfg = $this->cfg;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new ConfigException('Could not load config file. Config file does not exist', 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
public function init()
|
||||||
|
{
|
||||||
|
// Set cfg
|
||||||
|
$this->cfg = [];
|
||||||
|
|
||||||
|
for ($i = Priority::getLowestPriority(); $i >= Priority::getHighestPriority(); $i--) {
|
||||||
|
|
||||||
|
// If priority does not exist for this file, skip it
|
||||||
|
if (!isset($this->files[$i]))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Pass over each file in this priority
|
||||||
|
foreach ($this->files[$i] as $file) {
|
||||||
|
// Read the contents
|
||||||
|
$contents = (array) include $file;
|
||||||
|
|
||||||
|
// Merge them with the config as we know it
|
||||||
|
$this->cfg = array_replace_recursive($this->cfg, $contents);
|
||||||
|
|
||||||
|
// And save the last file that we found (with the highest priority)
|
||||||
|
$this->file = $file;
|
||||||
|
$this->loaded = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// When done, save originalCfg
|
||||||
|
$this->originalCfg = $this->cfg;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -88,6 +113,10 @@ class ConfigORM extends ConfigORMAbstract
|
|||||||
*/
|
*/
|
||||||
public function commit(): bool
|
public function commit(): bool
|
||||||
{
|
{
|
||||||
|
// If config has a lock file, don't write
|
||||||
|
if (isset($this->cfg['lock']))
|
||||||
|
throw new ConfigException("Could not write config file. $this->file is locked with the 'lock' key.");
|
||||||
|
|
||||||
// Write the changes
|
// Write the changes
|
||||||
if (is_writable($this->file)) {
|
if (is_writable($this->file)) {
|
||||||
$config = var_export($this->cfg, true);
|
$config = var_export($this->cfg, true);
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
* @link http://techfuze.net/fuzeworks
|
* @link http://techfuze.net/fuzeworks
|
||||||
* @since Version 0.0.1
|
* @since Version 0.0.1
|
||||||
*
|
*
|
||||||
* @version Version 1.2.0
|
* @version Version 1.3.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace FuzeWorks\ConfigORM;
|
namespace FuzeWorks\ConfigORM;
|
||||||
@ -53,14 +53,14 @@ abstract class ConfigORMAbstract implements Iterator
|
|||||||
*
|
*
|
||||||
* @var array Config file
|
* @var array Config file
|
||||||
*/
|
*/
|
||||||
protected $originalCfg = [];
|
protected array $originalCfg = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The current state of a config file.
|
* The current state of a config file.
|
||||||
*
|
*
|
||||||
* @var array Config file
|
* @var array Config file
|
||||||
*/
|
*/
|
||||||
protected $cfg = [];
|
protected array $cfg = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Revert to the original conditions of the config file.
|
* 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
|
* @return bool true on isset, false on not
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
*/
|
*/
|
||||||
public function __isset($name)
|
public function __isset(string $name)
|
||||||
{
|
{
|
||||||
return isset($this->cfg[$name]);
|
return isset($this->cfg[$name]);
|
||||||
}
|
}
|
||||||
@ -110,7 +110,7 @@ abstract class ConfigORMAbstract implements Iterator
|
|||||||
* @return mixed Value of the requested entry
|
* @return mixed Value of the requested entry
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
*/
|
*/
|
||||||
public function __get($name)
|
public function __get(string $name)
|
||||||
{
|
{
|
||||||
return $this->cfg[$name];
|
return $this->cfg[$name];
|
||||||
}
|
}
|
||||||
@ -122,7 +122,7 @@ abstract class ConfigORMAbstract implements Iterator
|
|||||||
* @return mixed Value of the requested entry
|
* @return mixed Value of the requested entry
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
*/
|
*/
|
||||||
public function get($name)
|
public function get(string $name)
|
||||||
{
|
{
|
||||||
return $this->cfg[$name];
|
return $this->cfg[$name];
|
||||||
}
|
}
|
||||||
@ -134,7 +134,7 @@ abstract class ConfigORMAbstract implements Iterator
|
|||||||
* @param mixed $value Value of the entry
|
* @param mixed $value Value of the entry
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
*/
|
*/
|
||||||
public function __set($name, $value)
|
public function __set(string $name, $value)
|
||||||
{
|
{
|
||||||
$this->cfg[$name] = $value;
|
$this->cfg[$name] = $value;
|
||||||
}
|
}
|
||||||
@ -146,7 +146,7 @@ abstract class ConfigORMAbstract implements Iterator
|
|||||||
* @param mixed $value Value of the entry
|
* @param mixed $value Value of the entry
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
*/
|
*/
|
||||||
public function set($name, $value)
|
public function set(string $name, $value)
|
||||||
{
|
{
|
||||||
$this->cfg[$name] = $value;
|
$this->cfg[$name] = $value;
|
||||||
}
|
}
|
||||||
@ -202,7 +202,7 @@ abstract class ConfigORMAbstract implements Iterator
|
|||||||
* Iterator method.
|
* Iterator method.
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
*/
|
*/
|
||||||
public function valid()
|
public function valid(): bool
|
||||||
{
|
{
|
||||||
return key($this->cfg) !== null;
|
return key($this->cfg) !== null;
|
||||||
}
|
}
|
||||||
@ -212,7 +212,7 @@ abstract class ConfigORMAbstract implements Iterator
|
|||||||
*
|
*
|
||||||
* @return array Config file
|
* @return array Config file
|
||||||
*/
|
*/
|
||||||
public function toArray()
|
public function toArray(): array
|
||||||
{
|
{
|
||||||
return $this->cfg;
|
return $this->cfg;
|
||||||
}
|
}
|
||||||
|
@ -31,10 +31,11 @@
|
|||||||
* @link http://techfuze.net/fuzeworks
|
* @link http://techfuze.net/fuzeworks
|
||||||
* @since Version 0.0.1
|
* @since Version 0.0.1
|
||||||
*
|
*
|
||||||
* @version Version 1.2.0
|
* @version Version 1.3.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace FuzeWorks;
|
namespace FuzeWorks;
|
||||||
|
use Exception;
|
||||||
use FuzeWorks\Exception\ConfiguratorException;
|
use FuzeWorks\Exception\ConfiguratorException;
|
||||||
use FuzeWorks\Exception\InvalidArgumentException;
|
use FuzeWorks\Exception\InvalidArgumentException;
|
||||||
|
|
||||||
@ -58,14 +59,14 @@ class Configurator
|
|||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $parameters = ['debugEnabled' => false];
|
protected array $parameters = ['debugEnabled' => false];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Components that have been added to FuzeWorks
|
* Components that have been added to FuzeWorks
|
||||||
*
|
*
|
||||||
* @var iComponent[]
|
* @var iComponent[]
|
||||||
*/
|
*/
|
||||||
protected $components = [];
|
protected array $components = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Directories that will be passed to FuzeWorks components.
|
* Directories that will be passed to FuzeWorks components.
|
||||||
@ -74,14 +75,14 @@ class Configurator
|
|||||||
*
|
*
|
||||||
* @var array of directories
|
* @var array of directories
|
||||||
*/
|
*/
|
||||||
protected $directories = [];
|
protected array $directories = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Array of ComponentClass methods to be invoked once ComponentClass is loaded
|
* Array of ComponentClass methods to be invoked once ComponentClass is loaded
|
||||||
*
|
*
|
||||||
* @var DeferredComponentClass[]
|
* @var DeferredComponentClass[]
|
||||||
*/
|
*/
|
||||||
protected $deferredComponentClassMethods = [];
|
protected array $deferredComponentClassMethods = [];
|
||||||
|
|
||||||
const COOKIE_SECRET = 'fuzeworks-debug';
|
const COOKIE_SECRET = 'fuzeworks-debug';
|
||||||
|
|
||||||
@ -128,7 +129,7 @@ class Configurator
|
|||||||
* @return $this
|
* @return $this
|
||||||
* @throws InvalidArgumentException
|
* @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))
|
if (!file_exists($directory))
|
||||||
throw new InvalidArgumentException("Could not add directory. Directory does not exist.");
|
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
|
* @param mixed $parameters,... Parameters for the method to be invoked
|
||||||
* @return DeferredComponentClass
|
* @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
|
// Retrieve arguments
|
||||||
$arguments = (func_num_args() > 3 ? array_slice(func_get_args(), 3) : []);
|
$arguments = (func_num_args() > 3 ? array_slice(func_get_args(), 3) : []);
|
||||||
@ -195,7 +196,7 @@ class Configurator
|
|||||||
* @return DeferredComponentClass
|
* @return DeferredComponentClass
|
||||||
* @codeCoverageIgnore
|
* @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());
|
return call_user_func_array([$this, 'deferComponentClassMethod'], func_get_args());
|
||||||
}
|
}
|
||||||
@ -270,8 +271,7 @@ class Configurator
|
|||||||
public function enableDebugMode(): Configurator
|
public function enableDebugMode(): Configurator
|
||||||
{
|
{
|
||||||
$this->parameters['debugEnabled'] = true;
|
$this->parameters['debugEnabled'] = true;
|
||||||
$this->parameters['debugMatch'] = (isset($this->parameters['debugMatch']) ? $this->parameters['debugMatch'] : true);
|
$this->parameters['debugMatch'] = $this->parameters['debugMatch'] ?? true;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -301,13 +301,11 @@ class Configurator
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise we run the regular detectDebugMode from Tracy
|
// Otherwise, we run the regular detectDebugMode from Tracy
|
||||||
$list = is_string($address)
|
$list = is_string($address)
|
||||||
? preg_split('#[,\s]+#', $address)
|
? preg_split('#[,\s]+#', $address)
|
||||||
: (array) $address;
|
: (array) $address;
|
||||||
$addr = isset($_SERVER['REMOTE_ADDR'])
|
$addr = $_SERVER['REMOTE_ADDR'] ?? php_uname('n');
|
||||||
? $_SERVER['REMOTE_ADDR']
|
|
||||||
: php_uname('n');
|
|
||||||
$secret = isset($_COOKIE[self::COOKIE_SECRET]) && is_string($_COOKIE[self::COOKIE_SECRET])
|
$secret = isset($_COOKIE[self::COOKIE_SECRET]) && is_string($_COOKIE[self::COOKIE_SECRET])
|
||||||
? $_COOKIE[self::COOKIE_SECRET]
|
? $_COOKIE[self::COOKIE_SECRET]
|
||||||
: NULL;
|
: NULL;
|
||||||
@ -336,7 +334,7 @@ class Configurator
|
|||||||
* When issue #101 is completed, this should be resolved.
|
* When issue #101 is completed, this should be resolved.
|
||||||
*
|
*
|
||||||
* @return Factory
|
* @return Factory
|
||||||
* @throws \Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function createContainer(): Factory
|
public function createContainer(): Factory
|
||||||
{
|
{
|
||||||
@ -345,7 +343,7 @@ class Configurator
|
|||||||
Core::$logDir = $this->parameters['logDir'];
|
Core::$logDir = $this->parameters['logDir'];
|
||||||
|
|
||||||
// Then prepare the debugger
|
// Then prepare the debugger
|
||||||
$debug = ($this->parameters['debugEnabled'] && $this->parameters['debugMatch'] ? true : false);
|
$debug = $this->parameters['debugEnabled'] && $this->parameters['debugMatch'];
|
||||||
|
|
||||||
// Then load the framework
|
// Then load the framework
|
||||||
$container = Core::init();
|
$container = Core::init();
|
||||||
@ -406,6 +404,10 @@ class Configurator
|
|||||||
$container->{$component}->setDirectories($priorityArray);
|
$container->{$component}->setDirectories($priorityArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// And add the fallback directory
|
||||||
|
$container->config->addComponentPath(Core::$coreDir . DS . 'Config', Priority::LOWEST);
|
||||||
|
|
||||||
|
// Initialize and return the container
|
||||||
$container->initFactory();
|
$container->initFactory();
|
||||||
Logger::stopLevel();
|
Logger::stopLevel();
|
||||||
return $container;
|
return $container;
|
||||||
|
@ -31,11 +31,12 @@
|
|||||||
* @link http://techfuze.net/fuzeworks
|
* @link http://techfuze.net/fuzeworks
|
||||||
* @since Version 0.0.1
|
* @since Version 0.0.1
|
||||||
*
|
*
|
||||||
* @version Version 1.2.0
|
* @version Version 1.3.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace FuzeWorks;
|
namespace FuzeWorks;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
use FuzeWorks\Exception\CoreException;
|
use FuzeWorks\Exception\CoreException;
|
||||||
use FuzeWorks\Exception\EventException;
|
use FuzeWorks\Exception\EventException;
|
||||||
|
|
||||||
@ -55,7 +56,7 @@ class Core
|
|||||||
*
|
*
|
||||||
* @var string Framework version
|
* @var string Framework version
|
||||||
*/
|
*/
|
||||||
public static $version = '1.2.0';
|
public static string $version = '1.2.0';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Working directory of the Framework.
|
* Working directory of the Framework.
|
||||||
@ -64,39 +65,39 @@ class Core
|
|||||||
*
|
*
|
||||||
* @var string
|
* @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
|
* Array of exception handlers, sorted by priority
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected static $exceptionHandlers = [];
|
protected static array $exceptionHandlers = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Array of error handlers, sorted by priority
|
* Array of error handlers, sorted by priority
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected static $errorHandlers = [];
|
protected static array $errorHandlers = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Array of all classMaps which can be autoloaded.
|
* Array of all classMaps which can be autoloaded.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected static $autoloadMap = [];
|
protected static array $autoloadMap = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the core.
|
* Initializes the core.
|
||||||
*
|
*
|
||||||
* @throws \Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public static function init(): Factory
|
public static function init(): Factory
|
||||||
{
|
{
|
||||||
@ -148,6 +149,26 @@ class Core
|
|||||||
Logger::stopLevel();
|
Logger::stopLevel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve a variable name from the php environment, while also providing a fallback variable
|
||||||
|
*
|
||||||
|
* @param string $varName
|
||||||
|
* @param string|null $default
|
||||||
|
* @return array|string|null
|
||||||
|
*/
|
||||||
|
public static function getEnv(string $varName, string $default = null)
|
||||||
|
{
|
||||||
|
// First retrieve the environment variable
|
||||||
|
$var = getenv($varName);
|
||||||
|
|
||||||
|
// If the environment variable doesn't exist, use the default one
|
||||||
|
if ($var === FALSE)
|
||||||
|
return $default;
|
||||||
|
|
||||||
|
// Otherwise, return the variable itself
|
||||||
|
return $var;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether the current running version of PHP is equal to the input string.
|
* Checks whether the current running version of PHP is equal to the input string.
|
||||||
*
|
*
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
* @link http://techfuze.net/fuzeworks
|
* @link http://techfuze.net/fuzeworks
|
||||||
* @since Version 0.0.1
|
* @since Version 0.0.1
|
||||||
*
|
*
|
||||||
* @version Version 1.2.0
|
* @version Version 1.3.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace FuzeWorks;
|
namespace FuzeWorks;
|
||||||
@ -42,17 +42,17 @@ class DeferredComponentClass
|
|||||||
/**
|
/**
|
||||||
* @var string Name of the class to be invoked
|
* @var string Name of the class to be invoked
|
||||||
*/
|
*/
|
||||||
public $componentClass;
|
public string $componentClass;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string name of the method to be invoked
|
* @var string name of the method to be invoked
|
||||||
*/
|
*/
|
||||||
public $method;
|
public string $method;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array arguments to invoke the method with
|
* @var array arguments to invoke the method with
|
||||||
*/
|
*/
|
||||||
public $arguments = [];
|
public array $arguments = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var mixed return from the invoked method
|
* @var mixed return from the invoked method
|
||||||
@ -62,7 +62,7 @@ class DeferredComponentClass
|
|||||||
/**
|
/**
|
||||||
* @var bool Whether the method has been invoked
|
* @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.
|
* @var callable A callback to call when method has been invoked.
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
* @link http://techfuze.net/fuzeworks
|
* @link http://techfuze.net/fuzeworks
|
||||||
* @since Version 0.0.1
|
* @since Version 0.0.1
|
||||||
*
|
*
|
||||||
* @version Version 1.2.0
|
* @version Version 1.3.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace FuzeWorks;
|
namespace FuzeWorks;
|
||||||
@ -46,7 +46,7 @@ namespace FuzeWorks;
|
|||||||
*/
|
*/
|
||||||
class Event
|
class Event
|
||||||
{
|
{
|
||||||
private $cancelled = false;
|
private bool $cancelled = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return bool True if the event is cancelled, false if the event is not cancelled
|
* @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
|
* @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) {
|
if ($cancelled == true) {
|
||||||
$this->cancelled = true;
|
$this->cancelled = true;
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
* @link http://techfuze.net/fuzeworks
|
* @link http://techfuze.net/fuzeworks
|
||||||
* @since Version 0.0.1
|
* @since Version 0.0.1
|
||||||
*
|
*
|
||||||
* @version Version 1.2.0
|
* @version Version 1.3.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace FuzeWorks\Event;
|
namespace FuzeWorks\Event;
|
||||||
@ -54,14 +54,14 @@ class ConfigGetEvent extends Event
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $configName;
|
public string $configName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The directories the config might be found in
|
* The directories the config might be found in
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $configPaths;
|
public array $configPaths;
|
||||||
|
|
||||||
|
|
||||||
public function init(string $configName, array $configPaths)
|
public function init(string $configName, array $configPaths)
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
* @link http://techfuze.net/fuzeworks
|
* @link http://techfuze.net/fuzeworks
|
||||||
* @since Version 1.2.0
|
* @since Version 1.2.0
|
||||||
*
|
*
|
||||||
* @version Version 1.2.0
|
* @version Version 1.3.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace FuzeWorks\Event;
|
namespace FuzeWorks\Event;
|
||||||
@ -51,7 +51,7 @@ class HaltExecutionEvent extends Event
|
|||||||
/**
|
/**
|
||||||
* @var array Log
|
* @var array Log
|
||||||
*/
|
*/
|
||||||
public $log;
|
public array $log;
|
||||||
|
|
||||||
public function init(array $log)
|
public function init(array $log)
|
||||||
{
|
{
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
* @link http://techfuze.net/fuzeworks
|
* @link http://techfuze.net/fuzeworks
|
||||||
* @since Version 0.0.1
|
* @since Version 0.0.1
|
||||||
*
|
*
|
||||||
* @version Version 1.2.0
|
* @version Version 1.3.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace FuzeWorks\Event;
|
namespace FuzeWorks\Event;
|
||||||
@ -54,14 +54,14 @@ class HelperLoadEvent extends Event
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $helperName;
|
public string $helperName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The directory of the helper that gets loaded
|
* The directory of the helper that gets loaded
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $helperPaths;
|
public array $helperPaths;
|
||||||
|
|
||||||
|
|
||||||
public function init(string $helperName, array $helperPaths)
|
public function init(string $helperName, array $helperPaths)
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
* @link http://techfuze.net/fuzeworks
|
* @link http://techfuze.net/fuzeworks
|
||||||
* @since Version 1.1.4
|
* @since Version 1.1.4
|
||||||
*
|
*
|
||||||
* @version Version 1.2.0
|
* @version Version 1.3.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace FuzeWorks\Event;
|
namespace FuzeWorks\Event;
|
||||||
@ -51,14 +51,14 @@ class PluginGetEvent extends Event
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $pluginName;
|
public string $pluginName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Potential plugin to return instead. If set, the plugins class will return this object
|
* 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)
|
public function init($pluginName)
|
||||||
{
|
{
|
||||||
@ -70,7 +70,7 @@ class PluginGetEvent extends Event
|
|||||||
*
|
*
|
||||||
* @param object $plugin
|
* @param object $plugin
|
||||||
*/
|
*/
|
||||||
public function setPlugin($plugin)
|
public function setPlugin(object $plugin)
|
||||||
{
|
{
|
||||||
$this->plugin = $plugin;
|
$this->plugin = $plugin;
|
||||||
}
|
}
|
||||||
@ -80,7 +80,7 @@ class PluginGetEvent extends Event
|
|||||||
*
|
*
|
||||||
* @return object|null $plugin
|
* @return object|null $plugin
|
||||||
*/
|
*/
|
||||||
public function getPlugin()
|
public function getPlugin(): ?object
|
||||||
{
|
{
|
||||||
return $this->plugin;
|
return $this->plugin;
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
* @link http://techfuze.net/fuzeworks
|
* @link http://techfuze.net/fuzeworks
|
||||||
* @since Version 0.0.1
|
* @since Version 0.0.1
|
||||||
*
|
*
|
||||||
* @version Version 1.2.0
|
* @version Version 1.3.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace FuzeWorks;
|
namespace FuzeWorks;
|
||||||
@ -66,7 +66,7 @@ class Events
|
|||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public static $listeners = array();
|
public static array $listeners = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether the event system is enabled or not.
|
* Whether the event system is enabled or not.
|
||||||
@ -129,7 +129,7 @@ class Events
|
|||||||
*
|
*
|
||||||
* @throws EventException
|
* @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) {
|
if (Priority::getPriority($priority) == false) {
|
||||||
throw new EventException('Unknown priority '.$priority);
|
throw new EventException('Unknown priority '.$priority);
|
||||||
@ -169,7 +169,7 @@ class Events
|
|||||||
$eventName = end($eventName);
|
$eventName = end($eventName);
|
||||||
$event = $input;
|
$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))
|
elseif (is_string($input))
|
||||||
{
|
{
|
||||||
$eventClass = ucfirst($input);
|
$eventClass = ucfirst($input);
|
||||||
@ -224,15 +224,15 @@ class Events
|
|||||||
//Check for listeners in this priority
|
//Check for listeners in this priority
|
||||||
if (isset(self::$listeners[$eventName][$priority])) {
|
if (isset(self::$listeners[$eventName][$priority])) {
|
||||||
$listeners = self::$listeners[$eventName][$priority];
|
$listeners = self::$listeners[$eventName][$priority];
|
||||||
Logger::newLevel('Found listeners with priority '.Priority::getPriority($priority));
|
Logger::newLevel('Listeners with priority '.Priority::getPriority($priority));
|
||||||
//Fire the event to each listener
|
//Fire the event to each listener
|
||||||
foreach ($listeners as $callbackArray) {
|
foreach ($listeners as $callbackArray) {
|
||||||
// @codeCoverageIgnoreStart
|
// @codeCoverageIgnoreStart
|
||||||
$callback = $callbackArray[0];
|
$callback = $callbackArray[0];
|
||||||
if (is_callable($callback)) {
|
if (is_array($callback)) {
|
||||||
Logger::newLevel('Firing function');
|
|
||||||
} elseif (!is_string($callback[0])) {
|
|
||||||
Logger::newLevel('Firing '.get_class($callback[0]).'->'.$callback[1]);
|
Logger::newLevel('Firing '.get_class($callback[0]).'->'.$callback[1]);
|
||||||
|
} elseif (is_callable($callback)) {
|
||||||
|
Logger::newLevel('Firing function');
|
||||||
} else {
|
} else {
|
||||||
Logger::newLevel('Firing '.implode('->', $callback));
|
Logger::newLevel('Firing '.implode('->', $callback));
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
* @link http://techfuze.net/fuzeworks
|
* @link http://techfuze.net/fuzeworks
|
||||||
* @since Version 0.0.1
|
* @since Version 0.0.1
|
||||||
*
|
*
|
||||||
* @version Version 1.2.0
|
* @version Version 1.3.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace FuzeWorks;
|
namespace FuzeWorks;
|
||||||
@ -67,56 +67,55 @@ class Factory
|
|||||||
/**
|
/**
|
||||||
* The Factory instance that is shared by default when calling Factory::getInstance();
|
* 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
|
* Whether the Factory has been initialized or not
|
||||||
*
|
*
|
||||||
* @var bool $initialized
|
* @var bool $initialized
|
||||||
*/
|
*/
|
||||||
private $initialized = false;
|
private bool $initialized = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Config Object
|
* Config Object
|
||||||
* @var Config
|
* @var Config
|
||||||
*/
|
*/
|
||||||
public $config;
|
public Config $config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logger Object
|
* Logger Object
|
||||||
* @var Logger
|
* @var Logger
|
||||||
*/
|
*/
|
||||||
public $logger;
|
public Logger $logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Events Object
|
* Events Object
|
||||||
* @var Events
|
* @var Events
|
||||||
*/
|
*/
|
||||||
public $events;
|
public Events $events;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Libraries Object
|
* Libraries Object
|
||||||
* @var Libraries
|
* @var Libraries
|
||||||
*/
|
*/
|
||||||
public $libraries;
|
public Libraries $libraries;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helpers Object
|
* Helpers Object
|
||||||
* @var Helpers
|
* @var Helpers
|
||||||
*/
|
*/
|
||||||
public $helpers;
|
public Helpers $helpers;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plugins Object
|
* Plugins Object
|
||||||
* @var Plugins
|
* @var Plugins
|
||||||
*/
|
*/
|
||||||
public $plugins;
|
public Plugins $plugins;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory instance constructor. Should only really be called once
|
* Factory instance constructor. Should only really be called once
|
||||||
* @throws ConfigException
|
|
||||||
* @throws FactoryException
|
* @throws FactoryException
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
@ -140,11 +139,8 @@ class Factory
|
|||||||
// Otherwise, copy the existing instances
|
// Otherwise, copy the existing instances
|
||||||
$x = self::getInstance();
|
$x = self::getInstance();
|
||||||
foreach ($x as $key => $value)
|
foreach ($x as $key => $value)
|
||||||
{
|
|
||||||
$this->{$key} = $value;
|
$this->{$key} = $value;
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -173,6 +169,9 @@ class Factory
|
|||||||
// Initialize all components
|
// Initialize all components
|
||||||
foreach ($this as $component)
|
foreach ($this as $component)
|
||||||
{
|
{
|
||||||
|
if (!is_object($component))
|
||||||
|
continue;
|
||||||
|
|
||||||
if (method_exists($component, 'init'))
|
if (method_exists($component, 'init'))
|
||||||
$component->init();
|
$component->init();
|
||||||
}
|
}
|
||||||
@ -223,7 +222,7 @@ class Factory
|
|||||||
* @return Factory Instance
|
* @return Factory Instance
|
||||||
* @throws FactoryException
|
* @throws FactoryException
|
||||||
*/
|
*/
|
||||||
public function newInstance($className, $namespace = 'FuzeWorks\\'): self
|
public function newInstance(string $className, string $namespace = 'FuzeWorks\\'): self
|
||||||
{
|
{
|
||||||
// Determine the class to load
|
// Determine the class to load
|
||||||
$instanceName = strtolower($className);
|
$instanceName = strtolower($className);
|
||||||
@ -285,7 +284,7 @@ class Factory
|
|||||||
* @param mixed $object Object to replace the class with
|
* @param mixed $object Object to replace the class with
|
||||||
* @return Factory Instance
|
* @return Factory Instance
|
||||||
*/
|
*/
|
||||||
public function setInstance($objectName, $object): self
|
public function setInstance(string $objectName, $object): self
|
||||||
{
|
{
|
||||||
// Determine the instance name
|
// Determine the instance name
|
||||||
$instanceName = strtolower($objectName);
|
$instanceName = strtolower($objectName);
|
||||||
@ -305,7 +304,7 @@ class Factory
|
|||||||
* @return Factory Factory Instance
|
* @return Factory Factory Instance
|
||||||
* @throws FactoryException
|
* @throws FactoryException
|
||||||
*/
|
*/
|
||||||
public function removeInstance($className): self
|
public function removeInstance(string $className): self
|
||||||
{
|
{
|
||||||
// Determine the instance name
|
// Determine the instance name
|
||||||
$instanceName = strtolower($className);
|
$instanceName = strtolower($className);
|
||||||
@ -328,7 +327,7 @@ class Factory
|
|||||||
* @param $componentName
|
* @param $componentName
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function instanceIsset($componentName)
|
public function instanceIsset($componentName): bool
|
||||||
{
|
{
|
||||||
return isset($this->{$componentName});
|
return isset($this->{$componentName});
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
* @link http://techfuze.net/fuzeworks
|
* @link http://techfuze.net/fuzeworks
|
||||||
* @since Version 0.0.1
|
* @since Version 0.0.1
|
||||||
*
|
*
|
||||||
* @version Version 1.2.0
|
* @version Version 1.3.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace FuzeWorks;
|
namespace FuzeWorks;
|
||||||
@ -49,7 +49,7 @@ use FuzeWorks\Exception\HelperException;
|
|||||||
* Text Helpers perform various text formatting routines, Cookie Helpers set and read cookies,
|
* Text Helpers perform various text formatting routines, Cookie Helpers set and read cookies,
|
||||||
* File Helpers help you deal with files, etc.
|
* 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.
|
* 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,
|
* 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
|
* @var array Array of loaded helperNames
|
||||||
*/
|
*/
|
||||||
protected $helpers = [];
|
protected array $helpers = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load a helper.
|
* Load a helper.
|
||||||
@ -145,14 +145,14 @@ class Helpers
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Alias for load
|
* Alias for load
|
||||||
* @see load() for more details
|
|
||||||
*
|
|
||||||
* @param string $helperName Name of the helper
|
* @param string $helperName Name of the helper
|
||||||
* @param array $helperPaths
|
* @param array $helperPaths
|
||||||
* @return bool Whether the helper was successfully loaded (true if yes)
|
* @return bool Whether the helper was successfully loaded (true if yes)
|
||||||
* @throws HelperException
|
* @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);
|
return $this->load($helperName, $helperPaths);
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
* @link http://techfuze.net/fuzeworks
|
* @link http://techfuze.net/fuzeworks
|
||||||
* @since Version 0.0.1
|
* @since Version 0.0.1
|
||||||
*
|
*
|
||||||
* @version Version 1.2.0
|
* @version Version 1.3.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace FuzeWorks;
|
namespace FuzeWorks;
|
||||||
@ -40,7 +40,6 @@ use FuzeWorks\Exception\ConfigException;
|
|||||||
use FuzeWorks\Exception\CoreException;
|
use FuzeWorks\Exception\CoreException;
|
||||||
use FuzeWorks\Exception\LibraryException;
|
use FuzeWorks\Exception\LibraryException;
|
||||||
use ReflectionClass;
|
use ReflectionClass;
|
||||||
use ReflectionException;
|
|
||||||
|
|
||||||
class Libraries
|
class Libraries
|
||||||
{
|
{
|
||||||
@ -51,14 +50,14 @@ class Libraries
|
|||||||
*
|
*
|
||||||
* @var array Library objects
|
* @var array Library objects
|
||||||
*/
|
*/
|
||||||
protected $libraryObjects = [];
|
protected array $libraryObjects = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Array of libraries with their classnames, so they can be easily loaded
|
* Array of libraries with their classnames, so they can be easily loaded
|
||||||
*
|
*
|
||||||
* @var array Library classes
|
* @var array Library classes
|
||||||
*/
|
*/
|
||||||
protected $libraryClasses = [];
|
protected array $libraryClasses = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FuzeWorks Factory object. For internal use.
|
* FuzeWorks Factory object. For internal use.
|
||||||
@ -83,7 +82,7 @@ class Libraries
|
|||||||
* @param string $libraryName
|
* @param string $libraryName
|
||||||
* @param object $libraryObject
|
* @param object $libraryObject
|
||||||
*/
|
*/
|
||||||
public function addLibraryObject(string $libraryName, $libraryObject)
|
public function addLibraryObject(string $libraryName, object $libraryObject)
|
||||||
{
|
{
|
||||||
$this->libraryObjects[strtolower($libraryName)] = $libraryObject;
|
$this->libraryObjects[strtolower($libraryName)] = $libraryObject;
|
||||||
}
|
}
|
||||||
@ -97,7 +96,7 @@ class Libraries
|
|||||||
*/
|
*/
|
||||||
public function addLibraryClass(string $libraryName, string $libraryClass)
|
public function addLibraryClass(string $libraryName, string $libraryClass)
|
||||||
{
|
{
|
||||||
if (!class_exists($libraryClass, false))
|
if (!class_exists($libraryClass, true))
|
||||||
throw new LibraryException("Could not add library class. '" . $libraryClass . "' could not be loaded.", 1);
|
throw new LibraryException("Could not add library class. '" . $libraryClass . "' could not be loaded.", 1);
|
||||||
|
|
||||||
$this->libraryClasses[strtolower($libraryName)] = $libraryClass;
|
$this->libraryClasses[strtolower($libraryName)] = $libraryClass;
|
||||||
@ -213,8 +212,6 @@ class Libraries
|
|||||||
$prefix = $classObject->getClassesPrefix();
|
$prefix = $classObject->getClassesPrefix();
|
||||||
if (!is_null($filePath) && !is_null($prefix))
|
if (!is_null($filePath) && !is_null($prefix))
|
||||||
Core::addAutoloadMap($prefix, $filePath);
|
Core::addAutoloadMap($prefix, $filePath);
|
||||||
} catch (ReflectionException $e) {
|
|
||||||
throw new LibraryException("Could not initiate library. ReflectionClass threw exception.");
|
|
||||||
} catch (CoreException $e) {
|
} catch (CoreException $e) {
|
||||||
throw new LibraryException("Could not initiate library. Failed to add to autoloader.");
|
throw new LibraryException("Could not initiate library. Failed to add to autoloader.");
|
||||||
}
|
}
|
||||||
|
@ -31,14 +31,15 @@
|
|||||||
* @link http://techfuze.net/fuzeworks
|
* @link http://techfuze.net/fuzeworks
|
||||||
* @since Version 0.0.1
|
* @since Version 0.0.1
|
||||||
*
|
*
|
||||||
* @version Version 1.2.0
|
* @version Version 1.3.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace FuzeWorks;
|
namespace FuzeWorks;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
use FuzeWorks\Exception\ConfigException;
|
use FuzeWorks\Exception\ConfigException;
|
||||||
use FuzeWorks\Exception\EventException;
|
use FuzeWorks\Exception\EventException;
|
||||||
use FuzeWorks\Exception\Exception;
|
use Throwable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logger Class.
|
* Logger Class.
|
||||||
@ -57,21 +58,21 @@ class Logger {
|
|||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public static $logs = [];
|
public static array $logs = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* whether to output the log after FuzeWorks has run.
|
* whether to output the log after FuzeWorks has run.
|
||||||
*
|
*
|
||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
private static $print_to_screen = false;
|
private static bool $print_to_screen = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether the Logger has been enabled or not
|
* Whether the Logger has been enabled or not
|
||||||
*
|
*
|
||||||
* @var bool
|
* @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.
|
* whether to output the log of the last entire request to a file after FuzeWorks has run.
|
||||||
@ -92,21 +93,21 @@ class Logger {
|
|||||||
*
|
*
|
||||||
* @var string Template name
|
* @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.
|
* whether to output the log after FuzeWorks has run, regardless of conditions.
|
||||||
*
|
*
|
||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
public static $debug = false;
|
public static bool $debug = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of all benchmark markpoints.
|
* List of all benchmark markpoints.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public static $markPoints = [];
|
public static array $markPoints = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initiates the Logger.
|
* Initiates the Logger.
|
||||||
@ -188,8 +189,8 @@ class Logger {
|
|||||||
*/
|
*/
|
||||||
public static function enableHandlers()
|
public static function enableHandlers()
|
||||||
{
|
{
|
||||||
Core::addErrorHandler(['\FuzeWorks\Logger', 'errorHandler'], Priority::NORMAL);
|
Core::addErrorHandler(['\FuzeWorks\Logger', 'errorHandler']);
|
||||||
Core::addExceptionHandler(['\FuzeWorks\Logger', 'exceptionHandler'], Priority::NORMAL);
|
Core::addExceptionHandler(['\FuzeWorks\Logger', 'exceptionHandler']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -200,8 +201,8 @@ class Logger {
|
|||||||
*/
|
*/
|
||||||
public static function disableHandlers()
|
public static function disableHandlers()
|
||||||
{
|
{
|
||||||
Core::removeErrorHandler(['\FuzeWorks\Logger', 'errorHandler'], Priority::NORMAL);
|
Core::removeErrorHandler(['\FuzeWorks\Logger', 'errorHandler']);
|
||||||
Core::removeExceptionHandler(['\FuzeWorks\Logger', 'exceptionHandler'], Priority::NORMAL);
|
Core::removeExceptionHandler(['\FuzeWorks\Logger', 'exceptionHandler']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -265,7 +266,7 @@ class Logger {
|
|||||||
* @param int Line. The line on which the error occured.
|
* @param int Line. The line on which the error occured.
|
||||||
* @param array context. Some of the error's relevant variables
|
* @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
|
// Check type
|
||||||
$thisType = self::getType($type);
|
$thisType = self::getType($type);
|
||||||
@ -279,20 +280,21 @@ class Logger {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Exception handler
|
* Exception handler
|
||||||
* Will be triggered when an uncaught exception occures. This function shows the error-message, and shuts down the script.
|
* Will be triggered when an uncaught exception occurs. This function shows the error-message, and shuts down the script.
|
||||||
* Please note that most of the user-defined exceptions will be caught in the router, and handled with the error-controller.
|
* Please note that most of the user-defined exceptions will be caught in the router, and handled with the error-controller.
|
||||||
*
|
*
|
||||||
* @param Exception $exception The occured exception.
|
* @param Throwable $exception The occurred exception.
|
||||||
* @param bool $haltExecution. Defaults to true
|
* @param bool $haltExecution. Defaults to true
|
||||||
*/
|
*/
|
||||||
public static function exceptionHandler($exception, bool $haltExecution = true)
|
public static function exceptionHandler(Throwable $exception, bool $haltExecution = true)
|
||||||
{
|
{
|
||||||
$LOG = array('type' => 'EXCEPTION',
|
$LOG = [
|
||||||
|
'type' => $exception instanceof Exception ? "EXCEPTION" : "ERROR",
|
||||||
'message' => $exception->getMessage(),
|
'message' => $exception->getMessage(),
|
||||||
'logFile' => $exception->getFile(),
|
'logFile' => $exception->getFile(),
|
||||||
'logLine' => $exception->getLine(),
|
'logLine' => $exception->getLine(),
|
||||||
'context' => $exception->getTraceAsString(),
|
'context' => $exception->getTraceAsString(),
|
||||||
'runtime' => round(self::getRelativeTime(), 4),);
|
'runtime' => round(self::getRelativeTime(), 4),];
|
||||||
self::$logs[] = $LOG;
|
self::$logs[] = $LOG;
|
||||||
|
|
||||||
// And return a 500 because this error was fatal
|
// And return a 500 because this error was fatal
|
||||||
@ -375,7 +377,7 @@ class Logger {
|
|||||||
* @param string $name Marker name
|
* @param string $name Marker name
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function mark($name)
|
public static function mark(string $name)
|
||||||
{
|
{
|
||||||
$LOG = array('type' => 'BMARK',
|
$LOG = array('type' => 'BMARK',
|
||||||
'message' => (!is_null($name) ? $name : ''),
|
'message' => (!is_null($name) ? $name : ''),
|
||||||
@ -388,30 +390,30 @@ class Logger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a information log entry.
|
* Create an information log entry.
|
||||||
*
|
*
|
||||||
* @param string $msg The information to be logged
|
* @param string $msg The information to be logged
|
||||||
* @param string $mod The name of the module
|
* @param string|null $mod The name of the module
|
||||||
* @param string $file The file where the log occurred
|
* @param string|null $file The file where the log occurred
|
||||||
* @param int $line The line 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);
|
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 $msg The information to be logged
|
||||||
* @param string $mod The name of the module
|
* @param string|null $mod The name of the module
|
||||||
* @param string $file The file where the log occurred
|
* @param string|null $file The file where the log occurred
|
||||||
* @param int $line The line 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',
|
$LOG = array('type' => 'INFO',
|
||||||
'message' => (!is_null($msg) ? $msg : ''),
|
'message' => ($msg),
|
||||||
'logFile' => (!is_null($file) ? $file : ''),
|
'logFile' => (!is_null($file) ? $file : ''),
|
||||||
'logLine' => (!is_null($line) ? $line : ''),
|
'logLine' => (!is_null($line) ? $line : ''),
|
||||||
'context' => (!is_null($mod) ? $mod : ''),
|
'context' => (!is_null($mod) ? $mod : ''),
|
||||||
@ -421,17 +423,17 @@ class Logger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a information log entry.
|
* Create an information log entry.
|
||||||
*
|
*
|
||||||
* @param string $msg The information to be logged
|
* @param string $msg The information to be logged
|
||||||
* @param string $mod The name of the module
|
* @param string|null $mod The name of the module
|
||||||
* @param string $file The file where the log occurred
|
* @param string|null $file The file where the log occurred
|
||||||
* @param int $line The line 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',
|
$LOG = array('type' => 'DEBUG',
|
||||||
'message' => (!is_null($msg) ? $msg : ''),
|
'message' => ($msg),
|
||||||
'logFile' => (!is_null($file) ? $file : ''),
|
'logFile' => (!is_null($file) ? $file : ''),
|
||||||
'logLine' => (!is_null($line) ? $line : ''),
|
'logLine' => (!is_null($line) ? $line : ''),
|
||||||
'context' => (!is_null($mod) ? $mod : ''),
|
'context' => (!is_null($mod) ? $mod : ''),
|
||||||
@ -444,14 +446,14 @@ class Logger {
|
|||||||
* Create a error log entry.
|
* Create a error log entry.
|
||||||
*
|
*
|
||||||
* @param string $msg The information to be logged
|
* @param string $msg The information to be logged
|
||||||
* @param string $mod The name of the module
|
* @param string|null $mod The name of the module
|
||||||
* @param string $file The file where the log occurred
|
* @param string|null $file The file where the log occurred
|
||||||
* @param int $line The line 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',
|
$LOG = array('type' => 'ERROR',
|
||||||
'message' => (!is_null($msg) ? $msg : ''),
|
'message' => ($msg),
|
||||||
'logFile' => (!is_null($file) ? $file : ''),
|
'logFile' => (!is_null($file) ? $file : ''),
|
||||||
'logLine' => (!is_null($line) ? $line : ''),
|
'logLine' => (!is_null($line) ? $line : ''),
|
||||||
'context' => (!is_null($mod) ? $mod : ''),
|
'context' => (!is_null($mod) ? $mod : ''),
|
||||||
@ -464,14 +466,14 @@ class Logger {
|
|||||||
* Create a warning log entry.
|
* Create a warning log entry.
|
||||||
*
|
*
|
||||||
* @param string $msg The information to be logged
|
* @param string $msg The information to be logged
|
||||||
* @param string $mod The name of the module
|
* @param string|null $mod The name of the module
|
||||||
* @param string $file The file where the log occurred
|
* @param string|null $file The file where the log occurred
|
||||||
* @param int $line The line 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',
|
$LOG = array('type' => 'WARNING',
|
||||||
'message' => (!is_null($msg) ? $msg : ''),
|
'message' => ($msg),
|
||||||
'logFile' => (!is_null($file) ? $file : ''),
|
'logFile' => (!is_null($file) ? $file : ''),
|
||||||
'logLine' => (!is_null($line) ? $line : ''),
|
'logLine' => (!is_null($line) ? $line : ''),
|
||||||
'context' => (!is_null($mod) ? $mod : ''),
|
'context' => (!is_null($mod) ? $mod : ''),
|
||||||
@ -484,14 +486,14 @@ class Logger {
|
|||||||
* Create a new Level log entry. Used to categorise logs.
|
* Create a new Level log entry. Used to categorise logs.
|
||||||
*
|
*
|
||||||
* @param string $msg The name of the new level
|
* @param string $msg The name of the new level
|
||||||
* @param string $mod The name of the module
|
* @param string|null $mod The name of the module
|
||||||
* @param string $file The file where the log occurred
|
* @param string|null $file The file where the log occurred
|
||||||
* @param int $line The line 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',
|
$LOG = array('type' => 'LEVEL_START',
|
||||||
'message' => (!is_null($msg) ? $msg : ''),
|
'message' => ($msg),
|
||||||
'logFile' => (!is_null($file) ? $file : ''),
|
'logFile' => (!is_null($file) ? $file : ''),
|
||||||
'logLine' => (!is_null($line) ? $line : ''),
|
'logLine' => (!is_null($line) ? $line : ''),
|
||||||
'context' => (!is_null($mod) ? $mod : ''),
|
'context' => (!is_null($mod) ? $mod : ''),
|
||||||
@ -503,12 +505,12 @@ class Logger {
|
|||||||
/**
|
/**
|
||||||
* Create a stop Level log entry. Used to close log categories.
|
* Create a stop Level log entry. Used to close log categories.
|
||||||
*
|
*
|
||||||
* @param string $msg The name of the new level
|
* @param string|null $msg The name of the new level
|
||||||
* @param string $mod The name of the module
|
* @param string|null $mod The name of the module
|
||||||
* @param string $file The file where the log occurred
|
* @param string|null $file The file where the log occurred
|
||||||
* @param int $line The line 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',
|
$LOG = array('type' => 'LEVEL_STOP',
|
||||||
'message' => (!is_null($msg) ? $msg : ''),
|
'message' => (!is_null($msg) ? $msg : ''),
|
||||||
@ -530,42 +532,29 @@ class Logger {
|
|||||||
*
|
*
|
||||||
* @return string String representation
|
* @return string String representation
|
||||||
*/
|
*/
|
||||||
public static function getType($type): string
|
public static function getType(int $type): string
|
||||||
{
|
{
|
||||||
switch ($type) {
|
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:
|
case E_ERROR:
|
||||||
return 'ERROR';
|
return 'ERROR';
|
||||||
case E_WARNING:
|
|
||||||
return 'WARNING';
|
|
||||||
case E_PARSE:
|
|
||||||
return 'ERROR';
|
|
||||||
case E_NOTICE:
|
case E_NOTICE:
|
||||||
return 'WARNING';
|
|
||||||
case E_CORE_ERROR:
|
|
||||||
return 'ERROR';
|
|
||||||
case E_CORE_WARNING:
|
case E_CORE_WARNING:
|
||||||
return 'WARNING';
|
|
||||||
case E_COMPILE_ERROR:
|
|
||||||
return 'ERROR';
|
|
||||||
case E_COMPILE_WARNING:
|
case E_COMPILE_WARNING:
|
||||||
return 'WARNING';
|
|
||||||
case E_USER_ERROR:
|
|
||||||
return 'ERROR';
|
|
||||||
case E_USER_WARNING:
|
case E_USER_WARNING:
|
||||||
return 'WARNING';
|
|
||||||
case E_USER_NOTICE:
|
case E_USER_NOTICE:
|
||||||
return 'WARNING';
|
|
||||||
case E_USER_DEPRECATED:
|
case E_USER_DEPRECATED:
|
||||||
return 'WARNING';
|
|
||||||
case E_STRICT:
|
|
||||||
return 'ERROR';
|
|
||||||
case E_RECOVERABLE_ERROR:
|
|
||||||
return 'ERROR';
|
|
||||||
case E_DEPRECATED:
|
case E_DEPRECATED:
|
||||||
|
case E_WARNING:
|
||||||
return 'WARNING';
|
return 'WARNING';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $type = 'Unknown error: ' . $type;
|
return 'Unknown error: ' . $type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -600,8 +589,6 @@ class Logger {
|
|||||||
private static function getRelativeTime(): float
|
private static function getRelativeTime(): float
|
||||||
{
|
{
|
||||||
$startTime = STARTTIME;
|
$startTime = STARTTIME;
|
||||||
$time = microtime(true) - $startTime;
|
return microtime(true) - $startTime;
|
||||||
|
|
||||||
return $time;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -31,7 +31,7 @@
|
|||||||
* @link http://techfuze.net/fuzeworks
|
* @link http://techfuze.net/fuzeworks
|
||||||
* @since Version 1.1.4
|
* @since Version 1.1.4
|
||||||
*
|
*
|
||||||
* @version Version 1.2.0
|
* @version Version 1.3.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace FuzeWorks;
|
namespace FuzeWorks;
|
||||||
@ -41,7 +41,6 @@ use FuzeWorks\Exception\CoreException;
|
|||||||
use FuzeWorks\Exception\FactoryException;
|
use FuzeWorks\Exception\FactoryException;
|
||||||
use FuzeWorks\Exception\PluginException;
|
use FuzeWorks\Exception\PluginException;
|
||||||
use ReflectionClass;
|
use ReflectionClass;
|
||||||
use ReflectionException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plugins Class.
|
* Plugins Class.
|
||||||
@ -72,7 +71,7 @@ class Plugins
|
|||||||
*
|
*
|
||||||
* @var array Array of loaded plugins
|
* @var array Array of loaded plugins
|
||||||
*/
|
*/
|
||||||
protected $plugins = array();
|
protected array $plugins = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Array of plugin header classes.
|
* Array of plugin header classes.
|
||||||
@ -80,14 +79,14 @@ class Plugins
|
|||||||
*
|
*
|
||||||
* @var array Array of loaded plugin header classes
|
* @var array Array of loaded plugin header classes
|
||||||
*/
|
*/
|
||||||
protected $headers = array();
|
protected array $headers = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Config file for the plugin system
|
* Config file for the plugin system
|
||||||
*
|
*
|
||||||
* @var ConfigORM
|
* @var ConfigORM
|
||||||
*/
|
*/
|
||||||
protected $cfg;
|
protected ConfigORM $cfg;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called upon initialization of the Container
|
* Called upon initialization of the Container
|
||||||
@ -142,11 +141,7 @@ class Plugins
|
|||||||
// Load the header
|
// Load the header
|
||||||
$this->loadHeader($header);
|
$this->loadHeader($header);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If it doesn't exist, skip it
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -197,13 +192,12 @@ class Plugins
|
|||||||
* Get a plugin.
|
* Get a plugin.
|
||||||
*
|
*
|
||||||
* @param string $pluginName Name of the 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
|
* @return mixed Plugin on success, bool on cancellation
|
||||||
* @throws Exception\EventException
|
* @throws Exception\EventException
|
||||||
* @throws PluginException
|
* @throws PluginException
|
||||||
* @throws ReflectionException
|
|
||||||
*/
|
*/
|
||||||
public function get($pluginName, array $parameters = null)
|
public function get(string $pluginName, array $parameters = null)
|
||||||
{
|
{
|
||||||
if (empty($pluginName))
|
if (empty($pluginName))
|
||||||
throw new PluginException("Could not load plugin. No name provided", 1);
|
throw new PluginException("Could not load plugin. No name provided", 1);
|
||||||
@ -219,7 +213,7 @@ class Plugins
|
|||||||
elseif ($event->getPlugin() != null)
|
elseif ($event->getPlugin() != null)
|
||||||
return $event->getPlugin();
|
return $event->getPlugin();
|
||||||
|
|
||||||
// Otherwise just set the variables
|
// Otherwise, just set the variables
|
||||||
$pluginName = $event->pluginName;
|
$pluginName = $event->pluginName;
|
||||||
|
|
||||||
// Check if the plugin is already loaded and return directly
|
// Check if the plugin is already loaded and return directly
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
* @link http://techfuze.net/fuzeworks
|
* @link http://techfuze.net/fuzeworks
|
||||||
* @since Version 0.0.1
|
* @since Version 0.0.1
|
||||||
*
|
*
|
||||||
* @version Version 1.2.0
|
* @version Version 1.3.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace FuzeWorks;
|
namespace FuzeWorks;
|
||||||
@ -90,22 +90,22 @@ abstract class Priority
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the highest 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
|
* @return int
|
||||||
*/
|
*/
|
||||||
public static function getHighestPriority()
|
public static function getHighestPriority(): int
|
||||||
{
|
{
|
||||||
return self::MONITOR;
|
return self::MONITOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the lowest priority
|
* 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
|
* @return int
|
||||||
*/
|
*/
|
||||||
public static function getLowestPriority()
|
public static function getLowestPriority(): int
|
||||||
{
|
{
|
||||||
return self::LOWEST;
|
return self::LOWEST;
|
||||||
}
|
}
|
||||||
|
@ -31,11 +31,12 @@
|
|||||||
* @link http://techfuze.net/fuzeworks
|
* @link http://techfuze.net/fuzeworks
|
||||||
* @since Version 1.2.0
|
* @since Version 1.2.0
|
||||||
*
|
*
|
||||||
* @version Version 1.2.0
|
* @version Version 1.3.0
|
||||||
*/
|
*/
|
||||||
if (!function_exists('getColoredString'))
|
if (!function_exists('getColoredString'))
|
||||||
{
|
{
|
||||||
function getColoredString($string, $foreground_color, $background_color) {
|
function getColoredString($string, $foreground_color, $background_color): string
|
||||||
|
{
|
||||||
|
|
||||||
// Determine the color system
|
// Determine the color system
|
||||||
$foreground_colors = array();
|
$foreground_colors = array();
|
||||||
|
@ -31,11 +31,9 @@
|
|||||||
* @link http://techfuze.net/fuzeworks
|
* @link http://techfuze.net/fuzeworks
|
||||||
* @since Version 0.0.1
|
* @since Version 0.0.1
|
||||||
*
|
*
|
||||||
* @version Version 1.2.0
|
* @version Version 1.3.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use FuzeWorks\Config;
|
|
||||||
use FuzeWorks\Core;
|
|
||||||
use FuzeWorks\Logger;
|
use FuzeWorks\Logger;
|
||||||
|
|
||||||
// First set the working directory
|
// First set the working directory
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
* @link http://techfuze.net/fuzeworks
|
* @link http://techfuze.net/fuzeworks
|
||||||
* @since Version 1.2.0
|
* @since Version 1.2.0
|
||||||
*
|
*
|
||||||
* @version Version 1.2.0
|
* @version Version 1.3.0
|
||||||
*/
|
*/
|
||||||
require_once(dirname(__DIR__) . '/vendor/autoload.php');
|
require_once(dirname(__DIR__) . '/vendor/autoload.php');
|
||||||
|
|
||||||
@ -45,10 +45,7 @@ $configurator->setLogDirectory(__DIR__ . '/temp');
|
|||||||
$configurator->setTimeZone('Europe/Amsterdam');
|
$configurator->setTimeZone('Europe/Amsterdam');
|
||||||
|
|
||||||
// Debug related
|
// Debug related
|
||||||
$configurator->enableDebugMode(true);
|
$configurator->enableDebugMode();
|
||||||
$configurator->setDebugAddress('ALL');
|
$configurator->setDebugAddress('ALL');
|
||||||
//$configurator->setDebugEmail('example@mail.com');
|
|
||||||
|
|
||||||
$container = $configurator->createContainer();
|
|
||||||
return $container;
|
|
||||||
|
|
||||||
|
return $configurator->createContainer();
|
@ -31,7 +31,7 @@
|
|||||||
* @link http://techfuze.net/fuzeworks
|
* @link http://techfuze.net/fuzeworks
|
||||||
* @since Version 1.2.0
|
* @since Version 1.2.0
|
||||||
*
|
*
|
||||||
* @version Version 1.2.0
|
* @version Version 1.3.0
|
||||||
*/
|
*/
|
||||||
namespace FuzeWorks\Component;
|
namespace FuzeWorks\Component;
|
||||||
use FuzeWorks\Configurator;
|
use FuzeWorks\Configurator;
|
||||||
@ -56,7 +56,7 @@ class TestComponent implements iComponent
|
|||||||
return $configurator;
|
return $configurator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onCreateContainer(Factory $container)
|
public function onCreateContainer(Factory $container): Factory
|
||||||
{
|
{
|
||||||
return $container;
|
return $container;
|
||||||
}
|
}
|
||||||
@ -64,5 +64,5 @@ class TestComponent implements iComponent
|
|||||||
|
|
||||||
class Test
|
class Test
|
||||||
{
|
{
|
||||||
public $variable = 5;
|
public int $variable = 5;
|
||||||
}
|
}
|
@ -31,7 +31,7 @@
|
|||||||
* @link http://techfuze.net/fuzeworks
|
* @link http://techfuze.net/fuzeworks
|
||||||
* @since Version 1.2.0
|
* @since Version 1.2.0
|
||||||
*
|
*
|
||||||
* @version Version 1.2.0
|
* @version Version 1.3.0
|
||||||
*/
|
*/
|
||||||
namespace FuzeWorks\Component;
|
namespace FuzeWorks\Component;
|
||||||
use FuzeWorks\ComponentPathsTrait;
|
use FuzeWorks\ComponentPathsTrait;
|
||||||
@ -47,12 +47,12 @@ class TestAddComponentDirectoryComponent implements iComponent
|
|||||||
return ['testaddcomponentdirectory' => 'FuzeWorks\Component\TestAddComponentDirectory'];
|
return ['testaddcomponentdirectory' => 'FuzeWorks\Component\TestAddComponentDirectory'];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onAddComponent(Configurator $configurator)
|
public function onAddComponent(Configurator $configurator): Configurator
|
||||||
{
|
{
|
||||||
return $configurator;
|
return $configurator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onCreateContainer(Factory $container)
|
public function onCreateContainer(Factory $container): Factory
|
||||||
{
|
{
|
||||||
return $container;
|
return $container;
|
||||||
}
|
}
|
||||||
@ -67,5 +67,5 @@ class TestAddComponentDirectory
|
|||||||
{
|
{
|
||||||
use ComponentPathsTrait;
|
use ComponentPathsTrait;
|
||||||
|
|
||||||
public $variable = 5;
|
public int $variable = 5;
|
||||||
}
|
}
|
@ -31,7 +31,7 @@
|
|||||||
* @link http://techfuze.net/fuzeworks
|
* @link http://techfuze.net/fuzeworks
|
||||||
* @since Version 1.2.0
|
* @since Version 1.2.0
|
||||||
*
|
*
|
||||||
* @version Version 1.2.0
|
* @version Version 1.3.0
|
||||||
*/
|
*/
|
||||||
namespace FuzeWorks\Component;
|
namespace FuzeWorks\Component;
|
||||||
use FuzeWorks\Configurator;
|
use FuzeWorks\Configurator;
|
||||||
@ -56,7 +56,7 @@ class TestAddComponentFailComponent implements iComponent
|
|||||||
return $configurator;
|
return $configurator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onCreateContainer(Factory $container)
|
public function onCreateContainer(Factory $container): Factory
|
||||||
{
|
{
|
||||||
return $container;
|
return $container;
|
||||||
}
|
}
|
||||||
@ -64,5 +64,5 @@ class TestAddComponentFailComponent implements iComponent
|
|||||||
|
|
||||||
class TestAddComponentFail
|
class TestAddComponentFail
|
||||||
{
|
{
|
||||||
public $variable = 5;
|
public int $variable = 5;
|
||||||
}
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* FuzeWorks Framework Core.
|
||||||
|
*
|
||||||
|
* The FuzeWorks PHP FrameWork
|
||||||
|
*
|
||||||
|
* Copyright (C) 2013-2019 TechFuze
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*
|
||||||
|
* @author TechFuze
|
||||||
|
* @copyright Copyright (c) 2013 - 2019, TechFuze. (http://techfuze.net)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
*
|
||||||
|
* @link http://techfuze.net/fuzeworks
|
||||||
|
* @since Version 1.2.0
|
||||||
|
*
|
||||||
|
* @version Version 1.2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
use FuzeWorks\Core;
|
||||||
|
|
||||||
|
return array(
|
||||||
|
'testKey' => Core::getEnv('TESTKEY'),
|
||||||
|
'otherKey' => Core::getEnv('OTHERKEY', 'somethingDefault')
|
||||||
|
);
|
@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* FuzeWorksCore
|
||||||
|
*
|
||||||
|
* Copyright (C) 2013-2021 i15
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*
|
||||||
|
* @author i15
|
||||||
|
* @copyright Copyright (c) 2013 - 2021, i15. (https://i15.nl)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
*
|
||||||
|
* @since Version 1.0.0
|
||||||
|
*
|
||||||
|
* @version Version 1.3.2
|
||||||
|
*/
|
||||||
|
return array(
|
||||||
|
'first' => 'world',
|
||||||
|
'onlyInHigh' => 'highValue',
|
||||||
|
'override' => 'firstValue'
|
||||||
|
);
|
@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* FuzeWorksCore
|
||||||
|
*
|
||||||
|
* Copyright (C) 2013-2021 i15
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*
|
||||||
|
* @author i15
|
||||||
|
* @copyright Copyright (c) 2013 - 2021, i15. (https://i15.nl)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
*
|
||||||
|
* @since Version 1.0.0
|
||||||
|
*
|
||||||
|
* @version Version 1.3.2
|
||||||
|
*/
|
||||||
|
return array(
|
||||||
|
'first' => 'hello',
|
||||||
|
'onlyInLow' => 'lowValue'
|
||||||
|
);
|
@ -31,14 +31,13 @@
|
|||||||
* @link http://techfuze.net/fuzeworks
|
* @link http://techfuze.net/fuzeworks
|
||||||
* @since Version 0.0.1
|
* @since Version 0.0.1
|
||||||
*
|
*
|
||||||
* @version Version 1.2.0
|
* @version Version 1.3.0
|
||||||
*/
|
*/
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use FuzeWorks\Events;
|
use FuzeWorks\Events;
|
||||||
use FuzeWorks\Factory;
|
use FuzeWorks\Factory;
|
||||||
use FuzeWorks\Core;
|
use FuzeWorks\Core;
|
||||||
use FuzeWorks\Config;
|
use FuzeWorks\Config;
|
||||||
use FuzeWorks\LoggerTracyBridge;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class CoreTestAbstract.
|
* Class CoreTestAbstract.
|
||||||
@ -50,7 +49,7 @@ abstract class CoreTestAbstract extends TestCase
|
|||||||
/**
|
/**
|
||||||
* Reset multiple components to their original state before running the next test
|
* 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
|
// Clear all events created by tests
|
||||||
Events::$listeners = [];
|
Events::$listeners = [];
|
||||||
|
@ -31,11 +31,12 @@
|
|||||||
* @link http://techfuze.net/fuzeworks
|
* @link http://techfuze.net/fuzeworks
|
||||||
* @since Version 0.0.1
|
* @since Version 0.0.1
|
||||||
*
|
*
|
||||||
* @version Version 1.2.0
|
* @version Version 1.3.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use FuzeWorks\Config;
|
use FuzeWorks\Config;
|
||||||
use FuzeWorks\Event\ConfigGetEvent;
|
use FuzeWorks\Event\ConfigGetEvent;
|
||||||
|
use FuzeWorks\Exception\ConfigException;
|
||||||
use FuzeWorks\Priority;
|
use FuzeWorks\Priority;
|
||||||
use FuzeWorks\Events;
|
use FuzeWorks\Events;
|
||||||
|
|
||||||
@ -51,9 +52,9 @@ class configTest extends CoreTestAbstract
|
|||||||
/**
|
/**
|
||||||
* @var Config
|
* @var Config
|
||||||
*/
|
*/
|
||||||
protected $config;
|
protected Config $config;
|
||||||
|
|
||||||
public function setUp()
|
public function setUp(): void
|
||||||
{
|
{
|
||||||
$this->config = new Config();
|
$this->config = new Config();
|
||||||
}
|
}
|
||||||
@ -90,10 +91,10 @@ class configTest extends CoreTestAbstract
|
|||||||
/**
|
/**
|
||||||
* @depends testLoadConfig
|
* @depends testLoadConfig
|
||||||
* @covers ::loadConfigFile
|
* @covers ::loadConfigFile
|
||||||
* @expectedException FuzeWorks\Exception\ConfigException
|
|
||||||
*/
|
*/
|
||||||
public function testFileNotFound()
|
public function testFileNotFound()
|
||||||
{
|
{
|
||||||
|
$this->expectException(ConfigException::class);
|
||||||
$this->config->getConfig('notFound');
|
$this->config->getConfig('notFound');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,11 +184,50 @@ class configTest extends CoreTestAbstract
|
|||||||
$this->assertSame($config, $config2);
|
$this->assertSame($config, $config2);
|
||||||
|
|
||||||
// First test the existing key
|
// First test the existing key
|
||||||
$this->assertEquals($config->key, 'value');
|
$this->assertEquals('value', $config->key);
|
||||||
|
|
||||||
// Change it and test if it's different now
|
// Change it and test if it's different now
|
||||||
$config->key = 'other_value';
|
$config->key = 'other_value';
|
||||||
$this->assertEquals($config2->key, 'other_value');
|
$this->assertEquals('other_value', $config2->key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @coversNothing
|
||||||
|
*/
|
||||||
|
public function testConfigWithEnvironmentVariables()
|
||||||
|
{
|
||||||
|
// First push the test variable
|
||||||
|
putenv('TESTKEY=Superb');
|
||||||
|
|
||||||
|
// Load the config
|
||||||
|
$config = $this->config->getConfig('testconfigwithenvironment', ['test'.DS.'config'.DS.'TestConfigWithEnvironment']);
|
||||||
|
|
||||||
|
// Check values
|
||||||
|
$this->assertEquals('Superb', $config->get('testKey'));
|
||||||
|
$this->assertEquals('somethingDefault', $config->get('otherKey'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers ::loadConfigFile
|
||||||
|
* @depends testLoadConfigCoreOverride
|
||||||
|
*/
|
||||||
|
public function testCumulativeConfigFile()
|
||||||
|
{
|
||||||
|
// Add folders
|
||||||
|
$this->config->addComponentPath('test'.DS.'config'.DS.'TestCumulativeConfigFile'.DS.'HighPriorityFolder', Priority::HIGH);
|
||||||
|
$this->config->addComponentPath('test'.DS.'config'.DS.'TestCumulativeConfigFile'.DS.'LowPriorityFolder', Priority::LOW);
|
||||||
|
|
||||||
|
// And override a value
|
||||||
|
Config::overrideConfig('cumulative', 'override', 'secondValue');
|
||||||
|
|
||||||
|
// Load the config
|
||||||
|
$config = $this->config->get('cumulative');
|
||||||
|
|
||||||
|
// Check values
|
||||||
|
$this->assertEquals("world", $config->get('first'));
|
||||||
|
$this->assertEquals("highValue", $config->get('onlyInHigh'));
|
||||||
|
$this->assertEquals("lowValue", $config->get('onlyInLow'));
|
||||||
|
$this->assertEquals("secondValue", $config->get('override'));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -31,11 +31,13 @@
|
|||||||
* @link http://techfuze.net/fuzeworks
|
* @link http://techfuze.net/fuzeworks
|
||||||
* @since Version 1.2.0
|
* @since Version 1.2.0
|
||||||
*
|
*
|
||||||
* @version Version 1.2.0
|
* @version Version 1.3.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use FuzeWorks\Config;
|
||||||
use FuzeWorks\Configurator;
|
use FuzeWorks\Configurator;
|
||||||
use FuzeWorks\Core;
|
use FuzeWorks\Core;
|
||||||
|
use FuzeWorks\Exception\ConfiguratorException;
|
||||||
use FuzeWorks\Factory;
|
use FuzeWorks\Factory;
|
||||||
use FuzeWorks\iComponent;
|
use FuzeWorks\iComponent;
|
||||||
use FuzeWorks\Logger;
|
use FuzeWorks\Logger;
|
||||||
@ -52,9 +54,9 @@ class configuratorTest extends CoreTestAbstract
|
|||||||
/**
|
/**
|
||||||
* @var Configurator
|
* @var Configurator
|
||||||
*/
|
*/
|
||||||
protected $configurator;
|
protected Configurator $configurator;
|
||||||
|
|
||||||
public function setUp()
|
public function setUp(): void
|
||||||
{
|
{
|
||||||
$this->configurator = new Configurator;
|
$this->configurator = new Configurator;
|
||||||
$this->configurator->setTempDirectory(dirname(__DIR__) . '/temp');
|
$this->configurator->setTempDirectory(dirname(__DIR__) . '/temp');
|
||||||
@ -62,7 +64,7 @@ class configuratorTest extends CoreTestAbstract
|
|||||||
$this->configurator->setTimeZone('Europe/Amsterdam');
|
$this->configurator->setTimeZone('Europe/Amsterdam');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tearDown()
|
public function tearDown(): void
|
||||||
{
|
{
|
||||||
parent::tearDown();
|
parent::tearDown();
|
||||||
|
|
||||||
@ -132,7 +134,6 @@ class configuratorTest extends CoreTestAbstract
|
|||||||
* @depends testAddComponent
|
* @depends testAddComponent
|
||||||
* @covers ::addComponent
|
* @covers ::addComponent
|
||||||
* @covers ::createContainer
|
* @covers ::createContainer
|
||||||
* @expectedException FuzeWorks\Exception\ConfiguratorException
|
|
||||||
*/
|
*/
|
||||||
public function testAddComponentFail()
|
public function testAddComponentFail()
|
||||||
{
|
{
|
||||||
@ -142,6 +143,7 @@ class configuratorTest extends CoreTestAbstract
|
|||||||
$this->configurator->addComponent($component);
|
$this->configurator->addComponent($component);
|
||||||
|
|
||||||
// Create container and fail
|
// Create container and fail
|
||||||
|
$this->expectException(ConfiguratorException::class);
|
||||||
$this->configurator->createContainer();
|
$this->configurator->createContainer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,11 +177,11 @@ class configuratorTest extends CoreTestAbstract
|
|||||||
/**
|
/**
|
||||||
* @depends testSetLogDirectory
|
* @depends testSetLogDirectory
|
||||||
* @covers ::setLogDirectory
|
* @covers ::setLogDirectory
|
||||||
* @expectedException \FuzeWorks\Exception\InvalidArgumentException
|
|
||||||
*/
|
*/
|
||||||
public function testSetLogDirectoryNotDirectory()
|
public function testSetLogDirectoryNotDirectory()
|
||||||
{
|
{
|
||||||
// Set the directory
|
// Set the directory
|
||||||
|
$this->expectException(\FuzeWorks\Exception\InvalidArgumentException::class);
|
||||||
$this->configurator->setLogDirectory('not_exist');
|
$this->configurator->setLogDirectory('not_exist');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,11 +206,11 @@ class configuratorTest extends CoreTestAbstract
|
|||||||
/**
|
/**
|
||||||
* @depends testSetTempDirectory
|
* @depends testSetTempDirectory
|
||||||
* @covers ::setTempDirectory
|
* @covers ::setTempDirectory
|
||||||
* @expectedException \FuzeWorks\Exception\InvalidArgumentException
|
|
||||||
*/
|
*/
|
||||||
public function testSetTempDirectoryNotDirectory()
|
public function testSetTempDirectoryNotDirectory()
|
||||||
{
|
{
|
||||||
// Set the directory
|
// Set the directory
|
||||||
|
$this->expectException(\FuzeWorks\Exception\InvalidArgumentException::class);
|
||||||
$this->configurator->setTempDirectory('not_exist');
|
$this->configurator->setTempDirectory('not_exist');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -245,10 +247,10 @@ class configuratorTest extends CoreTestAbstract
|
|||||||
/**
|
/**
|
||||||
* @depends testAddComponentDirectory
|
* @depends testAddComponentDirectory
|
||||||
* @covers ::addDirectory
|
* @covers ::addDirectory
|
||||||
* @expectedException \FuzeWorks\Exception\InvalidArgumentException
|
|
||||||
*/
|
*/
|
||||||
public function testAddComponentDirectoryNotExist()
|
public function testAddComponentDirectoryNotExist()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\FuzeWorks\Exception\InvalidArgumentException::class);
|
||||||
$this->configurator->addDirectory('not_exist', 'irrelevant');
|
$this->configurator->addDirectory('not_exist', 'irrelevant');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -342,11 +344,11 @@ class configuratorTest extends CoreTestAbstract
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @depends testSetTimezone
|
* @depends testSetTimezone
|
||||||
* @expectedException \FuzeWorks\Exception\InvalidArgumentException
|
|
||||||
* @covers ::setTimeZone
|
* @covers ::setTimeZone
|
||||||
*/
|
*/
|
||||||
public function testSetTimezoneInvalid()
|
public function testSetTimezoneInvalid()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\FuzeWorks\Exception\InvalidArgumentException::class);
|
||||||
$this->configurator->setTimeZone('Europe/Amsterdamned');
|
$this->configurator->setTimeZone('Europe/Amsterdamned');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -379,7 +381,7 @@ class configuratorTest extends CoreTestAbstract
|
|||||||
$this->configurator->createContainer();
|
$this->configurator->createContainer();
|
||||||
|
|
||||||
// Verify that the variable is set in the Config class
|
// 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 ------------------------------------------------- */
|
/* ---------------------------------- Debugging ------------------------------------------------- */
|
||||||
@ -472,10 +474,10 @@ class configuratorTest extends CoreTestAbstract
|
|||||||
/**
|
/**
|
||||||
* @depends testEnableDebugMode
|
* @depends testEnableDebugMode
|
||||||
* @covers ::setDebugAddress
|
* @covers ::setDebugAddress
|
||||||
* @expectedException \FuzeWorks\Exception\InvalidArgumentException
|
|
||||||
*/
|
*/
|
||||||
public function testSetDebugAddressInvalidArgument()
|
public function testSetDebugAddressInvalidArgument()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\FuzeWorks\Exception\InvalidArgumentException::class);
|
||||||
$this->configurator->setDebugAddress(null);
|
$this->configurator->setDebugAddress(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -497,7 +499,7 @@ class MockComponent implements iComponent
|
|||||||
return $configurator;
|
return $configurator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onCreateContainer(Factory $container)
|
public function onCreateContainer(Factory $container): Factory
|
||||||
{
|
{
|
||||||
return $container;
|
return $container;
|
||||||
}
|
}
|
||||||
|
@ -72,4 +72,20 @@ class coreTest extends CoreTestAbstract
|
|||||||
$this->assertTrue(Core::isPHP('1.2.0'));
|
$this->assertTrue(Core::isPHP('1.2.0'));
|
||||||
$this->assertFalse(Core::isphp('9999.9.9'));
|
$this->assertFalse(Core::isphp('9999.9.9'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers ::getEnv
|
||||||
|
*/
|
||||||
|
public function testGetEnv()
|
||||||
|
{
|
||||||
|
// First push some test variables
|
||||||
|
putenv('TESTGETENV=AFFIRMED');
|
||||||
|
|
||||||
|
// Then try and fetch using the method
|
||||||
|
$this->assertEquals('AFFIRMED', Core::getEnv('TESTGETENV'));
|
||||||
|
|
||||||
|
// Also test variables that don't exist
|
||||||
|
$this->assertNull(Core::getEnv('TESTNOTEXIST'));
|
||||||
|
$this->assertEquals('replacement', Core::getEnv('TESTNOTEXISTTWO', 'replacement'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,10 +31,9 @@
|
|||||||
* @link http://techfuze.net/fuzeworks
|
* @link http://techfuze.net/fuzeworks
|
||||||
* @since Version 1.0.4
|
* @since Version 1.0.4
|
||||||
*
|
*
|
||||||
* @version Version 1.2.0
|
* @version Version 1.3.0
|
||||||
*/
|
*/
|
||||||
use FuzeWorks\Events;
|
use FuzeWorks\Events;
|
||||||
use FuzeWorks\Event;
|
|
||||||
use FuzeWorks\Priority;
|
use FuzeWorks\Priority;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -31,11 +31,12 @@
|
|||||||
* @link http://techfuze.net/fuzeworks
|
* @link http://techfuze.net/fuzeworks
|
||||||
* @since Version 0.0.1
|
* @since Version 0.0.1
|
||||||
*
|
*
|
||||||
* @version Version 1.2.0
|
* @version Version 1.3.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use FuzeWorks\Event;
|
use FuzeWorks\Event;
|
||||||
use FuzeWorks\Events;
|
use FuzeWorks\Events;
|
||||||
|
use FuzeWorks\Exception\EventException;
|
||||||
use FuzeWorks\Priority;
|
use FuzeWorks\Priority;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -145,21 +146,21 @@ class eventsTest extends CoreTestAbstract
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @depends testFireEvent
|
* @depends testFireEvent
|
||||||
* @expectedException FuzeWorks\Exception\EventException
|
|
||||||
* @covers ::fireEvent
|
* @covers ::fireEvent
|
||||||
*/
|
*/
|
||||||
public function testInvalidTypeEvent()
|
public function testInvalidTypeEvent()
|
||||||
{
|
{
|
||||||
|
$this->expectException(EventException::class);
|
||||||
Events::fireEvent(array('x', 'y', 'z'));
|
Events::fireEvent(array('x', 'y', 'z'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @depends testFireEvent
|
* @depends testFireEvent
|
||||||
* @covers ::fireEvent
|
* @covers ::fireEvent
|
||||||
* @expectedException FuzeWorks\Exception\EventException
|
|
||||||
*/
|
*/
|
||||||
public function testInvalidClassEvent()
|
public function testInvalidClassEvent()
|
||||||
{
|
{
|
||||||
|
$this->expectException(EventException::class);
|
||||||
Events::fireEvent('nonExistingEvent', 'x', 'y', 'z');
|
Events::fireEvent('nonExistingEvent', 'x', 'y', 'z');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,30 +186,30 @@ class eventsTest extends CoreTestAbstract
|
|||||||
/**
|
/**
|
||||||
* @depends testAddAndRemoveListener
|
* @depends testAddAndRemoveListener
|
||||||
* @covers ::addListener
|
* @covers ::addListener
|
||||||
* @expectedException FuzeWorks\Exception\EventException
|
|
||||||
*/
|
*/
|
||||||
public function testAddInvalidPriorityListener()
|
public function testAddInvalidPriorityListener()
|
||||||
{
|
{
|
||||||
|
$this->expectException(EventException::class);
|
||||||
Events::addListener(function($event){}, 'mockEvent', 99);
|
Events::addListener(function($event){}, 'mockEvent', 99);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @depends testAddAndRemoveListener
|
* @depends testAddAndRemoveListener
|
||||||
* @covers ::addListener
|
* @covers ::addListener
|
||||||
* @expectedException FuzeWorks\Exception\EventException
|
|
||||||
*/
|
*/
|
||||||
public function testAddInvalidNameListener()
|
public function testAddInvalidNameListener()
|
||||||
{
|
{
|
||||||
|
$this->expectException(EventException::class);
|
||||||
Events::addListener(function($e) {}, '', Priority::NORMAL);
|
Events::addListener(function($e) {}, '', Priority::NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @depends testAddAndRemoveListener
|
* @depends testAddAndRemoveListener
|
||||||
* @covers ::removeListener
|
* @covers ::removeListener
|
||||||
* @expectedException FuzeWorks\Exception\EventException
|
|
||||||
*/
|
*/
|
||||||
public function testRemoveInvalidPriorityListener()
|
public function testRemoveInvalidPriorityListener()
|
||||||
{
|
{
|
||||||
|
$this->expectException(EventException::class);
|
||||||
Events::removeListener(function($event){}, 'mockEvent', 99);
|
Events::removeListener(function($event){}, 'mockEvent', 99);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,7 +229,7 @@ class eventsTest extends CoreTestAbstract
|
|||||||
public function testRemoveUnsetListener()
|
public function testRemoveUnsetListener()
|
||||||
{
|
{
|
||||||
Events::addListener(function($e) {}, 'mockEvent', Priority::NORMAL);
|
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
* @link http://techfuze.net/fuzeworks
|
* @link http://techfuze.net/fuzeworks
|
||||||
* @since Version 0.0.1
|
* @since Version 0.0.1
|
||||||
*
|
*
|
||||||
* @version Version 1.2.0
|
* @version Version 1.3.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use FuzeWorks\Exception\Exception;
|
use FuzeWorks\Exception\Exception;
|
||||||
@ -53,83 +53,63 @@ use FuzeWorks\Exception\ConfiguratorException;
|
|||||||
class exceptionTestTest extends CoreTestAbstract
|
class exceptionTestTest extends CoreTestAbstract
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException FuzeWorks\Exception\Exception
|
|
||||||
*/
|
|
||||||
public function testException()
|
public function testException()
|
||||||
{
|
{
|
||||||
|
$this->expectException(Exception::class);
|
||||||
throw new Exception("Exception Test Run", 1);
|
throw new Exception("Exception Test Run", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException FuzeWorks\Exception\CoreException
|
|
||||||
*/
|
|
||||||
public function testCoreException()
|
public function testCoreException()
|
||||||
{
|
{
|
||||||
|
$this->expectException(CoreException::class);
|
||||||
throw new CoreException("Exception Test Run", 1);
|
throw new CoreException("Exception Test Run", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException FuzeWorks\Exception\ConfigException
|
|
||||||
*/
|
|
||||||
public function testConfigException()
|
public function testConfigException()
|
||||||
{
|
{
|
||||||
|
$this->expectException(ConfigException::class);
|
||||||
throw new ConfigException("Exception Test Run", 1);
|
throw new ConfigException("Exception Test Run", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException FuzeWorks\Exception\EventException
|
|
||||||
*/
|
|
||||||
public function testEventException()
|
public function testEventException()
|
||||||
{
|
{
|
||||||
|
$this->expectException(EventException::class);
|
||||||
throw new EventException("Exception Test Run", 1);
|
throw new EventException("Exception Test Run", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException FuzeWorks\Exception\FactoryException
|
|
||||||
*/
|
|
||||||
public function testFactoryException()
|
public function testFactoryException()
|
||||||
{
|
{
|
||||||
|
$this->expectException(FactoryException::class);
|
||||||
throw new FactoryException("Exception Test Run", 1);
|
throw new FactoryException("Exception Test Run", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException FuzeWorks\Exception\HelperException
|
|
||||||
*/
|
|
||||||
public function testHelperException()
|
public function testHelperException()
|
||||||
{
|
{
|
||||||
|
$this->expectException(HelperException::class);
|
||||||
throw new HelperException("Exception Test Run", 1);
|
throw new HelperException("Exception Test Run", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException FuzeWorks\Exception\InvalidArgumentException
|
|
||||||
*/
|
|
||||||
public function testInvalidArgumentException()
|
public function testInvalidArgumentException()
|
||||||
{
|
{
|
||||||
|
$this->expectException(InvalidArgumentException::class);
|
||||||
throw new InvalidArgumentException("Exception Test Run", 1);
|
throw new InvalidArgumentException("Exception Test Run", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException FuzeWorks\Exception\LibraryException
|
|
||||||
*/
|
|
||||||
public function testLibraryException()
|
public function testLibraryException()
|
||||||
{
|
{
|
||||||
|
$this->expectException(LibraryException::class);
|
||||||
throw new LibraryException("Exception Test Run", 1);
|
throw new LibraryException("Exception Test Run", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException FuzeWorks\Exception\LoggerException
|
|
||||||
*/
|
|
||||||
public function testLoggerException()
|
public function testLoggerException()
|
||||||
{
|
{
|
||||||
|
$this->expectException(LoggerException::class);
|
||||||
throw new LoggerException("Exception Test Run", 1);
|
throw new LoggerException("Exception Test Run", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException FuzeWorks\Exception\ConfiguratorException
|
|
||||||
*/
|
|
||||||
public function testConfiguratorException()
|
public function testConfiguratorException()
|
||||||
{
|
{
|
||||||
|
$this->expectException(ConfiguratorException::class);
|
||||||
throw new ConfiguratorException("Exception Test Run", 1);
|
throw new ConfiguratorException("Exception Test Run", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
* @link http://techfuze.net/fuzeworks
|
* @link http://techfuze.net/fuzeworks
|
||||||
* @since Version 0.0.1
|
* @since Version 0.0.1
|
||||||
*
|
*
|
||||||
* @version Version 1.2.0
|
* @version Version 1.3.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use FuzeWorks\Factory;
|
use FuzeWorks\Factory;
|
||||||
@ -73,10 +73,10 @@ class factoryTest extends CoreTestAbstract
|
|||||||
/**
|
/**
|
||||||
* @depends testGetInstance
|
* @depends testGetInstance
|
||||||
* @covers ::getInstance
|
* @covers ::getInstance
|
||||||
* @expectedException \FuzeWorks\Exception\FactoryException
|
|
||||||
*/
|
*/
|
||||||
public function testGetInstanceNotFound()
|
public function testGetInstanceNotFound()
|
||||||
{
|
{
|
||||||
|
$this->expectException(FactoryException::class);
|
||||||
Factory::getInstance('NotFound');
|
Factory::getInstance('NotFound');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,7 +183,6 @@ class factoryTest extends CoreTestAbstract
|
|||||||
/**
|
/**
|
||||||
* @depends testCanLoadFactory
|
* @depends testCanLoadFactory
|
||||||
* @covers ::cloneInstance
|
* @covers ::cloneInstance
|
||||||
* @expectedException FuzeWorks\Exception\FactoryException
|
|
||||||
*/
|
*/
|
||||||
public function testCloneInstanceWrongClassname()
|
public function testCloneInstanceWrongClassname()
|
||||||
{
|
{
|
||||||
@ -191,6 +190,7 @@ class factoryTest extends CoreTestAbstract
|
|||||||
$factory = new Factory;
|
$factory = new Factory;
|
||||||
|
|
||||||
// Attempt
|
// Attempt
|
||||||
|
$this->expectException(FactoryException::class);
|
||||||
$factory->cloneInstance('fake');
|
$factory->cloneInstance('fake');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,7 +223,6 @@ class factoryTest extends CoreTestAbstract
|
|||||||
/**
|
/**
|
||||||
* @depends testNewFactoryInstance
|
* @depends testNewFactoryInstance
|
||||||
* @covers ::newInstance
|
* @covers ::newInstance
|
||||||
* @expectedException FuzeWorks\Exception\FactoryException
|
|
||||||
*/
|
*/
|
||||||
public function testFactoryNewInstanceNotExist()
|
public function testFactoryNewInstanceNotExist()
|
||||||
{
|
{
|
||||||
@ -231,13 +230,13 @@ class factoryTest extends CoreTestAbstract
|
|||||||
$factory = new Factory;
|
$factory = new Factory;
|
||||||
|
|
||||||
// First, it does not exist
|
// First, it does not exist
|
||||||
|
$this->expectException(FactoryException::class);
|
||||||
$factory->newInstance('fake');
|
$factory->newInstance('fake');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @depends testNewFactoryInstance
|
* @depends testNewFactoryInstance
|
||||||
* @covers ::newInstance
|
* @covers ::newInstance
|
||||||
* @expectedException FuzeWorks\Exception\FactoryException
|
|
||||||
*/
|
*/
|
||||||
public function testFactoryNewInstanceWrongNamespace()
|
public function testFactoryNewInstanceWrongNamespace()
|
||||||
{
|
{
|
||||||
@ -245,6 +244,7 @@ class factoryTest extends CoreTestAbstract
|
|||||||
$factory = new Factory;
|
$factory = new Factory;
|
||||||
|
|
||||||
// Second, it just fails
|
// Second, it just fails
|
||||||
|
$this->expectException(FactoryException::class);
|
||||||
$factory->newInstance('helpers', 'Test\\');
|
$factory->newInstance('helpers', 'Test\\');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,7 +278,6 @@ class factoryTest extends CoreTestAbstract
|
|||||||
/**
|
/**
|
||||||
* @depends testRemoveInstance
|
* @depends testRemoveInstance
|
||||||
* @covers ::removeInstance
|
* @covers ::removeInstance
|
||||||
* @expectedException FuzeWorks\Exception\FactoryException
|
|
||||||
*/
|
*/
|
||||||
public function testRemoveInstanceNotExist()
|
public function testRemoveInstanceNotExist()
|
||||||
{
|
{
|
||||||
@ -286,6 +285,7 @@ class factoryTest extends CoreTestAbstract
|
|||||||
$factory = new Factory;
|
$factory = new Factory;
|
||||||
|
|
||||||
// Test
|
// Test
|
||||||
|
$this->expectException(FactoryException::class);
|
||||||
$factory->removeInstance('fake');
|
$factory->removeInstance('fake');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,7 +308,7 @@ class factoryTest extends CoreTestAbstract
|
|||||||
$this->assertEquals(5, $factory->test);
|
$this->assertEquals(5, $factory->test);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tearDown()
|
public function tearDown(): void
|
||||||
{
|
{
|
||||||
parent::tearDown();
|
parent::tearDown();
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
* @link http://techfuze.net/fuzeworks
|
* @link http://techfuze.net/fuzeworks
|
||||||
* @since Version 0.0.1
|
* @since Version 0.0.1
|
||||||
*
|
*
|
||||||
* @version Version 1.2.0
|
* @version Version 1.3.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use FuzeWorks\Priority;
|
use FuzeWorks\Priority;
|
||||||
@ -50,9 +50,9 @@ class helperTest extends CoreTestAbstract
|
|||||||
/**
|
/**
|
||||||
* @var Helpers
|
* @var Helpers
|
||||||
*/
|
*/
|
||||||
protected $helpers;
|
protected Helpers $helpers;
|
||||||
|
|
||||||
public function setUp()
|
public function setUp(): void
|
||||||
{
|
{
|
||||||
// Prepare class
|
// Prepare class
|
||||||
$this->helpers = new Helpers();
|
$this->helpers = new Helpers();
|
||||||
|
@ -31,10 +31,10 @@
|
|||||||
* @link http://techfuze.net/fuzeworks
|
* @link http://techfuze.net/fuzeworks
|
||||||
* @since Version 0.0.1
|
* @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\Factory;
|
||||||
use FuzeWorks\Libraries;
|
use FuzeWorks\Libraries;
|
||||||
|
|
||||||
@ -50,9 +50,9 @@ class libraryTest extends CoreTestAbstract
|
|||||||
/**
|
/**
|
||||||
* @var Libraries
|
* @var Libraries
|
||||||
*/
|
*/
|
||||||
protected $libraries;
|
protected Libraries $libraries;
|
||||||
|
|
||||||
public function setUp()
|
public function setUp(): void
|
||||||
{
|
{
|
||||||
// Load new libraries class
|
// Load new libraries class
|
||||||
$this->libraries = new Libraries();
|
$this->libraries = new Libraries();
|
||||||
@ -110,10 +110,10 @@ class libraryTest extends CoreTestAbstract
|
|||||||
* @depends testGetLibraryFromDirectory
|
* @depends testGetLibraryFromDirectory
|
||||||
* @covers ::get
|
* @covers ::get
|
||||||
* @covers ::initLibrary
|
* @covers ::initLibrary
|
||||||
* @expectedException FuzeWorks\Exception\LibraryException
|
|
||||||
*/
|
*/
|
||||||
public function testGetLibraryFail()
|
public function testGetLibraryFail()
|
||||||
{
|
{
|
||||||
|
$this->expectException(LibraryException::class);
|
||||||
$this->libraries->get('FailLoadLibrary');
|
$this->libraries->get('FailLoadLibrary');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,10 +121,10 @@ class libraryTest extends CoreTestAbstract
|
|||||||
* @depends testGetLibraryFromDirectory
|
* @depends testGetLibraryFromDirectory
|
||||||
* @covers ::get
|
* @covers ::get
|
||||||
* @covers ::initLibrary
|
* @covers ::initLibrary
|
||||||
* @expectedException FuzeWorks\Exception\LibraryException
|
|
||||||
*/
|
*/
|
||||||
public function testGetLibraryNoName()
|
public function testGetLibraryNoName()
|
||||||
{
|
{
|
||||||
|
$this->expectException(LibraryException::class);
|
||||||
$this->libraries->get('');
|
$this->libraries->get('');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,10 +132,10 @@ class libraryTest extends CoreTestAbstract
|
|||||||
* @depends testGetLibraryFromDirectory
|
* @depends testGetLibraryFromDirectory
|
||||||
* @covers ::get
|
* @covers ::get
|
||||||
* @covers ::initLibrary
|
* @covers ::initLibrary
|
||||||
* @expectedException FuzeWorks\Exception\LibraryException
|
|
||||||
*/
|
*/
|
||||||
public function testGetLibraryNoClass()
|
public function testGetLibraryNoClass()
|
||||||
{
|
{
|
||||||
|
$this->expectException(LibraryException::class);
|
||||||
$this->libraries->get('TestGetLibraryNoClass');
|
$this->libraries->get('TestGetLibraryNoClass');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,9 +167,10 @@ class libraryTest extends CoreTestAbstract
|
|||||||
*/
|
*/
|
||||||
public function testAddLibraryObject()
|
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'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -188,10 +189,10 @@ class libraryTest extends CoreTestAbstract
|
|||||||
/**
|
/**
|
||||||
* @depends testAddLibraryClass
|
* @depends testAddLibraryClass
|
||||||
* @covers ::addLibraryClass
|
* @covers ::addLibraryClass
|
||||||
* @expectedException \FuzeWorks\Exception\LibraryException
|
|
||||||
*/
|
*/
|
||||||
public function testAddLibraryClassFail()
|
public function testAddLibraryClassFail()
|
||||||
{
|
{
|
||||||
|
$this->expectException(LibraryException::class);
|
||||||
$this->libraries->addLibraryClass('LibraryClassFail', '\Case\Not\Exist');
|
$this->libraries->addLibraryClass('LibraryClassFail', '\Case\Not\Exist');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,14 +215,14 @@ class libraryTest extends CoreTestAbstract
|
|||||||
/**
|
/**
|
||||||
* @depends testAddLibraryWithAutoloader
|
* @depends testAddLibraryWithAutoloader
|
||||||
* @covers ::initLibrary
|
* @covers ::initLibrary
|
||||||
* @expectedException \FuzeWorks\Exception\LibraryException
|
|
||||||
*/
|
*/
|
||||||
public function testAddBadAutoloader()
|
public function testAddBadAutoloader()
|
||||||
{
|
{
|
||||||
|
$this->expectException(LibraryException::class);
|
||||||
$this->assertInstanceOf('Application\Library\TestAddBadAutoloader', $this->libraries->get('TestAddBadAutoloader'));
|
$this->assertInstanceOf('Application\Library\TestAddBadAutoloader', $this->libraries->get('TestAddBadAutoloader'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tearDown()
|
public function tearDown(): void
|
||||||
{
|
{
|
||||||
parent::tearDown();
|
parent::tearDown();
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
* @link http://techfuze.net/fuzeworks
|
* @link http://techfuze.net/fuzeworks
|
||||||
* @since Version 0.0.1
|
* @since Version 0.0.1
|
||||||
*
|
*
|
||||||
* @version Version 1.2.0
|
* @version Version 1.3.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use FuzeWorks\Events;
|
use FuzeWorks\Events;
|
||||||
@ -47,11 +47,11 @@ use FuzeWorks\Exception\LoggerException;
|
|||||||
*/
|
*/
|
||||||
class loggerTest extends CoreTestAbstract
|
class loggerTest extends CoreTestAbstract
|
||||||
{
|
{
|
||||||
protected $logger;
|
protected Logger $logger;
|
||||||
|
|
||||||
protected $output;
|
protected string $output;
|
||||||
|
|
||||||
public function setUp()
|
public function setUp(): void
|
||||||
{
|
{
|
||||||
Factory::getInstance()->config->get('error')->fuzeworks_error_reporting = false;
|
Factory::getInstance()->config->get('error')->fuzeworks_error_reporting = false;
|
||||||
Logger::$logs = array();
|
Logger::$logs = array();
|
||||||
@ -105,7 +105,7 @@ class loggerTest extends CoreTestAbstract
|
|||||||
E_STRICT => 'ERROR',
|
E_STRICT => 'ERROR',
|
||||||
E_RECOVERABLE_ERROR => 'ERROR',
|
E_RECOVERABLE_ERROR => 'ERROR',
|
||||||
E_DEPRECATED => 'WARNING',
|
E_DEPRECATED => 'WARNING',
|
||||||
'UNKNOWN' => 'Unknown error: UNKNOWN'
|
0 => 'Unknown error: 0'
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach ($types as $errorType => $output) {
|
foreach ($types as $errorType => $output) {
|
||||||
@ -135,12 +135,32 @@ class loggerTest extends CoreTestAbstract
|
|||||||
Events::addListener(function($event){
|
Events::addListener(function($event){
|
||||||
$event->setCancelled(true);
|
$event->setCancelled(true);
|
||||||
$this->assertEquals('FAILURE', $event->log['message']);
|
$this->assertEquals('FAILURE', $event->log['message']);
|
||||||
|
$this->assertEquals("EXCEPTION", $event->log['type']);
|
||||||
}, 'haltExecutionEvent');
|
}, 'haltExecutionEvent');
|
||||||
|
|
||||||
// Log the exception
|
// Log the exception
|
||||||
Logger::exceptionHandler($exception);
|
Logger::exceptionHandler($exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers ::exceptionHandler
|
||||||
|
* @depends testExceptionHandler
|
||||||
|
*/
|
||||||
|
public function testErrorsToExceptionHandler()
|
||||||
|
{
|
||||||
|
// Create the error
|
||||||
|
$error = new ParseError("FAILURE_ERROR");
|
||||||
|
|
||||||
|
// Prepare to intercept
|
||||||
|
Events::addListener(function ($event) {
|
||||||
|
$event->setCancelled(true);
|
||||||
|
$this->assertEquals("FAILURE_ERROR", $event->log['message']);
|
||||||
|
$this->assertEquals("ERROR", $event->log['type']);
|
||||||
|
}, 'haltExecutionEvent');
|
||||||
|
|
||||||
|
Logger::exceptionHandler($error);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers ::log
|
* @covers ::log
|
||||||
*/
|
*/
|
||||||
@ -211,7 +231,7 @@ class loggerTest extends CoreTestAbstract
|
|||||||
$this->assertFalse(Logger::isEnabled());
|
$this->assertFalse(Logger::isEnabled());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tearDown()
|
public function tearDown(): void
|
||||||
{
|
{
|
||||||
parent::tearDown();
|
parent::tearDown();
|
||||||
|
|
||||||
|
@ -31,10 +31,10 @@
|
|||||||
* @link http://techfuze.net/fuzeworks
|
* @link http://techfuze.net/fuzeworks
|
||||||
* @since Version 1.1.4
|
* @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\Factory;
|
||||||
use FuzeWorks\Plugins;
|
use FuzeWorks\Plugins;
|
||||||
|
|
||||||
@ -50,9 +50,9 @@ class pluginTest extends CoreTestAbstract
|
|||||||
/**
|
/**
|
||||||
* @var FuzeWorks\Plugins
|
* @var FuzeWorks\Plugins
|
||||||
*/
|
*/
|
||||||
protected $plugins;
|
protected Plugins $plugins;
|
||||||
|
|
||||||
public function setUp()
|
public function setUp(): void
|
||||||
{
|
{
|
||||||
$this->plugins = new Plugins();
|
$this->plugins = new Plugins();
|
||||||
$this->plugins->init();
|
$this->plugins->init();
|
||||||
@ -106,10 +106,10 @@ class pluginTest extends CoreTestAbstract
|
|||||||
/**
|
/**
|
||||||
* @depends testLoadPlugin
|
* @depends testLoadPlugin
|
||||||
* @covers ::get
|
* @covers ::get
|
||||||
* @expectedException FuzeWorks\Exception\PluginException
|
|
||||||
*/
|
*/
|
||||||
public function testMissingHeader()
|
public function testMissingHeader()
|
||||||
{
|
{
|
||||||
|
$this->expectException(PluginException::class);
|
||||||
$this->plugins->get('testMissingHeader');
|
$this->plugins->get('testMissingHeader');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,39 +134,39 @@ class pluginTest extends CoreTestAbstract
|
|||||||
/**
|
/**
|
||||||
* @depends testLoadPlugin
|
* @depends testLoadPlugin
|
||||||
* @covers ::get
|
* @covers ::get
|
||||||
* @expectedException FuzeWorks\Exception\PluginException
|
|
||||||
*/
|
*/
|
||||||
public function testMissingPlugin()
|
public function testMissingPlugin()
|
||||||
{
|
{
|
||||||
|
$this->expectException(PluginException::class);
|
||||||
$this->plugins->get('testMissingPlugin');
|
$this->plugins->get('testMissingPlugin');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @depends testMissingPlugin
|
* @depends testMissingPlugin
|
||||||
* @covers ::get
|
* @covers ::get
|
||||||
* @expectedException FuzeWorks\Exception\PluginException
|
|
||||||
*/
|
*/
|
||||||
public function testLoadHeaderNotIPluginHeader()
|
public function testLoadHeaderNotIPluginHeader()
|
||||||
{
|
{
|
||||||
|
$this->expectException(PluginException::class);
|
||||||
$this->plugins->get('TestLoadHeaderNotIPluginHeader');
|
$this->plugins->get('TestLoadHeaderNotIPluginHeader');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @depends testLoadPlugin
|
* @depends testLoadPlugin
|
||||||
* @covers ::get
|
* @covers ::get
|
||||||
* @expectedException FuzeWorks\Exception\PluginException
|
|
||||||
*/
|
*/
|
||||||
public function testInvalidClass()
|
public function testInvalidClass()
|
||||||
{
|
{
|
||||||
|
$this->expectException(PluginException::class);
|
||||||
$this->plugins->get('testInvalidClass');
|
$this->plugins->get('testInvalidClass');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers ::get
|
* @covers ::get
|
||||||
* @expectedException FuzeWorks\Exception\PluginException
|
|
||||||
*/
|
*/
|
||||||
public function testGetMissingName()
|
public function testGetMissingName()
|
||||||
{
|
{
|
||||||
|
$this->expectException(PluginException::class);
|
||||||
$this->plugins->get('');
|
$this->plugins->get('');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,12 +174,12 @@ class pluginTest extends CoreTestAbstract
|
|||||||
* @depends testLoadPlugin
|
* @depends testLoadPlugin
|
||||||
* @covers ::get
|
* @covers ::get
|
||||||
* @covers ::loadHeadersFromPluginPaths
|
* @covers ::loadHeadersFromPluginPaths
|
||||||
* @expectedException FuzeWorks\Exception\PluginException
|
|
||||||
*/
|
*/
|
||||||
public function testDisabledPlugin()
|
public function testDisabledPlugin()
|
||||||
{
|
{
|
||||||
Factory::getInstance()->config->plugins->disabled_plugins = array('TestDisabledPlugin');
|
Factory::getInstance()->config->plugins->disabled_plugins = array('TestDisabledPlugin');
|
||||||
$this->plugins->loadHeadersFromPluginPaths();
|
$this->plugins->loadHeadersFromPluginPaths();
|
||||||
|
$this->expectException(PluginException::class);
|
||||||
$this->plugins->get('testDisabledPlugin');
|
$this->plugins->get('testDisabledPlugin');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,16 +187,16 @@ class pluginTest extends CoreTestAbstract
|
|||||||
* @depends testLoadPlugin
|
* @depends testLoadPlugin
|
||||||
* @covers ::get
|
* @covers ::get
|
||||||
* @covers ::loadHeadersFromPluginPaths
|
* @covers ::loadHeadersFromPluginPaths
|
||||||
* @expectedException FuzeWorks\Exception\PluginException
|
|
||||||
*/
|
*/
|
||||||
public function testRunInvalidDirectory()
|
public function testRunInvalidDirectory()
|
||||||
{
|
{
|
||||||
$this->plugins->addComponentPath('exists_not');
|
$this->plugins->addComponentPath('exists_not');
|
||||||
$this->plugins->loadHeadersFromPluginPaths();
|
$this->plugins->loadHeadersFromPluginPaths();
|
||||||
|
$this->expectException(PluginException::class);
|
||||||
$this->plugins->get('testRunInvalidDirectory');
|
$this->plugins->get('testRunInvalidDirectory');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tearDown()
|
public function tearDown(): void
|
||||||
{
|
{
|
||||||
parent::tearDown();
|
parent::tearDown();
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
* @link http://techfuze.net/fuzeworks
|
* @link http://techfuze.net/fuzeworks
|
||||||
* @since Version 1.0.4
|
* @since Version 1.0.4
|
||||||
*
|
*
|
||||||
* @version Version 1.2.0
|
* @version Version 1.3.0
|
||||||
*/
|
*/
|
||||||
use FuzeWorks\Priority;
|
use FuzeWorks\Priority;
|
||||||
|
|
||||||
@ -62,12 +62,12 @@ class priorityTest extends CoreTestAbstract
|
|||||||
*/
|
*/
|
||||||
public function testGetPriority()
|
public function testGetPriority()
|
||||||
{
|
{
|
||||||
$this->assertEquals(Priority::getPriority(5), 'Priority::LOWEST');
|
$this->assertEquals('Priority::LOWEST', Priority::getPriority(5));
|
||||||
$this->assertEquals(Priority::getPriority(4), 'Priority::LOW');
|
$this->assertEquals('Priority::LOW', Priority::getPriority(4));
|
||||||
$this->assertEquals(Priority::getPriority(3), 'Priority::NORMAL');
|
$this->assertEquals('Priority::NORMAL', Priority::getPriority(3));
|
||||||
$this->assertEquals(Priority::getPriority(2), 'Priority::HIGH');
|
$this->assertEquals('Priority::HIGH', Priority::getPriority(2));
|
||||||
$this->assertEquals(Priority::getPriority(1), 'Priority::HIGHEST');
|
$this->assertEquals('Priority::HIGHEST', Priority::getPriority(1));
|
||||||
$this->assertEquals(Priority::getPriority(0), 'Priority::MONITOR');
|
$this->assertEquals('Priority::MONITOR', Priority::getPriority(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -83,7 +83,7 @@ class priorityTest extends CoreTestAbstract
|
|||||||
*/
|
*/
|
||||||
public function testHighestPriority()
|
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()
|
public function testLowestPriority()
|
||||||
{
|
{
|
||||||
$this->assertEquals(Priority::getLowestPriority(), Priority::LOWEST);
|
$this->assertEquals(Priority::LOWEST, Priority::getLowestPriority());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
* @link http://techfuze.net/fuzeworks
|
* @link http://techfuze.net/fuzeworks
|
||||||
* @since Version 1.1.4
|
* @since Version 1.1.4
|
||||||
*
|
*
|
||||||
* @version Version 1.2.0
|
* @version Version 1.3.0
|
||||||
*/
|
*/
|
||||||
use FuzeWorks\Factory;
|
use FuzeWorks\Factory;
|
||||||
use FuzeWorks\Events;
|
use FuzeWorks\Events;
|
||||||
@ -64,11 +64,14 @@ class pluginGetEventTest extends CoreTestAbstract
|
|||||||
{
|
{
|
||||||
// Create mock listener
|
// Create mock listener
|
||||||
Events::addListener(
|
Events::addListener(
|
||||||
function($event){$event->setPlugin('test_string');return $event;},
|
function($event){
|
||||||
|
$z = new stdClass();
|
||||||
|
$event->setPlugin($z);return $event;
|
||||||
|
},
|
||||||
'pluginGetEvent',
|
'pluginGetEvent',
|
||||||
Priority::NORMAL);
|
Priority::NORMAL);
|
||||||
|
|
||||||
// And fire the event
|
// And fire the event
|
||||||
$this->assertEquals('test_string', Factory::getInstance()->plugins->get('test'));
|
$this->assertInstanceOf('\stdClass', Factory::getInstance()->plugins->get('test'));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -31,13 +31,13 @@
|
|||||||
* @link http://techfuze.net/fuzeworks
|
* @link http://techfuze.net/fuzeworks
|
||||||
* @since Version 0.0.1
|
* @since Version 0.0.1
|
||||||
*
|
*
|
||||||
* @version Version 1.2.0
|
* @version Version 1.3.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! function_exists('testCancelLoadHelper'))
|
if ( ! function_exists('testCancelLoadHelper'))
|
||||||
{
|
{
|
||||||
|
|
||||||
function testCancelLoadHelper($someParameter)
|
function testCancelLoadHelper(): string
|
||||||
{
|
{
|
||||||
return 'SomeResult';
|
return 'SomeResult';
|
||||||
}
|
}
|
||||||
|
@ -31,13 +31,13 @@
|
|||||||
* @link http://techfuze.net/fuzeworks
|
* @link http://techfuze.net/fuzeworks
|
||||||
* @since Version 0.0.1
|
* @since Version 0.0.1
|
||||||
*
|
*
|
||||||
* @version Version 1.2.0
|
* @version Version 1.3.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! function_exists('testGetHelper'))
|
if ( ! function_exists('testGetHelper'))
|
||||||
{
|
{
|
||||||
|
|
||||||
function testGetHelper($someParameter)
|
function testGetHelper(): string
|
||||||
{
|
{
|
||||||
return 'SomeResult';
|
return 'SomeResult';
|
||||||
}
|
}
|
||||||
|
@ -31,12 +31,12 @@
|
|||||||
* @link http://techfuze.net/fuzeworks
|
* @link http://techfuze.net/fuzeworks
|
||||||
* @since Version 1.2.0
|
* @since Version 1.2.0
|
||||||
*
|
*
|
||||||
* @version Version 1.2.0
|
* @version Version 1.3.0
|
||||||
*/
|
*/
|
||||||
if ( ! function_exists('testHelperFunction'))
|
if ( ! function_exists('testHelperFunction'))
|
||||||
{
|
{
|
||||||
|
|
||||||
function testHelperFunction($someParameter)
|
function testHelperFunction(): string
|
||||||
{
|
{
|
||||||
return 'SomeResult';
|
return 'SomeResult';
|
||||||
}
|
}
|
||||||
|
@ -31,13 +31,13 @@
|
|||||||
* @link http://techfuze.net/fuzeworks
|
* @link http://techfuze.net/fuzeworks
|
||||||
* @since Version 1.2.0
|
* @since Version 1.2.0
|
||||||
*
|
*
|
||||||
* @version Version 1.2.0
|
* @version Version 1.3.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! function_exists('testLoadHelperWithAltDirectory'))
|
if ( ! function_exists('testLoadHelperWithAltDirectory'))
|
||||||
{
|
{
|
||||||
|
|
||||||
function testLoadHelperWithAltDirectory($someParameter)
|
function testLoadHelperWithAltDirectory(): string
|
||||||
{
|
{
|
||||||
return 'SomeResult';
|
return 'SomeResult';
|
||||||
}
|
}
|
||||||
|
@ -31,13 +31,13 @@
|
|||||||
* @link http://techfuze.net/fuzeworks
|
* @link http://techfuze.net/fuzeworks
|
||||||
* @since Version 0.0.1
|
* @since Version 0.0.1
|
||||||
*
|
*
|
||||||
* @version Version 1.2.0
|
* @version Version 1.3.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! function_exists('testLoadHelperWithoutSubdirectory'))
|
if ( ! function_exists('testLoadHelperWithoutSubdirectory'))
|
||||||
{
|
{
|
||||||
|
|
||||||
function testLoadHelperWithoutSubdirectory($someParameter)
|
function testLoadHelperWithoutSubdirectory(): string
|
||||||
{
|
{
|
||||||
return 'SomeResult';
|
return 'SomeResult';
|
||||||
}
|
}
|
||||||
|
@ -31,13 +31,13 @@
|
|||||||
* @link http://techfuze.net/fuzeworks
|
* @link http://techfuze.net/fuzeworks
|
||||||
* @since Version 0.0.1
|
* @since Version 0.0.1
|
||||||
*
|
*
|
||||||
* @version Version 1.2.0
|
* @version Version 1.3.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! function_exists('testReloadHelper'))
|
if ( ! function_exists('testReloadHelper'))
|
||||||
{
|
{
|
||||||
|
|
||||||
function testReloadHelper($someParameter)
|
function testReloadHelper(): string
|
||||||
{
|
{
|
||||||
return 'SomeResult';
|
return 'SomeResult';
|
||||||
}
|
}
|
||||||
|
@ -1,36 +1,19 @@
|
|||||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.5/phpunit.xsd"
|
<?xml version="1.0"?>
|
||||||
bootstrap="autoload.php"
|
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" bootstrap="autoload.php" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" stopOnError="false" stopOnFailure="false" stopOnIncomplete="false" stopOnSkipped="false" colors="false">
|
||||||
convertErrorsToExceptions="true"
|
<coverage processUncoveredFiles="false">
|
||||||
convertNoticesToExceptions="true"
|
<include>
|
||||||
convertWarningsToExceptions="true"
|
|
||||||
stopOnError="false"
|
|
||||||
stopOnFailure="false"
|
|
||||||
stopOnIncomplete="false"
|
|
||||||
stopOnSkipped="false"
|
|
||||||
colors="false">
|
|
||||||
|
|
||||||
<testsuites>
|
|
||||||
<testsuite name="Core Functionality">
|
|
||||||
<directory>./</directory>
|
|
||||||
</testsuite>
|
|
||||||
</testsuites>
|
|
||||||
|
|
||||||
<logging>
|
|
||||||
<log type="json" target="../build/phpunit/logfile.json"/>
|
|
||||||
<log type="junit" target="../build/phpunit/logfile.xml"/>
|
|
||||||
<log type="testdox-html" target="../build/phpunit/testdox.html"/>
|
|
||||||
<log type="testdox-text" target="../build/phpunit/testdox.txt"/>
|
|
||||||
</logging>
|
|
||||||
|
|
||||||
<filter>
|
|
||||||
<whitelist processUncoveredFilesFromWhitelist="false">
|
|
||||||
<directory suffix=".php">../</directory>
|
<directory suffix=".php">../</directory>
|
||||||
|
</include>
|
||||||
<exclude>
|
<exclude>
|
||||||
<directory suffix=".php">../vendor/</directory>
|
<directory suffix=".php">../vendor/</directory>
|
||||||
<directory suffix=".php">../test/</directory>
|
<directory suffix=".php">../test/</directory>
|
||||||
<directory suffix=".php">../src/Layout/</directory>
|
<directory suffix=".php">../src/Layout/</directory>
|
||||||
<directory suffix=".php">../src/Config/</directory>
|
<directory suffix=".php">../src/Config/</directory>
|
||||||
</exclude>
|
</exclude>
|
||||||
</whitelist>
|
</coverage>
|
||||||
</filter>
|
<testsuites>
|
||||||
|
<testsuite name="Core Suite">
|
||||||
|
<directory>./</directory>
|
||||||
|
</testsuite>
|
||||||
|
</testsuites>
|
||||||
</phpunit>
|
</phpunit>
|
@ -31,7 +31,7 @@
|
|||||||
* @link http://techfuze.net/fuzeworks
|
* @link http://techfuze.net/fuzeworks
|
||||||
* @since Version 1.2.0
|
* @since Version 1.2.0
|
||||||
*
|
*
|
||||||
* @version Version 1.2.0
|
* @version Version 1.3.0
|
||||||
*/
|
*/
|
||||||
namespace Application\Plugin;
|
namespace Application\Plugin;
|
||||||
use FuzeWorks\iPluginHeader;
|
use FuzeWorks\iPluginHeader;
|
||||||
@ -48,7 +48,7 @@ class TestGetPluginMethodHeader implements iPluginHeader
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPlugin()
|
public function getPlugin(): string
|
||||||
{
|
{
|
||||||
return 'test_string';
|
return 'test_string';
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user