php-8
Is it possible to use named function parameters in PHP? [duplicate]
PHP 8.0 added support for named arguments with the acceptance of an RFC. Named arguments are passed by prefixing the value with the parameter name followed by a colon. Using reserved keywords as parameter names is allowed. The parameter name must be an identifier, specifying dynamically is not allowed. E.g. to pass just the 3rd … Read more
Is there a way to catch an Exception without having to create a variable?
Starting with PHP 8, it is possible to use a non-capturing catch. This is the relevant RFC, which was voted favourably 48-1. Now it will be possible to do something like this: try { readFile($file); } catch (FileDoesNotExist) { echo “File does not exist”; } catch (UnauthorizedAccess) { echo “User does not have the appropriate … Read more
Is it possible to type hint more than one type?
As of PHP 8.0, this will be possible with the inclusion of Union Types. The proposal has been voted 61 in favour to 5 against, and the implementation is ready to go. There was a previous RFC proposing this, mentioned in another answer, but that one ended up being rejected. It will work exactly as … Read more