PHP has three visibility levels: public, protected and private. If two classes in the same namespace need to share a method, it has to be public, which means your whole app can call it. This RFC from Rob Landers adds a fourth level, private(namespace), so code in the same namespace can use the member and code anywhere else can't.

How it works

namespace App\Auth;

class SessionManager {
    private(namespace) function checkExpiry(): bool { /* ... */ }
}

class SessionStore {
    public function refresh(SessionManager $session): void {
        $session->checkExpiry(); // OK, same namespace
    }
}

From another namespace, the same call fails:

namespace App\Controllers;

use App\Auth\SessionManager;

$session = new SessionManager();
$session->checkExpiry();
// Fatal error: Uncaught Error: Call to private(namespace) method
// App\Auth\SessionManager::checkExpiry() from scope App\Controllers

The RFC sets out these rules:

  • Exact match only. App\Auth\OAuth is a different namespace from App\Auth, so sub-namespaces don't get access.
  • Methods and properties, both static and instance, but not constants.
  • Works with asymmetric visibility. public private(namespace)(set) means anyone can read the property, but only the namespace can write it.
  • Inheritance works like protected. Child classes inherit these members, but access depends on the namespace where the member was declared, not the child's namespace.
  • No switching with protected. A child can't redeclare a private(namespace) method as protected, or the other way around.
  • Traits use the namespace of the class that uses them.
  • Reflection can still reach these members, and new isNamespacePrivate() methods tell you which ones they are.

Anonymous classes are treated as part of the global namespace for now. The RFC also points out that C#, Kotlin, Swift, Rust and Java all have something similar.

What it means for existing code

Nothing breaks. The syntax is a parse error today, the feature is opt-in, and current visibility rules don't change.

Where it stands

The RFC is under discussion on the internals mailing list. It's at version 1.2, dated November 10, 2025, and targets the next minor version, PHP 8.6 or 9.0. It needs a two-thirds majority to pass, and no vote has happened yet.