Dealing with Private Methods

Handling private abstract methods in traits

Generally, in PHP, we can’t enforce control over an abstract private method in an abstract super class because it will not be inherited. In PHP 8, however, we can define an abstract private method in a trait. This can be used as a use-of-code enforcement mechanism when we’re doing API development where the using class is required to define a specified private method.

Get hands-on with 1400+ tech skills courses.