diff --git a/modules/cms/twig/ComponentNode.php b/modules/cms/twig/ComponentNode.php index ce18c2c39..a7c0c11c8 100644 --- a/modules/cms/twig/ComponentNode.php +++ b/modules/cms/twig/ComponentNode.php @@ -43,4 +43,4 @@ class ComponentNode extends Twig_Node $compiler->write("unset(\$context['__cms_component_params']);\n"); } -} \ No newline at end of file +} diff --git a/modules/cms/twig/ComponentTokenParser.php b/modules/cms/twig/ComponentTokenParser.php index f090b1516..8c2726ccd 100644 --- a/modules/cms/twig/ComponentTokenParser.php +++ b/modules/cms/twig/ComponentTokenParser.php @@ -49,7 +49,11 @@ class ComponentTokenParser extends Twig_TokenParser break; default: - throw new Twig_Error_Syntax(sprintf('Invalid syntax in the partial tag. Line %s', $lineno), $stream->getCurrent()->getLine(), $stream->getFilename()); + throw new Twig_Error_Syntax( + sprintf('Invalid syntax in the partial tag. Line %s', $lineno), + $stream->getCurrent()->getLine(), + $stream->getFilename() + ); break; } } @@ -66,4 +70,4 @@ class ComponentTokenParser extends Twig_TokenParser { return 'component'; } -} \ No newline at end of file +} diff --git a/modules/cms/twig/ContentNode.php b/modules/cms/twig/ContentNode.php index 33e01e179..b64a75a7b 100644 --- a/modules/cms/twig/ContentNode.php +++ b/modules/cms/twig/ContentNode.php @@ -31,4 +31,4 @@ class ContentNode extends Twig_Node ->write(");\n") ; } -} \ No newline at end of file +} diff --git a/modules/cms/twig/ContentTokenParser.php b/modules/cms/twig/ContentTokenParser.php index b675041df..ee9973f65 100644 --- a/modules/cms/twig/ContentTokenParser.php +++ b/modules/cms/twig/ContentTokenParser.php @@ -39,4 +39,4 @@ class ContentTokenParser extends Twig_TokenParser { return 'content'; } -} \ No newline at end of file +} diff --git a/modules/cms/twig/DebugExtension.php b/modules/cms/twig/DebugExtension.php index 9546fbd5b..bfe0dde5c 100644 --- a/modules/cms/twig/DebugExtension.php +++ b/modules/cms/twig/DebugExtension.php @@ -35,7 +35,15 @@ class DebugExtension extends Twig_Extension */ protected $commentMap = []; - protected $blockMethods = ['componentDetails', 'defineProperties', 'getPropertyOptions', 'offsetExists', 'offsetGet', 'offsetSet', 'offsetUnset']; + protected $blockMethods = [ + 'componentDetails', + 'defineProperties', + 'getPropertyOptions', + 'offsetExists', + 'offsetGet', + 'offsetSet', + 'offsetUnset' + ]; /** * Creates the extension instance. @@ -54,7 +62,11 @@ class DebugExtension extends Twig_Extension public function getFunctions() { return array( - new Twig_SimpleFunction('dump', [$this, 'runDump'], array('is_safe' => ['html'], 'needs_context' => true, 'needs_environment' => true)), + new Twig_SimpleFunction('dump', [$this, 'runDump'], array( + 'is_safe' => ['html'], + 'needs_context' => true, + 'needs_environment' => true + )), ); } @@ -84,8 +96,7 @@ class DebugExtension extends Twig_Extension } $result .= $this->dump($vars, static::PAGE_CAPTION); - } - else { + } else { $this->variablePrefix = false; for ($i = 2; $i < $count; $i++) { $var = func_get_arg($i); @@ -124,19 +135,21 @@ class DebugExtension extends Twig_Extension $info = []; if (!is_array($variables)) { - if ($variables instanceof Paginator) + if ($variables instanceof Paginator) { $variables = $this->paginatorToArray($variables); - elseif (is_object($variables)) + } elseif (is_object($variables)) { $variables = $this->objectToArray($variables); - else + } else { $variables = [$variables]; + } } $output = []; $output[] = ''; - if ($caption) + if ($caption) { $output[] = $this->makeTableHeader($caption); + } foreach ($variables as $key => $item) { $output[] = $this->makeTableRow($key, $item); @@ -185,15 +198,12 @@ class DebugExtension extends Twig_Extension { if ($this->variablePrefix === true) { $output = '{{ %s }}'; - } - elseif (is_array($this->variablePrefix)) { + } elseif (is_array($this->variablePrefix)) { $prefix = implode('.', $this->variablePrefix); $output = '{{ '.$prefix.'.%s }}'; - } - elseif ($this->variablePrefix) { + } elseif ($this->variablePrefix) { $output = '{{ '.$this->variablePrefix.'.%s }}'; - } - else { + } else { $output = '%s'; } @@ -228,8 +238,9 @@ class DebugExtension extends Twig_Extension protected function getType($variable) { $type = gettype($variable); - if ($type == 'string' && substr($variable, 0, 12) == '___METHOD___') + if ($type == 'string' && substr($variable, 0, 12) == '___METHOD___') { return 'method'; + } return $type; } @@ -244,17 +255,15 @@ class DebugExtension extends Twig_Extension $class = get_class($variable); $label = class_basename($variable); - if ($variable instanceof ComponentBase) + if ($variable instanceof ComponentBase) { $label = 'Component'; - - elseif ($variable instanceof Collection) + } elseif ($variable instanceof Collection) { $label = 'Collection('.$variable->count().')'; - - elseif ($variable instanceof Paginator) + } elseif ($variable instanceof Paginator) { $label = 'Paged Collection('.$variable->count().')'; - - elseif ($variable instanceof Model) + } elseif ($variable instanceof Model) { $label = 'Model'; + } return ''.$label.''; } @@ -268,17 +277,21 @@ class DebugExtension extends Twig_Extension { $type = $this->getType($variable); - if ($type == 'method') + if ($type == 'method') { return $this->evalMethodDesc($variable); + } - if (isset($this->commentMap[$key])) + if (isset($this->commentMap[$key])) { return $this->commentMap[$key]; + } - if ($type == 'array') + if ($type == 'array') { return $this->evalArrDesc($variable); + } - if ($type == 'object') + if ($type == 'object') { return $this->evalObjDesc($variable); + } return ''; } @@ -291,8 +304,9 @@ class DebugExtension extends Twig_Extension protected function evalMethodDesc($variable) { $parts = explode('|', $variable); - if (count($parts) < 2) + if (count($parts) < 2) { return null; + } $method = $parts[1]; return isset($this->commentMap[$method]) ? $this->commentMap[$method] : null; @@ -370,13 +384,25 @@ class DebugExtension extends Twig_Extension $methods = []; foreach ($info->getMethods() as $method) { - if (!$method->isPublic()) continue; // Only public - if ($method->class != $class) continue; // Only locals + if (!$method->isPublic()) { + continue; // Only public + } + if ($method->class != $class) { + continue; // Only locals + } $name = $method->getName(); - if (in_array($name, $this->blockMethods)) continue; // Blocked methods - if (preg_match('/^on[A-Z]{1}[\w+]*$/', $name)) continue; // AJAX methods - if (preg_match('/^get[A-Z]{1}[\w+]*Options$/', $name)) continue; // getSomethingOptions - if (substr($name, 0, 1) == '_') continue; // Magic/hidden method + if (in_array($name, $this->blockMethods)) { + continue; // Blocked methods + } + if (preg_match('/^on[A-Z]{1}[\w+]*$/', $name)) { + continue; // AJAX methods + } + if (preg_match('/^get[A-Z]{1}[\w+]*Options$/', $name)) { + continue; // getSomethingOptions + } + if (substr($name, 0, 1) == '_') { + continue; // Magic/hidden method + } $name .= '()'; $methods[$name] = '___METHOD___|'.$name; $this->commentMap[$name] = $this->evalDocBlock($method); @@ -384,8 +410,12 @@ class DebugExtension extends Twig_Extension $vars = []; foreach ($info->getProperties() as $property) { - if (!$property->isPublic()) continue; // Only public - if ($property->class != $class) continue; // Only locals + if (!$property->isPublic()) { + continue; // Only public + } + if ($property->class != $class) { + continue; // Only locals + } $name = $property->getName(); $vars[$name] = $object->{$name}; $this->commentMap[$name] = $this->evalDocBlock($property); @@ -426,8 +456,9 @@ class DebugExtension extends Twig_Extension ]; $type = gettype($variable); - if ($type == 'NULL') + if ($type == 'NULL') { $css['color'] = '#999'; + } return $this->arrayToCss($css); } @@ -484,5 +515,4 @@ class DebugExtension extends Twig_Extension return join('; ', $strings); } - } diff --git a/modules/cms/twig/DefaultNode.php b/modules/cms/twig/DefaultNode.php index 9c501b968..1578b5262 100644 --- a/modules/cms/twig/DefaultNode.php +++ b/modules/cms/twig/DefaultNode.php @@ -28,4 +28,4 @@ class DefaultNode extends Twig_Node ->write("echo '';\n") ; } -} \ No newline at end of file +} diff --git a/modules/cms/twig/DefaultTokenParser.php b/modules/cms/twig/DefaultTokenParser.php index 4fac9037d..9303f5fb0 100644 --- a/modules/cms/twig/DefaultTokenParser.php +++ b/modules/cms/twig/DefaultTokenParser.php @@ -41,4 +41,4 @@ class DefaultTokenParser extends Twig_TokenParser { return 'default'; } -} \ No newline at end of file +} diff --git a/modules/cms/twig/Extension.php b/modules/cms/twig/Extension.php index 3b78af578..66158ce41 100644 --- a/modules/cms/twig/Extension.php +++ b/modules/cms/twig/Extension.php @@ -151,8 +151,9 @@ class Extension extends Twig_Extension */ public function placeholderFunction($name, $default = null) { - if (($result = Block::get($name)) === null) + if (($result = Block::get($name)) === null) { return null; + } $result = str_replace('', trim($default), $result); return $result; @@ -199,8 +200,9 @@ class Extension extends Twig_Extension */ public function displayBlock($name, $default = null) { - if (($result = Block::placeholder($name)) === null) + if (($result = Block::placeholder($name)) === null) { return null; + } $result = str_replace('', trim($default), $result); return $result; @@ -213,4 +215,4 @@ class Extension extends Twig_Extension { Block::endBlock($append); } -} \ No newline at end of file +} diff --git a/modules/cms/twig/FlashNode.php b/modules/cms/twig/FlashNode.php index fc53f3319..fae4a48f1 100644 --- a/modules/cms/twig/FlashNode.php +++ b/modules/cms/twig/FlashNode.php @@ -43,8 +43,7 @@ class FlashNode extends Twig_Node ->outdent() ->write('}'.PHP_EOL) ; - } - else { + } else { $compiler ->addDebugInfo($this) ->write('$context["type"] = ') @@ -66,4 +65,4 @@ class FlashNode extends Twig_Node ->write('$context["message"] = $_message;') ; } -} \ No newline at end of file +} diff --git a/modules/cms/twig/FlashTokenParser.php b/modules/cms/twig/FlashTokenParser.php index a13b6f806..69faba566 100644 --- a/modules/cms/twig/FlashTokenParser.php +++ b/modules/cms/twig/FlashTokenParser.php @@ -27,8 +27,7 @@ class FlashTokenParser extends Twig_TokenParser if ($token = $stream->nextIf(Twig_Token::NAME_TYPE)) { $name = $token->getValue(); - } - else { + } else { $name = 'all'; } $stream->expect(Twig_Token::BLOCK_END_TYPE); @@ -53,4 +52,4 @@ class FlashTokenParser extends Twig_TokenParser { return 'flash'; } -} \ No newline at end of file +} diff --git a/modules/cms/twig/FrameworkNode.php b/modules/cms/twig/FrameworkNode.php index e07044f93..2ca246181 100644 --- a/modules/cms/twig/FrameworkNode.php +++ b/modules/cms/twig/FrameworkNode.php @@ -28,14 +28,17 @@ class FrameworkNode extends Twig_Node $compiler ->addDebugInfo($this) - ->write("echo ''.PHP_EOL;" . PHP_EOL) + ->write("echo ''.PHP_EOL;" . PHP_EOL) ; if ($includeExtras) { $compiler - ->write("echo ''.PHP_EOL;" . PHP_EOL) - ->write("echo ''.PHP_EOL;" . PHP_EOL) + ->write("echo ''.PHP_EOL;" . PHP_EOL) + ->write("echo ''.PHP_EOL;" . PHP_EOL) ; } } -} \ No newline at end of file +} diff --git a/modules/cms/twig/FrameworkTokenParser.php b/modules/cms/twig/FrameworkTokenParser.php index 56ef5b8f1..300f5320d 100644 --- a/modules/cms/twig/FrameworkTokenParser.php +++ b/modules/cms/twig/FrameworkTokenParser.php @@ -45,4 +45,4 @@ class FrameworkTokenParser extends Twig_TokenParser { return 'framework'; } -} \ No newline at end of file +} diff --git a/modules/cms/twig/Loader.php b/modules/cms/twig/Loader.php index 501d29e7f..243da96e4 100644 --- a/modules/cms/twig/Loader.php +++ b/modules/cms/twig/Loader.php @@ -39,4 +39,4 @@ class Loader implements Twig_LoaderInterface { return $this->obj->isLoadedFromCache(); } -} \ No newline at end of file +} diff --git a/modules/cms/twig/PageNode.php b/modules/cms/twig/PageNode.php index ba3dcaf1c..64338f120 100644 --- a/modules/cms/twig/PageNode.php +++ b/modules/cms/twig/PageNode.php @@ -28,4 +28,4 @@ class PageNode extends Twig_Node ->write("echo \$this->env->getExtension('CMS')->pageFunction();\n") ; } -} \ No newline at end of file +} diff --git a/modules/cms/twig/PageTokenParser.php b/modules/cms/twig/PageTokenParser.php index a43dfdf4c..72908dd84 100644 --- a/modules/cms/twig/PageTokenParser.php +++ b/modules/cms/twig/PageTokenParser.php @@ -34,4 +34,4 @@ class PageTokenParser extends Twig_TokenParser { return 'page'; } -} \ No newline at end of file +} diff --git a/modules/cms/twig/PartialNode.php b/modules/cms/twig/PartialNode.php index 297446e93..e2b779b4b 100644 --- a/modules/cms/twig/PartialNode.php +++ b/modules/cms/twig/PartialNode.php @@ -43,4 +43,4 @@ class PartialNode extends Twig_Node $compiler->write("unset(\$context['__cms_partial_params']);\n"); } -} \ No newline at end of file +} diff --git a/modules/cms/twig/PartialTokenParser.php b/modules/cms/twig/PartialTokenParser.php index 5c7d7e0fc..e1cebad2d 100644 --- a/modules/cms/twig/PartialTokenParser.php +++ b/modules/cms/twig/PartialTokenParser.php @@ -53,7 +53,11 @@ class PartialTokenParser extends Twig_TokenParser break; default: - throw new Twig_Error_Syntax(sprintf('Invalid syntax in the partial tag. Line %s', $lineno), $stream->getCurrent()->getLine(), $stream->getFilename()); + throw new Twig_Error_Syntax( + sprintf('Invalid syntax in the partial tag. Line %s', $lineno), + $stream->getCurrent()->getLine(), + $stream->getFilename() + ); break; } } @@ -70,4 +74,4 @@ class PartialTokenParser extends Twig_TokenParser { return 'partial'; } -} \ No newline at end of file +} diff --git a/modules/cms/twig/PlaceholderNode.php b/modules/cms/twig/PlaceholderNode.php index 6b25e4235..26c5c04f1 100644 --- a/modules/cms/twig/PlaceholderNode.php +++ b/modules/cms/twig/PlaceholderNode.php @@ -15,8 +15,9 @@ class PlaceholderNode extends Twig_Node public function __construct($name, $body, $lineno, $tag = 'placeholder') { $nodes = []; - if ($body) + if ($body) { $nodes['default'] = $body; + } parent::__construct($nodes, ['name'=>$name], $lineno, $tag); } @@ -62,4 +63,4 @@ class PlaceholderNode extends Twig_Node ->raw("'".$varId."'") ->raw("]);"); } -} \ No newline at end of file +} diff --git a/modules/cms/twig/PlaceholderTokenParser.php b/modules/cms/twig/PlaceholderTokenParser.php index c66502680..37eff2435 100644 --- a/modules/cms/twig/PlaceholderTokenParser.php +++ b/modules/cms/twig/PlaceholderTokenParser.php @@ -60,4 +60,4 @@ class PlaceholderTokenParser extends Twig_TokenParser { return 'placeholder'; } -} \ No newline at end of file +} diff --git a/modules/cms/twig/PutNode.php b/modules/cms/twig/PutNode.php index 30ad241b2..a48eb5365 100644 --- a/modules/cms/twig/PutNode.php +++ b/modules/cms/twig/PutNode.php @@ -40,6 +40,6 @@ class PutNode extends Twig_Node ->write("echo \$this->env->getExtension('CMS')->endBlock(") ->raw($isOverwrite ? 'false' : 'true') ->write(");\n") - ; + ; } -} \ No newline at end of file +} diff --git a/modules/cms/twig/PutTokenParser.php b/modules/cms/twig/PutTokenParser.php index 3fc39354d..63494fc32 100644 --- a/modules/cms/twig/PutTokenParser.php +++ b/modules/cms/twig/PutTokenParser.php @@ -63,4 +63,4 @@ class PutTokenParser extends Twig_TokenParser { return 'put'; } -} \ No newline at end of file +} diff --git a/modules/cms/twig/ScriptsNode.php b/modules/cms/twig/ScriptsNode.php index 6545d5ab3..b40104c24 100644 --- a/modules/cms/twig/ScriptsNode.php +++ b/modules/cms/twig/ScriptsNode.php @@ -29,4 +29,4 @@ class ScriptsNode extends Twig_Node ->write("echo \$this->env->getExtension('CMS')->displayBlock('scripts');\n") ; } -} \ No newline at end of file +} diff --git a/modules/cms/twig/ScriptsTokenParser.php b/modules/cms/twig/ScriptsTokenParser.php index a66088af6..d8c0a498b 100644 --- a/modules/cms/twig/ScriptsTokenParser.php +++ b/modules/cms/twig/ScriptsTokenParser.php @@ -38,4 +38,4 @@ class ScriptsTokenParser extends Twig_TokenParser { return 'scripts'; } -} \ No newline at end of file +} diff --git a/modules/cms/twig/StylesNode.php b/modules/cms/twig/StylesNode.php index 5dc26ed8f..3c38a2590 100644 --- a/modules/cms/twig/StylesNode.php +++ b/modules/cms/twig/StylesNode.php @@ -29,4 +29,4 @@ class StylesNode extends Twig_Node ->write("echo \$this->env->getExtension('CMS')->displayBlock('styles');\n") ; } -} \ No newline at end of file +} diff --git a/modules/cms/twig/StylesTokenParser.php b/modules/cms/twig/StylesTokenParser.php index 4a3a729e9..5946cdd5a 100644 --- a/modules/cms/twig/StylesTokenParser.php +++ b/modules/cms/twig/StylesTokenParser.php @@ -38,4 +38,4 @@ class StylesTokenParser extends Twig_TokenParser { return 'styles'; } -} \ No newline at end of file +}