Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

var_dump includes non-existing (but somehow existing?) properties #16793

Closed
kkmuffme opened this issue Nov 14, 2024 · 2 comments
Closed

var_dump includes non-existing (but somehow existing?) properties #16793

kkmuffme opened this issue Nov 14, 2024 · 2 comments

Comments

@kkmuffme
Copy link

Description

I was using tideways PHP https://tideways.com/profiler/downloads "Span" https://support.tideways.com/documentation/reference/php-extension/custom-timespans.html
For some reason var_dump shows that the object has public properties, but upon accessing them, it fails, since these properties are not actually public.
property_exists() also returns false on it

ReflectionProperty also fails

ReflectionException: Property Tideways\Profiler\Span::$start does not exist

Which would mean it doesn't exist at all, neither privately nor publically.
Not sure what is going on here

The following code:

<?php
$span = \Tideways\Profiler::createSpan('other text');
$span->annotate(
	array(
		'title' => 'some text',
	)
);
var_dump($span);
var_dump(property_exists($span, 'start'));
var_dump($span->start);

https://support.tideways.com/documentation/reference/php-extension/custom-timespans.html

Resulted in this output:

object(Tideways\Profiler\Span)#2495 (6) {
  ["s"] => string(16) "redacted1"
  ["p"] => string(16) "redacted2"
  ["t"] => string(16) "redacted2"
  ["start"] => int(1731425730246)
  ["n"] => string(6) "custom"
  ["a"] => array(2) {
    ["title"] => string(6) "some text"
    ["custom_type"] => string(11) "other text"
  }
}
bool(false)
NULL

But I expected this output instead: (actually this is wrong too, since it's not "private" either, since ReflectionProperty fails. Not sure what is going on here)

object(Tideways\Profiler\Span)#2495 (6) {
  ["s":"Tideways\Profiler\Span":private] => string(16) "redacted1"
  ["p":"Tideways\Profiler\Span":private] => string(16) "redacted2"
  ["t":"Tideways\Profiler\Span":private] => string(16) "redacted2"
  ["start":"Tideways\Profiler\Span":private] => int(1731425730246)
  ["n":"Tideways\Profiler\Span":private] => string(6) "custom"
  ["a":"Tideways\Profiler\Span":private] => array(2) {
    ["title"] => string(6) "some text"
    ["custom_type"] => string(11) "other text"
  }
}
bool(false)
NULL

PHP Version

8.3

Operating System

No response

@cmb69
Copy link
Member

cmb69 commented Nov 14, 2024

Well, don't know about that extension (consider to ask Tideways), but I would assume that these properties are implemented similar to DateTime properties (see https://3v4l.org/Y684E). That is certainly not a bug in var_dump() or property_exists(), but rather a limitation of the extension.

@iluuu1994
Copy link
Member

Please contact Tideways. I'm not sure the extension is even open-source. There is not evident bug on PHPs side.

@iluuu1994 iluuu1994 closed this as not planned Won't fix, can't repro, duplicate, stale Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants