php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70958 Invalid opcode while using ::class as trait method paramater default value
Submitted: 2015-11-23 04:58 UTC Modified: 2015-11-23 05:00 UTC
From: laruence@php.net Assigned: laruence
Status: Closed Package: *General Issues
PHP Version: 7.0.0RC7 OS:
Private report: No CVE-ID:
 [2015-11-23 04:58 UTC] laruence@php.net
Description:
------------
See test script

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

trait Foo
{
    function bar($a = self::class) {}
}

class B {
    use Foo;
}

$b = new B;

$b->bar();

Expected result:
----------------
string(1) "C"

Actual result:
--------------
PHP-5.6: Fatal error: Invalid opcode 64/8/2. in /tmp/1.php on line 5
PHP-7.0: NULL
[Mon Nov 23 12:39:01 2015]  Script:  '/tmp/1.php'
/home/huixinchen/opensource/php-7.0/Zend/zend_string.h(121) :  Freeing 0x7FFFF8059B80 (32 bytes), script=/tmp/1.php
=== Total 1 memory leaks detected ===

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-11-23 05:00 UTC] laruence@php.net
-Assigned To: +Assigned To: laruence
 [2015-11-23 05:00 UTC] laruence@php.net
a quick fix is here: http://pastebin.com/iWZksF59

however, the reflection and other similar functions which exporting fucntion declaration function should also be fixed later
 [2015-11-23 10:35 UTC] laruence@php.net
Automatic comment on behalf of laruence@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=a2b85ddecf666281717e50246950fd6d153bb0a8
Log: Fixed bug #70958 (Invalid opcode while using ::class as trait method paramater default value)
 [2015-11-23 10:36 UTC] laruence@php.net
-Status: Assigned +Status: Closed
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Fri Apr 28 04:01:59 2017 UTC