Code style fixes.

This commit is contained in:
Dmitry Khomutov 2017-12-05 20:57:53 +07:00
commit e59e4a397f
No known key found for this signature in database
GPG key ID: EC19426474B37AAC
10 changed files with 59 additions and 43 deletions

View file

@ -188,7 +188,6 @@ class Config
} elseif (is_array($source[$target_key]) && is_array($target_value)) {
// Both are arrays, deep merge them
self::deepMerge($source[$target_key], $target_value);
} elseif (is_array($source[$target_key])) {
// Source is the array, push target value
$source[$target_key][] = $target_value;

View file

@ -2,7 +2,8 @@
namespace b8\Http;
use b8\Application, b8\Config;
use b8\Application;
use b8\Config;
class Router
{

View file

@ -7,6 +7,7 @@ use b8\View;
class Template extends View
{
public static $templateFunctions = [];
protected static $extension = 'html';
public function __construct($viewCode)
@ -222,10 +223,19 @@ class Template extends View
{
$matches = [];
if (preg_match('/([a-zA-Z0-9_\-\(\):\s.\"]+)\s+?([\!\=\<\>]+)?\s+?([a-zA-Z0-9\(\)_\-:\s.\"]+)?/', $condition,
$matches)) {
$left = is_numeric($matches[1]) ? intval($matches[1]) : $this->processVariableName($matches[1]);
$right = is_numeric($matches[3]) ? intval($matches[3]) : $this->processVariableName($matches[3]);
if (preg_match(
'/([a-zA-Z0-9_\-\(\):\s.\"]+)\s+?([\!\=\<\>]+)?\s+?([a-zA-Z0-9\(\)_\-:\s.\"]+)?/',
$condition,
$matches
)) {
$left = is_numeric($matches[1])
? intval($matches[1])
: $this->processVariableName($matches[1]);
$right = is_numeric($matches[3])
? intval($matches[3])
: $this->processVariableName($matches[3]);
$operator = $matches[2];
switch ($operator) {
@ -374,7 +384,6 @@ class Template extends View
{
// Case one - Test for function calls:
if (substr($varName, 0, 1) == '(' && substr($varName, -1) == ')') {
$functionCall = substr($varName, 1, -1);
$parts = explode(' ', $functionCall, 2);
$functionName = $parts[0];
@ -469,7 +478,8 @@ class Template extends View
{
if (array_key_exists($function, self::$templateFunctions)) {
$handler = self::$templateFunctions[$function];
$args = $this->processFunctionArguments($args);
$args = $this->processFunctionArguments($args);
return $handler($args, $this);
}
@ -478,15 +488,13 @@ class Template extends View
protected function processFunctionArguments($args)
{
$rtn = [];
$rtn = [];
$args = explode(';', $args);
foreach ($args as $arg) {
$arg = explode(':', $arg);
if (count($arg) == 2) {
$key = trim($arg[0]);
$val = trim($arg[1]);
@ -516,7 +524,6 @@ class Template extends View
}
foreach ($args['variables'] as $variable) {
$variable = explode('=>', $variable);
$variable = array_map('trim', $variable);
@ -533,7 +540,7 @@ class Template extends View
protected function callHelperFunction($args)
{
$helper = $args['helper'];
$helper = $args['helper'];
$function = $args['method'];
return $this->{$helper}()->{$function}();