View on GitHub

RefactoringPHP

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

Pull Up Field (353)

Inverse of Push Down Field (361)

Old Code

<?php
class Employee
{
    ...
}

class Salesman extends Employee
{
    private string $name;
}

class Engineer extends Employee
{
    private string $name;
}

New Code

<?php
class Employee
{
    protected string $name;
}

class Salesman extends Employee
{
    ...
}

class Engineer extends Employee
{
    ...
}