Last active
May 12, 2021 21:32
-
-
Save steverobbins/c116cfe5f4dc9f7bfd6e to your computer and use it in GitHub Desktop.
Display what information we can about Magento1 objects that are ioncubed (or any class really)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php ini_set('display_errors', 1) ?> | |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.5/styles/default.min.css"> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.5/highlight.min.js"></script> | |
<script>hljs.initHighlightingOnLoad();</script> | |
<?php | |
// we need the autoloader | |
include 'app/Mage.php'; | |
$classes = array( | |
'SFC_CyberSource_Helper_Gateway_Api', | |
'SFC_CyberSource_Helper_Gateway_Exception', | |
'SFC_CyberSource_Helper_Gateway', | |
'SFC_CyberSource_Helper_Payment', | |
'SFC_CyberSource_Helper_Tsvfile', | |
'SFC_CyberSource_Model_Api_ExtendedSoapClient', | |
'SFC_CyberSource_Model_Method', | |
'SFC_CyberSource_Model_Observer', | |
'SFC_CyberSource_Model_Session', | |
'SFC_CyberSource_Model_Source_Cctype', | |
'SFC_CyberSource_Model_Source_Month', | |
'SFC_CyberSource_Model_Source_Year', | |
); | |
foreach ($classes as $class) { | |
$rClass = new ReflectionClass($class); | |
$classComment = htmlentities($rClass->getDocComment()); | |
$className = $rClass->name; | |
$extends = ''; | |
if ($rParent = $rClass->getParentClass()) { | |
$extends = ' extends ' . $rParent->getName(); | |
} | |
$constants = $properties = $methods = ''; | |
foreach ($rClass->getConstants() as $name => $value) { | |
$constants .= <<<CONSTANT | |
const {$name} = '{$value}'; | |
CONSTANT; | |
} | |
$defaultProps = $rClass->getDefaultProperties(); | |
foreach ($rClass->getProperties() as $rProperty) { | |
$propComment = $rProperty->getDocComment(); | |
if ($rProperty->isPrivate()) { | |
$propVisibility = 'private'; | |
} elseif ($rProperty->isProtected()) { | |
$propVisibility = 'protected'; | |
} else { | |
$propVisibility = 'public'; | |
} | |
$propName = $rProperty->getName(); | |
$rProperty->setAccessible(true); | |
$propValue = ''; | |
if (isset($defaultProps[$propName])) { | |
$value = $defaultProps[$propName]; | |
if (is_bool($value)) { | |
$propValue = ' = ' . ($value ? 'true' : 'false'); | |
} elseif (is_array($value)) { | |
$propValue = ' = ' . implode( | |
"\n ", | |
explode( | |
"\n", | |
str_replace( | |
'array (', | |
'array(', | |
str_replace("(\n)", '()', var_export($value, true)) | |
) | |
) | |
); | |
} else { | |
$propValue = ' = \'' . $value . '\''; | |
} | |
} | |
$properties .= <<<PROPERTY | |
{$propComment} | |
{$propVisibility} \${$propName}{$propValue}; | |
PROPERTY; | |
} | |
foreach ($rClass->getMethods() as $method) { | |
$rMethod = new ReflectionMethod($class, $method->getName()); | |
$methodComment = htmlentities($rMethod->getDocComment()); | |
if ($rMethod->isPrivate()) { | |
$methodVisibility = 'private'; | |
} elseif ($rMethod->isProtected()) { | |
$methodVisibility = 'protected'; | |
} else { | |
$methodVisibility = 'public'; | |
} | |
$methodName = $rMethod->getName(); | |
$paramString = ''; | |
foreach ($rMethod->getParameters() as $rParam) { | |
if ($rParam->isPassedByReference()) { | |
$paramString .= '&'; | |
} | |
$paramString .= '$' . $rParam->getName(); | |
$paramString .= ', '; | |
} | |
$paramString = trim($paramString, ', '); | |
$methods .= <<<METHOD | |
{$methodComment} | |
{$methodVisibility} function {$methodName}({$paramString}); | |
METHOD; | |
} | |
echo <<<CLASS | |
<pre><code><?php | |
{$classComment} | |
class {$className} {$extends} | |
{ | |
{$constants} | |
{$properties} | |
{$methods} | |
}</code></pre> | |
CLASS; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
grep -lri ioncube app/code/
$classes
arrayphp magento-ioncube-module-info.php > info.html
Tada