Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(php) Move to PHP 7.1 #37

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .State

This file was deleted.

13 changes: 3 additions & 10 deletions Basic.php → Source/Basic.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* Hoa
*
Expand Down Expand Up @@ -45,25 +47,16 @@
*
* A basic and generic dispatcher. It supports function, closure, object and
* class (controller::action).
*
* @copyright Copyright © 2007-2017 Hoa community
* @license New BSD License
*/
class Basic extends Dispatcher
{
/**
* Resolve the dispatch call.
*
* @param array $rule Rule.
* @param \Hoa\Router $router Router.
* @param \Hoa\View\Viewable $view View.
* @return mixed
* @throws \Hoa\Dispatcher\Exception
*/
protected function resolve(
array $rule,
Router $router,
View\Viewable $view = null
?View\Viewable $view = null
) {
$called = null;
$variables = &$rule[Router::RULE_VARIABLES];
Expand Down
13 changes: 3 additions & 10 deletions ClassMethod.php → Source/ClassMethod.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* Hoa
*
Expand Down Expand Up @@ -45,25 +47,16 @@
*
* This class dispatches on a class/object and a method, nothing more. There is
* no concept of controller or action, it is just _call and _able.
*
* @copyright Copyright © 2007-2017 Hoa community
* @license New BSD License
*/
class ClassMethod extends Dispatcher
{
/**
* Resolve the dispatch call.
*
* @param array $rule Rule.
* @param \Hoa\Router $router Router.
* @param \Hoa\View\Viewable $view View.
* @return mixed
* @throws \Hoa\Dispatcher\Exception
*/
protected function resolve(
array $rule,
Router $router,
View\Viewable $view = null
?View\Viewable $view = null
) {
$called = null;
$variables = &$rule[Router::RULE_VARIABLES];
Expand Down
48 changes: 13 additions & 35 deletions Dispatcher.php → Source/Dispatcher.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* Hoa
*
Expand Down Expand Up @@ -45,23 +47,20 @@
* Class \Hoa\Dispatcher.
*
* Abstract dispatcher.
*
* @copyright Copyright © 2007-2017 Hoa community
* @license New BSD License
*/
abstract class Dispatcher implements Zformat\Parameterizable
{
/**
* Parameters.
*
* @var \Hoa\Zformat\Parameter
* @var Zformat\Parameter
*/
protected $_parameters = null;

/**
* Current view.
*
* @var \Hoa\View\Viewable
* @var ?View\Viewable
*/
protected $_currentView = null;

Expand All @@ -70,14 +69,12 @@ abstract class Dispatcher implements Zformat\Parameterizable
*
* @var string
*/
protected $_kit = 'Hoa\Dispatcher\Kit';
protected $_kit = Kit::class;



/**
* Build a new dispatcher.
*
* @param array $parameters Parameters.
*/
public function __construct(array $parameters = [])
{
Expand Down Expand Up @@ -108,23 +105,16 @@ public function __construct(array $parameters = [])

/**
* Get parameters.
*
* @return \Hoa\Zformat\Parameter
*/
public function getParameters()
public function getParameters(): Zformat\Parameter
{
return $this->_parameters;
}

/**
* Dispatch a router rule.
*
* @param \Hoa\Router $router Router.
* @param \Hoa\View\Viewable $view View.
* @return mixed
* @throws \Hoa\Controller\Exception
*/
public function dispatch(Router $router, View\Viewable $view = null)
public function dispatch(Router $router, ?View\Viewable $view = null)
{
$rule = $router->getTheRule();

Expand Down Expand Up @@ -155,27 +145,17 @@ public function dispatch(Router $router, View\Viewable $view = null)

/**
* Resolve the dispatch call.
*
* @param array $rule Rule.
* @param \Hoa\Router $router Router.
* @param \Hoa\View\Viewable $view View.
* @return mixed
* @throws \Hoa\Dispatcher\Exception
*/
abstract protected function resolve(
array $rule,
Router $router,
View\Viewable $view = null
array $rule,
Router $router,
?View\Viewable $view = null
);

/**
* Set kit's name.
*
* @param string $kit Kit's name.
* @return string
* @throws \Hoa\Dispatcher\Exception
*/
public function setKitName($kit)
public function setKitName(string $kit): string
{
$old = $this->_kit;
$this->_kit = $kit;
Expand All @@ -185,10 +165,8 @@ public function setKitName($kit)

/**
* Get kit's name.
*
* @return string
*/
public function getKitName()
public function getKitName(): string
{
return $this->_kit;
}
Expand All @@ -197,4 +175,4 @@ public function getKitName()
/**
* Flex entity.
*/
Consistency::flexEntity('Hoa\Dispatcher\Dispatcher');
Consistency::flexEntity(Dispatcher::class);
5 changes: 2 additions & 3 deletions Exception.php → Source/Exception.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* Hoa
*
Expand Down Expand Up @@ -42,9 +44,6 @@
* Class \Hoa\Dispatcher\Exception.
*
* Extending the \Hoa\Exception\Exception class.
*
* @copyright Copyright © 2007-2017 Hoa community
* @license New BSD License
*/
class Exception extends HoaException
{
Expand Down
23 changes: 8 additions & 15 deletions Kit.php → Source/Kit.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* Hoa
*
Expand Down Expand Up @@ -43,30 +45,27 @@
* Class \Hoa\Dispatcher\Kit.
*
* A structure, given to action, that holds some important data.
*
* @copyright Copyright © 2007-2017 Hoa community
* @license New BSD License
*/
class Kit
{
/**
* The router.
*
* @var \Hoa\Router
* @var Router
*/
public $router = null;

/**
* The dispatcher.
*
* @var \Hoa\Dispatcher
* @var Dispatcher
*/
public $dispatcher = null;

/**
* The view.
*
* @var \Hoa\View\Viewable
* @var ?View\Viewable
*/
public $view = null;

Expand All @@ -81,15 +80,11 @@ class Kit

/**
* Build a dispatcher kit.
*
* @param \Hoa\Router $router The router.
* @param \Hoa\Dispatcher $dispatcher The dispatcher.
* @param \Hoa\View\Viewable $view The view.
*/
public function __construct(
Router $router,
Dispatcher $dispatcher,
View\Viewable $view = null
Router $router,
Dispatcher $dispatcher,
?View\Viewable $view = null
) {
$this->router = $router;
$this->dispatcher = $dispatcher;
Expand All @@ -104,8 +99,6 @@ public function __construct(

/**
* This method is called just after the __construct() method.
*
* @return void
*/
public function construct()
{
Expand Down
5 changes: 2 additions & 3 deletions Test/Unit/ClassMethod.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* Hoa
*
Expand Down Expand Up @@ -44,9 +46,6 @@
* Class \Hoa\Dispatcher\Test\Unit\ClassMethod.
*
* Test suite of the class/method dispatcher.
*
* @copyright Copyright © 2007-2017 Hoa community
* @license New BSD License
*/
class ClassMethod extends Test\Unit\Suite
{
Expand Down
15 changes: 8 additions & 7 deletions Test/Unit/Dispatcher.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* Hoa
*
Expand Down Expand Up @@ -36,16 +38,15 @@

namespace Hoa\Dispatcher\Test\Unit;

use Hoa\Dispatcher as LUT;
use Hoa\Router;
use Hoa\Test;
use Hoa\Zformat;

/**
* Class \Hoa\Dispatcher\Test\Unit\Dispatcher.
*
* Test suite of the abstract dispatcher.
*
* @copyright Copyright © 2007-2017 Hoa community
* @license New BSD License
*/
class Dispatcher extends Test\Unit\Suite
{
Expand All @@ -56,7 +57,7 @@ public function case_getParameters()
->when($result = $dispatcher->getParameters())
->then
->object($result)
->isInstanceOf('Hoa\Zformat\Parameter');
->isInstanceOf(Zformat\Parameter::class);
}

public function case_kitname()
Expand All @@ -66,7 +67,7 @@ public function case_kitname()
->when($result = $dispatcher->setKitName('foo'))
->then
->string($result)
->isEqualTo('Hoa\Dispatcher\Kit')
->isEqualTo(LUT\Kit::class)

->when($result = $dispatcher->getKitName())
->string($result)
Expand Down Expand Up @@ -108,7 +109,7 @@ public function case_dispatch_already_routed()
->variable($routedView)
->isNull()
->object($routedParameters)
->isInstanceOf('Hoa\Zformat\Parameter')
->isInstanceOf(Zformat\Parameter::class)

->object($dispatcher->getParameters())
->isIdenticalTo($parameters)
Expand Down Expand Up @@ -161,7 +162,7 @@ public function case_dispatch_auto_route()
->variable($routedView)
->isNull()
->object($routedParameters)
->isInstanceOf('Hoa\Zformat\Parameter')
->isInstanceOf(Zformat\Parameter::class)

->object($dispatcher->getParameters())
->isIdenticalTo($parameters)
Expand Down
5 changes: 2 additions & 3 deletions Test/Unit/Kit.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* Hoa
*
Expand Down Expand Up @@ -43,9 +45,6 @@
* Class \Hoa\Dispatcher\Test\Unit\Kit.
*
* Test suite of the kit.
*
* @copyright Copyright © 2007-2017 Hoa community
* @license New BSD License
*/
class Kit extends Test\Unit\Suite
{
Expand Down
Loading