Req #78695 [NEW]: [ Feature req ] Typehints `uint`, `ufloat`, `+', 'resource+' and so on
| From: | 6562680 at gmail dot com | Date: | Sat, 19 Oct 2019 10:49:50 +0000 |
| Subject: | Req #78695 [NEW]: [ Feature req ] Typehints `uint`, `ufloat`, `+', 'resource+' and so on | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-223290@lists.php.net to get a copy of this message | ||
From: 6562680 at gmail dot com
Operating system: Win10
PHP version: 7.3.10
Package: *General Issues
Bug Type: Feature/Change Request
Bug description:[ Feature req ] Typehints
uint, ufloat, `+',
'resource+' and so on
Description:
------------
[ FEATURE REQUEST ]
[ NOT A BUG ]
uint - unsigned int (0,1,2,3)
ufloat - unsigned float
resource (replace to opened OR closed resource)
stack (array w/ordered ("default") int keys 0,1,2,3)
list (array w/non-ordered int keys 1,4,3,0)
assoc (array w/both int/string keys but fatal if only int/only string
keys)
dict (array w/string keys)
+ - non-empty
resource+ (opened resource)
int+ (1,2,3... but fatal if 0)
float+ (0.01, 0.02 but fatal if 0.0)
string+ (at least one letter or fatal)
array+ (at least one item or fatal)
would be great to but not so required
string[] // list(!) of strings
Object[] // list(!) of objects
and i know that will be implemented in 7.4 - co-return 'string|array',
'OneInterface|TwoInterface'
Test script:
---------------
function hello(? int $limit)
{
// damn i need this every time
$limit = max(0, $limit);
if (0 === $limit) throw \InvalidArgumentException('Error');
// yes, i can: $limit = max(1, $limit);
// and somewhere i could expect fatal error if 0 is going from another
function, but this function wont throw and will work like 1 passed
}
Expected result:
----------------
Reduce count of if/elses + exceptions required when you writing simple
scripts (usually required by Saas flow)
Actual result:
--------------
tonns of "if/else"
making properties to separate objects to "true OOP"
and then projects with 1500 files... instead of 100.
--
Edit bug report at https://bugs.php.net/bug.php?id=78695&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=78695&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=78695&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=78695&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=78695&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=78695&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=78695&r=support
Expected behavior: https://bugs.php.net/fix.php?id=78695&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=78695&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=78695&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=78695&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=78695&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=78695&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=78695&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=78695&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=78695&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=78695&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=78695&r=mysqlcfg