Fork me on GitHub
a Sensio Labs Product

I ate three cookies πŸͺ (v3.40.2) edition

Rule modernize_types_castingΒΆ

Replaces intval, floatval, doubleval, strval and boolval function calls with according type casting operator.

WarningΒΆ

Using this rule is riskyΒΆ

Risky if any of the functions intval, floatval, doubleval, strval or boolval are overridden.

ExamplesΒΆ

Example #1ΒΆ

--- Original
+++ New
 <?php
-    $a = intval($b);
-    $a = floatval($b);
-    $a = doubleval($b);
-    $a = strval ($b);
-    $a = boolval($b);
+    $a = (int) $b;
+    $a = (float) $b;
+    $a = (float) $b;
+    $a = (string) $b;
+    $a = (bool) $b;

Rule setsΒΆ

The rule is part of the following rule sets:

Source classΒΆ

PhpCsFixer\Fixer\CastNotation\ModernizeTypesCastingFixer