Bug #74156 [NEW]: Function throws TypeError, the Error can be circumnavigated by writing a commen

From: Date: Thu, 23 Feb 2017 15:33:39 +0000
Subject: Bug #74156 [NEW]: Function throws TypeError, the Error can be circumnavigated by writing a commen
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-207524@lists.php.net to get a copy of this message
From: jonatan at maennchen dot ch Operating system: 16.1.0 Darwin Kernel Version 16. PHP version: 7.0.16 Package: Scripting Engine problem Bug Type: Bug Bug description:Function throws TypeError, the Error can be circumnavigated by writing a commen 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 … -- Edit bug report at https://bugs.php.net/bug.php?id=74156&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=74156&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=74156&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=74156&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=74156&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=74156&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=74156&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=74156&r=needscript Try newer version: https://bugs.php.net/fix.php?id=74156&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=74156&r=support Expected behavior: https://bugs.php.net/fix.php?id=74156&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=74156&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=74156&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=74156&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74156&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=74156&r=dst IIS Stability: https://bugs.php.net/fix.php?id=74156&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=74156&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=74156&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=74156&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=74156&r=mysqlcfg

« previous php.bugs (#207524) next »