Updated to PHP 8.0.
continuous-integration/drone/push Build is passing Details

- Release version 1.3.3.
- Most property, argument and return types have been defined and are now enforced.
- Drone now performs tests for both PHP 7.4 and 8.0. Extend for future versions.
This commit is contained in:
Abel Hoogeveen 2021-11-24 19:31:59 +01:00
parent 51153520e2
commit 016fa03ac2
Signed by: abelhooge
GPG Key ID: C540221690CBFFBA
32 changed files with 126 additions and 115 deletions

View File

@ -8,8 +8,23 @@ steps:
commands:
- composer install
- name: test
- name: php74test
image: registry.i15.nl/i15/fuzephp:7.4-alpine
commands:
- docker-php-ext-enable xdebug
- vendor/bin/phpunit -c test/phpunit.xml
- vendor/bin/phpunit -c test/phpunit.xml
- name: php80test
image: registry.i15.nl/i15/fuzephp:8.0-alpine
commands:
- docker-php-ext-enable xdebug
- vendor/bin/phpunit -c test/phpunit.xml
- name: coverage
image: 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
View File

@ -1,4 +1,5 @@
.gitattributes export-ignore
.gitignore export-ignore
.gitlab-ci.yml export-ignore
.drone.yml export-ignore
test/ export-ignore

View File

@ -4,17 +4,13 @@
"license": ["MIT"],
"authors": [
{
"name": "TechFuze",
"homepage": "https://techfuze.net"
},
{
"name": "FuzeWorks Community",
"homepage": "https://techfuze.net/fuzeworks/contributors"
"name": "Abel Hoogeveen",
"homepage": "https://i15.nl"
}
],
"require": {
"php": ">=7.4.0",
"fuzeworks/core": "~1.2.0"
"fuzeworks/core": "~1.3.0"
},
"require-dev": {
"phpunit/phpunit": "^9",

View File

@ -31,7 +31,7 @@
* @link http://techfuze.net/fuzeworks
* @since Version 1.2.0
*
* @version Version 1.2.0
* @version Version 1.3.3
*/
/**
@ -44,7 +44,7 @@
* Custom callable: Adds a route that sends all matches to the provided callable. Allows user to replace defaultCallable
* 'routingString' => array('callable' => array(CALLABLE))
*
* Dynamic rewrite: Adds a route that rewrites an URL to a specific controller and method configuration, using a callable. The callable can dynamically determine which page to load.
* Dynamic rewrite: Adds a route that rewrites a URL to a specific controller and method configuration, using a callable. The callable can dynamically determine which page to load.
* 'routingString' => CALLABLE
*
* Static rewrite: Adds a route that rewrites and URL to a specific controller and method using a fixed route. This allows for pre-determined rewrites of pages.

View File

@ -31,7 +31,7 @@
* @link http://techfuze.net/fuzeworks
* @since Version 1.2.0
*
* @version Version 1.2.0
* @version Version 1.3.3
*/
namespace FuzeWorks;
@ -49,22 +49,22 @@ abstract class Controller
/**
* @var Plugins
*/
protected $plugins;
protected Plugins $plugins;
/**
* @var Libraries
*/
protected $libraries;
protected Libraries $libraries;
/**
* @var Helpers
*/
protected $helpers;
protected Helpers $helpers;
/**
* @var Config
*/
protected $config;
protected Config $config;
/**
* @var Controllers

View File

@ -31,7 +31,7 @@
* @link http://techfuze.net/fuzeworks
* @since Version 1.2.0
*
* @version Version 1.2.0
* @version Version 1.3.3
*/
namespace FuzeWorks;
@ -45,7 +45,7 @@ use FuzeWorks\Exception\NotFoundException;
* Controllers Class.
*
* Simple loader class for MVC Controllers.
* Typically loads controllers from Application\Controller unless otherwise specified.
* Typically, loads controllers from Application\Controller unless otherwise specified.
*
* @author Abel Hoogeveen <abel@techfuze.net>
* @copyright Copyright (c) 2013 - 2019, TechFuze. (http://techfuze.net)

View File

@ -31,7 +31,7 @@
* @link http://techfuze.net/fuzeworks
* @since Version 1.2.0
*
* @version Version 1.2.0
* @version Version 1.3.3
*/
namespace FuzeWorks\Event;
@ -52,28 +52,28 @@ class ControllerGetEvent extends Event
*
* @var array
*/
public $controllerPaths = array();
public array $controllerPaths = array();
/**
* The name of the controller to be loaded.
*
* @var string|null
*/
public $controllerName = null;
public ?string $controllerName = null;
/**
* The namespace of the controller to be loaded. Defaults to Application\Controller
*
* @var string
*/
public $namespace = '\Application\Controller\\';
public string $namespace = '\Application\Controller\\';
/**
* Arguments provided to the constructor
*
* @var array
*/
public $arguments = [];
public array $arguments = [];
public function init($controllerName, $controllerPaths, $namespace, $arguments)
{

View File

@ -31,7 +31,7 @@
* @link http://techfuze.net/fuzeworks
* @since Version 1.2.0
*
* @version Version 1.2.0
* @version Version 1.3.3
*/
namespace FuzeWorks\Event;
@ -53,28 +53,28 @@ class ModelGetEvent extends Event
*
* @var array
*/
public $modelPaths = array();
public array $modelPaths = array();
/**
* The name of the model to be loaded.
*
* @var string|null
*/
public $modelName = null;
public ?string $modelName = null;
/**
* The namespace of the model to be loaded. Defaults to Application\Model
*
* @var string
*/
public $namespace = '\Application\Model\\';
public string $namespace = '\Application\Model\\';
/**
* Arguments provided to the constructor
*
* @var array
*/
public $arguments = [];
public array $arguments = [];
public function init($modelName, $modelPaths, $namespace, $arguments)
{

View File

@ -31,7 +31,7 @@
* @link http://techfuze.net/fuzeworks
* @since Version 1.2.0
*
* @version Version 1.2.0
* @version Version 1.3.3
*/
namespace FuzeWorks\Event;
@ -46,7 +46,7 @@ use FuzeWorks\View;
*
* Use this to cancel the calling of a view method.
*
* Currently only used by Router::defaultCallable();
* Currently, only used by Router::defaultCallable();
*
* This event is currently used in the WebComponent project. It allows the component to stop loading when
* a CSRFException is thrown, and the view has no method of handling this request
@ -61,35 +61,35 @@ class RouterCallViewEvent extends Event
*
* @var array
*/
public $viewMethods;
public array $viewMethods;
/**
* The parameters that will be provided to the function in the view
*
* @var array
*/
public $viewParameters;
public array $viewParameters;
/**
* The route that resulted in this controller and view
*
* @var string
*/
public $route;
public string $route;
/**
* The view the method will be called on
*
* @var View
*/
public $view;
public View $view;
/**
* The controller that's associated with this View
*
* @var Controller
*/
public $controller;
public Controller $controller;
public function init(View $view, Controller $controller, array $viewMethods, array $viewParameters, string $route)
{

View File

@ -31,7 +31,7 @@
* @link http://techfuze.net/fuzeworks
* @since Version 1.2.0
*
* @version Version 1.2.0
* @version Version 1.3.3
*/
namespace FuzeWorks\Event;
@ -41,9 +41,9 @@ use FuzeWorks\Event;
/**
* Event that gets fired when a callable is to be loaded by the Router class
*
* Use this to cancel the modify the loading of a custom callable or the defaultCallable
* Use this to cancel the modification the loading of a custom callable or the defaultCallable
*
* Currently only used by Router::loadCallable();
* Currently, only used by Router::loadCallable();
*
* @author Abel Hoogeveen <abel@techfuze.net>
* @copyright Copyright (c) 2013 - 2019, TechFuze. (http://techfuze.net)
@ -63,21 +63,21 @@ class RouterLoadCallableEvent extends Event
*
* @var array
*/
public $matches;
public array $matches;
/**
* The static route configuration
*
* @var array
*/
public $routeData;
public array $routeData;
/**
* The route which resulted in this callable being loaded
*
* @var string
*/
public $route;
public string $route;
public function init(callable $callable, array $matches, array $routeData, string $route)
{

View File

@ -31,7 +31,7 @@
* @link http://techfuze.net/fuzeworks
* @since Version 1.2.0
*
* @version Version 1.2.0
* @version Version 1.3.3
*/
namespace FuzeWorks\Event;
@ -44,7 +44,7 @@ use FuzeWorks\Priority;
*
* Use this to cancel the loading of a combination, or change the details of what is loaded.
*
* Currently only used by Router::defaultCallable();
* Currently, only used by Router::defaultCallable();
*
* @author Abel Hoogeveen <abel@techfuze.net>
* @copyright Copyright (c) 2013 - 2019, TechFuze. (http://techfuze.net)
@ -56,49 +56,49 @@ class RouterLoadViewAndControllerEvent extends Event
*
* @var string
*/
public $viewName;
public string $viewName;
/**
* The type of view to be loaded
*
* @var string
*/
public $viewType;
public string $viewType;
/**
* The function that will be loaded in the view
*
* @var array
*/
public $viewMethods;
public array $viewMethods;
/**
* The parameters that will be provided to the function in the view
*
* @var array
*/
public $viewParameters;
public array $viewParameters;
/**
* The namespace to use to load the View and Controller
*
* @var string
*/
public $namespacePrefix;
public string $namespacePrefix;
/**
* The route that resulted in this controller and view
*
* @var string
*/
public $route;
public string $route;
/**
* A controller to be injected.
*
* @var Controller|null
*/
public $controller;
public ?Controller $controller = null;
public function init(string $viewName, string $viewType, array $viewMethods, array $viewParameters, string $namespacePrefix, string $route)
{

View File

@ -31,7 +31,7 @@
* @link http://techfuze.net/fuzeworks
* @since Version 1.2.0
*
* @version Version 1.2.0
* @version Version 1.3.3
*/
namespace FuzeWorks\Event;
@ -53,40 +53,40 @@ class ViewGetEvent extends Event
*
* @var array
*/
public $viewPaths = [];
public array $viewPaths = [];
/**
* The name of the view to be loaded.
*
* @var string|null
*/
public $viewName = null;
public ?string $viewName = null;
/**
* The type of view to be loaded. Eg: html, json, cli.
*
* @var string|null
*/
public $viewType = null;
public ?string $viewType = null;
/**
* The namespace of the View to be loaded. Defaults to Application\View
*
* @var string
*/
public $namespace = '\Application\View\\';
public string $namespace = '\Application\View\\';
/**
* Arguments provided to the constructor
*
* @var array
*/
public $arguments = [];
public array $arguments = [];
/**
* @var Controller
*/
public $controller;
public Controller $controller;
public function init($viewName, $viewType, $viewPaths, $namespace, $controller, $arguments)
{

View File

@ -31,7 +31,7 @@
* @link http://techfuze.net/fuzeworks
* @since Version 1.2.0
*
* @version Version 1.2.0
* @version Version 1.3.3
*/
namespace FuzeWorks;
@ -50,22 +50,22 @@ abstract class Model
/**
* @var Plugins
*/
protected $plugins;
protected Plugins $plugins;
/**
* @var Libraries
*/
protected $libraries;
protected Libraries $libraries;
/**
* @var Helpers
*/
protected $helpers;
protected Helpers $helpers;
/**
* @var Config
*/
protected $config;
protected Config $config;
/**
* @var Models

View File

@ -31,7 +31,7 @@
* @link http://techfuze.net/fuzeworks
* @since Version 1.2.0
*
* @version Version 1.2.0
* @version Version 1.3.3
*/
namespace FuzeWorks;
@ -45,7 +45,7 @@ use FuzeWorks\Exception\NotFoundException;
* Models Class.
*
* Simple loader class for MVC Models.
* Typically loads models from Application\Model unless otherwise specified.
* Typically, loads models from Application\Model unless otherwise specified.
*
* @author Abel Hoogeveen <abel@techfuze.net>
* @copyright Copyright (c) 2013 - 2019, TechFuze. (http://techfuze.net)

View File

@ -31,7 +31,7 @@
* @link http://techfuze.net/fuzeworks
* @since Version 1.2.0
*
* @version Version 1.2.0
* @version Version 1.3.3
*/
namespace FuzeWorks;
@ -54,7 +54,7 @@ class Router
*
* @var array
*/
protected $routes = [];
protected array $routes = [];
/**
* The current callable used
@ -68,10 +68,10 @@ class Router
*
* @var array|null
*/
protected $matches = null;
protected ?array $matches = null;
/**
* @var array|null
* @var array|Closure|null
*/
protected $routeData = null;
@ -80,36 +80,36 @@ class Router
*
* @var string|null
*/
protected $route = null;
protected ?string $route = null;
/**
* The current View
*
* @var View|null
*/
protected $view = null;
protected ?View $view = null;
/**
* The current Controller
*
* @var Controller|null
*/
protected $controller = null;
protected ?Controller $controller = null;
/**
* @var Config
*/
private $config;
private Config $config;
/**
* @var Controllers
*/
private $controllers;
private Controllers $controllers;
/**
* @var Views
*/
private $views;
private Views $views;
/**
* Router constructor.
@ -156,7 +156,7 @@ class Router
$routeConfig = ['callable' => [$this, 'defaultCallable']];
}
// Finally add the route
// Finally, add the route
$this->addRoute($route, $routeConfig);
}
}
@ -219,7 +219,7 @@ class Router
public function route(string $path, string $category = 'default', array $routes = [])
{
// Select the routes to use
$globalRoutes = isset($this->routes[$category]) ? $this->routes[$category] : [];
$globalRoutes = $this->routes[$category] ?? [];
$routes = empty($routes) ? $globalRoutes : $routes;
// Check all the provided custom paths, ordered by priority
@ -423,7 +423,7 @@ class Router
if (method_exists($this->view, $method))
{
// Execute this method on the view
Logger::newLevel("Calling method '{$method}' on " . get_class($this->view) . ' with ' . get_class($this->controller));
Logger::newLevel("Calling method '$method' on " . get_class($this->view) . ' with ' . get_class($this->controller));
$output = call_user_func_array([$this->view, $method], $event->viewParameters);
Logger::stopLevel();
return $output;

View File

@ -31,7 +31,7 @@
* @link http://techfuze.net/fuzeworks
* @since Version 1.2.0
*
* @version Version 1.2.0
* @version Version 1.3.3
*/
namespace FuzeWorks;
@ -61,29 +61,29 @@ abstract class View
/**
* @var Plugins
*/
protected $plugins;
protected Plugins $plugins;
/**
* @var Libraries
*/
protected $libraries;
protected Libraries $libraries;
/**
* @var Helpers
*/
protected $helpers;
protected Helpers $helpers;
/**
* @var Config
*/
protected $config;
protected Config $config;
/**
* The controller associated with this view
*
* @var Controller
*/
protected $controller;
protected Controller $controller;
/**
* Provide the View with its associated Controller

View File

@ -31,7 +31,7 @@
* @link http://techfuze.net/fuzeworks
* @since Version 1.2.0
*
* @version Version 1.2.0
* @version Version 1.3.3
*/
namespace FuzeWorks;
@ -44,7 +44,7 @@ use FuzeWorks\Exception\ViewException;
* Views Class.
*
* Simple loader class for MVC Views.
* Typically loads views from Application\View unless otherwise specified.
* Typically, loads views from Application\View unless otherwise specified.
*
* @author Abel Hoogeveen <abel@techfuze.net>
* @copyright Copyright (c) 2013 - 2019, TechFuze. (http://techfuze.net)
@ -130,7 +130,7 @@ class Views
// If the class already exists, return a new instance directly
$class = ucfirst($class);
$className = $namespace . $class . $viewType . 'View';
$className = $namespace . $class . ucfirst($viewType) . 'View';
if (class_exists($className, true)) {
/** @var View $view */
$view = new $className(...$arguments);

View File

@ -31,9 +31,11 @@
* @link http://techfuze.net/fuzeworks
* @since Version 0.0.1
*
* @version Version 1.2.0
* @version Version 1.3.3
*/
use FuzeWorks\MVCRComponent;
require_once(dirname(__DIR__) . '/vendor/autoload.php');
$configurator = new FuzeWorks\Configurator();
@ -44,14 +46,11 @@ $configurator->setLogDirectory(dirname(__FILE__) . '/temp');
// Other values
$configurator->setTimeZone('Europe/Amsterdam');
$configurator->setDebugAddress('NONE');
$configurator->setDebugAddress();
// Implement the MVCR Component
$configurator->addComponent(new \FuzeWorks\MVCRComponent());
$configurator->addComponent(new MVCRComponent());
// Create container
$container = $configurator->createContainer();
// And return the result
return $container;
return $configurator->createContainer();

View File

@ -40,5 +40,5 @@ use FuzeWorks\Controller;
class TestDifferentComponentPathPriorityController extends Controller
{
public $type = 'highest';
public string $type = 'highest';
}

View File

@ -40,5 +40,5 @@ use FuzeWorks\Controller;
class TestDifferentComponentPathPriorityController extends Controller
{
public $type = 'lowest';
public string $type = 'lowest';
}

View File

@ -53,7 +53,7 @@ class ControllersTest extends TestCase
/**
* @var Controllers
*/
protected $controllers;
protected Controllers $controllers;
public function setUp(): void
{

View File

@ -54,7 +54,7 @@ class ModelsTest extends TestCase
/**
* @var Models
*/
protected $models;
protected Models $models;
public function setUp(): void
{

View File

@ -55,14 +55,14 @@ class RouterTest extends TestCase
*
* @var Router
*/
protected $router;
protected Router $router;
/**
* Holds the Config object
*
* @var Config
*/
protected $config;
protected Config $config;
public function setUp(): void
{

View File

@ -55,7 +55,7 @@ class ViewsTest extends TestCase
/**
* @var Views
*/
protected $views;
protected Views $views;
/**
* @var Controller

View File

@ -40,5 +40,5 @@ use FuzeWorks\Model;
class TestDifferentComponentPathPriorityModel extends Model
{
public $type = 'highest';
public string $type = 'highest';
}

View File

@ -40,5 +40,5 @@ use FuzeWorks\Model;
class TestDifferentComponentPathPriorityModel extends Model
{
public $type = 'lowest';
public string $type = 'lowest';
}

View File

@ -31,7 +31,7 @@
* @link http://techfuze.net/fuzeworks
* @since Version 1.2.0
*
* @version Version 1.2.0
* @version Version 1.3.3
*/
namespace Application\View;
@ -40,5 +40,5 @@ use FuzeWorks\View;
class TestDifferentComponentPathPriorityStandardView extends View
{
public $type = 'highest';
public string $type = 'highest';
}

View File

@ -31,7 +31,7 @@
* @link http://techfuze.net/fuzeworks
* @since Version 1.2.0
*
* @version Version 1.2.0
* @version Version 1.3.3
*/
namespace Application\View;
@ -40,5 +40,5 @@ use FuzeWorks\View;
class TestDifferentComponentPathPriorityStandardView extends View
{
public $type = 'lowest';
public string $type = 'lowest';
}

View File

@ -31,7 +31,7 @@
* @link http://techfuze.net/fuzeworks
* @since Version 1.2.0
*
* @version Version 1.2.0
* @version Version 1.3.3
*/
namespace Application\View;
@ -41,7 +41,7 @@ use FuzeWorks\View;
class TestDefaultCallableTestView extends View
{
public function someMethod()
public function someMethod(): string
{
return "Verify Output";
}

View File

@ -31,7 +31,7 @@
* @link http://techfuze.net/fuzeworks
* @since Version 1.2.0
*
* @version Version 1.2.0
* @version Version 1.3.3
*/
namespace Application\View;
@ -40,12 +40,12 @@ use FuzeWorks\View;
class TestDefaultCallableChangeMethodTestView extends View
{
public function index()
public function index(): string
{
return "Not altered!";
}
public function altered(string $param1, string $param2)
public function altered(string $param1, string $param2): array
{
return ["Altered", $param1, $param2];
}

View File

@ -31,7 +31,7 @@
* @link http://techfuze.net/fuzeworks
* @since Version 1.2.0
*
* @version Version 1.2.0
* @version Version 1.3.3
*/
namespace Custom\View;
@ -41,7 +41,7 @@ use FuzeWorks\View;
class TestDefaultCallableCustomNamespaceTestView extends View
{
public function someMethod()
public function someMethod(): string
{
return "Verify Output, with custom namespace!";
}

View File

@ -31,7 +31,7 @@
* @link http://techfuze.net/fuzeworks
* @since Version 1.2.0
*
* @version Version 1.2.0
* @version Version 1.3.3
*/
namespace Application\View;
@ -40,6 +40,6 @@ use FuzeWorks\View;
class TestDefaultCallableHaltTestView extends View
{
public $halt = true;
public bool $halt = true;
}