This release focuses on making namespaces and classes work together more naturally. Classes now know which namespace they belong to, constructors accept fully qualified names, and a new unified add() method on PhpFile ties it all together. Under the hood, the Factory got a thorough refactoring and the codebase passed its first mandatory static analysis check.
-
PhpNamespace::add() now automatically assigns itself as the namespace of any ClassLike passed to it. If your code relied on
getNamespace()returningnullafter adding a class to a namespace, you'll need to update that assumption. -
PhpFile::add() – a single entry point for adding classes, interfaces, traits, enums, functions, and namespaces to a file. It handles namespace creation and bracket syntax automatically, so you can build a complete file with just
add()calls. -
ClassLike::getFullName() – returns the fully qualified name when the class belongs to a namespace (e.g.,
App\Model\User), the short name otherwise, ornullfor anonymous classes. -
ClassLike constructors now accept FQN – pass
'App\Model\User'and the namespace is extracted automatically. No need to create the namespace separately for simple cases. -
PhpNamespace::add() accepts GlobalFunction – the unified
add()method now handles functions alongside class-like types, making the namespace API more consistent. -
The
$namespaceparameter in ClassLike constructors is deprecated. UsesetNamespace()instead. The old signature still works for now, but will be removed in a future version.