PHPackages                             signpostmarv/daft-typed-object - 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. signpostmarv/daft-typed-object

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

signpostmarv/daft-typed-object
==============================

Typed Object, a simplified version of signpostmarv/daft-object

v0.5.5(6y ago)0980↓78.6%[2 PRs](https://github.com/daft-framework/Daft-Typed-Object/pulls)4Apache-2.0PHPPHP ^7.4

Since Aug 18Pushed 3y ago1 watchersCompare

[ Source](https://github.com/daft-framework/Daft-Typed-Object)[ Packagist](https://packagist.org/packages/signpostmarv/daft-typed-object)[ RSS](/packages/signpostmarv-daft-typed-object/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (10)Versions (18)Used By (4)

Copyright 2019 SignpostMarv

Daft-Typed-Object
=================

[](#daft-typed-object)

[![Coverage Status](https://camo.githubusercontent.com/1f2970cff4df9b7fcb898f16a6b019471261d712f7f259c5eb87af0c6f6d6d47/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f646166742d6672616d65776f726b2f446166742d54797065642d4f626a6563742f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/daft-framework/Daft-Typed-Object?branch=master)[![Build Status](https://camo.githubusercontent.com/02a8d29f9a98f9f536401b892205bacb5104b03fb5679fc412cc67a55fd9ceb1/68747470733a2f2f7472617669732d63692e6f72672f646166742d6672616d65776f726b2f446166742d54797065642d4f626a6563742e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/daft-framework/Daft-Typed-Object)[![Type Coverage](https://camo.githubusercontent.com/7795e17ad83a3d627ae0d4d9807ca3523da23eb747d656692869e75085c220c4/68747470733a2f2f73686570686572642e6465762f6769746875622f646166742d6672616d65776f726b2f446166742d54797065642d4f626a6563742f636f7665726167652e737667)](https://shepherd.dev/github/daft-framework/Daft-Typed-Object)

Typed Object, a simplified version of [signpostmarv/daft-object](https://github.com/SignpostMarv/daft-object)

Example
-------

[](#example)

### Immutable

[](#immutable)

```
use SignpostMarv\DaftTypedObject\Immutable as Base;

use SignpostMarv\DaftTypedObject\Immutable as Base;

/**
* @psalm-type DATA = array{id:int, name:string}
*
* @template-extends Base
*/
class Immutable extends Base
{
	const TYPED_PROPERTIES = ['id', 'name'];

	/**
	* @readonly
	*/
	public int $id;

	/**
	* @readonly
	*/
	public string $name;
}
```

### Mutable

[](#mutable)

```
use SignpostMarv\DaftTypedObject\DaftTypedObject as Base;

/**
* @psalm-type DATA = array{id:int, name:string}
*
* @template-extends Base
*/
class Mutable extends Base
{
	const TYPED_PROPERTIES = ['id', 'name'];

	public int $id;

	public string $name;
}
```

### Mutable with `DateTimeImmutable` &amp; nullables

[](#mutable-with-datetimeimmutable--nullables)

```
use DateTimeImmutable;
use SignpostMarv\DaftTypedObject\DaftTypedObject as Base;

/**
* @template T as array{id:int, name:string, date:DateTimeImmutable|null}
* @template S as array{id:int, name:string, date:string|null}
*
* @template-extends Base
*
* @property-read int $id
* @property-read string $name
* @property-read DateTimeImmutable $date
*/
class MutableWithNullables extends Base
{
	const TYPED_PROPERTIES = ['id', 'name', 'date'];

	const TYPED_NULLABLE_PROPERTIES = ['date'];

	/**
	* @var int
	*/
	protected $id;

	/**
	* @var string|null
	*/
	protected $name;

	/**
	* @var DateTimeImmutable|null
	*/
	protected $date;

	/**
	* @template K as key-of
	*
	* @param K $property
	* @param T[K] $value
	*
	* @return S[K]
	*/
	public static function PropertyValueToScalarOrNull(
		string $property,
		$value
	) {
		/**
		* @var T[K]|DateTimeImmutable
		*/
		$value = $value;

		if ($value instanceof DateTimeImmutable) {
			/**
			* @var S[K]
			*/
			return (string) $value->format('Y-m-d');
		}

		/**
		* @var S[K]
		*/
		return parent::PropertyValueToScalarOrNull((string) $property, $value);
	}

	/**
	* @template K as key-of
	*
	* @param K|'date' $property
	* @param S[K] $value
	*
	* @return T[K]
	*/
	public static function PropertyScalarOrNullToValue(
		string $property,
		$value
	) {
		/**
		* @var S[K]|string
		*/
		$value = $value;

		if ('date' === $property && is_string($value)) {
			$out = new DateTimeImmutable($value);
		} else {
			/**
			* @var S[K]
			*/
			$value = $value;

			/**
			* @var T[K]
			*/
			$out = parent::PropertyScalarOrNullToValue(
				(string) $property,
				$value
			);
		}

		/**
		* @var T[K]
		*/
		return $out;
	}
}
```

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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

Total

14

Last Release

2261d ago

PHP version history (2 changes)v0.1.0PHP ^7.3

v0.3.0PHP ^7.4

### Community

Maintainers

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

---

Top Contributors

[![SignpostMarv](https://avatars.githubusercontent.com/u/304403?v=4)](https://github.com/SignpostMarv "SignpostMarv (51 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/signpostmarv-daft-typed-object/health.svg)

```
[![Health](https://phpackages.com/badges/signpostmarv-daft-typed-object/health.svg)](https://phpackages.com/packages/signpostmarv-daft-typed-object)
```

###  Alternatives

[bk2k/extension-helper

Helper for TYPO3 Extension Maintenance

1257.7k21](/packages/bk2k-extension-helper)[moosend/website-tracking

By installing the Moosend PHP Tracking library you are can track page views, product views, add to cart events and successful purchases. You can later use these details to segment your user base, run automations, check how successful your latest promo has been and how many conversions your landing page has led to.

1121.6k1](/packages/moosend-website-tracking)

PHPackages © 2026

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