PK a#ÔZëαö3 3 LICENSE.mdnu „[µü¤ The MIT License (MIT) Copyright (c) Taylor Otwell Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. PK a#ÔZ,”°éÓ Ó composer.jsonnu „[µü¤ { "name": "laravel/tinker", "description": "Powerful REPL for the Laravel framework.", "keywords": ["tinker", "repl", "psysh", "laravel"], "license": "MIT", "authors": [ { "name": "Taylor Otwell", "email": "taylor@laravel.com" } ], "require": { "php": "^7.2.5|^8.0", "illuminate/console": "^6.0|^7.0|^8.0|^9.0|^10.0", "illuminate/contracts": "^6.0|^7.0|^8.0|^9.0|^10.0", "illuminate/support": "^6.0|^7.0|^8.0|^9.0|^10.0", "psy/psysh": "^0.10.4|^0.11.1", "symfony/var-dumper": "^4.3.4|^5.0|^6.0" }, "require-dev": { "mockery/mockery": "~1.3.3|^1.4.2", "phpunit/phpunit": "^8.5.8|^9.3.3" }, "suggest": { "illuminate/database": "The Illuminate Database package (^6.0|^7.0|^8.0|^9.0|^10.0)." }, "autoload": { "psr-4": { "Laravel\\Tinker\\": "src/" } }, "autoload-dev": { "psr-4": { "Laravel\\Tinker\\Tests\\": "tests/", "App\\": "tests/fixtures/app", "One\\Two\\": "tests/fixtures/vendor/one/two" } }, "extra": { "branch-alias": { "dev-master": "2.x-dev" }, "laravel": { "providers": [ "Laravel\\Tinker\\TinkerServiceProvider" ] } }, "config": { "sort-packages": true }, "minimum-stability": "dev", "prefer-stable": true } PK a#ÔZv·C”Ï Ï src/ClassAliasAutoloader.phpnu „[µü¤ shell = $shell; $this->vendorPath = dirname(dirname($classMapPath)); $this->includedAliases = collect($includedAliases); $this->excludedAliases = collect($excludedAliases); $classes = require $classMapPath; foreach ($classes as $class => $path) { if (! $this->isAliasable($class, $path)) { continue; } $name = class_basename($class); if (! isset($this->classes[$name])) { $this->classes[$name] = $class; } } } /** * Find the closest class by name. * * @param string $class * @return void */ public function aliasClass($class) { if (Str::contains($class, '\\')) { return; } $fullName = $this->classes[$class] ?? false; if ($fullName) { $this->shell->writeStdout("[!] Aliasing '{$class}' to '{$fullName}' for this Tinker session.\n"); class_alias($fullName, $class); } } /** * Unregister the alias loader instance. * * @return void */ public function unregister() { spl_autoload_unregister([$this, 'aliasClass']); } /** * Handle the destruction of the instance. * * @return void */ public function __destruct() { $this->unregister(); } /** * Whether a class may be aliased. * * @param string $class * @param string $path */ public function isAliasable($class, $path) { if (! Str::contains($class, '\\')) { return false; } if (! $this->includedAliases->filter(function ($alias) use ($class) { return Str::startsWith($class, $alias); })->isEmpty()) { return true; } if (Str::startsWith($path, $this->vendorPath)) { return false; } if (! $this->excludedAliases->filter(function ($alias) use ($class) { return Str::startsWith($class, $alias); })->isEmpty()) { return false; } return true; } } PK a#ÔZ€-æÅ@ @ src/TinkerServiceProvider.phpnu „[µü¤ app instanceof LaravelApplication && $this->app->runningInConsole()) { $this->publishes([$source => config_path('tinker.php')]); } elseif ($this->app instanceof LumenApplication) { $this->app->configure('tinker'); } $this->mergeConfigFrom($source, 'tinker'); } /** * Register the service provider. * * @return void */ public function register() { $this->app->singleton('command.tinker', function () { return new TinkerCommand; }); $this->commands(['command.tinker']); } /** * Get the services provided by the provider. * * @return array */ public function provides() { return ['command.tinker']; } } PK a#ÔZpàé7¼ ¼ src/Console/TinkerCommand.phpnu „[µü¤ getApplication()->setCatchExceptions(false); $config = Configuration::fromInput($this->input); $config->setUpdateCheck(Checker::NEVER); $config->getPresenter()->addCasters( $this->getCasters() ); if ($this->option('execute')) { $config->setRawOutput(true); } $shell = new Shell($config); $shell->addCommands($this->getCommands()); $shell->setIncludes($this->argument('include')); $path = Env::get('COMPOSER_VENDOR_DIR', $this->getLaravel()->basePath().DIRECTORY_SEPARATOR.'vendor'); $path .= '/composer/autoload_classmap.php'; $config = $this->getLaravel()->make('config'); $loader = ClassAliasAutoloader::register( $shell, $path, $config->get('tinker.alias', []), $config->get('tinker.dont_alias', []) ); if ($code = $this->option('execute')) { try { $shell->setOutput($this->output); $shell->execute($code); } finally { $loader->unregister(); } return 0; } try { return $shell->run(); } finally { $loader->unregister(); } } /** * Get artisan commands to pass through to PsySH. * * @return array */ protected function getCommands() { $commands = []; foreach ($this->getApplication()->all() as $name => $command) { if (in_array($name, $this->commandWhitelist)) { $commands[] = $command; } } $config = $this->getLaravel()->make('config'); foreach ($config->get('tinker.commands', []) as $command) { $commands[] = $this->getApplication()->add( $this->getLaravel()->make($command) ); } return $commands; } /** * Get an array of Laravel tailored casters. * * @return array */ protected function getCasters() { $casters = [ 'Illuminate\Support\Collection' => 'Laravel\Tinker\TinkerCaster::castCollection', 'Illuminate\Support\HtmlString' => 'Laravel\Tinker\TinkerCaster::castHtmlString', 'Illuminate\Support\Stringable' => 'Laravel\Tinker\TinkerCaster::castStringable', ]; if (class_exists('Illuminate\Database\Eloquent\Model')) { $casters['Illuminate\Database\Eloquent\Model'] = 'Laravel\Tinker\TinkerCaster::castModel'; } if (class_exists('Illuminate\Process\ProcessResult')) { $casters['Illuminate\Process\ProcessResult'] = 'Laravel\Tinker\TinkerCaster::castProcessResult'; } if (class_exists('Illuminate\Foundation\Application')) { $casters['Illuminate\Foundation\Application'] = 'Laravel\Tinker\TinkerCaster::castApplication'; } $config = $this->getLaravel()->make('config'); return array_merge($casters, (array) $config->get('tinker.casters', [])); } /** * Get the console command arguments. * * @return array */ protected function getArguments() { return [ ['include', InputArgument::IS_ARRAY, 'Include file(s) before starting tinker'], ]; } /** * Get the console command options. * * @return array */ protected function getOptions() { return [ ['execute', null, InputOption::VALUE_OPTIONAL, 'Execute the given code using Tinker'], ]; } } PK a#ÔZ7—èjR R src/TinkerCaster.phpnu „[µü¤ $property(); if (! is_null($val)) { $results[Caster::PREFIX_VIRTUAL.$property] = $val; } } catch (Exception $e) { // } } return $results; } /** * Get an array representing the properties of a collection. * * @param \Illuminate\Support\Collection $collection * @return array */ public static function castCollection($collection) { return [ Caster::PREFIX_VIRTUAL.'all' => $collection->all(), ]; } /** * Get an array representing the properties of an html string. * * @param \Illuminate\Support\HtmlString $htmlString * @return array */ public static function castHtmlString($htmlString) { return [ Caster::PREFIX_VIRTUAL.'html' => $htmlString->toHtml(), ]; } /** * Get an array representing the properties of a fluent string. * * @param \Illuminate\Support\Stringable $stringable * @return array */ public static function castStringable($stringable) { return [ Caster::PREFIX_VIRTUAL.'value' => (string) $stringable, ]; } /** * Get an array representing the properties of a process result. * * @param \Illuminate\Process\ProcessResult $result * @return array */ public static function castProcessResult($result) { return [ Caster::PREFIX_VIRTUAL.'output' => $result->output(), Caster::PREFIX_VIRTUAL.'errorOutput' => $result->errorOutput(), Caster::PREFIX_VIRTUAL.'exitCode' => $result->exitCode(), Caster::PREFIX_VIRTUAL.'successful' => $result->successful(), ]; } /** * Get an array representing the properties of a model. * * @param \Illuminate\Database\Eloquent\Model $model * @return array */ public static function castModel($model) { $attributes = array_merge( $model->getAttributes(), $model->getRelations() ); $visible = array_flip( $model->getVisible() ?: array_diff(array_keys($attributes), $model->getHidden()) ); $hidden = array_flip($model->getHidden()); $appends = (function () { return array_combine($this->appends, $this->appends); })->bindTo($model, $model)(); foreach ($appends as $appended) { $attributes[$appended] = $model->{$appended}; } $results = []; foreach ($attributes as $key => $value) { $prefix = ''; if (isset($visible[$key])) { $prefix = Caster::PREFIX_VIRTUAL; } if (isset($hidden[$key])) { $prefix = Caster::PREFIX_PROTECTED; } $results[$prefix.$key] = $value; } return $results; } } PK a#ÔZ«ÀùÒî î README.mdnu „[µü¤