|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74156 Function throws TypeError, the Error can be circumnavigated by writing a commen
Submitted: 2017-02-23 15:33 UTC Modified: 2021-04-25 04:22 UTC
Avg. Score:2.5 ± 0.5
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: jonatan at maennchen dot ch Assigned: cmb (profile)
Status: No Feedback Package: Scripting Engine problem
PHP Version: 7.0.16 OS: 16.1.0 Darwin Kernel Version 16.
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
39 + 44 = ?
Subscribe to this entry?

 [2017-02-23 15:33 UTC] jonatan at maennchen dot ch
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

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



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2021-04-13 13:41 UTC]
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2021-04-13 13:41 UTC]
Does this still happen to you with any of the actively supported
PHP versions[1]?

[1] <>
 [2021-04-25 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue May 11 21:01:26 2021 UTC