Plugin-php: Bug unintentional type cast from float to int

Created on 4 Sep 2019  路  4Comments  路  Source: prettier/plugin-php

@prettier/plugin-php v0.11.2
Playground link

Input:

<?php

$check = 1. === 1.0;

if ($check) {
    echo 'true';
} else {
    echo 'false';
}
echo PHP_EOL;

Output:

<?php

$check = 1 === 1.0;

if ($check) {
    echo 'true';
} else {
    echo 'false';
}
echo PHP_EOL;

A number 1. should be formatted as 1.0 not 1

Btw nice issue reporter :D

bug

All 4 comments

hm, why you need . here? Prettier do same https://prettier.io/playground/#N4Igxg9gdgLgprEAuEASMALOYDWACAXjwEYA6QgosgBgG4AdKRgSwDM8AKdLXASj2CM8wvKgBuAQwBOhPAHIYUgK5w5DKAF88cADYBnOAKEjx02XNYT9q9RsYgANCAgAHGM2h7koaVIgB3AAVpBC8UCTEIZgATRxAAIykJXDgYAGUXZOYoAHNkRRUnDBgAWx0AdQxmeD1MsDg00OrmMWqAT2RwPS8nbIMpGECknJKJZEtrJwArPQAPACEklPSJErgAGWy4casDabm07JydOABFJQh4HcmQTKl+zviJeLadaDiXKWyYcpiYDGQAA5qE5PhADOUki5Op84P0xNsnABHC7wIauMIgCR6AC0UDgcGihLiUjgKOYpKGEhGYyQEz2IAMJWY+WUcCceiOJ3Ol22dN27JAMGev2i-2QACYnIoJMwdEcAMIQEqjTpQaCIkBKAwAFWeYXpcA0GiAA

Well the point is your javascript example does not change the behavior (both versions are true) while in the php example the pre formatting outputs true and and post formatting outputs false

Yes, bug :+1: Will be fixed in next release

Was this page helpful?
0 / 5 - 0 ratings