PHPackages                             data-values/common - 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. data-values/common

ActiveLibrary

data-values/common
==================

Contains common implementations of the interfaces defined by DataValuesInterfaces

1.2.0(1y ago)11934.5k↑54.9%912GPL-2.0-or-laterPHPPHP &gt;=7.4CI passing

Since Nov 17Pushed 4mo ago13 watchersCompare

[ Source](https://github.com/DataValues/Common)[ Packagist](https://packagist.org/packages/data-values/common)[ Docs](https://github.com/DataValues/Common)[ RSS](/packages/data-values-common/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (18)Used By (12)

DataValues Common
=================

[](#datavalues-common)

DataValues Common is a small library built on top of DataValues that provides common implementations of the DataValues, ValueParsers, ValueFormatters, and ValueValidators interfaces.

It is part of the [DataValues set of libraries](https://github.com/DataValues).

[![Build Status](https://camo.githubusercontent.com/971833a23bfebe301e42e7413d933326aaf95ef4625b650157e06679bdc02268/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f4461746156616c7565732f436f6d6d6f6e2f7068702e796d6c3f6272616e63683d6d6173746572)](https://github.com/DataValues/Common/actions/workflows/php.yml?query=workflow%3APHP)[![Code Coverage](https://camo.githubusercontent.com/f81f062f0271560b18f6fc95bc2db705f18b296fce3f3c6cd988cdc7b799989f/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4461746156616c7565732f436f6d6d6f6e2f6261646765732f636f7665726167652e706e673f733d36343332643239626633666564303638393935653636303933616435326530353330393961393136)](https://scrutinizer-ci.com/g/DataValues/Common/)

On [Packagist](https://packagist.org/packages/data-values/common): [![Latest Stable Version](https://camo.githubusercontent.com/54333916f99a73be2b3d6e8a807dd2e2280d475084774f5a4f32d319b66db0ce/68747470733a2f2f706f7365722e707567782e6f72672f646174612d76616c7565732f636f6d6d6f6e2f762f737461626c65)](https://packagist.org/packages/data-values/common)[![Download count](https://camo.githubusercontent.com/d5ad302515bb75761913451ad8e44b9aeee722295563972d9a58b4e134d91905/68747470733a2f2f706f7365722e707567782e6f72672f646174612d76616c7565732f636f6d6d6f6e2f646f776e6c6f616473)](https://packagist.org/packages/data-values/common)

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

[](#installation)

The recommended way to use this library is via [Composer](http://getcomposer.org/).

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

```
{
    "require": {
        "data-values/common": "^1.1.0"
    }
}

```

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 Github Actions.

### Running the tests

[](#running-the-tests)

For tests only

```
composer test

```

For style checks only

```
composer cs

```

For a full CI run

```
composer ci

```

Authors
-------

[](#authors)

DataValues Common has been written by the Wikidata team, as [Wikimedia Germany](https://wikimedia.de)employees for the [Wikidata project](https://wikidata.org/).

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

[](#release-notes)

### 1.2.0 (2024-12-10)

[](#120-2024-12-10)

- Dropped support for PHP 7.2 and PHP 7.3
- Improved support for PHP 8.4 by explicitly declaring nullable types
- Upgraded codesniffer rules to current `mediawiki/mediawiki-codesniffer` version (45.0.0)
- Added testing with PHP 8.1 up to 8.4

### 1.1.0 (2022-10-21)

[](#110-2022-10-21)

- Improved compatibility with PHP 8.1; in particular, the new `__serialize`/`__unserialize` methods are implemented now (in addition to the still supported `Serializable` interface). Make sure to also use `data-values/data-values` version 3.1.0 (or later) to keep hashes stable.

### 1.0.0 (2021-01-22)

[](#100-2021-01-22)

- Updated minimum required PHP version from 5.5.9 to 7.2
- Added compatibility with `data-values/data-values` 3.x
- Added compatibility with `data-values/interfaces` 1.x
- Removed the `DATAVALUES_COMMON_VERSION` constant
- Deprecated `getSortKey` methods from `DataValue` implementations
- Classes in the `ValueParsers\Test` namespace are now package private. Notably `ValueParserTestBase` and `StringValueParserTest`
- The `StringFormatter` constructor does not accept options any more
- `StringParser::parse` now throws a `ParseException` instead of an `InvalidArgumentException`
- Added `TrimmingStringNormalizer`
- Made `FORMAT_NAME` constants in the Parser classes private

### 0.4.3 (2019-06-28)

[](#043-2019-06-28)

- Fixed typo in error message in `DispatchingValueParser`

### 0.4.2 (2018-08-16)

[](#042-2018-08-16)

- The component can now be installed together with DataValues 2.x

### 0.4.1 (2017-08-09)

[](#041-2017-08-09)

- Fixed version number not updated before.

### 0.4.0 (2017-08-09)

[](#040-2017-08-09)

- Deprecated `MonolingualTextValue::newFromArray` and `MultilingualTextValue::newFromArray`
- `MismatchingDataValueTypeException` no longer modifies custom error messages in its constructor
- Updated minimal required PHP version from 5.3 to 5.5.9
- Updated the MediaWiki entry point to use the extension.json format

### 0.3.1 (2015-08-14)

[](#031-2015-08-14)

- The component can now be installed together with DataValues Interfaces 0.1.5

### 0.3.0 (2015-08-11)

[](#030-2015-08-11)

- Added `DispatchingValueParser`
- Added `StringNormalizer` interface
- Added `NullStringNormalizer`
- Added `StringParser`
- Dropped deprecated constant `DataValuesCommon_VERSION`, use `DATAVALUES_COMMON_VERSION` instead
- Dropped `ValueParserTestBase::getParserClass`
- Dropped `ValueParserTestBase::newParserOptions`
- Made `ValueParserTestBase::getInstance` abstract
- Made `ValueParserTestBase::invalidInputProvider` abstract
- Lowered visibility of all class fields to private

### 0.2.3 (2014-10-09)

[](#023-2014-10-09)

- Introduced `FORMAT_NAME` class constants on ValueParsers in order to use them as expectedFormat
- Changed ValueParsers to pass rawValue and expectedFormat arguments when constructing a `ParseException`
- Installation together with DataValues 1.x is now supported

### 0.2.2 (2014-04-11)

[](#022-2014-04-11)

- Added `MismatchingDataValueTypeException`

### 0.2.1 (2014-03-12)

[](#021-2014-03-12)

- Minor code cleanup
- Improved PHPUnit bootstrap

### 0.2.0 (2013-12-16)

[](#020-2013-12-16)

- Added FloatParser (moved from data-values/number)
- Added IntParser (moved from data-values/number)

### 0.1.1 (2013-11-22)

[](#011-2013-11-22)

- Fixed link in the MediaWiki credits

### 0.1.0 (2013-11-17)

[](#010-2013-11-17)

Initial release with these features:

- Several DataValue implementations
    - MonolingualTextValue
    - MultilingualTextValue
- Several ValueFormatter implementations
    - StringFormatter
- Several ValueParser implementations
    - BoolParser
    - DecimalParser
    - NullParser

Links
-----

[](#links)

- [DataValues Common on Packagist](https://packagist.org/packages/data-values/common)

###  Health Score

57

—

FairBetter than 98% of packages

Maintenance60

Regular maintenance activity

Popularity48

Moderate usage in the ecosystem

Community37

Small or concentrated contributor base

Maturity72

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 ~269 days

Recently: every ~497 days

Total

16

Last Release

525d ago

Major Versions

0.4.x-dev → 1.0.02021-01-25

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

1.0.0PHP &gt;=7.2.0

1.2.0PHP &gt;=7.4

### Community

Maintainers

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

![](https://avatars.githubusercontent.com/u/22235?v=4)[Stefan Wasilewski](/maintainers/SMW)[@smw](https://github.com/smw)

![](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 (130 commits)")[![thiemowmde](https://avatars.githubusercontent.com/u/6576639?v=4)](https://github.com/thiemowmde "thiemowmde (60 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 (14 commits)")[![lucaswerkmeister](https://avatars.githubusercontent.com/u/2346599?v=4)](https://github.com/lucaswerkmeister "lucaswerkmeister (8 commits)")[![itamargiv](https://avatars.githubusercontent.com/u/6132917?v=4)](https://github.com/itamargiv "itamargiv (7 commits)")[![tobijat](https://avatars.githubusercontent.com/u/2997252?v=4)](https://github.com/tobijat "tobijat (6 commits)")[![filbertkm](https://avatars.githubusercontent.com/u/135401?v=4)](https://github.com/filbertkm "filbertkm (4 commits)")[![Ladsgroup](https://avatars.githubusercontent.com/u/5351225?v=4)](https://github.com/Ladsgroup "Ladsgroup (3 commits)")[![DanweDE](https://avatars.githubusercontent.com/u/101926?v=4)](https://github.com/DanweDE "DanweDE (3 commits)")[![manicki](https://avatars.githubusercontent.com/u/3524114?v=4)](https://github.com/manicki "manicki (3 commits)")[![reedy](https://avatars.githubusercontent.com/u/67615?v=4)](https://github.com/reedy "reedy (3 commits)")[![adrianheine](https://avatars.githubusercontent.com/u/139208?v=4)](https://github.com/adrianheine "adrianheine (2 commits)")[![codders](https://avatars.githubusercontent.com/u/17782?v=4)](https://github.com/codders "codders (2 commits)")[![AlaaSarhan](https://avatars.githubusercontent.com/u/1851753?v=4)](https://github.com/AlaaSarhan "AlaaSarhan (2 commits)")[![zonuexe](https://avatars.githubusercontent.com/u/822086?v=4)](https://github.com/zonuexe "zonuexe (1 commits)")[![JonasKress](https://avatars.githubusercontent.com/u/13198391?v=4)](https://github.com/JonasKress "JonasKress (1 commits)")[![jaakristioja](https://avatars.githubusercontent.com/u/2684083?v=4)](https://github.com/jaakristioja "jaakristioja (1 commits)")[![legoktm](https://avatars.githubusercontent.com/u/81392?v=4)](https://github.com/legoktm "legoktm (1 commits)")[![tstarling](https://avatars.githubusercontent.com/u/389141?v=4)](https://github.com/tstarling "tstarling (1 commits)")

---

Tags

wikidatadatavaluesvalueparsersvalueformattersvaluevalidators

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[data-values/number

Numerical value objects, parsers and formatters

18303.0k14](/packages/data-values-number)[data-values/time

Time value objects, parsers and formatters

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

Geographical value objects, parsers and formatters

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

Small standalone library for representing differences between data structures, computing such differences, and applying them as patches

2041.6M12](/packages/diff-diff)[data-values/data-values

Defines the DataValue interface and some trivial implementations

171.0M22](/packages/data-values-data-values)[wikibase/data-model

PHP implementation of the Wikibase DataModel

37243.3k23](/packages/wikibase-data-model)

PHPackages © 2026

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