View Issue Details

IDProjectCategoryView StatusLast Update
0001181Xdebugpublic2015-12-07 11:32
ReporterBlizz Assigned Toderick  
PrioritynormalSeveritycrashReproducibilityalways
Status closedResolutionfixed 
PlatformMacOSMacOSOS Version10.10.4
Product Version2.3.3 
Target Version2.4.1Fixed in Version2.4.0rc2 
Summary0001181: Derived class with __get gets called on fetching base class private property
Description

Yii2's get() implementation throws an exception when get is called with a non-existing $name. It seems that XDebug calls the __get function to obtain the value for a private variable of the base class and the resulting exception is not caught.

Possibly related: Clicking open a Closure also results in an similar exception ("Closue object cannot have properties"). Please let me know if you would like an extra ticket for that.

Code example (no dependencies):
<?php

class BaseClass {
protected $protected = [1, 2, 3];
private $private = ['a', 'b', 'c'];
}

class DerivedClass extends BaseClass {
function __get($name)
{
throw new \Exception('Derived class getter called with: ' . $name);
}
}

try {
$test = new DerivedClass();
echo "Statement to break on."; // Breakpoint here
}
catch (\Exception $e) {
echo $e->getMessage();
}

Steps To Reproduce

Set the breakpoint, start the session and when the breakpoint hits, open up the $test variable. In the test variable, click open BaseClassprivate.
After this, do a step over. It will jump into the catch handler.

Additional Information

Reported in https://youtrack.jetbrains.com/issue/WI-28237 and per your instructions duplicated here. A screencast of the behavior can be found there as well.

Jetbrains reports that it is not reproducible in 2.3.2 but it is in 2.3.3, haven't tried to confirm this.

Direct links:
Screencast: https://youtrack.jetbrains.com/_persistent/Exception.mov?file=74-250258&amp;v=0&amp;c=true
Source file: https://youtrack.jetbrains.com/_persistent/test.php?file=74-250259&amp;v=0&amp;c=true

TagsNo tags attached.
Attached Files
xdebug.log (35,204 bytes)
test.php (391 bytes)   
<?php

class BaseClass {
    protected $protected = [1, 2, 3];
    private $private = ['a', 'b', 'c'];
}

class DerivedClass extends BaseClass {
    function __get($name)
    {
        throw new \Exception('Derived class getter called with: ' .  $name);
    }
}

try {
    $test = new DerivedClass();
    echo "Statement to break on.";
}
catch (\Exception $e) {
    echo $e->getMessage();
}
test.php (391 bytes)   
Operating SystemCentos 7.1
PHP Version5.6.0-5.6.4

Activities

derick

2015-11-22 15:39

administrator   ~0003256

Fixed in 2.4.0. Thanks for the report! I would indeed like a separate issue
for the closure issue - unless that got fixed with this bug fix of course.

Issue History

Date Modified Username Field Change
2015-08-25 17:47 Blizz New Issue
2015-08-25 17:47 Blizz File Added: xdebug.log
2015-08-25 18:01 Blizz File Added: test.php
2015-11-20 17:59 derick Target Version => 2.4.1
2015-11-22 15:39 derick Note Added: 0003256
2015-11-22 15:39 derick Status new => closed
2015-11-22 15:39 derick Assigned To => derick
2015-11-22 15:39 derick Resolution open => fixed
2015-11-22 15:39 derick Fixed in Version => 2.4.0
2015-12-07 11:32 derick Fixed in Version 2.4.0 => 2.4.0rc2
2016-07-31 12:35 derick Category Debug client (console) => debugclient (debugging tool)
2016-07-31 12:35 derick Category debugclient (debugging tool) => (No Category)