Add daily email for 2025-01-31

Keep your PHP code up to date using Rector
This commit is contained in:
Oliver Davies 2025-02-12 00:43:07 +00:00
parent 3a6a0b7a44
commit 3daf22fae2

View file

@ -0,0 +1,25 @@
---
title: Keep your PHP code up to date using Rector
date: 2025-01-31
permalink: daily/2025/01/31/rector
tags:
- software-development
- php
cta: ~
snippet: |
Do you want to keep your PHP code up to date with the latest standards and using the latest features? You can automate this with Rector.
---
Do you want to make it easier to keep your PHP code up to date with the latest standards and using the latest features?
Rector is a tool for refactoring PHP code and it was presets for different versions of PHP.
It can refactor your code to follow best practices such as using early returns, having private methods by default and enabling strict typing - making code cleaner whilst using the latest PHP features.
Once installed, it can be executed and will make changes to your files, but what about keeping it up to date going forward?
Why not add `rector --dry-run` to your CI pipeline and have it checked automatically?
Then, if code is committed that doesn't match the latest standards, the pipeline will fail and the code can be updated.
This will ensure the code is always up to date and you won't be stuck on old or unsupported PHP versions.