PHPackages                             data-values/data-types - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. data-values/data-types

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

data-values/data-types
======================

PHP library defining the DataTypes\\DataType class of which instances represent a type of value, such as "positive integer" or "percentage".

2.0.0(8y ago)085.5k1GPL-2.0+PHPPHP &gt;=5.5.9

Since Dec 15Pushed 8y ago21 watchersCompare

[ Source](https://github.com/wikimedia/mediawiki-extensions-DataTypes)[ Packagist](https://packagist.org/packages/data-values/data-types)[ Docs](https://github.com/wmde/DataTypes)[ RSS](/packages/data-values-data-types/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (4)Versions (17)Used By (1)

\[READ-ONLY\] This component has been integrated into [Wikibase](https://gerrit.wikimedia.org/r/#/admin/projects/mediawiki/extensions/Wikibase) extension.

DataTypes
=========

[](#datatypes)

PHP library defining the `DataTypes\DataType` class of which instances represent a type of value, such as "positive integer" or "percentage".

[![Build Status](https://camo.githubusercontent.com/4c24f66cdbe4c3922ef5a3e74845f381daa1aed4fc3074207981122e2b58c126/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f776d64652f4461746154797065732e706e673f6272616e63683d6d6173746572)](http://travis-ci.org/wmde/DataTypes)[![Code Coverage](https://camo.githubusercontent.com/56ed39b29b39b669b2be57d784ef002c991948744b1c2e6b75e965399424d2fb/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f776d64652f4461746154797065732f6261646765732f636f7665726167652e706e673f733d38316361393033346538393864306666326565363033666664636630373833356339623566306433)](https://scrutinizer-ci.com/g/wmde/DataTypes/)[![Scrutinizer Quality Score](https://camo.githubusercontent.com/53078c4c624ff1a58c78dd160f63ce47b32479a00db0df4fa0ac7008ecf6ef4d/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f776d64652f4461746154797065732f6261646765732f7175616c6974792d73636f72652e706e673f733d32343035636536306330383965373435343539386165353065323335663030316236386264356362)](https://scrutinizer-ci.com/g/wmde/DataTypes/)[![Dependency Status](https://camo.githubusercontent.com/f4db3cd01d98950da77d1d18ddd8a97884cab72b99f3db71b46c06d9397a1da5/68747470733a2f2f7777772e76657273696f6e6579652e636f6d2f7068702f646174612d76616c7565733a646174612d74797065732f6465762d6d61737465722f62616467652e706e67)](https://www.versioneye.com/php/data-values:data-types/dev-master)

On [Packagist](https://packagist.org/packages/data-values/data-types): [![Latest Stable Version](https://camo.githubusercontent.com/7f4e62c9f907e777760b68fbe3e1fa256fbf816e8b6dceaeca17eb813659d994/68747470733a2f2f706f7365722e707567782e6f72672f646174612d76616c7565732f646174612d74797065732f76657273696f6e2e706e67)](https://packagist.org/packages/data-values/data-types)[![Download count](https://camo.githubusercontent.com/c94c0b33a3d91b90dad80337ea760e1c06455174b63639b9106c198c0666a729/68747470733a2f2f706f7365722e707567782e6f72672f646174612d76616c7565732f646174612d74797065732f642f746f74616c2e706e67)](https://packagist.org/packages/data-values/data-types)

Installation
------------

[](#installation)

You can use [Composer](http://getcomposer.org/) to download and install this package as well as its dependencies. Alternatively you can simply clone the git repository and take care of loading yourself.

### Composer

[](#composer)

To add this package as a local, per-project dependency to your project, simply add a dependency on `data-values/data-types` to your project's `composer.json` file. Here is a minimal example of a `composer.json` file that just defines a dependency on DataTypes 1.0:

```
{
    "require": {
        "data-values/data-types": "~1.0"
    }
}

```

### Manual

[](#manual)

Get the DataTypes code, either via git, or some other means. Also get all dependencies. You can find a list of the dependencies in the "require" section of the composer.json file. Load all dependencies and the load the DataTypes library by including its entry point: DataTypes.php.

Tests
-----

[](#tests)

This library comes with a set up PHPUnit tests that cover all non-trivial code. You can run these tests using the PHPUnit configuration file found in the root directory. The tests can also be run via TravisCI, as a TravisCI configuration file is also provided in the root directory.

Authors
-------

[](#authors)

DataTypes has been written by the Wikidata team at [Wikimedia Germany](https://wikimedia.de)for the [Wikidata project](https://wikidata.org/).

Release notes
-------------

[](#release-notes)

### 2.0.0 (2017-11-14)

[](#200-2017-11-14)

- Removed `DataTypesModules`
- Removed MediaWiki integration. The library is no longer a MediaWiki extension.
- Removed JavaScript files and internationalizations (moved to a separate package).

### 1.0.0 (2016-12-29)

[](#100-2016-12-29)

- `DataType` and `DataTypeFactory` do not accept empty strings any more.
- Removed `DataType::getLabel` along with the `DataTypes\Message` class.
- Added `DataType::getMessageKey`.
- Added a basic PHPCS rule set, can be run with `composer phpcs`.

### 0.5.2 (2016-02-17)

[](#052-2016-02-17)

- Fixed cache invalidation in `DataTypesModule`.
- Fixed `DataTypeFactory` to report invalid arguments on construction.

### 0.5.1 (2015-10-20)

[](#051-2015-10-20)

- `DataTypeFactory::getTypes()` now returns array with typeId keys as documented

### 0.5.0 (2015-08-10)

[](#050-2015-08-10)

#### Breaking changes

[](#breaking-changes)

- `DataType` no longer takes an array of `ValueValidator` in its constructor
- `DataType::getValidators` has been removed
- `DataTypeFactory` now takes a map from data type id to data value type.
- `DataTypeFactory::registerBuilder` has been removed

### 0.4.3 (2015-06-18)

[](#043-2015-06-18)

- Fixed version number constant.

### 0.4.2 (2015-06-18)

[](#042-2015-06-18)

- Updated code documentation for being able to automatically generate a proper documentation using JSDuck.
- Removed the ResourceLoader module "dependencies" which had been defined by accident.

### 0.4.1 (2014-11-18)

[](#041-2014-11-18)

- Improved path detection so it does not break when the library is included in `vendor` rather than `extensions`

### 0.4.0 (2014-05-21)

[](#040-2014-05-21)

- Removed the global variable `wgDataTypes`

### 0.3.0 (2014-05-21)

[](#030-2014-05-21)

- Rename `monolingual-text` to `monolingualtext`
- Rename `multilingual-text` to `multilingualtext`

### 0.2.1 (2014-05-06)

[](#021-2014-05-06)

- Migrated the i18n support to the new MediaWiki JSON format
- The tests are now run on PHP 5.6 and HHVM on travis

### 0.2.0 (2014-03-14)

[](#020-2014-03-14)

#### Breaking changes

[](#breaking-changes-1)

- `dataTypes.DataType` JavaScript object may no longer be initialized from a `dataValues.DataValue` object.
- Removed `dataTypes.DataType.getLabel`.
- Removed global DataType registration in the `dataTypes` object; `DataTypeStore` is to be used instead.
- Split up generic "dataTypes" ResourceLoader module into "dataTypes.DataType" and "dataTypes.DataTypeStore".

#### Enhancements

[](#enhancements)

- Removed MediaWiki and DataValues dependencies from JavaScript code.
- Made code PSR-4 compliant
- Removed ResourceLoader dependency of QUnit tests.
- Implemented DataTypeStore.

### 0.1.1 (2013-12-23)

[](#011-2013-12-23)

- Remove assumption about where the extension is installed in the resource loading paths.

### 0.1.0 (2013-12-15)

[](#010-2013-12-15)

Initial release.

Links
-----

[](#links)

- [DataTypes on Packagist](https://packagist.org/packages/data-values/data-types)
- [DataTypes on Ohloh](https://www.ohloh.net/p/DataTypesPHP)
- [TravisCI build status](https://travis-ci.org/wmde/DataTypes)
- [DataTypes on ScrutinizerCI](https://scrutinizer-ci.com/g/wmde/DataTypes/)
- [Issue tracker](https://phabricator.wikimedia.org/project/view/123/)

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community28

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~102 days

Recently: every ~206 days

Total

15

Last Release

3106d ago

Major Versions

0.5.2 → 1.0.02016-12-30

1.0.0 → 2.0.02017-11-14

PHP version history (3 changes)0.1PHP &gt;=5.3.0

1.0.0PHP &gt;=5.5.0

2.0.0PHP &gt;=5.5.9

### Community

Maintainers

![](https://www.gravatar.com/avatar/451bd4039d530fed8f9c3da91bfa519233a397d2182cdfdcad700f6cfea19b7f?d=identicon)[Jeroen De Dauw](/maintainers/Jeroen%20De%20Dauw)

![](https://www.gravatar.com/avatar/054adb441e7ee248ec924bc45fa793835c284710eb31627587fa5de21bab9e96?d=identicon)[wmde](/maintainers/wmde)

![](https://www.gravatar.com/avatar/5406ed1d40d50ffc61d67e9f5149914dbfe0b8a52bdf297299f5ccfab0a73d91?d=identicon)[thiemowmde](/maintainers/thiemowmde)

![](https://www.gravatar.com/avatar/fe4220e5a109212ea1a84969fbcb0795ceaf975145c1f0577bd758d0500e6428?d=identicon)[manicki](/maintainers/manicki)

![](https://www.gravatar.com/avatar/0c1ddc1309ce2f268d42afc35c3065421f8a6d21e4ca25eb338db3a297cdef1b?d=identicon)[DataValues](/maintainers/DataValues)

---

Top Contributors

[![JeroenDeDauw](https://avatars.githubusercontent.com/u/146040?v=4)](https://github.com/JeroenDeDauw "JeroenDeDauw (119 commits)")[![translatewiki](https://avatars.githubusercontent.com/u/24829418?v=4)](https://github.com/translatewiki "translatewiki (114 commits)")[![DanweDE](https://avatars.githubusercontent.com/u/101926?v=4)](https://github.com/DanweDE "DanweDE (52 commits)")[![thiemowmde](https://avatars.githubusercontent.com/u/6576639?v=4)](https://github.com/thiemowmde "thiemowmde (35 commits)")[![addshore](https://avatars.githubusercontent.com/u/3308769?v=4)](https://github.com/addshore "addshore (20 commits)")[![mariushoch](https://avatars.githubusercontent.com/u/2446964?v=4)](https://github.com/mariushoch "mariushoch (19 commits)")[![tobijat](https://avatars.githubusercontent.com/u/2997252?v=4)](https://github.com/tobijat "tobijat (16 commits)")[![Nikerabbit](https://avatars.githubusercontent.com/u/1109395?v=4)](https://github.com/Nikerabbit "Nikerabbit (15 commits)")[![snaterlicious](https://avatars.githubusercontent.com/u/5755120?v=4)](https://github.com/snaterlicious "snaterlicious (13 commits)")[![manicki](https://avatars.githubusercontent.com/u/3524114?v=4)](https://github.com/manicki "manicki (11 commits)")[![Ladsgroup](https://avatars.githubusercontent.com/u/5351225?v=4)](https://github.com/Ladsgroup "Ladsgroup (8 commits)")[![siebrand](https://avatars.githubusercontent.com/u/210297?v=4)](https://github.com/siebrand "siebrand (6 commits)")[![adrianheine](https://avatars.githubusercontent.com/u/139208?v=4)](https://github.com/adrianheine "adrianheine (3 commits)")[![danmichaelo](https://avatars.githubusercontent.com/u/434495?v=4)](https://github.com/danmichaelo "danmichaelo (3 commits)")[![umherirrender](https://avatars.githubusercontent.com/u/1174884?v=4)](https://github.com/umherirrender "umherirrender (2 commits)")[![filbertkm](https://avatars.githubusercontent.com/u/135401?v=4)](https://github.com/filbertkm "filbertkm (2 commits)")[![Southparkfan](https://avatars.githubusercontent.com/u/5605877?v=4)](https://github.com/Southparkfan "Southparkfan (1 commits)")[![legoktm](https://avatars.githubusercontent.com/u/81392?v=4)](https://github.com/legoktm "legoktm (1 commits)")[![Benestar](https://avatars.githubusercontent.com/u/2998254?v=4)](https://github.com/Benestar "Benestar (1 commits)")

---

Tags

datavaluesdatatypes

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/data-values-data-types/health.svg)

```
[![Health](https://phpackages.com/badges/data-values-data-types/health.svg)](https://phpackages.com/packages/data-values-data-types)
```

###  Alternatives

[data-values/data-values

Defines the DataValue interface and some trivial implementations

171.0M22](/packages/data-values-data-values)[data-values/geo

Geographical value objects, parsers and formatters

20631.0k18](/packages/data-values-geo)[data-values/number

Numerical value objects, parsers and formatters

18303.0k14](/packages/data-values-number)[michael-rubel/laravel-couponables

This package provides polymorphic coupon functionality for your Laravel application.

19590.7k1](/packages/michael-rubel-laravel-couponables)[data-values/time

Time value objects, parsers and formatters

10318.6k14](/packages/data-values-time)[loadsys/cakephp_sitemap

A CakePHP Plugin for adding automatic XML and HTML Sitemaps to an app

2819.6k](/packages/loadsys-cakephp-sitemap)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
