nette / tracy

😎 Tracy: the addictive tool to ease debugging PHP code for cool developers. Friendly design, logging, profiler, advanced features like debugging AJAX calls or CLI support. You will love it.
https://tracy.nette.org
Other
1.75k stars 218 forks source link

TypeError: Tracy\Dumper\Describer::addPropertyTo(): Argument #2 ($k) must be of type string, int given #559

Closed Gappa closed 1 year ago

Gappa commented 1 year ago

Version: 2.10.1

Bug Description

image

TypeError: Tracy\Dumper\Describer::addPropertyTo(): Argument #2 ($k) must be of type string, int given, called in
/{path_to_project}/vendor/tracy/tracy/src/Tracy/Dumper/Exposer.php on line 27 and defined in
/{path_to_project}/vendor/tracy/tracy/src/Tracy/Dumper/Describer.php:235

Steps To Reproduce

In a latte template:

{foreach new \ArrayIterator(['a', 'b', 'c']) as $foo}
    {$foo}
{/foreach}

Expected Behavior

No error is shown in the Tracy bar. Previous versions did not have this problem.

Possible Solution

Retyping the $k parameter to string:

As it is already done here:

dg commented 1 year ago

I can't replicate the bug. I would rather say that it is caused by some parameter added to $this->template.

Gappa commented 1 year ago

Doh, you're right, I fiddled with it so much that I mucked up the test case.

So, the correct steps:

  1. Create empty nette/web-project.
  2. Enable debug mode.
  3. Modify HomePresenter (add the actionDefault method):
final class HomePresenter extends Nette\Application\UI\Presenter
{
    public function actionDefault(): void
    {
        $this->template->foo = new \ArrayIterator(['a', 'b', 'c']);
    }
}

image

But it should fail in any presenter, I just wanted to make it as clean as possible.

The DIC panel also fails (It's disabled in my project) on the same error.

dg commented 1 year ago

Yeah, there's a bug. And I added a test specifically for ArrayIterator, but it didn't catch that.

Fixed.

Gappa commented 1 year ago

Thanks :)