</div>'; if (isset($classAdmin->dependencies)) { echo "\n\t\t<p>Dependencies: "; $comma = ""; foreach ($classAdmin->dependencies as $dep) { echo $comma . '<a href="/admin/Class/Class Details/' . $dep . '">' . $dep . '</a>'; $comma = ", "; } echo ' </p>'; } // Scour the list of methods from the plugin through the file itself echo ' <h3>`' . $classAdmin->pluginName . '` Methods (Extended)</h3> <pre>'; if ($methodList = File::getLines($classAdmin->data['path'] . "/" . $class . ".php")) { $collect = false; $html = ""; for ($a = 0, $len = count($methodList); $a < $len; $a++) { if (strpos($methodList[$a], "public ") !== false) { $collect = true; $html = $methodList[$a - 1] . "<br />" . $methodList[$a]; } else { if ($collect == true) { $html .= $methodList[$a] . "<br />"; } } if (strpos($methodList[$a], "RETURN") !== false) { if ($collect == true) { $collect = false; echo $html . '<br /><br />';
public static function convert($class, $dir = "") { // Do not allow the Classes_Convert plugin to be converted if ($class == "Classes_Convert") { return false; } // Get the plugin configurations, so that we can identify the file's directory if (!($classConfig = Classes_Meta::getConfig($class, $dir))) { return false; } // Get the file contents if (!($contents = File::getLines($classConfig->data['path'] . '/' . $classConfig->pluginName . '.php'))) { return false; } // Simple Conversions $contents = str_replace('<?php', '<?hh', $contents); // Line by Line Conversions foreach ($contents as $key => $line) { // Method Parameters $param = ""; if (strpos($line, ' $') !== false) { $param = '$'; } else { if (strpos($line, ' &$') !== false) { $param = '&$'; } } if ($param !== "") { $type = self::varType($line, "// "); // Perform the update, if possible if ($type != "") { $contents[$key] = str_replace("\t" . $param, "\t" . $type . " " . $param, $line); continue; } } // Class Variables if (strpos($line, '$') !== false) { $type = self::varType($line, "// "); // and (strpos($line, "public") !== false or strpos($line, "private") !== false or strpos($line, "protected") !== false) if ($type != "") { $contents[$key] = str_replace('$', $type . ' $', $line); continue; } } // If there is a RETURN value if (strpos($line, "\t)") !== false) { $type = self::varType($line, "RETURNS "); // Perform the update, if possible if ($type != "") { $contents[$key] = str_replace("\t)", "\t): " . $type, $line); continue; } } // If the method line itself has a comment (for generic types) if (strpos($line, "function") !== false) { $type = self::varType($line, "// "); // Perform the update, if possible if ($type == "T") { $contents[$key] = str_replace("// <T>", "<T> // <T>", $line); continue; } } } // Convert to String $fullContent = ""; foreach ($contents as $key => $line) { $fullContent .= ($key == 0 ? "" : "\n") . $line; } // Remove Documentation //$between = Data_Parse::through($fullContent, "/*", "*/"); //$fullContent = str_replace($between, "", $fullContent); // Display Result // echo "<br /><pre>" . htmlspecialchars($fullContent) . "</pre>"; // Save the File return File::write($classConfig->data['path'] . '/hhvm/' . $classConfig->pluginName . '.php', $fullContent); }