Workshop in English - UK at Longhorn PHP 2025
                                                    
                            Track Name:
                                                            Main Ballroom
                                                                                    
                                                    
                                                        View Slides: https://www.daveliddament.co.uk/talks/writing-rector-rules_longhorn.pdf 
                                                                                                                                                                    
                        
                        Short URL: https://joind.in/talk/c2194
                        (QR-Code (opens in new window))
                    
Are you working on a legacy project that is in need of upgrading?
Do you need to make changes to your project that require the same repetitive refactor applied to your codebase hundreds of times and no existing tools can to help automate the task?
If either of these scenarios are familiar you've probably had a look at or used Rector. Rector has hundreds of rules that help with automating upgrades and refactors.
However what happens if you need to do something custom to your project, that is not available with an existing Rector Rule? In this case you can create your own custom Rector rule.
This tutorial will teach you how to create custom Rector rules that can automate tasks specific to your project. By the end of this tutorial you'll know how to create your own rules and have a framework for creating rules for whatever refactor you wish to automate.
Comments
Please login to leave a comment
Great tutorial! I really enjoyed how he started off with energy — the examples were clear, practical, and very well prepared. I’m feeling more confident using Rector now and won’t hesitate to write custom rules when my IDE doesn’t already support them or when no existing rule fits. Thanks for the inspiring session!
A really great overview of Rector with practical exercises that get people writing configurable, flexible, and tested(!) rectors. This helped fill in some gaps in my experience, and I'm excited to take this newfound knowledge back to work!
Starting with writing your own custom rules was a better experience than trying to 'learn rector' via other tutorials. This approach was completely backwards from how I've approached rector in the past, and Dave's approach worked quite well. Certainly for me, but the other folks around me were all engaged and 'getting it' too.
Really clear and approachable workshop. Dave did a great job answering questions and making a pretty intimidating topic feel much more manageable.
Excellent hands-on session. Just the right level of complexity. Hopefully I remember it when I next do a major upgrade on one of my libraries so I can try to include a migration path. :-)