PHPackages                             haspadar/psalm-eo-rules - 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. [Testing &amp; Quality](/categories/testing)
4. /
5. haspadar/psalm-eo-rules

ActiveLibrary[Testing &amp; Quality](/categories/testing)

haspadar/psalm-eo-rules
=======================

Psalm plugin providing Elegant Objects rules: forbids static, null, isset, empty, instanceof, promotes immutability and object composition

v0.5.0(6mo ago)0581MITPHPPHP ^8.2CI passing

Since Nov 3Pushed 6mo agoCompare

[ Source](https://github.com/haspadar/psalm-eo-rules)[ Packagist](https://packagist.org/packages/haspadar/psalm-eo-rules)[ RSS](/packages/haspadar-psalm-eo-rules/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (7)Versions (13)Used By (1)

Psalm EO Rules
==============

[](#psalm-eo-rules)

[![PHP Version](https://camo.githubusercontent.com/91cb649feb797bb507583f5f4e88d0727695b25c0a7265b8b1c7448848b13ef9/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e322d626c7565)](https://www.php.net/releases/8.2/)[![CI](https://github.com/haspadar/psalm-eo-rules/actions/workflows/ci.yml/badge.svg)](https://github.com/haspadar/psalm-eo-rules/actions/workflows/ci.yml)

---

📦 About
-------

[](#-about)

**Psalm EO Rules** is a [Psalm](https://psalm.dev) plugin that codifies the principles from [Elegant Objects](https://www.yegor256.com/elegant-objects.html). Every rule enforces immutability, explicit composition, and clear ownership.

The plugin focuses on eliminating hidden shared state, encouraging immutable objects, and making composition and contracts explicit.

---

⚙️ Installation
---------------

[](#️-installation)

```
composer require --dev haspadar/psalm-eo-rules
```

Enable the plugin in `psalm.xml`:

```

```

Requirements: PHP 8.1+ and Psalm 5.25 or newer.

> Suppressions are supported for every rule listed below. Use `@psalm-suppress IssueName` sparingly when a deviation is intentional.

---

🧭 Rules
-------

[](#-rules)

Issue codeTriggerEO rationale`NoStaticMethodDeclaration`Declaring a `static function`Static helpers break encapsulation and make behaviour context dependent`NoStaticProperty`Declaring or reading a static propertyShared state hides dependencies and produces hidden coupling`NoMutableProperty`Property declared without the `readonly` flagObjects should be immutable after construction`NoNullableType`Parameter typed as `?Type`Optional behaviour should be modelled explicitly (Optional, Null Object, Either, etc.)`NoNull`Using `null` in returns, assignments, or as function/method arguments`null` represents absence and breaks object integrity. Prefer explicit `Optional` or `NullObject``NonFinalOrAbstractClass`Class that is neither `final` nor `abstract`Every class should either be closed for inheritance or clearly designed for extension`NoInterfaceImplementation`Concrete class that does not implement any interfaceKeeps polymorphism explicit and substitution possible`NoTraitUsage`Using traits in a classTraits blur object boundaries; prefer composition or delegation`NoConstructorException``throw` statements inside a constructorConstructors must not fail; delegate validation to factories`NoProtected`Protected methods or propertiesWithout subclassing there is no need for protected members---

🚀 Usage Tips
------------

[](#-usage-tips)

- Add selected suppressions near the expression or class you need to relax: `/** @psalm-suppress NoEmpty */`.
- Combine with Psalm baselines to track legacy violations separately from new code.
- Rules rely on Psalm’s standard autoloader; ensure Composer’s autoload file is available when Psalm runs.

---

🧪 Tests
-------

[](#-tests)

Each rule has a dedicated PHPUnit suite that executes Psalm against curated fixtures and asserts on the reported issues. Run everything locally with:

```
composer test
```

Additional helpers:

- `composer psalm` – run Psalm on the plugin itself
- `composer analyze` – run PHPStan
- `composer fix` – apply coding standards

The CI workflow mirrors these steps.

---

🤝 Contributing
--------------

[](#-contributing)

1. Fork and branch from `main`.
2. Keep fixtures under `tests/Fixtures/`; positive and negative cases should be explicit.
3. Add a TestDox description for every scenario so failures read naturally in CI output.
4. Run `composer test` before submitting a PR.

---

📄 License
---------

[](#-license)

[MIT](LICENSE)

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance67

Regular maintenance activity

Popularity8

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity45

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

Total

6

Last Release

191d ago

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

v0.3.0PHP ^8.2

### Community

Maintainers

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

---

Top Contributors

[![haspadar](https://avatars.githubusercontent.com/u/1282194?v=4)](https://github.com/haspadar "haspadar (30 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Psalm, Rector

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/haspadar-psalm-eo-rules/health.svg)

```
[![Health](https://phpackages.com/badges/haspadar-psalm-eo-rules/health.svg)](https://phpackages.com/packages/haspadar-psalm-eo-rules)
```

###  Alternatives

[phpspec/prophecy

Highly opinionated mocking framework for PHP 5.3+

8.5k551.7M682](/packages/phpspec-prophecy)[vimeo/psalm

A static analysis tool for finding errors in PHP applications

5.8k77.5M6.7k](/packages/vimeo-psalm)[brianium/paratest

Parallel testing for PHP

2.5k118.8M754](/packages/brianium-paratest)[beberlei/assert

Thin assertion library for input validation in business models.

2.4k96.9M570](/packages/beberlei-assert)[mikey179/vfsstream

Virtual file system to mock the real file system in unit tests.

1.4k108.0M2.7k](/packages/mikey179-vfsstream)[orchestra/testbench

Laravel Testing Helper for Packages Development

2.2k39.1M32.1k](/packages/orchestra-testbench)

PHPackages © 2026

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