Skip to content

Releases

Released version 4.2.4

Choose a tag to compare

@dg dg released this 26 Oct 22:18

🐛 Bug Fixes

  • fromCode() now keeps a file comment placed before declare(strict_types=1) (#182)
  • Extracting method and property hook bodies ignores the members of anonymous classes nested inside them
  • PropertyHookType is now an alias of PropertyAccessMode, so both enums are interchangeable wherever hooks are added or looked up

🛡️ Robustness

  • Invalid declarations now report a clear error when printed: a readonly property that is static or has a default value, a final private constant, an abstract final property hook, and an enum whose backing type is not int or string or whose case values do not match it
  • setHooks() validates hook types, and the presence of php-parser 5 is detected reliably, with a clear message when an older version is installed

Released version 4.2.3

Choose a tag to compare

@dg dg released this 22 Oct 01:14

✨ New Features

  • PHP 8.6 is now supported

🐛 Bug Fixes

  • Loading a class with ClassType::from() or fromCode() now keeps the types of typed class constants (PHP 8.3)

Released version 4.2.2

Choose a tag to compare

@dg dg released this 09 Feb 05:49

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() returning null after 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, or null for 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 $namespace parameter in ClassLike constructors is deprecated. Use setNamespace() instead. The old signature still works for now, but will be removed in a future version.

Released version 4.2.0

Choose a tag to compare

@dg dg released this 06 Aug 17:51
  • requires PHP 8.1
  • Visibility, PropertyHookType & PropertyAccessMode are enums (BC break)
  • removed deprecated stuff
  • addTrait() second argument is deprecated (BC break)

Released version 4.1.9 (end of support)

Choose a tag to compare

@dg dg released this 06 Aug 15:01
  • support for PHP 8.5
  • final promoted property in PHP 8.5
  • optimized global function calls

Released version 4.1.8

Choose a tag to compare

@dg dg released this 31 Mar 00:34
  • Factory::fromClassReflection() extracts property hook bodies (#172)
  • Factory::fromClassReflection() rejects $withBodies for interfaces
  • improved tests
  • cs

Released version 4.1.7

Choose a tag to compare

@dg dg released this 29 Nov 01:45
  • added support for PHP 8.4 features
    • properties hooks
    • asymmetric visibility
    • property can be abstract / final
    • interfaces can have properties
  • added Visibility
  • ClassManipulator::implement() can implement abstract classes
  • ClassManipulator::implementInterface() renamed to implement()
  • PsrPrinter is not final
  • Constant: type can be nullable
  • Factory: fixed visibility of promoted property

Released version 4.0.10 (end of support)

Choose a tag to compare

@dg dg released this 29 Nov 01:44
  • Extractor::extractAll() fixed file comment parsing
  • Factory: $withBodies cannot be used for internal classes/functions
  • Printer: fixed falsy Attribute aren't printed (#142)
  • added Visibility

Released version 4.1.6

Choose a tag to compare

@dg dg released this 10 Sep 09:16
  • added ClassManipulator
  • Parameter & Property: isNullable() returns true when default value is null (possible BC break)
  • added TraitsAware::hasTrait method (#163)
  • support for PHP 8.4

Released version 4.1.5

Choose a tag to compare

@dg dg released this 12 May 17:13
  • added PhpNamespace::getClass() & getFunction()
  • added CommentAware::removeComment()
  • added PhpFile::removeNamespace()
  • Factory, Extractor: sets flag readonly for promoted properties #158 (reverts "Factory: properties in readonly classes are not readonly")
  • ClassType: cloning includes attributes and parameters
  • GlobalFunction, Method: from() accepts first-class callables
⌂ 换网址