View on GitHub

RefactoringPHP

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

Push Down Field (361)

Inverse of Pull Up Field (353)

Old Code

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

class Engineer extends Employee
{
    ...
}

class Salesman extends Employee
{
    ...
}

New Code

<?php
class Employee
{
    ...
}

class Engineer extends Employee
{
    ...
}

class Salesman extends Employee
{
    private string $quota;
}