Skip to content

Commit

Permalink
Remove from/import and update to PHP5.4.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hywan committed Oct 5, 2014
1 parent 8292482 commit 05ffe66
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 78 deletions.
51 changes: 18 additions & 33 deletions Basic.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,10 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

namespace {
namespace Hoa\Dispatcher;

from('Hoa')

/**
* \Hoa\Dispatcher\Exception
*/
-> import('Dispatcher.Exception')

/**
* \Hoa\Dispatcher
*/
-> import('Dispatcher.~');

}

namespace Hoa\Dispatcher {
use Hoa\Router;
use Hoa\View;

/**
* Class \Hoa\Dispatcher\Basic.
Expand All @@ -75,23 +62,23 @@ class Basic extends Dispatcher {
* @return mixed
* @throw \Hoa\Dispatcher\Exception
*/
protected function resolve ( Array $rule, \Hoa\Router $router,
\Hoa\View\Viewable $view = null ) {
protected function resolve ( Array $rule, Router $router,
View\Viewable $view = null ) {

$called = null;
$variables = &$rule[\Hoa\Router::RULE_VARIABLES];
$variables = &$rule[Router::RULE_VARIABLES];
$call = isset($variables['controller'])
? $variables['controller']
: (isset($variables['_call'])
? $variables['_call']
: $rule[\Hoa\Router::RULE_CALL]);
: $rule[Router::RULE_CALL]);
$able = isset($variables['action'])
? $variables['action']
: (isset($variables['_able'])
? $variables['_able']
: $rule[\Hoa\Router::RULE_ABLE]);
$rtv = array($router, $this, $view);
$arguments = array();
: $rule[Router::RULE_ABLE]);
$rtv = [$router, $this, $view];
$arguments = [];
$reflection = null;

if($call instanceof \Closure) {
Expand Down Expand Up @@ -128,7 +115,7 @@ protected function resolve ( Array $rule, \Hoa\Router $router,
'The closured action for the rule with pattern %s needs ' .
'a value for the parameter $%s and this value does not ' .
'exist.',
1, array($rule[\Hoa\Router::RULE_PATTERN], $name));
1, [$rule[Router::RULE_PATTERN], $name]);
}
}
elseif(is_string($call) && null === $able) {
Expand Down Expand Up @@ -164,7 +151,7 @@ protected function resolve ( Array $rule, \Hoa\Router $router,
'The functional action for the rule with pattern %s needs ' .
'a value for the parameter $%s and this value does not ' .
'exist.',
3, array($rule[\Hoa\Router::RULE_PATTERN], $name));
3, [$rule[Router::RULE_PATTERN], $name]);
}
}
else {
Expand Down Expand Up @@ -201,8 +188,8 @@ protected function resolve ( Array $rule, \Hoa\Router $router,
throw new Exception(
'Controller %s is not found ' .
'(method: %s, asynchronous: %s).',
4, array($controller, strtoupper($router->getMethod()),
true === $async ? 'true': 'false'), $e);
4, [$controller, strtoupper($router->getMethod()),
true === $async ? 'true': 'false'], $e);
}

$kitname = $this->getKitName();
Expand All @@ -218,9 +205,9 @@ protected function resolve ( Array $rule, \Hoa\Router $router,
throw new Exception(
'Action %s does not exist on the controller %s ' .
'(method: %s, asynchronous: %s).',
5, array($action, get_class($controller),
strtoupper($router->getMethod()),
true === $async ? 'true': 'false'));
5, [$action, get_class($controller),
strtoupper($router->getMethod()),
true === $async ? 'true': 'false']);

$called = $controller;
$reflection = new \ReflectionMethod($controller, $action);
Expand All @@ -239,7 +226,7 @@ protected function resolve ( Array $rule, \Hoa\Router $router,
throw new Exception(
'The action %s on the controller %s needs a value for ' .
'the parameter $%s and this value does not exist.',
6, array($action, get_class($controller), $name));
6, [$action, get_class($controller), $name]);
}
}

Expand All @@ -251,5 +238,3 @@ protected function resolve ( Array $rule, \Hoa\Router $router,
return $return;
}
}

}
52 changes: 17 additions & 35 deletions Dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,11 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

namespace {
namespace Hoa\Dispatcher;

from('Hoa')

/**
* \Hoa\Dispatcher\Exception
*/
-> import('Dispatcher.Exception')

/**
* \Hoa\Router
*/
-> import('Router.~');

}

namespace Hoa\Dispatcher {
use Hoa\Core;
use Hoa\Router;
use Hoa\View;

/**
* Class \Hoa\Dispatcher.
Expand All @@ -62,7 +50,7 @@
* @license New BSD License
*/

abstract class Dispatcher implements \Hoa\Core\Parameter\Parameterizable {
abstract class Dispatcher implements Core\Parameter\Parameterizable {

/**
* Parameters.
Expand Down Expand Up @@ -94,16 +82,16 @@ abstract class Dispatcher implements \Hoa\Core\Parameter\Parameterizable {
* @param array $parameters Parameters.
* @return void
*/
public function __construct ( Array $parameters = array() ) {
public function __construct ( Array $parameters = [] ) {

$this->_parameters = new \Hoa\Core\Parameter(
$this->_parameters = new Core\Parameter(
__CLASS__,
array(
[
'controller' => 'main',
'action' => 'main',
'method' => null
),
array(
],
[
'synchronous.controller' => 'Application\Controller\(:controller:U:)',
'synchronous.action' => '(:action:U:)Action',

Expand All @@ -115,7 +103,7 @@ public function __construct ( Array $parameters = array() ) {
*
* 'variables.…' => …
*/
)
]
);
$this->_parameters->setParameters($parameters);

Expand All @@ -142,8 +130,8 @@ public function getParameters ( ) {
* @return mixed
* @throw \Hoa\Controller\Exception
*/
public function dispatch ( \Hoa\Router $router,
\Hoa\View\Viewable $view = null ) {
public function dispatch ( Router $router,
View\Viewable $view = null ) {

$rule = $router->getTheRule();

Expand All @@ -161,7 +149,7 @@ public function dispatch ( \Hoa\Router $router,
$parameters = $this->_parameters;
$this->_parameters = clone $this->_parameters;

foreach($rule[\Hoa\Router::RULE_VARIABLES] as $key => $value)
foreach($rule[Router::RULE_VARIABLES] as $key => $value)
$this->_parameters->setParameter('variables.' . $key, $value);

$this->_parameters->setKeyword('method', $router->getMethod());
Expand All @@ -183,8 +171,8 @@ public function dispatch ( \Hoa\Router $router,
* @return mixed
* @throw \Hoa\Dispatcher\Exception
*/
abstract protected function resolve ( Array $rule, \Hoa\Router $router,
\Hoa\View\Viewable $view = null );
abstract protected function resolve ( Array $rule, Router $router,
View\Viewable $view = null );

/**
* Set kit's name.
Expand Down Expand Up @@ -214,13 +202,7 @@ public function getKitName ( ) {
}
}

}

namespace {

/**
* Flex entity.
*/
Hoa\Core\Consistency::flexEntity('Hoa\Dispatcher\Dispatcher');

}
Core\Consistency::flexEntity('Hoa\Dispatcher\Dispatcher');
8 changes: 4 additions & 4 deletions Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

namespace Hoa\Dispatcher {
namespace Hoa\Dispatcher;

use Hoa\Core;

/**
* Class \Hoa\Dispatcher\Exception.
Expand All @@ -46,6 +48,4 @@
* @license New BSD License
*/

class Exception extends \Hoa\Core\Exception { }

}
class Exception extends Core\Exception { }
13 changes: 7 additions & 6 deletions Kit.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

namespace Hoa\Dispatcher {
namespace Hoa\Dispatcher;

use Hoa\Router;
use Hoa\View;

/**
* Class \Hoa\Dispatcher\Kit.
Expand Down Expand Up @@ -87,9 +90,9 @@ class Kit {
* @param \Hoa\View\Viewable $view The view.
* @return void
*/
public function __construct ( \Hoa\Router $router,
Dispatcher $dispatcher,
\Hoa\View\Viewable $view = null ) {
public function __construct ( Router $router,
Dispatcher $dispatcher,
View\Viewable $view = null ) {

$this->router = $router;
$this->dispatcher = $dispatcher;
Expand All @@ -112,5 +115,3 @@ public function construct ( ) {
return;
}
}

}

0 comments on commit 05ffe66

Please sign in to comment.