Book on OOP in PHP8
Basics
Introduction
Classes and Objects
Properties
Methods
Method Parameters
Properties Inside Classes
Methods Inside Classes
Constructor
Properties via Constructor Parameters
Private Properties
Private Methods
Property Getters
Property Setters
Advantages of Setters and Getters
Advanced
Class Files
Method Chains in a Class
A Class as a Set of Methods
Arrays of Objects
Objects Inside Classes
The Safe Extraction Operator
The Safe Extraction Operator in Chains
Object Manipulation in Classes
Pass by Reference
The instanceof Operator
Inheritance
Class Inheritance
Inheritance of Public Methods
Child Methods
Overriding Parent Methods
Calling an Overridden Method
Constructor in Inheritance
Private Methods in Inheritance
Private Properties in Inheritance
The Problem of Private Properties in Inheritance
Protected Methods
Protected Properties
The instanceof Operator and Inheritance
Calls
Property Name from a Variable
Property Name from an Array
Property Name from an Associative Array
Property Name from a Function
Property Name from an Object
Method from a Variable
Call After Creation
Static
Static Methods
Static Methods Inside a Class
Static Properties
Static Property Inside a Class
Access via Class and Object
Combination with static
Static Methods and $this
Example
Functions
Getting the Class Name
Getting Class Methods
Getting Class Properties
Getting Object Properties
Checking for Class Existence
Checking for Method Existence
Checking for Property Existence
Getting the Parent Class
Checking Class Inheritance
Checking Object Belonging
Getting All Declared Classes
Abstract
Interfaces
Introduction to Interfaces
Practice on Using Interfaces
Interface Naming Rules
Using Interfaces
Method Parameters in an Interface
Constructor Declaration in an Interface
Inheritance of Interfaces from Each Other
Interfaces and instanceof
Implementation of Multiple Interfaces
Class Inheritance and Interface Implementation
Constants in Interfaces
Functions for Interfaces
Traits
Introduction to Traits
Multiple Traits
Method Conflicts
Access Modifiers
Changing Access Rights to Trait Methods
Method Priority
Abstract Methods
Traits in Traits
Functions for Traits
Magic
Introduction
The __toString Method
Getting Properties
Read-Only Properties
Reading a Non-Existent Property
Setting Properties
Writing to a Non-Existent Property
Checking Properties on Write
Practice