Skip to content

Commit

Permalink
Merge pull request #2 from smichaelsen/task/php-cs-fixer
Browse files Browse the repository at this point in the history
[TASK] Use php-cs-fixer for enforcing PHP coding styles
  • Loading branch information
Sebastian Michaelsen authored Aug 29, 2018
2 parents 7d706cf + 1357dfd commit 651c596
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 92 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
vendor/
/.php_cs.cache
/composer.lock
/vendor/
75 changes: 75 additions & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?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__ . '/Classes')
);
10 changes: 4 additions & 6 deletions Classes/TcaUtility.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<?php
declare(strict_types=1);

namespace Smichaelsen\MelonImages;

class TcaUtility
{

/**
* Example:
* $cropVariants = [
Expand All @@ -20,12 +18,12 @@ class TcaUtility
* 'height' => 0.8,
* ],
* ],
* 'resolutions' => [
* 'aspectRatios' => [
* '978x450',
* ],
* ],
* 'mobile' => [ // breakpoint name as defined in TypoScript
* 'resolutions' => [
* 'aspectRatios' => [
* '356x338',
* ],
* ],
Expand All @@ -41,11 +39,11 @@ public static function writeCropVariantsConfigurationToTca(array $cropVariants,
foreach ($cropVariants as $type => $fields) {
foreach ($fields as $fieldName => $sizes) {
if ($type === '__default') {
$fieldConfig =&
$fieldConfig = &
$GLOBALS['TCA'][$table]['columns'][$fieldName]
['config']['overrideChildTca']['columns']['crop']['config'];
} else {
$fieldConfig =&
$fieldConfig = &
$GLOBALS['TCA'][$table]['types'][$type]['columnsOverrides'][$fieldName]
['config']['overrideChildTca']['columns']['crop']['config'];
}
Expand Down
8 changes: 3 additions & 5 deletions Classes/ViewHelpers/ResponsivePictureViewHelper.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php
declare(strict_types=1);

namespace Smichaelsen\MelonImages\ViewHelpers;

use Smichaelsen\MelonImages\BreakpointNotAvailableException;
Expand All @@ -16,7 +15,6 @@

class ResponsivePictureViewHelper extends AbstractTagBasedViewHelper
{

protected $tagName = 'picture';

/**
Expand Down Expand Up @@ -70,9 +68,9 @@ public function render(): string
$srcset[] = $imageUri . ' ' . $dpiBreakpoint . 'x';
}
if (!empty($breakpoint)) {
$sourceMarkups[] = '<source srcset="' . join(', ', $srcset) . '" media="' . $breakpoint . '">';
$sourceMarkups[] = '<source srcset="' . implode(', ', $srcset) . '" media="' . $breakpoint . '">';
} else {
$sourceMarkups[] = '<source srcset="' . join(', ', $srcset) . '">';
$sourceMarkups[] = '<source srcset="' . implode(', ', $srcset) . '">';
}
}
// the last available breakpoint will be used for the fallback image
Expand All @@ -91,7 +89,7 @@ public function render(): string
);
}

$this->tag->setContent(join("\n", $sourceMarkups));
$this->tag->setContent(implode("\n", $sourceMarkups));
return $this->tag->render();
}

Expand Down
22 changes: 11 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "smichaelsen/melon-images",
"description": "Responsive Images Management for TYPO3 8.7",
"license": "GPL-3.0",
"autoload": {
"psr-4": {
"Smichaelsen\\MelonImages\\": "Classes/"
}
},
"require-dev": {
"squizlabs/php_codesniffer": "*"
}
"name": "smichaelsen/melon-images",
"description": "Responsive Images Management for TYPO3 8.7",
"license": "GPL-3.0",
"autoload": {
"psr-4": {
"Smichaelsen\\MelonImages\\": "Classes/"
}
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.12"
}
}
69 changes: 0 additions & 69 deletions composer.lock

This file was deleted.

0 comments on commit 651c596

Please sign in to comment.