File manager - Edit - /home/autoph/public_html/projects/Rating-AutoHub/public/css/psysh.zip
Back
PK 31�Z�m�.� � bin/psyshnu �[��� #!/usr/bin/env php <?php /* * This file is part of Psy Shell. * * (c) 2012-2023 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ // Try to find an autoloader for a local psysh version. // We'll wrap this whole mess in a Closure so it doesn't leak any globals. call_user_func(function () { $cwd = null; // Find the cwd arg (if present) $argv = isset($_SERVER['argv']) ? $_SERVER['argv'] : array(); foreach ($argv as $i => $arg) { if ($arg === '--cwd') { if ($i >= count($argv) - 1) { fwrite(STDERR, 'Missing --cwd argument.' . PHP_EOL); exit(1); } $cwd = $argv[$i + 1]; break; } if (preg_match('/^--cwd=/', $arg)) { $cwd = substr($arg, 6); break; } } // Or fall back to the actual cwd if (!isset($cwd)) { $cwd = getcwd(); } $cwd = str_replace('\\', '/', $cwd); $chunks = explode('/', $cwd); while (!empty($chunks)) { $path = implode('/', $chunks); $prettyPath = $path; if (isset($_SERVER['HOME']) && $_SERVER['HOME']) { $prettyPath = preg_replace('/^' . preg_quote($_SERVER['HOME'], '/') . '/', '~', $path); } // Find composer.json if (is_file($path . '/composer.json')) { if ($cfg = json_decode(file_get_contents($path . '/composer.json'), true)) { if (isset($cfg['name']) && $cfg['name'] === 'psy/psysh') { // We're inside the psysh project. Let's use the local Composer autoload. if (is_file($path . '/vendor/autoload.php')) { if (realpath($path) !== realpath(__DIR__ . '/..')) { fwrite(STDERR, 'Using local PsySH version at ' . $prettyPath . PHP_EOL); } require $path . '/vendor/autoload.php'; } return; } } } // Or a composer.lock if (is_file($path . '/composer.lock')) { if ($cfg = json_decode(file_get_contents($path . '/composer.lock'), true)) { foreach (array_merge($cfg['packages'], $cfg['packages-dev']) as $pkg) { if (isset($pkg['name']) && $pkg['name'] === 'psy/psysh') { // We're inside a project which requires psysh. We'll use the local Composer autoload. if (is_file($path . '/vendor/autoload.php')) { if (realpath($path . '/vendor') !== realpath(__DIR__ . '/../../..')) { fwrite(STDERR, 'Using local PsySH version at ' . $prettyPath . PHP_EOL); } require $path . '/vendor/autoload.php'; } return; } } } } array_pop($chunks); } }); // We didn't find an autoloader for a local version, so use the autoloader that // came with this script. if (!class_exists('Psy\Shell')) { /* <<< */ if (is_file(__DIR__ . '/../vendor/autoload.php')) { require __DIR__ . '/../vendor/autoload.php'; } elseif (is_file(__DIR__ . '/../../../autoload.php')) { require __DIR__ . '/../../../autoload.php'; } else { fwrite(STDERR, 'PsySH dependencies not found, be sure to run `composer install`.' . PHP_EOL); fwrite(STDERR, 'See https://getcomposer.org to get Composer.' . PHP_EOL); exit(1); } /* >>> */ } // If the psysh binary was included directly, assume they just wanted an // autoloader and bail early. // // Keep this PHP 5.3 and 5.4 code around for a while in case someone is using a // globally installed psysh as a bin launcher for older local versions. if (version_compare(PHP_VERSION, '5.3.6', '<')) { $trace = debug_backtrace(); } elseif (version_compare(PHP_VERSION, '5.4.0', '<')) { $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); } else { $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2); } if (Psy\Shell::isIncluded($trace)) { unset($trace); return; } // Clean up after ourselves. unset($trace); // If the local version is too old, we can't do this if (!function_exists('Psy\bin')) { $argv = isset($_SERVER['argv']) ? $_SERVER['argv'] : array(); $first = array_shift($argv); if (preg_match('/php(\.exe)?$/', $first)) { array_shift($argv); } array_unshift($argv, 'vendor/bin/psysh'); fwrite(STDERR, 'A local PsySH dependency was found, but it cannot be loaded. Please update to' . PHP_EOL); fwrite(STDERR, 'the latest version, or run the local copy directly, e.g.:' . PHP_EOL); fwrite(STDERR, PHP_EOL); fwrite(STDERR, ' ' . implode(' ', $argv) . PHP_EOL); exit(1); } // And go! call_user_func(Psy\bin()); PK 31�Z� �۩ � composer.jsonnu �[��� { "name": "psy/psysh", "description": "An interactive shell for modern PHP.", "type": "library", "keywords": ["console", "interactive", "shell", "repl"], "homepage": "http://psysh.org", "license": "MIT", "authors": [ { "name": "Justin Hileman", "email": "justin@justinhileman.info", "homepage": "http://justinhileman.com" } ], "require": { "php": "^8.0 || ^7.0.8", "ext-json": "*", "ext-tokenizer": "*", "symfony/console": "^6.0 || ^5.0 || ^4.0 || ^3.4", "symfony/var-dumper": "^6.0 || ^5.0 || ^4.0 || ^3.4", "nikic/php-parser": "^4.0 || ^3.1" }, "require-dev": { "bamarni/composer-bin-plugin": "^1.2" }, "suggest": { "ext-pcntl": "Enabling the PCNTL extension makes PsySH a lot happier :)", "ext-posix": "If you have PCNTL, you'll want the POSIX extension as well.", "ext-readline": "Enables support for arrow-key history navigation, and showing and manipulating command history.", "ext-pdo-sqlite": "The doc command requires SQLite to work." }, "autoload": { "files": ["src/functions.php"], "psr-4": { "Psy\\": "src/" } }, "autoload-dev": { "psr-4": { "Psy\\Test\\": "test/" } }, "bin": ["bin/psysh"], "config": { "allow-plugins": { "bamarni/composer-bin-plugin": true } }, "extra": { "branch-alias": { "dev-main": "0.11.x-dev" } }, "conflict": { "symfony/console": "4.4.37 || 5.3.14 || 5.3.15 || 5.4.3 || 5.4.4 || 6.0.3 || 6.0.4" } } PK 31�Z.F�V V src/ParserFactory.phpnu �[��� <?php /* * This file is part of Psy Shell. * * (c) 2012-2023 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Psy; use PhpParser\Parser; use PhpParser\ParserFactory as OriginalParserFactory; /** * Parser factory to abstract over PHP parser library versions. */ class ParserFactory { const ONLY_PHP5 = 'ONLY_PHP5'; const ONLY_PHP7 = 'ONLY_PHP7'; const PREFER_PHP5 = 'PREFER_PHP5'; const PREFER_PHP7 = 'PREFER_PHP7'; /** * Possible kinds of parsers for the factory, from PHP parser library. * * @return string[] */ public static function getPossibleKinds(): array { return ['ONLY_PHP5', 'ONLY_PHP7', 'PREFER_PHP5', 'PREFER_PHP7']; } /** * Default kind (if supported, based on current interpreter's version). * * @return string|null */ public function getDefaultKind() { return static::ONLY_PHP7; } /** * New parser instance with given kind. * * @param string|null $kind One of class constants (only for PHP parser 2.0 and above) */ public function createParser($kind = null): Parser { $originalFactory = new OriginalParserFactory(); $kind = $kind ?: $this->getDefaultKind(); if (!\in_array($kind, static::getPossibleKinds())) { throw new \InvalidArgumentException('Unknown parser kind'); } $parser = $originalFactory->create(\constant(OriginalParserFactory::class.'::'.$kind)); return $parser; } } PK 31�Z[2� ! ! src/Sudo.phpnu �[��� <?php /* * This file is part of Psy Shell. * * (c) 2012-2023 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Psy; /** * Helpers for bypassing visibility restrictions, mostly used in code generated * by the `sudo` command. */ class Sudo { /** * Fetch a property of an object, bypassing visibility restrictions. * * @param object $object * @param string $property property name * * @return mixed Value of $object->property */ public static function fetchProperty($object, string $property) { $prop = self::getProperty(new \ReflectionObject($object), $property); return $prop->getValue($object); } /** * Assign the value of a property of an object, bypassing visibility restrictions. * * @param object $object * @param string $property property name * @param mixed $value * * @return mixed Value of $object->property */ public static function assignProperty($object, string $property, $value) { $prop = self::getProperty(new \ReflectionObject($object), $property); $prop->setValue($object, $value); return $value; } /** * Call a method on an object, bypassing visibility restrictions. * * @param object $object * @param string $method method name * @param mixed $args... * * @return mixed */ public static function callMethod($object, string $method, ...$args) { $refl = new \ReflectionObject($object); $reflMethod = $refl->getMethod($method); $reflMethod->setAccessible(true); return $reflMethod->invokeArgs($object, $args); } /** * Fetch a property of a class, bypassing visibility restrictions. * * @param string|object $class class name or instance * @param string $property property name * * @return mixed Value of $class::$property */ public static function fetchStaticProperty($class, string $property) { $prop = self::getProperty(new \ReflectionClass($class), $property); $prop->setAccessible(true); return $prop->getValue(); } /** * Assign the value of a static property of a class, bypassing visibility restrictions. * * @param string|object $class class name or instance * @param string $property property name * @param mixed $value * * @return mixed Value of $class::$property */ public static function assignStaticProperty($class, string $property, $value) { $prop = self::getProperty(new \ReflectionClass($class), $property); $prop->setValue($value); return $value; } /** * Call a static method on a class, bypassing visibility restrictions. * * @param string|object $class class name or instance * @param string $method method name * @param mixed $args... * * @return mixed */ public static function callStatic($class, string $method, ...$args) { $refl = new \ReflectionClass($class); $reflMethod = $refl->getMethod($method); $reflMethod->setAccessible(true); return $reflMethod->invokeArgs(null, $args); } /** * Fetch a class constant, bypassing visibility restrictions. * * @param string|object $class class name or instance * @param string $const constant name * * @return mixed */ public static function fetchClassConst($class, string $const) { $refl = new \ReflectionClass($class); do { if ($refl->hasConstant($const)) { return $refl->getConstant($const); } $refl = $refl->getParentClass(); } while ($refl !== false); return false; } /** * Construct an instance of a class, bypassing private constructors. * * @param string $class class name * @param mixed $args... */ public static function newInstance(string $class, ...$args) { $refl = new \ReflectionClass($class); $instance = $refl->newInstanceWithoutConstructor(); $constructor = $refl->getConstructor(); $constructor->setAccessible(true); $constructor->invokeArgs($instance, $args); return $instance; } /** * Get a ReflectionProperty from an object (or its parent classes). * * @throws \ReflectionException if neither the object nor any of its parents has this property * * @param \ReflectionClass $refl * @param string $property property name * * @return \ReflectionProperty */ private static function getProperty(\ReflectionClass $refl, string $property): \ReflectionProperty { $firstException = null; do { try { $prop = $refl->getProperty($property); $prop->setAccessible(true); return $prop; } catch (\ReflectionException $e) { if ($firstException === null) { $firstException = $e; } $refl = $refl->getParentClass(); } } while ($refl !== false); throw $firstException; } } PK 31�Zr;�bs/ s/ src/CodeCleaner.phpnu �[��� <?php /* * This file is part of Psy Shell. * * (c) 2012-2023 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Psy; use PhpParser\NodeTraverser; use PhpParser\Parser; use PhpParser\PrettyPrinter\Standard as Printer; use Psy\CodeCleaner\AbstractClassPass; use Psy\CodeCleaner\AssignThisVariablePass; use Psy\CodeCleaner\CalledClassPass; use Psy\CodeCleaner\CallTimePassByReferencePass; use Psy\CodeCleaner\CodeCleanerPass; use Psy\CodeCleaner\EmptyArrayDimFetchPass; use Psy\CodeCleaner\ExitPass; use Psy\CodeCleaner\FinalClassPass; use Psy\CodeCleaner\FunctionContextPass; use Psy\CodeCleaner\FunctionReturnInWriteContextPass; use Psy\CodeCleaner\ImplicitReturnPass; use Psy\CodeCleaner\InstanceOfPass; use Psy\CodeCleaner\IssetPass; use Psy\CodeCleaner\LabelContextPass; use Psy\CodeCleaner\LeavePsyshAlonePass; use Psy\CodeCleaner\ListPass; use Psy\CodeCleaner\LoopContextPass; use Psy\CodeCleaner\MagicConstantsPass; use Psy\CodeCleaner\NamespacePass; use Psy\CodeCleaner\PassableByReferencePass; use Psy\CodeCleaner\RequirePass; use Psy\CodeCleaner\ReturnTypePass; use Psy\CodeCleaner\StrictTypesPass; use Psy\CodeCleaner\UseStatementPass; use Psy\CodeCleaner\ValidClassNamePass; use Psy\CodeCleaner\ValidConstructorPass; use Psy\CodeCleaner\ValidFunctionNamePass; use Psy\Exception\ParseErrorException; /** * A service to clean up user input, detect parse errors before they happen, * and generally work around issues with the PHP code evaluation experience. */ class CodeCleaner { private $yolo = false; private $parser; private $printer; private $traverser; private $namespace; /** * CodeCleaner constructor. * * @param Parser|null $parser A PhpParser Parser instance. One will be created if not explicitly supplied * @param Printer|null $printer A PhpParser Printer instance. One will be created if not explicitly supplied * @param NodeTraverser|null $traverser A PhpParser NodeTraverser instance. One will be created if not explicitly supplied * @param bool $yolo run without input validation */ public function __construct(Parser $parser = null, Printer $printer = null, NodeTraverser $traverser = null, bool $yolo = false) { $this->yolo = $yolo; if ($parser === null) { $parserFactory = new ParserFactory(); $parser = $parserFactory->createParser(); } $this->parser = $parser; $this->printer = $printer ?: new Printer(); $this->traverser = $traverser ?: new NodeTraverser(); foreach ($this->getDefaultPasses() as $pass) { $this->traverser->addVisitor($pass); } } /** * Check whether this CodeCleaner is in YOLO mode. */ public function yolo(): bool { return $this->yolo; } /** * Get default CodeCleaner passes. * * @return CodeCleanerPass[] */ private function getDefaultPasses(): array { if ($this->yolo) { return $this->getYoloPasses(); } $useStatementPass = new UseStatementPass(); $namespacePass = new NamespacePass($this); // Try to add implicit `use` statements and an implicit namespace, // based on the file in which the `debug` call was made. $this->addImplicitDebugContext([$useStatementPass, $namespacePass]); return [ // Validation passes new AbstractClassPass(), new AssignThisVariablePass(), new CalledClassPass(), new CallTimePassByReferencePass(), new FinalClassPass(), new FunctionContextPass(), new FunctionReturnInWriteContextPass(), new InstanceOfPass(), new IssetPass(), new LabelContextPass(), new LeavePsyshAlonePass(), new ListPass(), new LoopContextPass(), new PassableByReferencePass(), new ReturnTypePass(), new EmptyArrayDimFetchPass(), new ValidConstructorPass(), // Rewriting shenanigans $useStatementPass, // must run before the namespace pass new ExitPass(), new ImplicitReturnPass(), new MagicConstantsPass(), $namespacePass, // must run after the implicit return pass new RequirePass(), new StrictTypesPass(), // Namespace-aware validation (which depends on aforementioned shenanigans) new ValidClassNamePass(), new ValidFunctionNamePass(), ]; } /** * A set of code cleaner passes that don't try to do any validation, and * only do minimal rewriting to make things work inside the REPL. * * This list should stay in sync with the "rewriting shenanigans" in * getDefaultPasses above. * * @return CodeCleanerPass[] */ private function getYoloPasses(): array { $useStatementPass = new UseStatementPass(); $namespacePass = new NamespacePass($this); // Try to add implicit `use` statements and an implicit namespace, // based on the file in which the `debug` call was made. $this->addImplicitDebugContext([$useStatementPass, $namespacePass]); return [ new LeavePsyshAlonePass(), $useStatementPass, // must run before the namespace pass new ExitPass(), new ImplicitReturnPass(), new MagicConstantsPass(), $namespacePass, // must run after the implicit return pass new RequirePass(), new StrictTypesPass(), ]; } /** * "Warm up" code cleaner passes when we're coming from a debug call. * * This is useful, for example, for `UseStatementPass` and `NamespacePass` * which keep track of state between calls, to maintain the current * namespace and a map of use statements. * * @param array $passes */ private function addImplicitDebugContext(array $passes) { $file = $this->getDebugFile(); if ($file === null) { return; } try { $code = @\file_get_contents($file); if (!$code) { return; } $stmts = $this->parse($code, true); if ($stmts === false) { return; } // Set up a clean traverser for just these code cleaner passes $traverser = new NodeTraverser(); foreach ($passes as $pass) { $traverser->addVisitor($pass); } $traverser->traverse($stmts); } catch (\Throwable $e) { // Don't care. } } /** * Search the stack trace for a file in which the user called Psy\debug. * * @return string|null */ private static function getDebugFile() { $trace = \debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS); foreach (\array_reverse($trace) as $stackFrame) { if (!self::isDebugCall($stackFrame)) { continue; } if (\preg_match('/eval\(/', $stackFrame['file'])) { \preg_match_all('/([^\(]+)\((\d+)/', $stackFrame['file'], $matches); return $matches[1][0]; } return $stackFrame['file']; } } /** * Check whether a given backtrace frame is a call to Psy\debug. * * @param array $stackFrame */ private static function isDebugCall(array $stackFrame): bool { $class = isset($stackFrame['class']) ? $stackFrame['class'] : null; $function = isset($stackFrame['function']) ? $stackFrame['function'] : null; return ($class === null && $function === 'Psy\\debug') || ($class === Shell::class && $function === 'debug'); } /** * Clean the given array of code. * * @throws ParseErrorException if the code is invalid PHP, and cannot be coerced into valid PHP * * @param array $codeLines * @param bool $requireSemicolons * * @return string|false Cleaned PHP code, False if the input is incomplete */ public function clean(array $codeLines, bool $requireSemicolons = false) { $stmts = $this->parse('<?php '.\implode(\PHP_EOL, $codeLines).\PHP_EOL, $requireSemicolons); if ($stmts === false) { return false; } // Catch fatal errors before they happen $stmts = $this->traverser->traverse($stmts); // Work around https://github.com/nikic/PHP-Parser/issues/399 $oldLocale = \setlocale(\LC_NUMERIC, 0); \setlocale(\LC_NUMERIC, 'C'); $code = $this->printer->prettyPrint($stmts); // Now put the locale back \setlocale(\LC_NUMERIC, $oldLocale); return $code; } /** * Set the current local namespace. * * @param array|null $namespace (default: null) */ public function setNamespace(array $namespace = null) { $this->namespace = $namespace; } /** * Get the current local namespace. * * @return array|null */ public function getNamespace() { return $this->namespace; } /** * Lex and parse a block of code. * * @see Parser::parse * * @throws ParseErrorException for parse errors that can't be resolved by * waiting a line to see what comes next * * @param string $code * @param bool $requireSemicolons * * @return array|false A set of statements, or false if incomplete */ protected function parse(string $code, bool $requireSemicolons = false) { try { return $this->parser->parse($code); } catch (\PhpParser\Error $e) { if ($this->parseErrorIsUnclosedString($e, $code)) { return false; } if ($this->parseErrorIsUnterminatedComment($e, $code)) { return false; } if ($this->parseErrorIsTrailingComma($e, $code)) { return false; } if (!$this->parseErrorIsEOF($e)) { throw ParseErrorException::fromParseError($e); } if ($requireSemicolons) { return false; } try { // Unexpected EOF, try again with an implicit semicolon return $this->parser->parse($code.';'); } catch (\PhpParser\Error $e) { return false; } } } private function parseErrorIsEOF(\PhpParser\Error $e): bool { $msg = $e->getRawMessage(); return ($msg === 'Unexpected token EOF') || (\strpos($msg, 'Syntax error, unexpected EOF') !== false); } /** * A special test for unclosed single-quoted strings. * * Unlike (all?) other unclosed statements, single quoted strings have * their own special beautiful snowflake syntax error just for * themselves. * * @param \PhpParser\Error $e * @param string $code */ private function parseErrorIsUnclosedString(\PhpParser\Error $e, string $code): bool { if ($e->getRawMessage() !== 'Syntax error, unexpected T_ENCAPSED_AND_WHITESPACE') { return false; } try { $this->parser->parse($code."';"); } catch (\Throwable $e) { return false; } return true; } private function parseErrorIsUnterminatedComment(\PhpParser\Error $e, $code): bool { return $e->getRawMessage() === 'Unterminated comment'; } private function parseErrorIsTrailingComma(\PhpParser\Error $e, $code): bool { return ($e->getRawMessage() === 'A trailing comma is not allowed here') && (\substr(\rtrim($code), -1) === ','); } } PK 31�Z�Ftl l src/SuperglobalsEnv.phpnu �[��� <?php /* * This file is part of Psy Shell. * * (c) 2012-2023 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Psy; /** * Environment variables implementation via $_SERVER superglobal. */ class SuperglobalsEnv implements EnvInterface { /** * Get an environment variable by name. * * @return string|null */ public function get(string $key) { if (isset($_SERVER[$key]) && $_SERVER[$key]) { return $_SERVER[$key]; } return null; } } PK 31�Z�~��7 7 src/ContextAware.phpnu �[��� <?php /* * This file is part of Psy Shell. * * (c) 2012-2023 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Psy; /** * ContextAware interface. * * This interface is used to pass the Shell's context into commands and such * which require access to the current scope variables. */ interface ContextAware { /** * Set the Context reference. * * @param Context $context */ public function setContext(Context $context); } PK 31�Z��� � % src/Reflection/ReflectionConstant.phpnu �[��� <?php /* * This file is part of Psy Shell. * * (c) 2012-2023 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Psy\Reflection; /** * @deprecated ReflectionConstant is now ReflectionClassConstant. This class * name will be reclaimed in the next stable release, to be used for * ReflectionConstant_ :) */ class ReflectionConstant extends ReflectionClassConstant { /** * {inheritDoc}. */ public function __construct($class, $name) { @\trigger_error('ReflectionConstant is now ReflectionClassConstant', \E_USER_DEPRECATED); parent::__construct($class, $name); } } PK 31�ZY��eZ Z &