Req #81268 [NEW]: intersection type incompatible with nullable props/returns
From: nicolasgrekas
Operating system:
PHP version: 8.1Git-2021-07-16 (Git)
Package: Scripting Engine problem
Bug Type: Feature/Change Request
Bug description:intersection type incompatible with nullable props/returns
Description:
------------
This code yields "Default value for property of type X&Y may not be
null. Use the nullable type ?X&Y to allow null default value":
class Test {
public X&Y $y = null;
}
Fine, let's add the suggested "?". But then I get "Parse error: syntax
error, unexpected token "&", expecting variable".
About returning null|intersection, should this be possible?
class Test {
function foo(): ?X&Y
{
return null;
}
}
Right now it yields a syntax error.
--
Edit bug report at https://bugs.php.net/bug.php?id=81268&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=81268&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=81268&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=81268&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=81268&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=81268&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=81268&r=support
Expected behavior: https://bugs.php.net/fix.php?id=81268&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=81268&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=81268&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=81268&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=81268&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=81268&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=81268&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=81268&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=81268&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=81268&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=81268&r=mysqlcfg
Thread (12 messages)
- nicolasgrekas@php.net
- girgias@php.netReq #81268 [Opn]: intersection type incompatible with nullable props/returns
- girgias@php.netReq #81268 [Opn->Ver]: intersection type incompatible with nullable props/returns
- nicolasgrekas@php.netReq #81268 [Ver]: intersection type incompatible with nullable props/returns
- nicolasgrekas@php.netReq #81268 [Ver]: intersection type incompatible with nullable props/returns
- girgias@php.netReq #81268 [Ver]: intersection type incompatible with nullable props/returns
- girgias@php.netReq #81268 [Ver]: intersection type incompatible with nullable props/returns
- nicolasgrekas@php.netReq #81268 [Ver]: intersection type incompatible with nullable props/returns
- girgias@php.netReq #81268 [Ver]: intersection type incompatible with nullable props/returns
- me at derrabus dot deReq #81268 [Com]: intersection type incompatible with nullable props/returns
- girgias@php.netReq #81268 [Ver]: intersection type incompatible with nullable props/returns
- patrickallaert@php.netReq #81268 [Ver->Wfx]: intersection type incompatible with nullable props/returns