Skip to content

Added __debugInfo with human readable properties to EnumSet & EnumMap #141

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

Merged
merged 1 commit into from
Apr 16, 2020

Conversation

marc-mabe
Copy link
Owner

  • EnumSet: Add virtual private property "__enumerators" with a list of enumerator values set to the result of var_dump. This helps debugging as internally the enumerators of this EnumSet gets stored as either integer or binary bit-array.

  • EnumMap: Add virtual private property "__pairs" with a list of key-value-pairs to the result of var_dump. This helps debugging as internally the map is using the ordinal number.

@marc-mabe marc-mabe added this to the 4.3.0 milestone Apr 5, 2020
*/
public function __debugInfo(): array {
$dbg = (array)$this;
$dbg["\0" . self::class . "\0__pairs"] = array_map(function ($k, $v) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be static::class instead because the class is not final?

Copy link
Owner Author

@marc-mabe marc-mabe Apr 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, because this is debug information only and it should not make the impression to access this.
Adding it as private property of the base class shows it's impossible to access (at least without reflection/closure).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I understand, thx for the clarification :)

@marc-mabe marc-mabe merged commit 5c048f2 into master Apr 16, 2020
@marc-mabe marc-mabe deleted the debugInfo branch April 27, 2020 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants