add PHPCS Squiz.Arrays.ArrayDeclaration.KeyNotAligned rule

This commit is contained in:
Marc Tobias Metten
2018-05-08 00:37:41 +02:00
parent c555b60b36
commit 8841a328c8
4 changed files with 35 additions and 34 deletions

View File

@@ -33,33 +33,33 @@ $aPlaceDetails['rank_search'] = (int) $aPointDetails['rank_search'];
$aPlaceDetails['isarea'] = ($aPointDetails['isarea'] == 't'); $aPlaceDetails['isarea'] = ($aPointDetails['isarea'] == 't');
$aPlaceDetails['centroid'] = array( $aPlaceDetails['centroid'] = array(
'type' => 'Point', 'type' => 'Point',
'coordinates' => array( (float) $aPointDetails['lon'], (float) $aPointDetails['lat'] ) 'coordinates' => array( (float) $aPointDetails['lon'], (float) $aPointDetails['lat'] )
); );
$aPlaceDetails['geometry'] = json_decode($aPointDetails['asgeojson']); $aPlaceDetails['geometry'] = json_decode($aPointDetails['asgeojson']);
$funcMapAddressLine = function ($aFull) { $funcMapAddressLine = function ($aFull) {
$aMapped = array( $aMapped = array(
'localname' => $aFull['localname'], 'localname' => $aFull['localname'],
'place_id' => isset($aFull['place_id']) ? (int) $aFull['place_id'] : null, 'place_id' => isset($aFull['place_id']) ? (int) $aFull['place_id'] : null,
'osm_id' => isset($aFull['osm_id']) ? (int) $aFull['osm_id'] : null, 'osm_id' => isset($aFull['osm_id']) ? (int) $aFull['osm_id'] : null,
'osm_type' => isset($aFull['osm_type']) ? $aFull['osm_type'] : null, 'osm_type' => isset($aFull['osm_type']) ? $aFull['osm_type'] : null,
'class' => $aFull['class'], 'class' => $aFull['class'],
'type' => $aFull['type'], 'type' => $aFull['type'],
'admin_level' => isset($aFull['admin_level']) ? (int) $aFull['admin_level'] : null, 'admin_level' => isset($aFull['admin_level']) ? (int) $aFull['admin_level'] : null,
'rank_address' => $aFull['rank_address'] ? (int) $aFull['rank_address'] : null, 'rank_address' => $aFull['rank_address'] ? (int) $aFull['rank_address'] : null,
'distance' => (float) $aFull['distance'] 'distance' => (float) $aFull['distance']
); );
return $aMapped; return $aMapped;
}; };
$funcMapKeyword = function ($aFull) { $funcMapKeyword = function ($aFull) {
$aMapped = array( $aMapped = array(
'id' => (int) $aFull['word_id'], 'id' => (int) $aFull['word_id'],
'token' => $aFull['word_token'] 'token' => $aFull['word_token']
); );
return $aMapped; return $aMapped;
}; };

View File

@@ -93,6 +93,8 @@
INDENTATION, SPACING INDENTATION, SPACING
************************************************************** --> ************************************************************** -->
<rule ref="Squiz.Arrays.ArrayDeclaration.KeyNotAligned" />
<!-- Aligned looks nicer, but causes too many warnings currently --> <!-- Aligned looks nicer, but causes too many warnings currently -->
<rule ref="Squiz.Arrays.ArrayDeclaration.DoubleArrowNotAligned"> <rule ref="Squiz.Arrays.ArrayDeclaration.DoubleArrowNotAligned">
<severity>0</severity> <severity>0</severity>
@@ -103,7 +105,6 @@
<!-- ************************************************************** <!-- **************************************************************
VARIABLES VARIABLES
************************************************************** --> ************************************************************** -->

View File

@@ -179,19 +179,19 @@ EOT
// header are taken from first group item, thus no key3 gets printed // header are taken from first group item, thus no key3 gets printed
$aGroups = array( $aGroups = array(
'group1' => array( 'group1' => array(
array('key1' => 'val1', 'key2' => 'val2'), array('key1' => 'val1', 'key2' => 'val2'),
array('key1' => 'one', 'key2' => 'two', 'unknown' => 1), array('key1' => 'one', 'key2' => 'two', 'unknown' => 1),
), ),
'group2' => array( 'group2' => array(
array('key1' => 'val1', 'key2' => 'val2', 'key3' => 'val3'), array('key1' => 'val1', 'key2' => 'val2', 'key3' => 'val3'),
) )
); );
Debug::printGroupTable('Table3', $aGroups); Debug::printGroupTable('Table3', $aGroups);
$aGroups = array( $aGroups = array(
'group1' => array($this->oWithDebuginfo, $this->oWithDebuginfo), 'group1' => array($this->oWithDebuginfo, $this->oWithDebuginfo),
); );
Debug::printGroupTable('Table4', $aGroups); Debug::printGroupTable('Table4', $aGroups);
} }
} }

View File

@@ -24,9 +24,9 @@ try {
} catch (Exception $oErr) { } catch (Exception $oErr) {
if ($sOutputFormat == 'json') { if ($sOutputFormat == 'json') {
$aResponse = array( $aResponse = array(
'status' => $oErr->getCode(), 'status' => $oErr->getCode(),
'message' => $oErr->getMessage() 'message' => $oErr->getMessage()
); );
javascript_renderData($aResponse); javascript_renderData($aResponse);
} else { } else {
header('HTTP/1.0 500 Internal Server Error'); header('HTTP/1.0 500 Internal Server Error');
@@ -39,10 +39,10 @@ try {
if ($sOutputFormat == 'json') { if ($sOutputFormat == 'json') {
$epoch = $oStatus->dataDate(); $epoch = $oStatus->dataDate();
$aResponse = array( $aResponse = array(
'status' => 0, 'status' => 0,
'message' => 'OK', 'message' => 'OK',
'data_updated' => (new DateTime('@'.$epoch))->format(DateTime::RFC3339) 'data_updated' => (new DateTime('@'.$epoch))->format(DateTime::RFC3339)
); );
javascript_renderData($aResponse); javascript_renderData($aResponse);
} else { } else {
echo 'OK'; echo 'OK';