[phpcs] Add missing rules

- Do not add spaces after opening or before closing parenthesis

  // Wrong
  if( !is_null($var) ) {
    ...
  }

  // Right
  if(!is_null($var)) {
    ...
  }

- Add space after closing parenthesis

  // Wrong
  if(true){
    ...
  }

  // Right
  if(true) {
    ...
  }

- Add body into new line
- Close body in new line

  // Wrong
  if(true) { ... }

  // Right
  if(true) {
    ...
  }

Notice: Spaces after keywords are not detected:

  // Wrong (not detected)
  // -> space after 'if' and missing space after 'else'
  if (true) {
    ...
  } else{
    ...
  }

  // Right
  if(true) {
    ...
  } else {
    ...
  }
This commit is contained in:
logmanoriginal 2017-07-29 19:28:00 +02:00
parent 38b56bf23a
commit a4b9611e66
128 changed files with 692 additions and 694 deletions

View file

@ -1,7 +1,7 @@
<?php
function validateData(&$data, $parameters){
$validateTextValue = function($value, $pattern = null){
if(!is_null($pattern)){
if(!is_null($pattern)) {
$filteredValue = filter_var($value,
FILTER_VALIDATE_REGEXP,
array('options' => array(
@ -42,8 +42,8 @@ function validateData(&$data, $parameters){
if($filteredValue === false)
return null;
if(!in_array($filteredValue, $expectedValues)){ // Check sub-values?
foreach($expectedValues as $subName => $subValue){
if(!in_array($filteredValue, $expectedValues)) { // Check sub-values?
foreach($expectedValues as $subName => $subValue) {
if(is_array($subValue) && in_array($filteredValue, $subValue))
return $filteredValue;
}
@ -56,16 +56,16 @@ function validateData(&$data, $parameters){
if(!is_array($data))
return false;
foreach($data as $name => $value){
foreach($data as $name => $value) {
$registered = false;
foreach($parameters as $context => $set){
if(array_key_exists($name, $set)){
foreach($parameters as $context => $set) {
if(array_key_exists($name, $set)) {
$registered = true;
if(!isset($set[$name]['type'])){
if(!isset($set[$name]['type'])) {
$set[$name]['type'] = 'text';
}
switch($set[$name]['type']){
switch($set[$name]['type']) {
case 'number':
$data[$name] = $validateNumberValue($value);
break;
@ -77,7 +77,7 @@ function validateData(&$data, $parameters){
break;
default:
case 'text':
if(isset($set[$name]['pattern'])){
if(isset($set[$name]['pattern'])) {
$data[$name] = $validateTextValue($value, $set[$name]['pattern']);
} else {
$data[$name] = $validateTextValue($value);
@ -85,7 +85,7 @@ function validateData(&$data, $parameters){
break;
}
if(is_null($data[$name])){
if(is_null($data[$name])) {
echo 'Parameter \'' . $name . '\' is invalid!' . PHP_EOL;
return false;
}