Skip to content
This repository has been archived by the owner on Dec 15, 2020. It is now read-only.

Commit

Permalink
Add PHPCS
Browse files Browse the repository at this point in the history
  • Loading branch information
thiemowmde committed Aug 19, 2016
1 parent b9da9c9 commit 18f5bb5
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 7 deletions.
8 changes: 8 additions & 0 deletions composer.json
Expand Up @@ -25,12 +25,20 @@
"require": {
"php": ">=5.3.0"
},
"require-dev": {
"mediawiki/mediawiki-codesniffer": "~0.5"
},
"autoload": {
"files" : [
"DataTypes.php"
],
"psr-4": {
"DataTypes\\": "src/"
}
},
"scripts": {
"phpcs": [
"vendor/bin/phpcs src/* tests/* --standard=phpcs.xml -sp"
]
}
}
9 changes: 9 additions & 0 deletions phpcs.xml
@@ -0,0 +1,9 @@
<?xml version="1.0"?>
<ruleset name="DataValuesDataTypes">
<!-- See https://github.com/wikimedia/mediawiki-tools-codesniffer/blob/master/MediaWiki/ruleset.xml -->
<rule ref="vendor/mediawiki/mediawiki-codesniffer/MediaWiki">
<exclude name="Generic.Arrays.DisallowLongArraySyntax" />
</rule>

<arg name="extensions" value="php" />
</ruleset>
7 changes: 3 additions & 4 deletions src/Modules/DataTypesModule.php
Expand Up @@ -69,7 +69,6 @@ public static function extractDataTypesConfigVarNameFromResourceDefinition(
? $resourceDefinition['datatypesconfigvarname']
: null;


if ( !is_string( $dataTypesConfigVarName ) || $dataTypesConfigVarName === '' ) {
throw new Exception(
'The "datatypesconfigvarname" value of the resource definition' .
Expand Down Expand Up @@ -147,7 +146,7 @@ public function getScript( ResourceLoaderContext $context ) {
$configVarName = $this->getConfigVarName();
$typesJson = array();

foreach( $this->dataTypes as $dataType ) {
foreach ( $this->dataTypes as $dataType ) {
$typesJson[ $dataType->getId() ] = $dataType->toArray();
}
$typesJson = FormatJson::encode( $typesJson );
Expand All @@ -160,12 +159,12 @@ public function getScript( ResourceLoaderContext $context ) {
* @see ResourceLoaderModule::getMessages
* @since 0.1
*
* @return Array
* @return string[]
*/
public function getMessages() {
$messageKeys = array();

foreach( $this->dataTypes as $dataType ) {
foreach ( $this->dataTypes as $dataType ) {
// TODO: currently we assume that the type is using a message while it does not have to.
// Either change the system to ensure that a message is used or put the type labels
// directly into the JSON. Either way, the information should be in DataType::toArray.
Expand Down
3 changes: 1 addition & 2 deletions tests/Modules/DataTypesModuleTest.php
Expand Up @@ -37,7 +37,7 @@ public function provideDataTypesModuleAndResourceDefinition() {

$cases = array();

foreach( $validResourceDefinitions as $definition ) {
foreach ( $validResourceDefinitions as $definition ) {
$instance = new DataTypesModule( $definition );
$cases[] = array( $instance, $definition );
}
Expand Down Expand Up @@ -174,7 +174,6 @@ public function testGetDefinitionSummary_notEqualForDifferentDataTypes() {
$this->assertNotEquals( $summary1[0]['dataHash'], $summary2[0]['dataHash'] );
}


private function makeDefinition( array $dataTypes ) {
return array(
'datatypesconfigvarname' => 'foo123',
Expand Down
2 changes: 1 addition & 1 deletion tests/bootstrap.php
Expand Up @@ -9,7 +9,7 @@
* @author Jeroen De Dauw < jeroendedauw@gmail.com >
*/

if ( php_sapi_name() !== 'cli' ) {
if ( PHP_SAPI !== 'cli' ) {
die( 'Not an entry point' );
}

Expand Down

0 comments on commit 18f5bb5

Please sign in to comment.