ENGLISH

Rector - The Power of Automated Refactorin

Book information

Language
english
Format
PDF
Filesize
894 kB (914953 bytes)
Pages
\190
Time added
2021-07-11 13:42:53

Description

Table of Contents Preface A Trainer's Journey The Other Side Who's Fault is It? From Blame to Pain From Pain to Idea From Idea to First Real Reconstructor We've Just Started, Now You Get on Board Introduction What is Rector? Who Should Read This Book? An Overview of the Contents About the Code Samples About the Authors Matthias Noback Tomas Votruba Acknowledgements We Want Your Feedback Programmatically Modifying PHP Code Introduction Primitive Ways of Modifying Code Tokenizing PHP Code Parsing PHP Tokens: the Abstract Syntax Tree Converting the AST Back to PHP Code Manipulating the AST Node Visitors Manipulating the AST with a Node Visitor Built-in Node Visitors Connecting Nodes Resolving Fully-qualified Names Finding Nodes Summary PHP Tools in the Game Introduction Working Together with Giants 2007 to 2021 Timeline The Primary Feature 1. Coding Standard Tools PHP_CodeSniffer PHP CS Fixer EasyCodingStandard 2. Static Analyzers PHP-Parser PHPStan Psalm 3. Instant Upgrade Tools Symfony-Upgrade-Fixer Rector 4. Instant Downgrade Tools PHP-Backporter Galapagos Transphpilea 7to5 Rector When to Use Which Tool? Is Your Project Bare Without Any Tools? Run Rector First, Then Polish with Coding Standards Recommended Tools Summary Creating Your First Rector Rule Introduction What's a Rector Rule? Creating a Custom Rule Extending AbstractRector Finding the Right Node Class Running a Single Rule Refactoring the Method Call Node What Is the Type of a Variable? What if We Run Rector Twice? Effectivity Beats Perfection Summary Test-driven Rule Development Introduction Migrating from DateTime to DateTimeImmutable Creating a Test Class Adding First Test Fixture Making the First Test Pass Narrowing the Scope of the Refactoring Capturing the Return Value of modify() Skipping Calls On Classes That Are Not DateTime Summary More Testing Techniques Testing Multiple Rules Combined Rules Should Be Idempotent Removing the Clone Step Comparing Return Values to Validate Correctness Shouldn't You Start with a Rule Set Test? Low-Hanging Fruit First Create a Configurable Generic Rule Using a Configurable Instead of a Custom Rule Making Rule Behavior Configurable Configurable Rule Makes Hidden Assumptions Explicit Using Supporting Classes in Fixtures Summary Continuous Rectifying Introduction The Next Member of Your Team Turning a Junior Into a Senior on Day 1 Who's to Blame? What Does it Look Like to Work with Rector in CI? How Rector is Rectifying Itself Work First, Enjoy Later Removing Boring Work Opens Your Creativity Summary Rector + GitHub Actions = Next Member of Your Team Introduction What Are The Steps for a Rector Run? How to Add Rector to GitHub Actions 1. Generic PHP Setup 2. Rector Setup What Feedback Do We Get? How to Work with Rector's Output? 1. Manual Changes 2. Run Rector Locally 3. Let Rector Code for Us in Pull Requests What is The Work We Want to Automate? Make Your Rector Workflow Come Alive Make Rector Push Changes Summary The Future of Instant Upgrades Introduction Removing Legacy How Can We Be So Confident? No Backward-Compatibility Breaks and No Backward-Compatibility A Bot That Sends Pull-Requests Daily Instant Upgrades on Click PHP Stands Out Epilogue

Similar books