php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70957 self::class can not be resolved with reflection for abstract class
Submitted: 2015-11-22 19:34 UTC Modified: 2015-11-23 03:47 UTC
From: lisachenko dot it at gmail dot com Assigned: laruence (profile)
Status: Closed Package: Reflection related
PHP Version: 5.6.15 OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: lisachenko dot it at gmail dot com
New email:
PHP Version: OS:

 

 [2015-11-22 19:34 UTC] lisachenko dot it at gmail dot com
Description:
------------
Can not export reflection method in the abstract class to the string value for method with default parameter, equals to 'self::class'

See https://3v4l.org/3TdIg, reproduced in all latest 5.6 versions.

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

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


$refMethod = new \ReflectionMethod('Foo', 'bar');
echo "Exported: ", $refMethod;

Expected result:
----------------
Exported: Method [ <user> private method bar ] {
  @@ /in/3TdIg 5 - 5

  - Parameters [1] {
    Parameter #0 [ <optional> $a = 'Foo' ]
  }
}

Actual result:
--------------
Exported: 
Process exited with code 139.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-11-23 03:47 UTC] laruence@php.net
-Assigned To: +Assigned To: laruence
 [2015-11-23 03:47 UTC] laruence@php.net
actually, this is not only about refelction, see also:

<?php

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

trait T {
    public function bar() {
    }
}

class Bar extends Foo
{
    use T;
}
 [2015-11-23 04:41 UTC] laruence@php.net
Automatic comment on behalf of laruence@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=ab17840d33354cc32d24c88d3e401d7b0869c996
Log: Fixed bug #70957 (self::class can not be resolved with reflection for abstract class)
 [2015-11-23 04:41 UTC] laruence@php.net
-Status: Assigned +Status: Closed
 [2015-11-23 04:41 UTC] laruence@php.net
Automatic comment on behalf of laruence@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=ab17840d33354cc32d24c88d3e401d7b0869c996
Log: Fixed bug #70957 (self::class can not be resolved with reflection for abstract class)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 13:01:29 2024 UTC