Download the PHP package simtel/rector-rules without Composer
On this page you can find all versions of the php package simtel/rector-rules. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download simtel/rector-rules
More information about simtel/rector-rules
Files in simtel/rector-rules
Package rector-rules
Short Description Some custom rector rules for use or extend
License MIT
Informations about the package rector-rules
Rector Rules
A collection of custom Rector rules for automated PHP code refactoring.
Overview
This package provides custom Rector rules to help modernize and improve PHP codebases through automated refactoring. Currently includes the RenameFindAndGetMethodCallRector and WithConsecutiveToCallbackRector rules.
Requirements
- PHP 8.3+
- Rector 2.0+
Installation
Clone this repository and install dependencies:
Rules
RenameFindAndGetMethodCallRector
Automatically renames find* methods to get* when they return a non-nullable entity type.
What it does
This rule enforces a naming convention where:
- Methods starting with
findthat return nullable types (e.g.,?User) keep their name - Methods starting with
findthat return non-nullable entity types are renamed toget
This follows the common convention where:
find*methods may returnnullwhen the entity is not foundget*methods always return an entity and throw exceptions when not found
Before
After
Rules for transformation
The rule will rename a method from find* to get* if:
- Method name starts with "find"
- Has a return type declaration
- Return type is not nullable (
?Type) - Return type is not a union type
- Return type is not a primitive type (int, string, bool, float, array, object, mixed, void)
WithConsecutiveToCallbackRector
Replaces deprecated PHPUnit willReturnCallback to ensure compatibility with PHPUnit 10+.
What it does
This rule transforms deprecated withConsecutive method calls to use willReturnCallback with conditional assertions based on invocation count. This is necessary because withConsecutive was deprecated in PHPUnit 9.6 and removed in PHPUnit 10.
Before
After
Usage
Manual Configuration
Create a rector.php configuration file:
Running Rector
Execute the refactoring:
Development
Continuous Integration
This project uses GitHub Actions for automated testing and code quality checks:
- Tests Workflow: Runs PHPUnit tests on PHP 8.3 and 8.4 with both lowest and stable dependencies
- Code Quality Workflow: Performs static analysis with PHPStan, syntax checking, and security audits
- Coverage: Test coverage reports are uploaded to Codecov
Local Development Scripts
Running Tests
Code Analysis
Code Formatting
This project uses Laravel Pint for code formatting, configured to follow PSR-12 standards:
The Pint configuration is stored in pint.json and includes:
- PSR-12 preset
- Short array syntax
- Alphabetical import ordering
- Removal of unused imports
- Trailing commas in multiline arrays
Project Structure
Contributing
- Fork the repository
- Create a feature branch
- Add your changes with tests
- Ensure all tests pass
- Submit a pull request
License
This project is open source. Please check the license file for more details.
Author
Created by Simtel
For more information about Rector, visit https://getrector.org/