Bug #78648 [Asn->Csd]: Integer defaults are not cast to float for float properties
| From: | nikic@php.net | Date: | Tue, 08 Oct 2019 13:44:20 +0000 |
| Subject: | Bug #78648 [Asn->Csd]: Integer defaults are not cast to float for float properties | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-223142@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=78648&edit=1
ID: 78648
Updated by: nikic@php.net
Reported by: andreas dot bittner at aracom dot de
Summary: Integer defaults are not cast to float for float
properties
-Status: Assigned
+Status: Closed
Type: Bug
Package: Class/Object related
Operating System: Docker 7.4.0RC3-apache
PHP Version: 7.4.0RC3
Assigned To: nikic
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of nikita.ppv@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=9004102b99be4d3811d69ad61149dc2959579e0a
Log: Fixed bug #78648
Previous Comments:
------------------------------------------------------------------------
[2019-10-08 13:32:24] andreas dot bittner at aracom dot de
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 this bug report at https://bugs.php.net/bug.php?id=78648&edit=1