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

DOM functions show no dumped data #1

Open
tfedor opened this issue Jun 3, 2022 · 6 comments
Open

DOM functions show no dumped data #1

tfedor opened this issue Jun 3, 2022 · 6 comments

Comments

@tfedor
Copy link

tfedor commented Jun 3, 2022

Trying to use sage when debugging DOM manipulation with https://www.php.net/manual/en/book.dom.php functions, dump shows no real info.

DOMNodeList

print_r output:

DOMNodeList Object
(
    [length] => 1
)

sage output (omitted header with variable name and trace string):

DOMNodeList (0)

DOMElement

print_r output:

DOMElement Object
(
    [tagName] => span
    [schemaTypeInfo] =>
    [nodeName] => span
    [nodeValue] => This item is currently unavailable in your region
    [nodeType] => 1
    [parentNode] => (object value omitted)
    [childNodes] => (object value omitted)
    [firstChild] => (object value omitted)
    [lastChild] => (object value omitted)
    [previousSibling] => (object value omitted)
    [nextSibling] => (object value omitted)
    [attributes] => (object value omitted)
    [ownerDocument] => (object value omitted)
    [namespaceURI] =>
    [prefix] =>
    [localName] => span
    [baseURI] =>
    [textContent] => This item is currently unavailable in your region
)

sage output (omitted header with variable name and trace string):

DOMElement (0)
@raveren
Copy link
Collaborator

raveren commented Jun 3, 2022

I'm humbled to receive the first issue on this new branch of Sage - thank you!

Can you please provide me with the object you're dumping - is it something like

d(
    new DOMElement('<span>This item is currently unavailable in your region')
);

?

@tfedor
Copy link
Author

tfedor commented Jun 3, 2022

Basically like that, here's a minimal example with DOMNode, DOMNodeList and DOMAttr, but I think basically any object like that will do the same thing. It seems to me, that sage won't print public properties from these objects.

$dom = new DOMDocument();
$dom->loadHTML(<<<HTML
<html>
    <body>
        <div>
            <p id="id1">first span</p>
            <p id="id2" title="Fancy span">second span</p>
            <p id="id3">third span</p>        
        </div>
    </body>
</html>
HTML);

$xpath = new DOMXPath($dom);

$div = $xpath->query("//div")->item(0);
sage($div);
print_r($div);

$pNodeList = $xpath->query("//p");
sage($pNodeList);
print_r($pNodeList);

$attr = $xpath->query("//*[@id='id2']/@title");
sage($attr->item(0));
print_r($attr->item(0));

I didn't really dug deep into how sage works, but I saw you have different parsers - maybe it would be enough to fall back to parser that you use for basic objects, because when I tried this, it worked as expected:

$o = new class {
    public $a1 = 1;
    public $a2 = 2;
    public $a3 = 3;
};

sage($o);
print_r($o);

@raveren
Copy link
Collaborator

raveren commented Jun 13, 2022

I am sorry for the delay in solving this, I had some computer trouble, my new one is arriving shortly, I'll fix this ASAP :)

@raveren
Copy link
Collaborator

raveren commented Jul 22, 2022

Hey, so sorry for the delay, life was not eeasy :) I tried it out on php8.1 and everything outputs huge amounts of data:

image

can you tell me, what PHP version are you on?

(note that there is a minor visual bug - the "* RECURSION *" in some top rows with children - I'll investigate it, most probably PHP-version related)

@raveren raveren closed this as completed Nov 29, 2022
@raveren
Copy link
Collaborator

raveren commented Nov 29, 2022

closing it, I couldn't reproduce it sorry

@raveren
Copy link
Collaborator

raveren commented Jun 21, 2023

Yeah, there's definitely something still wrong there, but I have to find time and motivation, I think I am going to work with an xml API soon...

@raveren raveren reopened this Jun 21, 2023
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

No branches or pull requests

2 participants