PHPackages                             netresearch/agent-php-modernization - 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. netresearch/agent-php-modernization

ActiveAi-agent-skill[Utility &amp; Helpers](/categories/utility)

netresearch/agent-php-modernization
===================================

Netresearch AI skill for PHP 8.x modernization, type safety and legacy code upgrades

v1.14.0(1mo ago)114[1 PRs](https://github.com/netresearch/php-modernization-skill/pulls)(MIT AND CC-BY-SA-4.0)ShellCI passing

Since Dec 16Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/netresearch/php-modernization-skill)[ Packagist](https://packagist.org/packages/netresearch/agent-php-modernization)[ RSS](/packages/netresearch-agent-php-modernization/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (28)Used By (0)

PHP Modernization Skill
=======================

[](#php-modernization-skill)

Expert patterns for modernizing PHP applications to PHP 8.x with type safety, PSR/PER compliance, static analysis tools, and Symfony best practices.

Compatibility
-------------

[](#compatibility)

This is an **Agent Skill** following the [open standard](https://agentskills.io) originally developed by Anthropic and released for cross-platform use.

**Supported Platforms:**

- Claude Code (Anthropic)
- Cursor
- GitHub Copilot
- Other skills-compatible AI agents

> Skills are portable packages of procedural knowledge that work across any AI agent supporting the Agent Skills specification.

Features
--------

[](#features)

- **PHP 8.x Features**: Constructor property promotion, readonly properties and classes, named arguments, enums and match expressions, attributes (replacing annotations), union and intersection types, nullsafe operator
- **Static Analysis Tools**: PHPStan (level 9+), PHPat (architecture testing), Rector (automated refactoring), PHP-CS-Fixer (coding style)
- **PSR/PER Compliance**: Enforces all active PHP-FIG standards (PSR-1, 3, 4, 6, 7, 11, 12, 13, 14, 15, 16, 17, 18, 20) and PER Coding Style
- **Type Safety Patterns**: DTOs and Value Objects over arrays, generic collection typing via PHPDoc, strict typing enforcement, PHPStan level 10 compliance, runtime type validation
- **Symfony Integration**: Dependency injection patterns, service configuration (YAML to PHP), event dispatcher and PSR-14, form handling modernization, security component updates

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

[](#installation)

### Marketplace (Recommended)

[](#marketplace-recommended)

Add the [Netresearch marketplace](https://github.com/netresearch/claude-code-marketplace) once, then browse and install skills:

```
# Claude Code
/plugin marketplace add netresearch/claude-code-marketplace
```

### npx ([skills.sh](https://skills.sh))

[](#npx-skillssh)

Install with any [Agent Skills](https://agentskills.io)-compatible agent:

```
npx skills add https://github.com/netresearch/php-modernization-skill --skill php-modernization
```

### Download Release

[](#download-release)

Download the [latest release](https://github.com/netresearch/php-modernization-skill/releases/latest) and extract to your agent's skills directory.

### Git Clone

[](#git-clone)

```
git clone https://github.com/netresearch/php-modernization-skill.git
```

### Composer (PHP Projects)

[](#composer-php-projects)

```
composer require netresearch/php-modernization-skill
```

Requires [netresearch/composer-agent-skill-plugin](https://github.com/netresearch/composer-agent-skill-plugin).

Usage
-----

[](#usage)

This skill is automatically triggered when:

- Modernizing PHP codebases to PHP 8.1/8.2/8.3/8.4/8.5
- Implementing type safety and strict typing
- Setting up static analysis tools (PHPStan, PHPat, Rector, PHP-CS-Fixer)
- Ensuring PSR/PER compliance
- Adopting Symfony best practices
- Achieving PHPStan level 9+/10 compliance
- Upgrading from older PHP versions
- Implementing generic collection patterns

Example queries:

- "Modernize this PHP class to PHP 8.2"
- "Add strict type safety with PHPStan level 10"
- "Set up PHPat architecture tests"
- "Configure Rector for PHP 8.3 upgrade"
- "Ensure this code follows PSR standards"
- "Convert YAML service configuration to PHP"
- "Implement readonly class with constructor promotion"
- "Make this HTTP client PSR-18 compliant"

Structure
---------

[](#structure)

```
php-modernization-skill/
├── SKILL.md                              # Skill metadata and core patterns
├── references/
│   ├── static-analysis-tools.md          # PHPStan, PHPat, Rector, PHP-CS-Fixer
│   ├── psr-per-compliance.md             # Active PSR and PER standards
│   ├── php8-features.md                  # PHP 8.0-8.5 feature adoption patterns
│   ├── type-safety.md                    # Type system maximization strategies
│   ├── symfony-patterns.md               # Modern Symfony architecture
│   ├── phpstan-compliance.md             # PHPStan configuration details
│   └── migration-strategies.md           # Version upgrade planning
└── scripts/
    └── verify-php-project.sh             # Verification script

```

Expertise Areas
---------------

[](#expertise-areas)

### Required Static Analysis Tools

[](#required-static-analysis-tools)

All modern PHP projects must use these tools:

ToolPurposeRequirement[PHPStan](https://phpstan.org/)Type checking, bug detection**Level 9 minimum**, level 10 recommended[PHPat](https://www.phpat.dev/)Architecture testing**Required** for projects with defined architecture[Rector](https://getrector.com/)Automated refactoring**Required** for modernization[PHP-CS-Fixer](https://cs.symfony.com/)Coding style**Required** with `@PER-CS`### PSR/PER Compliance

[](#psrper-compliance)

All modern PHP code must follow active PHP-FIG standards:

StandardPurposeRequirementPSR-1Basic Coding**Required**PSR-4Autoloading**Required**PER Coding StyleCoding Style**Required** (supersedes PSR-12)PSR-3LoggerUse when loggingPSR-6/16CacheUse when cachingPSR-7/17/18HTTPUse for HTTP clientsPSR-11ContainerUse for DI containersPSR-14EventsUse for event dispatchingPSR-15MiddlewareUse for HTTP middlewarePSR-20ClockUse for time-dependent code**Source of truth:**  and

### PHP 8.x Features

[](#php-8x-features)

- Constructor property promotion
- Readonly properties and classes
- Named arguments
- Enums and match expressions
- Attributes (replacing annotations)
- Union and intersection types
- Nullsafe operator

### Type Safety Patterns

[](#type-safety-patterns)

- **DTOs and Value Objects over arrays** (see below)
- Generic collection typing via PHPDoc
- Strict typing enforcement
- PHPStan level 9+/10 compliance
- Runtime type validation

### DTOs and Value Objects (Required)

[](#dtos-and-value-objects-required)

**Never pass or return raw arrays** for structured data. Use typed objects instead:

Instead ofUse`array $userData``UserDTO $user``array{email: string, name: string}``readonly class UserDTO``array $config``readonly class Config` or Value Object`array $request``RequestDTO::fromRequest($request)``return ['success' => true, 'data' => $x]``return new ResultDTO($x)`**Why:**

- Arrays lack type safety at runtime
- No IDE autocompletion for array keys
- PHPStan cannot verify array shapes across boundaries
- Refactoring arrays is error-prone

**Pattern:**

```
// ❌ Bad: Array passing
public function createUser(array $data): array

// ✅ Good: DTO pattern
public function createUser(CreateUserDTO $dto): UserDTO
```

See `references/request-dtos.md` for complete patterns including Request DTOs, Command/Query DTOs, and Value Objects

### Enums (Required)

[](#enums-required)

**Never use string/integer constants or arrays** for fixed sets of values. Use PHP 8.1+ backed enums instead:

Instead ofUse`const STATUS_DRAFT = 'draft'``enum Status: string { case Draft = 'draft'; }``['draft', 'published', 'archived']``Status::cases()``string $status` parameter`Status $status` parameter`switch ($status)``match($status)` with enum**Why enums are required:**

- Compile-time type checking (invalid values caught before runtime)
- IDE autocompletion for all valid values
- Exhaustive `match()` enforcement (compiler ensures all cases handled)
- Methods encapsulate related logic (labels, colors, validation)
- Self-documenting API with clear valid options

**Pattern:**

```
// ❌ Bad: String constants
class Order {
    public const STATUS_DRAFT = 'draft';
    public const STATUS_PENDING = 'pending';
    public const STATUS_COMPLETED = 'completed';

    public function setStatus(string $status): void // Any string accepted!
}

// ✅ Good: Backed enum
enum OrderStatus: string {
    case Draft = 'draft';
    case Pending = 'pending';
    case Completed = 'completed';

    public function label(): string {
        return match($this) {
            self::Draft => 'Draft Order',
            self::Pending => 'Awaiting Payment',
            self::Completed => 'Order Complete',
        };
    }
}

class Order {
    public function setStatus(OrderStatus $status): void // Only valid statuses!
}
```

See `references/php8-features.md` for complete enum patterns including methods, validation, and database integration.

### Symfony Integration

[](#symfony-integration)

- Dependency injection patterns
- Service configuration (YAML to PHP)
- Event dispatcher and PSR-14
- Form handling modernization
- Security component updates

Migration Checklist
-------------------

[](#migration-checklist)

### Static Analysis Setup

[](#static-analysis-setup)

- PHPStan at level 9+ (level 10 for new projects)
- PHPat architecture tests for layer dependencies
- Rector with `LevelSetList::UP_TO_PHP_83` and `SetList::CODE_QUALITY`
- PHP-CS-Fixer with `@PER-CS` ruleset

### PHP Version Upgrade

[](#php-version-upgrade)

- Update composer.json PHP requirement
- Enable strict\_types in all files
- Replace annotations with attributes
- Convert to constructor property promotion
- Use readonly where applicable
- Replace switch with match expressions
- **Replace string/int constants with backed enums**
- **Use enums for all status, type, and option values**

### PSR/PER Compliance

[](#psrper-compliance-1)

- Configure PSR-4 autoloading in composer.json
- Enforce PER Coding Style via PHP-CS-Fixer (`@PER-CS`)
- Type-hint against PSR interfaces (not implementations)
- Use PSR-3 for logging
- Use PSR-14 for event dispatching
- Use PSR-18/17 for HTTP clients
- Use PSR-20 for time-dependent code

### Type Safety Enhancement

[](#type-safety-enhancement)

- Add return types to all methods
- Add parameter types to all methods
- Use union types instead of mixed
- **Replace array parameters with DTOs**
- **Replace array returns with typed objects**
- **Use Value Objects for domain concepts (Email, Money, etc.)**
- **Use backed enums for all fixed value sets (status, type, options)**
- Add @template annotations for generics
- Remove @var annotations where inferrable

Related Skills
--------------

[](#related-skills)

- **security-audit-skill**: Security patterns for PHP applications
- **typo3-testing-skill**: PHPUnit patterns (applicable to any PHP project)

License
-------

[](#license)

This project uses split licensing:

- **Code** (scripts, workflows, configs): [MIT](LICENSE-MIT)
- **Content** (skill definitions, documentation, references): [CC-BY-SA-4.0](LICENSE-CC-BY-SA-4.0)

See the individual license files for full terms.

Credits
-------

[](#credits)

Developed and maintained by [Netresearch DTT GmbH](https://www.netresearch.de/).

---

**Made with love for Open Source by [Netresearch](https://www.netresearch.de/)**

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance89

Actively maintained with recent releases

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 99.2% 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 ~4 days

Total

25

Last Release

48d ago

### Community

Maintainers

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

---

Top Contributors

[![CybotTM](https://avatars.githubusercontent.com/u/326348?v=4)](https://github.com/CybotTM "CybotTM (124 commits)")[![renovate[bot]](https://avatars.githubusercontent.com/in/2740?v=4)](https://github.com/renovate[bot] "renovate[bot] (1 commits)")

---

Tags

agent-skillsai-agentopen-standard

### Embed Badge

![Health badge](/badges/netresearch-agent-php-modernization/health.svg)

```
[![Health](https://phpackages.com/badges/netresearch-agent-php-modernization/health.svg)](https://phpackages.com/packages/netresearch-agent-php-modernization)
```

PHPackages © 2026

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