Bug #80637 [NEW]: bindParam() changes type property to string

From: Date: Sun, 17 Jan 2021 19:45:52 +0000
Subject: Bug #80637 [NEW]: bindParam() changes type property to string
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-231606@lists.php.net to get a copy of this message
From: php at evilazrael dot de Operating system: Linux PHP version: 7.4.14 Package: PDO Core Bug Type: Bug Bug description:bindParam() changes type property to string Description: ------------ Nothing new, but still unexpected. bindParam() changes the bound variable to type string. According to comments on bindParam() this is the normal behaviour for at least 11 years, but with the typed property support introduced in 7.4 this is even more unexpected to have an int property containing a string, something you can do directly. I tested this with SQLite and PostgreSQL and seems to be independent of the used database. Test script: --------------- <?php class TestClass { public int $a; } $x = new TestClass; $x->a = 17; var_dump($x); /* class TestClass#3 (1) { public int $a => int(17) } */ $db = new PDO("sqlite::memory:"); $stmt = $db->prepare("SELECT :val"); $stmt->bindValue(":val", $x->a); $stmt->execute(); $stmt->closeCursor(); var_dump($x); /* class TestClass#3 (1) { public int $a => int(17) } */ $stmt->bindParam(":val", $x->a); $stmt->execute(); $stmt->closeCursor(); var_dump($x); /* class TestClass#3 (1) { public int $a => string(2) "17" } */ Expected result: ---------------- Int typed property containing an int value Actual result: -------------- Int typed property containing a string. -- Edit bug report at https://bugs.php.net/bug.php?id=80637&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=80637&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=80637&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=80637&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=80637&r=needscript Try newer version: https://bugs.php.net/fix.php?id=80637&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=80637&r=support Expected behavior: https://bugs.php.net/fix.php?id=80637&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=80637&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=80637&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=80637&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=80637&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=80637&r=dst IIS Stability: https://bugs.php.net/fix.php?id=80637&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=80637&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=80637&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=80637&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=80637&r=mysqlcfg

« previous php.bugs (#231606) next »