Skip to content

Commit 2f42ca8

Browse files
NamelessCoderMarc Neuhaus
authored and
Marc Neuhaus
committed
[TASK] Fix code style issues suggested by Scrutinizer (TYPO3#205)
1 parent cbbe195 commit 2f42ca8

19 files changed

+186
-184
lines changed

examples/example_conditions.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
// Assigning View variables: we assign variables that will be used by the
1414
// expressions we build in this example. Refer to the names of these
1515
// variables to understand what goes on.
16-
$view->assign('vartrue', TRUE);
17-
$view->assign('varfalse', FALSE);
16+
$view->assign('vartrue', true);
17+
$view->assign('varfalse', false);
1818
$view->assign('vararray1', ['foo' => 'bar']);
1919
$view->assign('vararray2', ['bar' => 'foo']);
20-
$view->assign('checkTernary', TRUE);
20+
$view->assign('checkTernary', true);
2121
$view->assign('ternaryTrue', 'The ternary expression is TRUE');
2222
$view->assign('ternaryFalse', 'The ternary expression is FALSE');
2323

examples/example_customresolving.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717

1818
if (!defined('FLUID_CACHE_DIRECTORY')) {
19-
define('FLUID_CACHE_DIRECTORY', __DIR__ . '/cache/');
19+
define('FLUID_CACHE_DIRECTORY', __DIR__ . '/cache/');
2020
}
2121

2222
require __DIR__ . '/include/view_init.php';

examples/example_multiplepaths.php

+12-12
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,18 @@
2727
// Specifying this array can also be done as constructor argument for the
2828
// TemplatePaths class which can be passed to the View; see view_init.php.
2929
$view->getTemplatePaths()->fillFromConfigurationArray([
30-
\TYPO3Fluid\Fluid\View\TemplatePaths::CONFIG_TEMPLATEROOTPATHS => [
31-
__DIR__ . '/Resources/Private/Templates/',
32-
__DIR__ . '/ResourceOverrides/Private/Templates/',
33-
],
34-
\TYPO3Fluid\Fluid\View\TemplatePaths::CONFIG_LAYOUTROOTPATHS => [
35-
__DIR__ . '/Resources/Private/Layouts/',
36-
__DIR__ . '/ResourceOverrides/Private/Layouts/',
37-
],
38-
\TYPO3Fluid\Fluid\View\TemplatePaths::CONFIG_PARTIALROOTPATHS => [
39-
__DIR__ . '/Resources/Private/Partials/',
40-
__DIR__ . '/ResourceOverrides/Private/Partials/',
41-
]
30+
\TYPO3Fluid\Fluid\View\TemplatePaths::CONFIG_TEMPLATEROOTPATHS => [
31+
__DIR__ . '/Resources/Private/Templates/',
32+
__DIR__ . '/ResourceOverrides/Private/Templates/',
33+
],
34+
\TYPO3Fluid\Fluid\View\TemplatePaths::CONFIG_LAYOUTROOTPATHS => [
35+
__DIR__ . '/Resources/Private/Layouts/',
36+
__DIR__ . '/ResourceOverrides/Private/Layouts/',
37+
],
38+
\TYPO3Fluid\Fluid\View\TemplatePaths::CONFIG_PARTIALROOTPATHS => [
39+
__DIR__ . '/Resources/Private/Partials/',
40+
__DIR__ . '/ResourceOverrides/Private/Partials/',
41+
]
4242
]);
4343

4444
$view->assign('foobar', 'This is foobar');

examples/example_namespaceresolving.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010
*/
1111

1212
if (!defined('FLUID_CACHE_DIRECTORY')) {
13-
define('FLUID_CACHE_DIRECTORY', __DIR__ . '/cache/');
13+
define('FLUID_CACHE_DIRECTORY', __DIR__ . '/cache/');
1414
}
1515

1616
require __DIR__ . '/include/view_init.php';
1717
require_once __DIR__ . '/include/class_customviewhelper.php';
1818

1919
// We alias our only ViewHelper so we can access it using multiple names.
2020
if (!class_exists('TYPO3Fluid\\FluidExample\\ViewHelpers\\Nested\\CustomViewHelper')) {
21-
class_alias('TYPO3Fluid\\FluidExample\\ViewHelpers\\CustomViewHelper', 'TYPO3Fluid\\FluidExample\\ViewHelpers\\Nested\\CustomViewHelper');
21+
class_alias('TYPO3Fluid\\FluidExample\\ViewHelpers\\CustomViewHelper', 'TYPO3Fluid\\FluidExample\\ViewHelpers\\Nested\\CustomViewHelper');
2222
}
2323

2424
// Assigning the template path and filename to be rendered. Doing this overrides

examples/example_structures.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@
1515
$view->getTemplatePaths()->setTemplatePathAndFilename(__DIR__ . '/Resources/Private/Singles/Structures.html');
1616

1717
$view->assign('dynamicSection', 'Dynamic');
18-
$view->assign('notTrue', FALSE);
19-
$view->assign('notTrueEither', FALSE);
20-
$view->assign('butTrue', TRUE);
18+
$view->assign('notTrue', false);
19+
$view->assign('notTrueEither', false);
20+
$view->assign('butTrue', true);
2121
$view->assign('switchValue', 3);
2222
$view->assign('secondSwitchValue', 'b');
2323
$view->assign('array', ['one', 'two', 'three']);
2424
$view->assign('group', [
25-
['property' => 'one'],
26-
['property' => 'one'],
27-
['property' => 'two']
25+
['property' => 'one'],
26+
['property' => 'one'],
27+
['property' => 'two']
2828
]);
2929

3030
// Rendering the View: plain old rendering of single file, no bells and whistles.

examples/example_variables.php

+24-24
Original file line numberDiff line numberDiff line change
@@ -18,31 +18,31 @@
1818
// In this example we assign all our variables in one array. Alternative is
1919
// to repeatedly call $view->assign('name', 'value').
2020
$view->assignMultiple([
21-
// Casting types
22-
'types' => [
23-
'csv' => 'one,two',
24-
'aStringWithNumbers' => '132 a string',
25-
'anArray' => ['one', 'two'],
26-
'typeNameInteger' => 'integer'
27-
],
21+
// Casting types
22+
'types' => [
23+
'csv' => 'one,two',
24+
'aStringWithNumbers' => '132 a string',
25+
'anArray' => ['one', 'two'],
26+
'typeNameInteger' => 'integer'
27+
],
2828
'foobar' => 'string foo',
29-
// The variables we will use as dynamic part names:
30-
'dynamic1' => $dynamic1,
31-
'dynamic2' => $dynamic2,
32-
// Strings we will be accessing dynamically:
33-
'stringwith' . $dynamic1 . 'part' => 'String using $dynamic1',
34-
'stringwith' . $dynamic2 . 'part' => 'String using $dynamic2',
35-
// Arrays we will be accessing dynamically:
36-
'array' => [
37-
'fixed' => 'Fixed key in $array[fixed]',
38-
// A numerically indexed array which we will access directly.
39-
'numeric' => [
40-
'foo',
41-
'bar'
42-
],
43-
$dynamic1 => 'Dynamic key in $array[$dynamic1]',
44-
$dynamic2 => 'Dynamic key in $array[$dynamic2]',
45-
],
29+
// The variables we will use as dynamic part names:
30+
'dynamic1' => $dynamic1,
31+
'dynamic2' => $dynamic2,
32+
// Strings we will be accessing dynamically:
33+
'stringwith' . $dynamic1 . 'part' => 'String using $dynamic1',
34+
'stringwith' . $dynamic2 . 'part' => 'String using $dynamic2',
35+
// Arrays we will be accessing dynamically:
36+
'array' => [
37+
'fixed' => 'Fixed key in $array[fixed]',
38+
// A numerically indexed array which we will access directly.
39+
'numeric' => [
40+
'foo',
41+
'bar'
42+
],
43+
$dynamic1 => 'Dynamic key in $array[$dynamic1]',
44+
$dynamic2 => 'Dynamic key in $array[$dynamic2]',
45+
],
4646
'123numericprefix' => 'Numeric prefixed variable'
4747
]);
4848

examples/include/class_customvariableprovider.php

+34-32
Original file line numberDiff line numberDiff line change
@@ -16,39 +16,41 @@
1616
* state manipulation on variables. Used by
1717
* example_variableprovider.php.
1818
*/
19-
class CustomVariableProvider extends StandardVariableProvider implements VariableProviderInterface {
19+
class CustomVariableProvider extends StandardVariableProvider implements VariableProviderInterface
20+
{
2021

21-
/**
22-
* @var integer
23-
*/
24-
protected $incrementer = 0;
22+
/**
23+
* @var integer
24+
*/
25+
protected $incrementer = 0;
2526

26-
/**
27-
* Get a variable by dotted path expression, retrieving the
28-
* variable from nested arrays/objects one segment at a time.
29-
* If the second variable is passed, it is expected to contain
30-
* extraction method names (constants from VariableExtractor)
31-
* which indicate how each value is extracted.
32-
*
33-
* @param string $path
34-
* @return mixed
35-
*/
36-
public function getByPath($path, array $accessors = []) {
37-
if ($path === 'random') {
38-
return 'random' . sha1(rand(0, 999999999));
39-
} elseif ($path === 'incrementer') {
40-
return ++ $this->incrementer;
41-
} else {
42-
return parent::getByPath($path);
43-
}
44-
}
45-
46-
/**
47-
* @param string $identifier
48-
* @return boolean
49-
*/
50-
public function exists($identifier) {
51-
return ($identifier === 'incrementer' || $identifier === 'random' || parent::exists($identifier));
52-
}
27+
/**
28+
* Get a variable by dotted path expression, retrieving the
29+
* variable from nested arrays/objects one segment at a time.
30+
* If the second variable is passed, it is expected to contain
31+
* extraction method names (constants from VariableExtractor)
32+
* which indicate how each value is extracted.
33+
*
34+
* @param string $path
35+
* @return mixed
36+
*/
37+
public function getByPath($path, array $accessors = [])
38+
{
39+
if ($path === 'random') {
40+
return 'random' . sha1(rand(0, 999999999));
41+
} elseif ($path === 'incrementer') {
42+
return ++ $this->incrementer;
43+
} else {
44+
return parent::getByPath($path);
45+
}
46+
}
5347

48+
/**
49+
* @param string $identifier
50+
* @return boolean
51+
*/
52+
public function exists($identifier)
53+
{
54+
return ($identifier === 'incrementer' || $identifier === 'random' || parent::exists($identifier));
55+
}
5456
}

examples/include/class_customviewhelper.php

+32-30
Original file line numberDiff line numberDiff line change
@@ -21,34 +21,36 @@
2121
* value and makes it optional before delivering
2222
* the arguments definitions to Fluid.
2323
*/
24-
class CustomViewHelper extends AbstractViewHelper {
25-
26-
/**
27-
* @var boolean
28-
*/
29-
protected $escapeChildren = FALSE;
30-
31-
/**
32-
* @var boolean
33-
*/
34-
protected $escapeOutput = FALSE;
35-
36-
/**
37-
* @return void
38-
*/
39-
public function initializeArguments() {
40-
$this->registerArgument('page', 'string', 'An arbitrary page identifier', TRUE);
41-
}
42-
43-
/**
44-
* @return string
45-
*/
46-
public function render() {
47-
return 'The following is a dump of the "page"' . PHP_EOL .
48-
'Argument passed to CustomViewHelper:' . PHP_EOL .
49-
'---------------------------' . PHP_EOL .
50-
var_export($this->arguments['page'], TRUE) . PHP_EOL .
51-
'---------------------------';
52-
}
53-
24+
class CustomViewHelper extends AbstractViewHelper
25+
{
26+
27+
/**
28+
* @var boolean
29+
*/
30+
protected $escapeChildren = false;
31+
32+
/**
33+
* @var boolean
34+
*/
35+
protected $escapeOutput = false;
36+
37+
/**
38+
* @return void
39+
*/
40+
public function initializeArguments()
41+
{
42+
$this->registerArgument('page', 'string', 'An arbitrary page identifier', true);
43+
}
44+
45+
/**
46+
* @return string
47+
*/
48+
public function render()
49+
{
50+
return 'The following is a dump of the "page"' . PHP_EOL .
51+
'Argument passed to CustomViewHelper:' . PHP_EOL .
52+
'---------------------------' . PHP_EOL .
53+
var_export($this->arguments['page'], true) . PHP_EOL .
54+
'---------------------------';
55+
}
5456
}

examples/include/class_customviewhelperresolver.php

+40-38
Original file line numberDiff line numberDiff line change
@@ -18,44 +18,46 @@
1818
* changing a wide array of details about how a
1919
* template gets parsed.
2020
*/
21-
class CustomViewHelperResolver extends ViewHelperResolver {
21+
class CustomViewHelperResolver extends ViewHelperResolver
22+
{
2223

23-
/**
24-
* Returns the built-in set of ViewHelper classes with
25-
* one addition, `f:myLink` which is redirected to anoter
26-
* class.
27-
*
28-
* @param string $namespaceIdentifier
29-
* @param string $methodIdentifier
30-
* @return string
31-
*/
32-
public function resolveViewHelperClassName($namespaceIdentifier, $methodIdentifier) {
33-
if ($namespaceIdentifier === 'f' && $methodIdentifier === 'myLink') {
34-
return 'TYPO3Fluid\\FluidExample\\ViewHelpers\\CustomViewHelper';
35-
}
36-
return parent::resolveViewHelperClassName($namespaceIdentifier, $methodIdentifier);
37-
}
38-
39-
/**
40-
* Asks the ViewHelper for argument definitions and adds
41-
* a case which matches our custom ViewHelper in order to
42-
* manipulate its argument definitions.
43-
*
44-
* @param ViewHelperInterface $viewHelper
45-
* @return ArgumentDefinition[]
46-
*/
47-
public function getArgumentDefinitionsForViewHelper(ViewHelperInterface $viewHelper) {
48-
$arguments = parent::getArgumentDefinitionsForViewHelper($viewHelper);
49-
if ($viewHelper instanceof CustomViewHelper) {
50-
$arguments['page'] = new ArgumentDefinition(
51-
'page',
52-
'array', // our argument must now be an array
53-
'This is our new description for the argument',
54-
FALSE, // argument is no longer mandatory
55-
['foo' => 'bar'] // our argument has a new default value if argument is not provided
56-
);
57-
}
58-
return $arguments;
59-
}
24+
/**
25+
* Returns the built-in set of ViewHelper classes with
26+
* one addition, `f:myLink` which is redirected to anoter
27+
* class.
28+
*
29+
* @param string $namespaceIdentifier
30+
* @param string $methodIdentifier
31+
* @return string
32+
*/
33+
public function resolveViewHelperClassName($namespaceIdentifier, $methodIdentifier)
34+
{
35+
if ($namespaceIdentifier === 'f' && $methodIdentifier === 'myLink') {
36+
return 'TYPO3Fluid\\FluidExample\\ViewHelpers\\CustomViewHelper';
37+
}
38+
return parent::resolveViewHelperClassName($namespaceIdentifier, $methodIdentifier);
39+
}
6040

41+
/**
42+
* Asks the ViewHelper for argument definitions and adds
43+
* a case which matches our custom ViewHelper in order to
44+
* manipulate its argument definitions.
45+
*
46+
* @param ViewHelperInterface $viewHelper
47+
* @return ArgumentDefinition[]
48+
*/
49+
public function getArgumentDefinitionsForViewHelper(ViewHelperInterface $viewHelper)
50+
{
51+
$arguments = parent::getArgumentDefinitionsForViewHelper($viewHelper);
52+
if ($viewHelper instanceof CustomViewHelper) {
53+
$arguments['page'] = new ArgumentDefinition(
54+
'page',
55+
'array', // our argument must now be an array
56+
'This is our new description for the argument',
57+
false, // argument is no longer mandatory
58+
['foo' => 'bar'] // our argument has a new default value if argument is not provided
59+
);
60+
}
61+
return $arguments;
62+
}
6163
}

0 commit comments

Comments
 (0)