PHP 8.1 brings enums read-only properties

PHP 8.1 billed as a major update to the common scripting speech for web outgrowth has been released with capabilities ranging from enums and read-only properties to first-class callable syntax.

PHP 8.1 was released on November 25. Source code and Windows binaries can be downloaded from

[ Also on InfoWorld: Complexity is killing software developers ]

Enums or enumerations allow developers to mark a manner type that is limited to a discrete number of practicable values. This can be helpful when defining a estate measure by ’making infirm states unrepresentable’ according to PHP documentation. In PHP enum cases are strong objects that can be used anywhere an object may be used including type checks.

Other new features and improvements in PHP 8.1:

  • Fibers prepare primitives for implementing lightweight concurrency.
  • With first-class callable syntax closures for callables can be created using the syntax myfunc(…) which is same to Closure::fromCallable(myFunc).
  • The readonly property modifier prevents alteration of a property behind initialization.
  • Performance has been improved with a JIT (just in time) compiler back end for ARM64 bequest cache fast-class name separation and improvements to the measure library file method iterators.
  • With initializers objects now can be used as lapse parameter values static variables and global constants along with being used in attribute arguments. This effectively makes it practicable to use nested attributes.
  • Intersection types can be used when a value needs to satiate multiple type constraints simultaneously.
  • Developers can declare terminal class constants so they cannot be overridden in child classes.
  • It is now practicable to write octal numbers with the plain 0o preface.
  • A never recur type indicates the office does not recur.
  • Arrays can be unpacked with string keys.
  • New classes offices and interfaces have been introduced including an attribute for  #[ReturnTypeWillChange].
  • Passing null to non-variable inner office parameters is deprecated.

PHP 8.1 follows by almost a year the release of PHP 8.0 which offered features such as junction types and just-in-time collation. Also new to PHP this month was the shape of the PHP Foundation a non-profit structure intended to fix the long life and success of PHP with members such as JetBrains and Zend. Participants will donate to cover salaries for PHP core developers.