Skip to content

Instantly share code, notes, and snippets.

@ThomasWeinert
Created February 12, 2015 11:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ThomasWeinert/1d6217630020c1ebb94b to your computer and use it in GitHub Desktop.
Save ThomasWeinert/1d6217630020c1ebb94b to your computer and use it in GitHub Desktop.
Test if HHVM still uses __get/__set or has implemented the properties.
<?php
$xml = <<<'XML'
<root attribute="42"></root>
XML;
$dom = new DOMDocument();
$dom->preserveWhiteSpace = FALSE;
$dom->loadXml($xml);
$objects = [
$dom,
$dom->documentElement,
$dom->documentElement->attributes->getNamedItem('attribute'),
$dom->createTextNode(''),
$dom->createComment(''),
$dom->createCDATASection(''),
$dom->createProcessingInstruction('pi', ''),
$dom->createDocumentFragment(),
new DOMXPath($dom)
];
echo str_pad('class', 25, ' '), ' | ', '__get ', ' | ', '__set ', "\n";
echo str_repeat('-', 25), ' | ', '------', ' | ', '------', "\n";
foreach ($objects as $object) {
echo
str_pad(get_class($object), 25, ' '),
' | ',
method_exists($object, '__get') ? 'true ' : 'false ',
' | ',
method_exists($object, '__set') ? 'true ' : 'false ',
"\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment