🎉 Hooray! After 3 years of work, I've finally released the ebook on design patterns! Check it out »
Visitor

Visitor in PHP

Visitor is a behavioral design pattern that allows adding new behaviors to existing class hierarchy without altering any existing code.

Read why Visitors can’t be simply replaced with method overloading in our article Visitor and Double Dispatch.

Learn more about Visitor

Usage of the pattern in PHP

Complexity:

Popularity:

Usage examples: The Visitor pattern isn’t very common in PHP code because of its complexity and narrow applicability.

Visitor in Other Languages

Visitor in Java Visitor in C# Visitor in Python Visitor in Ruby Visitor in Swift Visitor in TypeScript