WMDE-leszek has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/391178 )

Change subject: Remove DataTypesModule class and other MediaWiki integration 
files
......................................................................

Remove DataTypesModule class and other MediaWiki integration files

This is no longer a MediaWiki extension

Change-Id: Id399975f678687ffd59c443f9e79e500c480fca6
---
D DataTypes.php
M README.md
M composer.json
D extension.json
M phpcs.xml
D src/DataTypesHooks.php
D src/DataTypesModule.php
D src/Modules/DataTypesModule.php
D tests/Modules/DataTypesModuleTest.php
9 files changed, 5 insertions(+), 493 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DataTypes 
refs/changes/78/391178/1

diff --git a/DataTypes.php b/DataTypes.php
deleted file mode 100644
index 1f9c09b..0000000
--- a/DataTypes.php
+++ /dev/null
@@ -1,22 +0,0 @@
-<?php
-
-/**
- * DataTypes extension
- *
- * @ingroup Extensions
- *
- * The license governing the extension code:
- * @license GNU General Public Licence 2.0 or later
- */
-
-if ( function_exists( 'wfLoadExtension' ) ) {
-       wfLoadExtension( 'DataTypes', __DIR__ . '/extension.json' );
-       /* wfWarn(
-               'Deprecated PHP entry point used for DataTypes extension. ' .
-               'Please use wfLoadExtension instead, ' .
-               'see https://www.mediawiki.org/wiki/Extension_registration for 
more details.'
-       ); */
-       return true;
-} else {
-       die( 'This version of the DataTypes extension requires MediaWiki 1.25+' 
);
-}
diff --git a/README.md b/README.md
index a23fb3c..9eecec8 100644
--- a/README.md
+++ b/README.md
@@ -51,7 +51,9 @@
 
 ## Release notes
 
-### 1.1.0 (dev)
+### 2.0.0 (dev)
+* Removed `DataTypesModules`
+* Removed MediaWiki integration. The library is no longer a MediaWiki 
extension.
 * Updated internationalizations.
 
 ### 1.0.0 (2016-12-29)
diff --git a/composer.json b/composer.json
index 39a6c87..ed3c9a9 100644
--- a/composer.json
+++ b/composer.json
@@ -32,9 +32,6 @@
                "jakub-onderka/php-console-highlighter": "0.3.2"
        },
        "autoload": {
-               "files" : [
-                       "DataTypes.php"
-               ],
                "psr-4": {
                        "DataTypes\\": "src/",
                        "DataTypes\\Tests\\": "tests/"
@@ -44,7 +41,8 @@
                "fix": "phpcbf",
                "test": [
                        "parallel-lint . --exclude vendor --exclude 
node_modules",
-                       "phpcs -p -s"
+                       "phpcs -p -s",
+                       "phpunit"
                ]
        }
 }
diff --git a/extension.json b/extension.json
deleted file mode 100644
index f6ccac4..0000000
--- a/extension.json
+++ /dev/null
@@ -1,49 +0,0 @@
-{
-       "name": "datavalues",
-       "descriptionmsg": "datatypes-desc",
-       "license-name": "GPL-2.0+",
-       "author": [
-               "The Wikidata team"
-       ],
-       "url": "https://phabricator.wikimedia.org/diffusion/EDTY/";,
-       "load_composer_autoloader": true,
-       "ResourceFileModulePaths": {
-               "localBasePath": "js",
-               "remoteExtPath": "DataTypes/js"
-       },
-       "ResourceModules": {
-               "dataTypes.__namespace": {
-                       "scripts": [
-                               "dataTypes/__namespace.js"
-                       ]
-               },
-               "dataTypes.DataType": {
-                       "scripts": "dataTypes/DataType.js",
-                       "dependencies": "dataTypes.__namespace"
-               },
-               "dataTypes.DataTypeStore": {
-                       "scripts": "dataTypes/DataTypeStore.js",
-                       "dependencies": [
-                               "dataTypes.__namespace",
-                               "dataTypes.DataType"
-                       ]
-               }
-       },
-       "MessagesDirs": {
-               "DataTypes": [
-                       "i18n"
-               ]
-       },
-       "AutoloadClasses": {
-               "DataTypes\\DataTypesHooks": "src/DataTypesHooks.php",
-               "DataTypes\\DataType": "src/DataType.php",
-               "DataTypes\\DataTypeFactory": "src/DataTypeFactory.php",
-               "DataTypes\\Modules\\DataTypesModule": 
"src/Modules/DataTypesModule.php"
-       },
-       "Hooks": {
-               "UnitTestsList": [
-                       "DataTypes\\DataTypesHooks::onUnitTestsList"
-               ]
-       },
-       "manifest_version": 1
-}
diff --git a/phpcs.xml b/phpcs.xml
index 7f95d6b..fae5645 100644
--- a/phpcs.xml
+++ b/phpcs.xml
@@ -2,9 +2,5 @@
 <ruleset name="DataValuesDataTypes">
        <rule ref="./vendor/wikibase/wikibase-codesniffer/Wikibase" />
 
-       <rule ref="Generic.NamingConventions.UpperCaseConstantName">
-               <exclude-pattern>DataTypes\.php</exclude-pattern>
-       </rule>
-
        <file>.</file>
 </ruleset>
diff --git a/src/DataTypesHooks.php b/src/DataTypesHooks.php
deleted file mode 100644
index 28ad348..0000000
--- a/src/DataTypesHooks.php
+++ /dev/null
@@ -1,12 +0,0 @@
-<?php
-
-namespace DataTypes;
-
-class DataTypesHooks {
-
-       public static function onUnitTestsList( &$paths ) {
-               $paths[] = __DIR__ . '/../tests/Modules';
-               $paths[] = __DIR__ . '/../tests/Phpunit';
-       }
-
-}
diff --git a/src/DataTypesModule.php b/src/DataTypesModule.php
deleted file mode 100644
index 260efaf..0000000
--- a/src/DataTypesModule.php
+++ /dev/null
@@ -1,15 +0,0 @@
-<?php
-
-namespace DataTypes;
-
-use DataTypes\Modules\DataTypesModule as CurrentClass;
-
-/**
- * @deprecated
- *
- * @license GPL-2.0+
- * @author Jeroen
- */
-class DataTypesModule extends CurrentClass {
-
-}
diff --git a/src/Modules/DataTypesModule.php b/src/Modules/DataTypesModule.php
deleted file mode 100644
index 5f880b8..0000000
--- a/src/Modules/DataTypesModule.php
+++ /dev/null
@@ -1,194 +0,0 @@
-<?php
-
-namespace DataTypes\Modules;
-
-use DataTypes\DataType;
-use DataTypes\DataTypeFactory;
-use Exception;
-use FormatJson;
-use ResourceLoaderContext;
-use ResourceLoaderModule;
-
-/**
- * Resource loader module for defining resources that will create a MW config 
var in JavaScript
- * holding information about all data types known to a given DataTypeFactory.
- *
- * The resource definition requires the following additional keys:
- * - (string) datatypesconfigvarname: Name of the "mw.config.get( '...' )" 
config variable.
- * - (Function|DataTypeFactory) datatypefactory: Provider for the data types. 
Can be a callback
- *   returning a DataTypeFactory instance.
- *
- * @license GPL-2.0+
- * @author Daniel Werner < daniel.wer...@wikimedia.de >
- */
-class DataTypesModule extends ResourceLoaderModule {
-
-       /**
-        * @var DataType[]
-        */
-       protected $dataTypes;
-
-       /**
-        * @var string
-        */
-       protected $dataTypesConfigVarName;
-
-       /**
-        * @var DataTypeFactory
-        */
-       protected $dataTypeFactory;
-
-       /**
-        * @since 0.1
-        *
-        * @param array $resourceDefinition
-        */
-       public function __construct( array $resourceDefinition ) {
-               $this->dataTypesConfigVarName =
-                       
static::extractDataTypesConfigVarNameFromResourceDefinition( 
$resourceDefinition );
-
-               $this->dataTypeFactory =
-                       static::extractDataTypeFactoryFromResourceDefinition( 
$resourceDefinition );
-
-               $dataTypeFactory = $this->getDataTypeFactory();
-               $this->dataTypes = $dataTypeFactory->getTypes();
-       }
-
-       /**
-        * @since 0.1
-        *
-        * @param array $resourceDefinition
-        *
-        * @return string
-        * @throws Exception If the given resource definition is not sufficient
-        */
-       public static function 
extractDataTypesConfigVarNameFromResourceDefinition(
-               array $resourceDefinition
-       ) {
-               $dataTypesConfigVarName = array_key_exists( 
'datatypesconfigvarname', $resourceDefinition )
-                       ? $resourceDefinition['datatypesconfigvarname']
-                       : null;
-
-               if ( !is_string( $dataTypesConfigVarName ) || 
$dataTypesConfigVarName === '' ) {
-                       throw new Exception(
-                               'The "datatypesconfigvarname" value of the 
resource definition' .
-                               ' has to be a non-empty string value'
-                       );
-               }
-
-               return $dataTypesConfigVarName;
-       }
-
-       /**
-        * @since 0.1
-        *
-        * @param array $resourceDefinition
-        *
-        * @return DataTypeFactory
-        * @throws Exception If the given resource definition is not sufficient
-        */
-       public static function extractDataTypeFactoryFromResourceDefinition(
-               array $resourceDefinition
-       ) {
-               $dataTypeFactory = array_key_exists( 'datatypefactory', 
$resourceDefinition )
-                       ? $resourceDefinition['datatypefactory']
-                       : null;
-
-               if ( is_callable( $dataTypeFactory ) ) {
-                       $dataTypeFactory = call_user_func( $dataTypeFactory );
-               }
-
-               if ( !( $dataTypeFactory instanceof DataTypeFactory ) ) {
-                       throw new Exception(
-                               'The "datatypefactory" value of the resource 
definition has' .
-                               ' to be an instance of DataTypeFactory or a 
callback returning one'
-                       );
-               }
-
-               return $dataTypeFactory;
-       }
-
-       /**
-        * Returns the name of the config var key under which the data type 
definition will be available
-        * in JavaScript using "mw.config.get( '...' )"
-        *
-        * @since 0.1
-        *
-        * @return string
-        */
-       public function getConfigVarName() {
-               return $this->dataTypesConfigVarName;
-       }
-
-       /**
-        * Returns the data types factory providing the data type information.
-        *
-        * @since 0.1
-        *
-        * @return DataTypeFactory
-        */
-       public function getDataTypeFactory() {
-               return $this->dataTypeFactory;
-       }
-
-       /**
-        * Used to propagate available data type ids to JavaScript.
-        * Data type ids will be available in 'wbDataTypeIds' config var.
-        * @see ResourceLoaderModule::getScript
-        *
-        * @since 0.1
-        *
-        * @param ResourceLoaderContext $context
-        *
-        * @return string
-        */
-       public function getScript( ResourceLoaderContext $context ) {
-               $configVarName = $this->getConfigVarName();
-               $typesJson = [];
-
-               foreach ( $this->dataTypes as $dataType ) {
-                       $typesJson[ $dataType->getId() ] = $dataType->toArray();
-               }
-               $typesJson = FormatJson::encode( $typesJson );
-
-               return "mediaWiki.config.set( '$configVarName', $typesJson );";
-       }
-
-       /**
-        * Returns the message keys of the registered data types.
-        * @see ResourceLoaderModule::getMessages
-        * @since 0.1
-        *
-        * @return string[]
-        */
-       public function getMessages() {
-               $messageKeys = [];
-
-               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.
-                       $messageKeys[] = 'datatypes-type-' . $dataType->getId();
-               }
-
-               return $messageKeys;
-       }
-
-       /**
-        * @see ResourceLoaderModule::getDefinitionSummary
-        *
-        * @param ResourceLoaderContext $context
-        *
-        * @return array
-        */
-       public function getDefinitionSummary( ResourceLoaderContext $context ) {
-               $summary = parent::getDefinitionSummary( $context );
-
-               $summary[] = [
-                       'dataHash' => sha1( json_encode( array_keys( 
$this->dataTypes ) ) )
-               ];
-
-               return $summary;
-       }
-
-}
diff --git a/tests/Modules/DataTypesModuleTest.php 
b/tests/Modules/DataTypesModuleTest.php
deleted file mode 100644
index c132efc..0000000
--- a/tests/Modules/DataTypesModuleTest.php
+++ /dev/null
@@ -1,192 +0,0 @@
-<?php
-
-namespace DataTypes\Tests\Modules;
-
-use DataTypes\DataTypeFactory;
-use DataTypes\Modules\DataTypesModule;
-use Exception;
-use ResourceLoaderContext;
-
-/**
- * @covers DataTypes\Modules\DataTypesModule
- *
- * @group DataTypes
- *
- * @license GPL-2.0+
- * @author Daniel Werner < daniel.wer...@wikimedia.de >
- * @author Katie Filbert < aude.w...@gmail.com >
- */
-class DataTypesModuleTest extends \PHPUnit_Framework_TestCase {
-
-       /**
-        * @return array [instance, resource definition]
-        */
-       public function provideDataTypesModuleAndResourceDefinition() {
-               $dataTypeFactory = new DataTypeFactory( [ 'url' => 'string' ] );
-
-               $validResourceDefinitions = [
-                       [
-                               'datatypesconfigvarname' => 'foo',
-                               'datatypefactory' => function() {
-                                       return new DataTypeFactory( [] );
-                               }
-                       ],
-                       [
-                               'datatypesconfigvarname' => 'bar123',
-                               'datatypefactory' => $dataTypeFactory
-                       ],
-               ];
-
-               $cases = [];
-
-               foreach ( $validResourceDefinitions as $definition ) {
-                       $instance = new DataTypesModule( $definition );
-                       $cases[] = [ $instance, $definition ];
-               }
-
-               return $cases;
-       }
-
-       /**
-        * @dataProvider provideDataTypesModuleAndResourceDefinition
-        *
-        * @param DataTypesModule $module
-        */
-       public function testGetDataTypeFactory( DataTypesModule $module ) {
-               $this->assertInstanceOf( DataTypeFactory::class, 
$module->getDataTypeFactory() );
-       }
-
-       /**
-        * @return array [invalid resource definition, case description]
-        */
-       public function provideInvalidResourceDefinition() {
-               $dataTypeFactory = new DataTypeFactory( [] );
-
-               $validDefinition = [
-                       'datatypesconfigvarname' => 'foo',
-                       'datatypefactory' => function() {
-                               return new DataTypeFactory( [] );
-                       }
-               ];
-
-               return [
-                       [
-                               [
-                                       'datatypesconfigvarname' => 'foo'
-                               ],
-                               'missing "datatypefactory" field'
-                       ],
-                       [
-                               [
-                                       'datatypefactory' => $dataTypeFactory
-                               ],
-                               'missing "datatypesconfigvarname" field'
-                       ],
-                       [
-                               [],
-                               'all fields missing'
-                       ],
-                       [
-                               array_merge(
-                                       $validDefinition,
-                                       [
-                                               'datatypefactory' => 123
-                                       ]
-                               ),
-                               '"datatypefactory" field has value of wrong 
type'
-                       ],
-                       [
-                               array_merge(
-                                       $validDefinition,
-                                       [
-                                               'datatypefactory' => function() 
{
-                                                       return null;
-                                               }
-                                       ]
-                               ),
-                               '"datatypefactory" callback does not return a 
DataTypeFactory instance'
-                       ],
-               ];
-       }
-
-       /**
-        * @dataProvider provideDataTypesModuleAndResourceDefinition
-        *
-        * @param DataTypesModule $module
-        * @param array $definition
-        */
-       public function testGetConfigVarName( DataTypesModule $module, array 
$definition ) {
-               $configVarName = $module->getConfigVarName();
-
-               $this->assertInternalType( 'string', $configVarName );
-
-               $this->assertSame(
-                       $definition['datatypesconfigvarname'],
-                       $module->getConfigVarName()
-               );
-       }
-
-       /**
-        * @dataProvider provideInvalidResourceDefinition
-        *
-        * @param array $definition
-        * @param string $caseDescription
-        */
-       public function testConstructorErrors( array $definition, 
$caseDescription ) {
-               $this->setName( 'Instantiation raises exception in case ' . 
$caseDescription );
-               $this->setExpectedException( Exception::class );
-
-               new DataTypesModule( $definition );
-       }
-
-       public function testGetDefinitionSummary() {
-               $definition = $this->makeDefinition(
-                       [ 'foo' => 'string' ]
-               );
-
-               $module = new DataTypesModule( $definition );
-               $summary = $module->getDefinitionSummary( $this->getContext() );
-
-               $this->assertInternalType( 'array', $summary );
-               $this->assertArrayHasKey( 0, $summary );
-               $this->assertArrayHasKey( 'dataHash', $summary[0] );
-       }
-
-       public function 
testGetDefinitionSummary_notEqualForDifferentDataTypes() {
-               $definition1 = $this->makeDefinition( [
-                       'foo' => 'string'
-               ] );
-
-               $definition2 = $this->makeDefinition( [
-                       'foo' => 'string',
-                       'bar' => 'string'
-               ] );
-
-               $module1 = new DataTypesModule( $definition1 );
-               $module2 = new DataTypesModule( $definition2 );
-
-               $context = $this->getContext();
-
-               $summary1 = $module1->getDefinitionSummary( $context );
-               $summary2 = $module2->getDefinitionSummary( $context );
-
-               $this->assertNotEquals( $summary1[0]['dataHash'], 
$summary2[0]['dataHash'] );
-       }
-
-       private function makeDefinition( array $dataTypes ) {
-               return [
-                       'datatypesconfigvarname' => 'foo123',
-                       'datatypefactory' => new DataTypeFactory( $dataTypes )
-               ];
-       }
-
-       /**
-        * @return ResourceLoaderContext
-        */
-       private function getContext() {
-               return $this->getMockBuilder( ResourceLoaderContext::class )
-                       ->disableOriginalConstructor()
-                       ->getMock();
-       }
-
-}

-- 
To view, visit https://gerrit.wikimedia.org/r/391178
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id399975f678687ffd59c443f9e79e500c480fca6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DataTypes
Gerrit-Branch: master
Gerrit-Owner: WMDE-leszek <leszek.mani...@wikimedia.de>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to