Bug #80649 [NEW]: Incorrect type checking behaviour

From: Date: Wed, 20 Jan 2021 00:21:40 +0000
Subject: Bug #80649 [NEW]: Incorrect type checking behaviour
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-231660@lists.php.net to get a copy of this message
From:             graham at alt-three dot com
Operating system: Linux
PHP version:      8.0.1
Package:          *General Issues
Bug Type:         Bug
Bug description:Incorrect type checking behaviour

Description:
------------
Many mb_ functions are not throwing type errors when the provided input
does not match the type signature, on PHP 8.

Test script:
---------------
<?php

function f(string $x) {}

var_dump((new
ReflectionFunction('mb_strpos'))->getParameters()[0]->getType()->getName());
var_dump((new
ReflectionFunction('f'))->getParameters()[0]->getType()->getName());

mb_strpos(null, 'a');
f(null);


Expected result:
----------------
string(6) "string"
string(6) "string"

Fatal error: Uncaught TypeError: mb_strpos(): Argument #1 ($haystack)
must be of type string


Actual result:
--------------
string(6) "string"
string(6) "string"

Fatal error: Uncaught TypeError: f(): Argument #1 ($x) must be of type
string


-- 
Edit bug report at https://bugs.php.net/bug.php?id=80649&edit=1
-- 
Fix committed:                    https://bugs.php.net/fix.php?id=80649&r=fixed
Fixed in release:                 https://bugs.php.net/fix.php?id=80649&r=alreadyfixed
Need backtrace:                   https://bugs.php.net/fix.php?id=80649&r=needtrace
Need Reproduce Script:            https://bugs.php.net/fix.php?id=80649&r=needscript
Try newer version:                https://bugs.php.net/fix.php?id=80649&r=oldversion
Not developer issue:              https://bugs.php.net/fix.php?id=80649&r=support
Expected behavior:                https://bugs.php.net/fix.php?id=80649&r=notwrong
Not enough info:                  https://bugs.php.net/fix.php?id=80649&r=notenoughinfo
Submitted twice:                  https://bugs.php.net/fix.php?id=80649&r=submittedtwice
register_globals:                 https://bugs.php.net/fix.php?id=80649&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=80649&r=phptooold
Daylight Savings:                 https://bugs.php.net/fix.php?id=80649&r=dst
IIS Stability:                    https://bugs.php.net/fix.php?id=80649&r=isapi
Install GNU Sed:                  https://bugs.php.net/fix.php?id=80649&r=gnused
Floating point limitations:       https://bugs.php.net/fix.php?id=80649&r=float
No Zend Extensions:               https://bugs.php.net/fix.php?id=80649&r=nozend
MySQL Configuration Error:        https://bugs.php.net/fix.php?id=80649&r=mysqlcfg


Thread (4 messages)

« previous php.bugs (#231660) next »