imponeer / properties
Add a possibility to define class variables with strict data type behaviors
dev-main
2026-04-02 11:14 UTC
Requires
- php: ^8.3
- ext-curl: *
- ext-fileinfo: *
- ext-mbstring: *
- guzzlehttp/guzzle: ^7.0
- intervention/image: ^4.0
- jetbrains/phpstorm-attributes: ^1.2
- metasyntactical/inmemory-logger: ^2.1
- psr/container: ^2.0
- psr/http-message: ^2.0
- psr/log: ^3.0
- symfony/translation: ^7.3
- symfony/translation-contracts: ^3.6
Requires (Dev)
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^12.0
- squizlabs/php_codesniffer: ^3.7 || ^4.0
Suggests
- ext-gd: Enable gd image for basic image information support
- ext-imagick: Enabled Imageck better image information support
- dev-main
- dev-claude/remove-icms-core-textsanitizer-stub
- dev-codex/update-readme-badges
- dev-claude/let-user-configure-censorstring
- dev-claude/remove-composer-lock
- dev-codex/add-missing-tests
- dev-codex/rename-license-txt-to-license-md
- dev-codex/upgrade-intervention-image-requirement
- dev-codex/make-it-pass-tests
- dev-codex/use-php-version-action-for-ci
- dev-codex/add-phpstan-and-fix-issues
- dev-codex/fix-phpcs-errors
- dev-dependabot/composer/intervention/image-tw-3.0or-tw-4.0
- dev-dependabot/github_actions/shivammathur/setup-php-2.37.0
- dev-dependabot/github_actions/dependabot/fetch-metadata-3.0.0
This package is auto-updated.
Last update: 2026-04-02 11:16:40 UTC
README
Properties
PHP library that lets you define strict, validated class variables (with change tracking and serialization helpers) in one place and reuse them across your own domain classes.
Installation
composer require imponeer/properties
Usage
Quick start:
- Extend
Imponeer\Properties\PropertiesSupport(or implementPropertiesInterfaceyourself). - Define each property in the constructor with
initVar()using aDataTypeenum (or the legacyDTYPE_*constants available onPropertiesInterface). - Use the generated magic accessors or helper methods like
toArray()/assignVars()as you would with normal public properties.
use DateTimeImmutable; use Imponeer\Properties\Enum\DataType; use Imponeer\Properties\PropertiesSupport; final class Article extends PropertiesSupport { public function __construct() { $this->initVar('id', DataType::INTEGER, null, true); $this->initVar('title', DataType::STRING, 'Untitled', true, ['maxlength' => 150]); $this->initVar('published_at', DataType::DATETIME, null, false); } } $article = new Article(); $article->title = 'Hello world'; $article->published_at = new DateTimeImmutable(); var_dump($article->toArray()); // Strictly typed values, ready to persist or render
How to contribute?
If you want to add some functionality or fix bugs, you can fork, change and create pull request. If you are new to Git or GitHub, start with the GitHub Skills “Introduction to GitHub” course.
If you found any bug or have some questions, use issues tab and write there your questions.