|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2021-04-13 13:41 UTC] cmb@php.net
-Status: Open
+Status: Feedback
-Assigned To:
+Assigned To: cmb
[2021-04-13 13:41 UTC] cmb@php.net
[2021-04-25 04:22 UTC] php-bugs at lists dot php dot net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 15:00:01 2025 UTC |
Description: ------------ The error is very strange. I'm not able to provide a short reproducible code snippet. If I don't let my whole test suite run I can't reproduce the bug. The code is proprietary, so I can't share it. To find out the issue, you'll have to communicate with me, sorry :S In my code there is a function getId with a type declaration (I put it in the Test Script) When I run my Test Suite with PHPUnit I get the error seen in "Actual Result". If I put the anything before the line with the return, the error vanishes. Even a line comment with no content is enough. I've tried several things to find out details about the error: * Happens with Opcache disabled * Happens when run on CircleCI (PHP 7.0.4) * Happens when I write the function as one line. * Disappears if I try to log the value before returning it. "error_log(var_export($this->id, true));" * Disappears if I put an empty line there Things checked: * Dumped the file with xxd and found no special characters * OpCache * Debugged with XDebug, found not a single step where id is not int PHP Version: PHP 7.0.15 (cli) (built: Jan 22 2017 08:51:45) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies with Xdebug v2.5.0, Copyright (c) 2002-2016, by Derick Rethans Configure Command => './configure' '--prefix=/usr/local/Cellar/php70/7.0.15_8' '--localstatedir=/usr/local/var' '--sysconfdir=/usr/local/etc/php/7.0' '--with-config-file-path=/usr/local/etc/php/7.0' '--with-config-file-scan-dir=/usr/local/etc/php/7.0/conf.d' '--mandir=/usr/local/Cellar/php70/7.0.15_8/share/man' '--enable-bcmath' '--enable-calendar' '--enable-dba' '--enable-exif' '--enable-ftp' '--enable-gd-native-ttf' '--enable-mbregex' '--enable-mbstring' '--enable-shmop' '--enable-soap' '--enable-sockets' '--enable-sysvmsg' '--enable-sysvsem' '--enable-sysvshm' '--enable-wddx' '--enable-zip' '--with-freetype-dir=/usr/local/opt/freetype' '--with-gd' '--with-gettext=/usr/local/opt/gettext' '--with-iconv-dir=/usr' '--with-icu-dir=/usr/local/opt/icu4c' '--with-jpeg-dir=/usr/local/opt/jpeg' '--with-kerberos=/usr' '--with-mhash' '--with-ndbm=/usr' '--with-png-dir=/usr/local/opt/libpng' '--with-xmlrpc' '--with-zlib=/usr' '--with-readline=/usr/local/opt/readline' '--without-gmp' '--without-snmp' '--with-libxml-dir=/usr/local/opt/libxml2' '--with-pdo-odbc=unixODBC,/usr/local/opt/unixodbc' '--with-unixODBC=/usr/local/opt/unixodbc' '--with-bz2=/usr' '--with-openssl=/usr/local/opt/openssl' '--enable-fpm' '--with-fpm-user=_www' '--with-fpm-group=_www' '--with-curl' '--with-xsl=/usr' '--with-ldap' '--with-ldap-sasl=/usr' '--with-mysql-sock=/tmp/mysql.sock' '--with-mysqli=mysqlnd' '--with-mysql=mysqlnd' '--with-pdo-mysql=mysqlnd' '--disable-opcache' '--enable-pcntl' '--without-pear' '--enable-dtrace' '--disable-phpdbg' '--enable-zend-signals' PHP Packages: $ brew list | grep php70 php70 php70-apcu php70-geoip php70-imagick php70-intl php70-mcrypt php70-xdebug Test script: --------------- # Code Producing the error: public function getId(): int { return $this->id; } # Code NOT producing the error (and that's the only change): public function getId(): int { // return $this->id; } Expected result: ---------------- returns the int Actual result: -------------- 1) Tests\Functional\AppBundle\EventControllerTest::testLikeForeign TypeError: Return value of AppBundle\Entity\User::getId() must be of the type integer, string returned path/src/AppBundle/Entity/User.php:445 …