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

Update and fix coding guidelines #435

Merged
merged 1 commit into from
Mar 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
/Tests/ export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.php_cs export-ignore
/.php_cs.dist export-ignore
/.travis.yml export-ignore
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
/ext_emconf.php
/ext_icon.png
/ext_localconf.php
/.php_cs.cache
52 changes: 0 additions & 52 deletions .php_cs

This file was deleted.

79 changes: 79 additions & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?php
return PhpCsFixer\Config::create()
->setRiskyAllowed(true)
->setRules([
'@PSR2' => true,
'array_syntax' => [
'syntax' => 'short',
],
'binary_operator_spaces' => true,
'concat_space' => [
'spacing' => 'one',
],
'function_typehint_space' => true,
'hash_to_slash_comment' => true,
'linebreak_after_opening_tag' => true,
'lowercase_cast' => true,
'method_separation' => true,
'native_function_casing' => true,
'new_with_braces' => true,
'no_alias_functions' => true,
'no_blank_lines_after_class_opening' => true,
'no_blank_lines_after_phpdoc' => true,
'no_blank_lines_before_namespace' => true,
'no_empty_comment' => true,
'no_empty_phpdoc' => true,
'no_empty_statement' => true,
'no_extra_consecutive_blank_lines' => [
'continue',
'curly_brace_block',
'extra',
'parenthesis_brace_block',
'square_brace_block',
'throw',
],
'no_leading_import_slash' => true,
'no_leading_namespace_whitespace' => true,
'no_multiline_whitespace_around_double_arrow' => true,
'no_multiline_whitespace_before_semicolons' => true,
'no_short_bool_cast' => true,
'no_singleline_whitespace_before_semicolons' => true,
'no_trailing_comma_in_list_call' => true,
'no_trailing_comma_in_singleline_array' => true,
'no_unneeded_control_parentheses' => [
'break',
'clone',
'continue',
'echo_print',
'return',
'switch_case',
],
'no_unreachable_default_argument_value' => true,
'no_unused_imports' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'no_whitespace_before_comma_in_array' => true,
'no_whitespace_in_blank_line' => true,
'normalize_index_brace' => true,
'ordered_imports' => true,
'phpdoc_add_missing_param_annotation' => true,
'phpdoc_no_package' => true,
'phpdoc_order' => true,
'phpdoc_scalar' => true,
'phpdoc_types' => true,
'self_accessor' => true,
'short_scalar_cast' => true,
'single_quote' => true,
'standardize_not_equals' => true,
'ternary_operator_spaces' => true,
'trailing_comma_in_multiline_array' => true,
'whitespace_after_comma_in_array' => true,
])
->setFinder(
PhpCsFixer\Finder::create()
->in(__DIR__)
->exclude('.Build')
->exclude('Documentation')
->exclude('Libraries')
->notName('ext_emconf.php')
);
74 changes: 49 additions & 25 deletions .styleci.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,59 @@
preset: psr2

enabled:
- no_leading_import_slash
- no_trailing_comma_in_singleline_array
- no_singleline_whitespace_before_semicolons
- no_unused_imports
- concat_with_spaces
- no_whitespace_in_blank_line
- ordered_imports
- single_quote
- no_extra_consecutive_blank_lines
- phpdoc_no_package
- phpdoc_scalar
- no_blank_lines_after_phpdoc
- short_array_syntax
- whitespace_after_comma_in_array
- function_typehint_space
- hash_to_slash_comment
- no_alias_functions
- lowercase_cast
- no_leading_namespace_whitespace
- native_function_casing
- no_empty_statement
- self_accessor
- no_short_bool_cast
- no_unneeded_control_parentheses
- alpha_ordered_imports
- binary_operator_spaces
- concat_with_spaces
- function_typehint_space
- hash_to_slash_comment
- linebreak_after_opening_tag
- lowercase_cast
- method_separation
- native_function_casing
- new_with_braces
- no_alias_functions
- no_blank_lines_after_class_opening
- no_blank_lines_after_phpdoc
- no_blank_lines_before_namespace
- no_empty_comment
- no_empty_phpdoc
- no_empty_statement
- no_extra_block_blank_lines
- no_extra_consecutive_blank_lines
- no_leading_import_slash
- no_leading_namespace_whitespace
- no_multiline_whitespace_around_double_arrow
- no_multiline_whitespace_before_semicolons
- no_short_bool_cast
- no_singleline_whitespace_before_semicolons
- no_trailing_comma_in_list_call
- no_trailing_comma_in_singleline_array
- no_unneeded_control_parentheses
- no_unreachable_default_argument_value
- no_unused_imports
- no_useless_else
- no_useless_return
- no_whitespace_before_comma_in_array
- no_whitespace_in_blank_line
- normalize_index_brace
- phpdoc_add_missing_param_annotation
- phpdoc_no_package
- phpdoc_order
- phpdoc_scalar
- phpdoc_types
- self_accessor
- short_array_syntax
- short_scalar_cast
- single_quote
- standardize_not_equals
- ternary_operator_spaces
- trailing_comma_in_multiline_array
- whitespace_after_comma_in_array

finder:
name:
- "*.php"
not-path:
exclude:
- ".Build"
- "Documentation"
- "Libraries"
2 changes: 1 addition & 1 deletion Classes/Command/BackendCommandController.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function unlockCommand()
public function lockForEditorsCommand()
{
$this->ensureConfigValueModifiable();
$lockedForEditors = $this->configurationService->getLocal('BE/adminOnly') !== self::LOCK_TYPE_UNLOCKED;
$lockedForEditors = $this->configurationService->getLocal('BE/adminOnly') !== self::LOCK_TYPE_UNLOCKED;
if (!$lockedForEditors) {
$this->configurationService->setLocal('BE/adminOnly', self::LOCK_TYPE_ADMIN);
$this->outputLine('<info>Locked backend for editor access!</info>');
Expand Down
2 changes: 1 addition & 1 deletion Classes/Command/DatabaseCommandController.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function updateSchemaCommand(array $schemaUpdateTypes = ['safe'], $verbos
'<info>No schema updates %s performed for update type%s:%s</info>',
[$dryRun ? 'must be' : 'were',
count($expandedSchemaUpdateTypes) > 1 ? 's' : '',
PHP_EOL . implode('", "', $expandedSchemaUpdateTypes)]
PHP_EOL . implode('", "', $expandedSchemaUpdateTypes), ]
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions Classes/Command/InstallCommandController.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,14 @@ public function generatePackageStatesCommand(array $frameworkExtensions = [], $a
[
implode(', ', array_map(function (PackageInterface $package) {
return $package->getPackageKey();
}, $activatedExtensions))
}, $activatedExtensions)),
]
);
if (!empty($excludedExtensions)) {
$this->outputLine(
'<info>The following third party extensions were excluded during this process:</info> %s',
[
implode(', ', $excludedExtensions)
implode(', ', $excludedExtensions),
]
);
}
Expand Down
2 changes: 1 addition & 1 deletion Classes/Composer/InstallerScript/GeneratePackageStates.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ public function shouldRun(ScriptEvent $event)

/**
* @param ScriptEvent $event
* @return bool
* @throws \RuntimeException
* @return bool
* @internal
*/
public function run(ScriptEvent $event)
Expand Down
2 changes: 1 addition & 1 deletion Classes/Composer/InstallerScript/InstallDummyExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public function shouldRun(ScriptEvent $event)

/**
* @param ScriptEvent $event
* @return bool
* @throws \RuntimeException
* @return bool
* @internal
*/
public function run(ScriptEvent $event)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public function shouldRun(ScriptEvent $event)
* Called from Composer
*
* @param ScriptEvent $event
* @return bool
* @throws \RuntimeException
* @return bool
* @internal
*/
public function run(ScriptEvent $event)
Expand Down
2 changes: 1 addition & 1 deletion Classes/Composer/InstallerScriptInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public function shouldRun(ScriptEvent $event);
* This is executed, when shouldRun returned true
*
* @param ScriptEvent $event
* @return bool Return false if the script failed
* @throws \RuntimeException
* @return bool Return false if the script failed
*/
public function run(ScriptEvent $event);
}
2 changes: 1 addition & 1 deletion Classes/Composer/InstallerScripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ class InstallerScripts
* Called from Composer
*
* @param ScriptEvent $event
* @return void
* @throws \RuntimeException
* @return void
* @internal
*/
public static function setupConsole(ScriptEvent $event)
Expand Down
5 changes: 2 additions & 3 deletions Classes/Core/Booting/RunLevel.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,16 @@ public function buildSequenceForCommand($commandIdentifier)
* Builds the sequence for the given run level
*
* @param string $runLevel
* @return Sequence
* @throws \InvalidArgumentException
* @return Sequence
* @internal
*/
public function buildSequence($runLevel)
{
if (is_callable([$this, $runLevel])) {
return $this->{$runLevel}($runLevel);
} else {
throw new \InvalidArgumentException('Invalid run level "' . $runLevel . '"', 1402075492);
}
throw new \InvalidArgumentException('Invalid run level "' . $runLevel . '"', 1402075492);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Classes/Core/Booting/Scripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ protected static function loadCommandLineBackendUser()
'be_users',
[
'username' => $userName,
'password' => GeneralUtility::getRandomHexString(48)
'password' => GeneralUtility::getRandomHexString(48),
]
);
$backendUser->setBeUserByName($userName);
Expand Down
2 changes: 1 addition & 1 deletion Classes/Core/Booting/Sequence.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ public function addStep(Step $step, $previousStepIdentifier = 'start')
* Removes all occurrences of the specified step from this sequence
*
* @param string $stepIdentifier
* @return void
* @throws \Exception
* @return void
*/
public function removeStep($stepIdentifier)
{
Expand Down
2 changes: 1 addition & 1 deletion Classes/Core/Booting/Step.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Step
protected $identifier;

/**
* @var Callable
* @var callable
*/
protected $callback;

Expand Down
4 changes: 2 additions & 2 deletions Classes/Core/ConsoleBootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ public function registerRequestHandler(RequestHandlerInterface $requestHandler)
/**
* Iterates over the registered request handlers and determines which one fits best.
*
* @return RequestHandlerInterface A request handler
* @throws \RuntimeException
* @return RequestHandlerInterface A request handler
*/
public function resolveCliRequestHandler()
{
Expand Down Expand Up @@ -347,7 +347,7 @@ public function disableCoreCaches()
$cacheConfigurations = &$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'];
$cacheConfigurations['dbal'] = [
'backend' => \TYPO3\CMS\Core\Cache\Backend\TransientMemoryBackend::class,
'groups' => []
'groups' => [],
];
}
}
Expand Down
7 changes: 3 additions & 4 deletions Classes/Database/Process/MysqlCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,10 @@ public function mysql(array $additionalArguments = [], $inputStream = STDIN, $ou
// I did not figure out how to change pipes with symfony/process
$interactiveProcess = new InteractiveProcess();
return $interactiveProcess->run($this->processBuilder->getProcess()->getCommandLine());
} else {
$process = $this->processBuilder->getProcess();
$process->setInput($inputStream);
return $process->run($this->buildDefaultOutputCallback($outputCallback));
}
$process = $this->processBuilder->getProcess();
$process->setInput($inputStream);
return $process->run($this->buildDefaultOutputCallback($outputCallback));
}

/**
Expand Down