What are the best practices for setting visibility (public, protected, private) for class properties in PHP?

When setting visibility for class properties in PHP, it is important to follow best practices to ensure proper encapsulation and maintainability of the code. Generally, class properties should be declared as private unless they need to be accessed by subclasses, in which case they can be declared as protected. Public properties should be avoided as they expose the internal state of the class and can lead to unexpected behavior.

class Example {
    private $privateProperty;
    protected $protectedProperty;
    
    public function __construct($private, $protected) {
        $this->privateProperty = $private;
        $this->protectedProperty = $protected;
    }
}