Skip to content

Commit

Permalink
Fix CS errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Aug 23, 2020
1 parent 83e90fc commit b15aed6
Show file tree
Hide file tree
Showing 21 changed files with 845 additions and 838 deletions.
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,11 @@ before_script:

- composer update --no-interaction

- if [[ $PHPCS = 1 ]]; then composer require cakephp/cakephp-codesniffer:^3.0; fi

script:
- if [[ $DEFAULT = 1 ]]; then vendor/bin/phpunit; fi
- if [[ $COVERAGE = 1 ]]; then vendor/bin/phpunit --coverage-clover=clover.xml; fi

- if [[ $PHPCS = 1 ]]; then vendor/bin/phpcs -p --extensions=php --standard=vendor/cakephp/cakephp-codesniffer/CakePHP ./src ./tests; fi
- if [[ $PHPCS = 1 ]]; then composer cs-check; fi

after_success:
- if [[ $COVERAGE = 1 ]]; then bash <(curl -s https://codecov.io/bash); fi
Expand Down
8 changes: 4 additions & 4 deletions src/Shell/BootstrapShell.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ public function getOptionParser()
return $parser->setDescription([
'Bootstrap Shell',
'',
''
'',
])->addSubcommand('install', [
'help' => 'Installs Bootstrap assets and links them to app\'s webroot.'
'help' => 'Installs Bootstrap assets and links them to app\'s webroot.',
])->addSubcommand('copyLayouts', [
'help' => 'Copies sample layouts to app\'s Template/Layout/TwitterBootstrap folder.'
'help' => 'Copies sample layouts to app\'s Template/Layout/TwitterBootstrap folder.',
])->addSubcommand('modifyView', [
'help' => 'Modifies AppView.php to extend this plugin\'s UIView. Don\'t use, if you have a already modified AppView'
'help' => 'Modifies AppView.php to extend this plugin\'s UIView. Don\'t use, if you have a already modified AppView',
]);
}
}
8 changes: 4 additions & 4 deletions src/View/Helper/BreadcrumbsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class BreadcrumbsHelper extends CoreBreadcrumbsHelper
'wrapper' => '<nav aria-label="breadcrumb"><ol{{attrs}}>{{content}}</ol></nav>',
'item' => '<li{{attrs}}><a href="{{url}}"{{innerAttrs}}>{{title}}</a></li>',
'itemWithoutLink' => '<li{{attrs}}><span{{innerAttrs}}>{{title}}</span></li>',
'separator' => ''
]
'separator' => '',
],
];

/**
Expand All @@ -28,8 +28,8 @@ class BreadcrumbsHelper extends CoreBreadcrumbsHelper
protected $_defaultAttributes = [
'class' => [
'wrapper' => 'breadcrumb',
'item' => 'breadcrumb-item'
]
'item' => 'breadcrumb-item',
],
];

/**
Expand Down
8 changes: 5 additions & 3 deletions src/View/Helper/FlashHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class FlashHelper extends Helper
protected $_defaultConfig = [
'class' => ['alert', 'alert-dismissible', 'fade', 'show'],
'attributes' => ['role' => 'alert'],
'element' => 'BootstrapUI.Flash/default'
'element' => 'BootstrapUI.Flash/default',
];

/**
Expand Down Expand Up @@ -63,7 +63,8 @@ public function render($key = 'flash', array $options = [])
$this->getView()->getRequest()->getSession()->delete("Flash.$key");

$element = $message['element'];
if (strpos($element, '.') === false &&
if (
strpos($element, '.') === false &&
preg_match('#Flash/(default|success|error|info|warning)$#', $element, $matches)
) {
$class = $matches[1];
Expand All @@ -73,7 +74,8 @@ public function render($key = 'flash', array $options = [])
$message['params']['class'][] = 'alert-' . $class;
}

if (is_string($message['params']['class']) &&
if (
is_string($message['params']['class']) &&
preg_match('#primary|secondary|light|dark#', $message['params']['class'], $matches)
) {
$message['params']['class'] = $this->_config['class'];
Expand Down
35 changes: 21 additions & 14 deletions src/View/Helper/FormHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

class FormHelper extends Helper
{

use OptionsAwareTrait;

/**
Expand Down Expand Up @@ -125,7 +124,7 @@ class FormHelper extends Helper
'multicheckboxContainer' => '<div class="form-group row {{type}}{{required}}" role="group" aria-labelledby="{{groupId}}">{{content}}</div>',
'multicheckboxContainerError' => '<div class="form-group row {{type}}{{required}} is-invalid" role="group" aria-labelledby="{{groupId}}">{{content}}</div>',
'multicheckboxLabel' => '<label id="{{groupId}}" class="col-form-label d-block pt-0 %s">{{text}}</label>',
]
],
];

/**
Expand Down Expand Up @@ -219,7 +218,7 @@ public function create($model = null, array $options = [])
public function submit($caption = null, array $options = [])
{
$options += [
'class' => 'primary'
'class' => 'primary',
];
$options = $this->applyButtonClasses($options);

Expand Down Expand Up @@ -325,7 +324,8 @@ public function control($fieldName, array $options = [])
$inline = false;
}

if ($inline ||
if (
$inline ||
$this->_align === 'inline'
) {
if (!$custom) {
Expand Down Expand Up @@ -353,7 +353,8 @@ public function control($fieldName, array $options = [])
$options['templateVars']['groupId'] = $this->_domId($fieldName . '-group-label');
$options['templates']['label'] = $this->templater()->get('radioLabel');

if ($inline ||
if (
$inline ||
$this->_align === 'inline'
) {
if (!$custom) {
Expand Down Expand Up @@ -382,7 +383,8 @@ public function control($fieldName, array $options = [])
$options['templates']['checkboxWrapper'] = $this->templater()->get('customCheckboxWrapper');
}

if ($inline ||
if (
$inline ||
$this->_align === 'inline'
) {
if (!$custom) {
Expand All @@ -397,7 +399,8 @@ public function control($fieldName, array $options = [])
}
}

if ($custom &&
if (
$custom &&
$options['type'] !== 'multicheckbox'
) {
$options['injectFormControl'] = false;
Expand All @@ -416,13 +419,15 @@ public function control($fieldName, array $options = [])
$options['templates']['label'] = $this->templater()->get('customFileLabel');
$options['templates']['formGroup'] = $this->templater()->get('customFileFormGroup');

if ($options['prepend'] ||
if (
$options['prepend'] ||
$options['append']
) {
if ($options['label'] === null) {
$options['label'] = [];
}
if ($options['label'] !== false &&
if (
$options['label'] !== false &&
!isset($options['label']['text'])
) {
$text = $fieldName;
Expand Down Expand Up @@ -554,7 +559,8 @@ public function multiCheckbox($fieldName, $options, array $attributes = [])
protected function multiInputAttributes(array $attributes)
{
$classPrefix = 'form-check';
if (isset($attributes['custom']) &&
if (
isset($attributes['custom']) &&
$attributes['custom']
) {
$classPrefix = 'custom-control';
Expand Down Expand Up @@ -609,7 +615,7 @@ public function staticControl($fieldName, array $options = [])
'escape' => true,
'required' => false,
'secure' => true,
'hiddenField' => true
'hiddenField' => true,
];

$secure = $options['secure'];
Expand All @@ -623,7 +629,7 @@ public function staticControl($fieldName, array $options = [])

$content = $options['escape'] ? h($options['val']) : $options['val'];
$static = $this->formatTemplate('staticControl', [
'content' => $content
'content' => $content,
]);

if (!$hiddenField) {
Expand Down Expand Up @@ -730,7 +736,8 @@ protected function _datetimeOptions($options)
unset($options['hasError']);

foreach ($this->_datetimeParts as $part) {
if (isset($options[$part]) &&
if (
isset($options[$part]) &&
$options[$part] !== false
) {
if ($hasError) {
Expand All @@ -739,7 +746,7 @@ protected function _datetimeOptions($options)

$options[$part] += ['templateVars' => []];
$options[$part]['templateVars'] += [
'part' => $part
'part' => $part,
];
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/View/Helper/PaginatorHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ public function __construct(View $View, array $config = [])
'current' => '<li class="page-item active"><a class="page-link" href="#">{{text}} <span class="sr-only">(current)</span></a></li>',
'first' => '<li class="page-item first"><a class="page-link" href="{{url}}">{{text}}</a></li>',
'last' => '<li class="page-item last"><a class="page-link" href="{{url}}">{{text}}</a></li>',
'number' => '<li class="page-item"><a class="page-link" href="{{url}}">{{text}}</a></li>'
'number' => '<li class="page-item"><a class="page-link" href="{{url}}">{{text}}</a></li>',
] + $this->_defaultConfig['templates'];

parent::__construct($View, $config + [
'labels' => [
'first' => '&laquo;',
'last' => '&raquo;',
'prev' => '&lsaquo;',
'next' => '&rsaquo;'
'next' => '&rsaquo;',
],
]);
}
Expand Down
3 changes: 2 additions & 1 deletion src/View/UIViewTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ trait UIViewTrait
*/
public function initializeUI(array $options = [])
{
if ((!isset($options['layout']) || $options['layout'] === true) &&
if (
(!isset($options['layout']) || $options['layout'] === true) &&
$this->layout === 'default'
) {
$this->layout = 'BootstrapUI.default';
Expand Down
3 changes: 1 addition & 2 deletions src/View/Widget/ButtonWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

class ButtonWidget extends \Cake\View\Widget\ButtonWidget
{

use OptionsAwareTrait;

/**
Expand All @@ -24,7 +23,7 @@ class ButtonWidget extends \Cake\View\Widget\ButtonWidget
'info',
'light',
'dark',
'link'
'link',
];

/**
Expand Down
5 changes: 3 additions & 2 deletions src/View/Widget/FileWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ public function render(array $data, ContextInterface $context)
$data['injectFormControl'] = false;

$inputClass = 'form-control-file';
if (isset($data['custom']) &&
if (
isset($data['custom']) &&
$data['custom']
) {
$inputClass = 'custom-file-input';
Expand All @@ -65,7 +66,7 @@ public function render(array $data, ContextInterface $context)

if (isset($data['inputGroupLabel'])) {
$data['inputGroupLabel'] += [
'for' => $data['id']
'for' => $data['id'],
];
$data['templateVars']['label'] = $this->_label->render($data['inputGroupLabel'], $context);
unset($data['inputGroupLabel']);
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixture/ArticlesFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class ArticlesFixture extends TestFixture
'author_id' => ['type' => 'integer', 'null' => true],
'title' => ['type' => 'string', 'null' => true],
'body' => 'text',
'_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]]
'_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]],
];

public $records = [
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixture/AuthorsFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class AuthorsFixture extends TestFixture
public $fields = [
'id' => ['type' => 'integer'],
'name' => ['type' => 'string', 'default' => null],
'_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]]
'_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]],
];

public $records = [
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase/Bake/BakeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class BakeTest extends ConsoleIntegrationTestCase

public $fixtures = [
'plugin.BootstrapUI.Articles',
'plugin.BootstrapUI.Authors'
'plugin.BootstrapUI.Authors',
];

public function setUp()
Expand All @@ -27,7 +27,7 @@ public function setUp()
'Bake',
'WyriHaximus/TwigView' => [
'bootstrap' => true,
]
],
]);
}

Expand Down
12 changes: 6 additions & 6 deletions tests/TestCase/View/Helper/BreadcrumbsHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function testCrumbList()
'/span',
'/li',
'/ol',
'/nav'
'/nav',
];
$this->assertHtml($expected, $result);
}
Expand Down Expand Up @@ -115,7 +115,7 @@ public function testAttributes()
'/a',
'/li',
'/ol',
'/nav'
'/nav',
];
$this->assertHtml($expected, $result);
}
Expand Down Expand Up @@ -149,7 +149,7 @@ public function testAriaCurrentLastWithLink()
'/span',
'/li',
'/ol',
'/nav'
'/nav',
];
$this->assertHtml($expected, $result);
}
Expand Down Expand Up @@ -177,7 +177,7 @@ public function testAriaCurrentLastWithLinkNoCrumbWithLink()
'/span',
'/li',
'/ol',
'/nav'
'/nav',
];
$this->assertHtml($expected, $result);
}
Expand All @@ -203,7 +203,7 @@ public function testAriaCurrentRemoveAndInject()
'/span',
'/li',
'/ol',
'/nav'
'/nav',
];
$this->assertHtml($expected, $result);

Expand All @@ -230,7 +230,7 @@ public function testAriaCurrentRemoveAndInject()
'/span',
'/li',
'/ol',
'/nav'
'/nav',
];
$this->assertHtml($expected, $result);
}
Expand Down
Loading

0 comments on commit b15aed6

Please sign in to comment.