View on GitHub

RefactoringPHP

A PHP version of the refactors from Refactoring: Improving the Design of Existing Code (Second Edition) by Martin Fowler

Refactor Listing

Chapter 06 - A First Set of Refactorings

Extract Function (106)

Inline Function (115)

Extract Variable (119)

Inline Variable (123)

Change Function Declaration (124)

Encapsulate Variable (132)

Rename Variable (137)

Introduce Parameter Object (140)

Combine Functions Into Class (144)

Combine Functions into Transform (149)

Split Phase

Chapter 07 - Encapsulation

Encapsulate Record (162)

Encapsulate Collection (170)

Replace Primitive with Object (174)

Replace Temp with Query (178)

Extract Class (182)

Inline Class (186)

Hide Delegate (189)

Remove Middle Man (192)

Substitute Algorithm (195)

Chapter 08 - Moving Features

Move Function (198)

Move Field (207)

Move Statements into Function (213)

Move Statements to Callers (217)

Replace Inline Code with Function Call (222)

Slide Statements (223)

Split Loop (227)

Replace Loop with Pipeline (231)

Remove Dead Code (237)

Chapter 09 - Organizing Data

Split Variable (240)

Rename Field (244)

Replace Derived Variable with Query (248)

Change Reference to Value (252)

Change Value to Reference (256)

Chapter 10 - Simplifying Conditional Logic

Decompose Conditional (260)

Consolidate Conditional Expression (263)

Replace Nested Conditional with Guard Clause (266)

Replace Conditional with Polymorphism (272)

Introduce Special Case (289)

Introduce Assertion (302)

Chapter 11 - Refactoring APIs

Separate Query from Modifier (306)

Parameterize Function (310)

Remove Flag Argument (314)

Preserve Whole Object (319)

Replace Parameter with Query (324)

Replace Query with Parameter (327)

Remove Setting Method (331)

Replace Constructor with Factory Function (334)

Replace Function with Command (337)

Replace Command with Function (344)

Chapter 12 - Dealing with Inheritance

Pull Up Method (350)

Pull Up Field (353)

Pull Up Constructor Body (355)

Push Down Method (359)

Push Down Field (361)

Replace Type Code with Subclasses (362)

Remove Subclass (369)

Extract Superclass (375)

Replace Subclass with Delegate (381)

Replace Superclass with Delegate (399)