Skip to content

Nuttige (nieuwe) PHP features #9

@pjdevries

Description

@pjdevries

Algemeen

Per PHP versie

  • 5.6
    • const
    • ... for variadic function parameters and array unpacking.
    • ** Exponentation operator
  • 7.0
    • Function return type declarations: string, ìnt, float, bool, array (type ...$types).
    • Function parameter type declarations: string, ìnt, float, bool, array.
    • Null coalescing operator: ??
    • Spaceship operator: <=>
    • Constant arrays: define('FOO] , [1, 2, 3])
    • Anonymous classes: new class [implements Interface] {}
    • Group use declarations: use some\namespace\{ClassA, ClassB, ClassC as C};
    • preg_replace_callback_array()
  • 7.1
    • Nullable function parameter and return types: function d(?int $foo): ?string.
    • Void functions: function f(): void
    • Array destructuring (list() shorthand): [$foo, $bar] = [1, 2]
    • Scoped class constants.
    • Iterable pseudo-type: function f(iterable $i)
    • Multi catch exception handling: catch (Exception1 | Exception2 | .... $e)
    • Keys in list() and array destructuring: ['foo' => $item1, 'bar' => $item2] = ['foo' => 1, 'bar' => 2]
  • 7.2
  • 7.3
    • More flexible Heredoc and Nowdoc.
  • 7.4
    • Typed class properties.
    • Arrow functions.
    • Limited return type covariance and argument type contravariance.
    • Null coalescing assignment operator: ??=
    • Unpacking inside arrays: [1, 2, ...[3, 4], 5]
  • 8.0
  • 8.1
    • Array Unpacking with String Keys: [1, 2, [...['foo' => 3, 'bar' => 4], 5]
    • Enumerations
    • First Class Callable Syntax: $fn = callable(...)
    • Intersection types: function f(Foo&Bar $param)
    • Never return type: function f(): never { exit; }
    • new in Initializers: default value of a parameter, static variable, global constant initializers, and as attribute arguments.
    • Readonly properties
    • Final class constants: final public const foo = "bar";
  • 8.2
    • SensitiveParameter Attribute: #[\SensitiveParameter]
    • Stand alone types null, false and true.
    • Intersection and union types can be combined.
    • Readonly classes.

Metadata

Metadata

Labels

PHP specifiekPIMtopics die tijdens de komende PIM aan de orde komen

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions