Download the PHP package valkyrja/ci-rector without Composer
On this page you can find all versions of the php package valkyrja/ci-rector. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download valkyrja/ci-rector
More information about valkyrja/ci-rector
Files in valkyrja/ci-rector
Package ci-rector
Short Description Rector for the Valkyrja Project.
License MIT
Homepage https://www.valkyrja.io/
Informations about the package ci-rector
Valkyrja Rector
Shared Rector configuration for Valkyrja PHP projects — a reusable rule set, custom Rector rules, and a workflow that enforce consistent automated refactoring across consuming repositories.
Overview
This repository contains two things:
Valkyrja\Rector\Rules— a reusableRectorConfigBuilderfactory that wires up all rules used across the Valkyrja monorepo. Drop it into anyrector.phpconfig and set your paths on the returned builder.- Custom Rector rules — project-specific refactoring rules that fill gaps in the built-in Rector library.
Installation
Usage
Call Rules::getConfig() from your rector.php configuration file and set
the source paths on the returned builder:
getConfig() takes no arguments and returns a RectorConfigBuilder. Chain
any additional Rector configuration — paths, skip rules, PHP version sets,
etc. — directly on the returned builder before returning it.
Run Rector as normal:
Or in dry-run mode to preview changes without writing them:
Configuration Details
Parallel Execution
withParallel() is enabled, allowing Rector to process files concurrently
across multiple worker processes.
Import Names
withImportNames(removeUnusedImports: true) is set, so Rector will:
- Add fully-qualified
useimports for any names that aren't already imported - Remove
usestatements that are no longer referenced
Rules
Built-in Rules
| Rule | Description |
|---|---|
AddVoidReturnTypeWhereNoReturnRector |
Adds : void return type to methods that have no return statement |
AddOverrideAttributeToOverriddenMethodsRector |
Adds #[Override] attribute to methods that override a parent |
ConvertStaticToSelfRector |
Converts static:: to self:: inside non-final classes where late static binding is not needed |
ExplicitNullableParamTypeRector |
Converts ?Type param declarations to Type\|null union syntax |
NewMethodCallWithoutParenthesesRector |
Removes unnecessary parentheses from new expressions used directly in method chains (PHP 8.4) |
RemoveParentCallWithoutParentRector |
Removes parent::method() calls when no parent class exists |
RemoveUselessAliasInUseStatementRector |
Removes aliases in use statements where the alias matches the class's own short name |
RemoveUselessParamTagRector |
Removes @param PHPDoc tags whose type is already expressed in the signature |
RemoveUselessReturnTagRector |
Removes @return PHPDoc tags whose type is already expressed in the signature |
SeparateMultiUseImportsRector |
Splits use A, B; into individual use A; use B; statements |
StaticToSelfOnFinalClassRector |
Converts static:: to self:: inside final classes |
Custom Rules
RemoveNonConflictingAliasInUseStatementRector
Valkyrja\Rector\CodingStyle\Rector\Stmt\RemoveNonConflictingAliasInUseStatementRector
Removes aliases from use statements when the alias serves no purpose —
i.e. when nothing in the file would conflict if the alias were dropped.
The built-in RemoveUselessAliasInUseStatementRector only removes an alias
when it is identical to the imported class's short name. This rule goes
further: it removes the alias whenever keeping it is unnecessary, checking
for conflicts against:
- Other
usestatements in the file (by class name and by alias) - The file's own class, interface, trait, or enum name
When the alias is removed, all references to it throughout the file —
including PHPDoc comments, type declarations, extends, implements, and
use (traits) — are rewritten to the unaliased short name.
Before:
After:
An alias is preserved whenever it would cause a naming conflict — for example when two imports share the same short name, or when the short name clashes with the file's own class name.
Workflows
The _workflow-call.yml reusable
workflow runs Rector against the calling repository's source. It is
designed to be called from other repositories via workflow_call.
Inputs
| Input | Type | Default | Description |
|---|---|---|---|
paths |
string | — | Required. YAML filter spec with two keys: ci (CI config files that trigger a base-branch fetch) and files (all files that trigger the check). |
post-pr-comment |
boolean | true |
Post a PR comment on failure and remove it on success. Disable when the calling workflow handles its own reporting. |
composer-options |
string | '' |
Extra flags passed to every composer install step (e.g. --ignore-platform-req=ext-openswoole). |
php-version |
string | '8.4' |
PHP version to use. |
ci-directory |
string | '.github/ci/rector' |
Path to the CI directory containing composer.json and the tool config. |
extensions |
string | 'mbstring, intl' |
PHP extensions to install via shivammathur/setup-php. |
Usage
secrets: inherit is required to pass the VALKYRJA_GHA_APP_ID and
VALKYRJA_GHA_PRIVATE_KEY org secrets used for PR comments.
Contributing
See CONTRIBUTING.md for the submission process and
VOCABULARY.md for the terminology used across Valkyrja.
Security Issues
If you discover a security vulnerability, please follow our disclosure procedure.
License
Licensed under the MIT license. See
LICENSE.md.
