Bug #78648 [NEW]: Integer defaults are not cast to float for float properties
| From: | andreas dot bittner at aracom dot de | Date: | Tue, 08 Oct 2019 13:32:25 +0000 |
| Subject: | Bug #78648 [NEW]: Integer defaults are not cast to float for float properties | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-223141@lists.php.net to get a copy of this message | ||
From: andreas dot bittner at aracom dot de
Operating system: Docker 7.4.0RC3-apache
PHP version: 7.4.0RC3
Package: Class/Object related
Bug Type: Bug
Bug description:Integer defaults are not cast to float for float properties
Description:
------------
A float property that is defaulted to an integer has the type integer
instead of float. I would expect the default integer to be cast to float
when assigned to a float type property.
Please see provided test script for an example.
Test script:
---------------
<?php
echo 'PHP Version: ' . PHP_VERSION;
class Foo {
public float $baa = 1;
}
$instance = new Foo();
echo "\n\nbefore assign\n";
var_dump($instance->baa);
var_dump(gettype($instance->baa));
$instance->baa = 1;
echo "\n\nafter assign\n";
var_dump($instance->baa);
var_dump(gettype($instance->baa));
Expected result:
----------------
PHP Version: 7.4.0RC3
before assign
float(1)
string(6) "double"
after assign
float(1)
string(6) "double"
Actual result:
--------------
PHP Version: 7.4.0RC3
before assign
int(1)
string(7) "integer"
after assign
float(1)
string(6) "double"
--
Edit bug report at https://bugs.php.net/bug.php?id=78648&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=78648&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=78648&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=78648&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=78648&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=78648&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=78648&r=support
Expected behavior: https://bugs.php.net/fix.php?id=78648&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=78648&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=78648&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=78648&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=78648&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=78648&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=78648&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=78648&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=78648&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=78648&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=78648&r=mysqlcfg