4 ms·
# Summary of some of the new changes: ## Union types Specify multiple types public function foo(Foo|Bar $input): int|float; ## JIT Just in time compile
by tylerjwilk00 7y ago
# Summary of some of the new changes:
## Union types
Specify multiple types
public function foo(Foo|Bar $input): int|float;
## JIT
Just in time compiler for improved performance
## Static return type
Return static of class
class Foo
{
public function test(): static
{
return new static();
}
}
## Weak maps
Prevent blocking of garbage collection for improved memory usage when needed
private WeakMap $cache;
## ::class on objects
Get class type from object like get_class($object)
$foo = new Foo();
var_dump($foo::class);
## fdiv function
When you don't care about division by zero
fdiv($x,0);
## Concatenation precedence
Math takes precedence in string concatenation.
// this
echo "sum: " . $a + $b;
// evaluated as this
echo "sum: " . ($a + $b);
## Some others
- Create DateTime objects from interface
- Type annotations for internal functions
- Variable syntax tweaks
- Breaking changes
- Consistent type errors
- Reclassified engine warnings
- Reflection method signature changes
* Note: HN pretty please get improved mark down parsing