Skip to content

Instantly share code, notes, and snippets.

@steverobbins
Last active May 12, 2021 21:32
Show Gist options
  • Save steverobbins/c116cfe5f4dc9f7bfd6e to your computer and use it in GitHub Desktop.
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)
<?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>&lt;?php
{$classComment}
class {$className} {$extends}
{
{$constants}
{$properties}
{$methods}
}</code></pre>
CLASS;
}
@steverobbins
Copy link
Author

  • Find ioncubed files: grep -lri ioncube app/code/
  • Convert those to class names and fill in $classes array
  • php magento-ioncube-module-info.php > info.html

Tada

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment