upgraded dependencies

This commit is contained in:
RafficMohammed
2023-01-08 01:59:16 +05:30
parent 51056e3aad
commit f9ae387337
6895 changed files with 133617 additions and 178680 deletions

View File

@@ -1,4 +0,0 @@
php:
preset: laravel
js: true
css: true

View File

@@ -1,30 +1,32 @@
<p align="center"><img src="https://laravel.com/assets/img/components/logo-tinker.svg"></p>
<p align="center"><img src="/art/logo.svg" alt="Logo Laravel Tinker"></p>
<p align="center">
<a href="https://travis-ci.org/laravel/tinker"><img src="https://travis-ci.org/laravel/tinker.svg" alt="Build Status"></a>
<a href="https://packagist.org/packages/laravel/tinker"><img src="https://poser.pugx.org/laravel/tinker/d/total.svg" alt="Total Downloads"></a>
<a href="https://packagist.org/packages/laravel/tinker"><img src="https://poser.pugx.org/laravel/tinker/v/stable.svg" alt="Latest Stable Version"></a>
<a href="https://packagist.org/packages/laravel/tinker"><img src="https://poser.pugx.org/laravel/tinker/license.svg" alt="License"></a>
<a href="https://github.com/laravel/tinker/actions"><img src="https://github.com/laravel/tinker/workflows/tests/badge.svg" alt="Build Status"></a>
<a href="https://packagist.org/packages/laravel/tinker"><img src="https://img.shields.io/packagist/dt/laravel/tinker" alt="Total Downloads"></a>
<a href="https://packagist.org/packages/laravel/tinker"><img src="https://img.shields.io/packagist/v/laravel/tinker" alt="Latest Stable Version"></a>
<a href="https://packagist.org/packages/laravel/tinker"><img src="https://img.shields.io/packagist/l/laravel/tinker" alt="License"></a>
</p>
## Introduction
Laravel Tinker is a powerful REPL for the Laravel framework.
## Installation
## Official Documentation
To get started with Laravel Tinker, simply run:
Documentation for Tinker can be found on the [Laravel website](https://laravel.com/docs/artisan#tinker).
composer require laravel/tinker
## Contributing
## Basic Usage
Thank you for considering contributing to Tinker! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
From your console, execute the `php artisan tinker` command.
## Code of Conduct
### Dispatching Jobs
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
The `dispatch` helper function and `dispatch` method on the `Dispatchable` class depends on garbage collection to place the job on the queue. Therefore, when using `tinker`, you should use `Bus::dispatch` or `Queue::push` to dispatch jobs.
## Security Vulnerabilities
Please review [our security policy](https://github.com/laravel/tinker/security/policy) on how to report security vulnerabilities.
## License
Laravel Tinker is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
Laravel Tinker is open-sourced software licensed under the [MIT license](LICENSE.md).

View File

@@ -10,15 +10,19 @@
}
],
"require": {
"php": ">=5.5.9",
"illuminate/console": "~5.1|^6.0",
"illuminate/contracts": "~5.1|^6.0",
"illuminate/support": "~5.1|^6.0",
"psy/psysh": "0.7.*|0.8.*|0.9.*",
"symfony/var-dumper": "~3.0|~4.0"
"php": "^7.2.5|^8.0",
"illuminate/console": "^6.0|^7.0|^8.0|^9.0",
"illuminate/contracts": "^6.0|^7.0|^8.0|^9.0",
"illuminate/support": "^6.0|^7.0|^8.0|^9.0",
"psy/psysh": "^0.10.4|^0.11.1",
"symfony/var-dumper": "^4.3.4|^5.0|^6.0"
},
"require-dev": {
"phpunit/phpunit": "~4.0|~5.0"
"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)."
},
"autoload": {
"psr-4": {
@@ -27,12 +31,14 @@
},
"autoload-dev": {
"psr-4": {
"Laravel\\Tinker\\Tests\\": "tests/"
"Laravel\\Tinker\\Tests\\": "tests/",
"App\\": "tests/fixtures/app",
"One\\Two\\": "tests/fixtures/vendor/one/two"
}
},
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
"dev-master": "2.x-dev"
},
"laravel": {
"providers": [
@@ -43,7 +49,6 @@
"config": {
"sort-packages": true
},
"suggest": {
"illuminate/database": "The Illuminate Database package (~5.1)."
}
"minimum-stability": "dev",
"prefer-stable": true
}

View File

@@ -19,7 +19,22 @@ return [
/*
|--------------------------------------------------------------------------
| Alias Blacklist
| Auto Aliased Classes
|--------------------------------------------------------------------------
|
| Tinker will not automatically alias classes in your vendor namespaces
| but you may explicitly allow a subset of classes to get aliased by
| adding the names of each of those classes to the following list.
|
*/
'alias' => [
//
],
/*
|--------------------------------------------------------------------------
| Classes That Should Not Be Aliased
|--------------------------------------------------------------------------
|
| Typically, Tinker automatically aliases classes as you require them in

View File

@@ -2,8 +2,8 @@
namespace Laravel\Tinker;
use Psy\Shell;
use Illuminate\Support\Str;
use Psy\Shell;
class ClassAliasAutoloader
{
@@ -21,16 +21,39 @@ class ClassAliasAutoloader
*/
protected $classes = [];
/**
* Path to the vendor directory.
*
* @var string
*/
protected $vendorPath;
/**
* Explicitly included namespaces/classes.
*
* @var \Illuminate\Support\Collection
*/
protected $includedAliases;
/**
* Excluded namespaces/classes.
*
* @var \Illuminate\Support\Collection
*/
protected $excludedAliases;
/**
* Register a new alias loader instance.
*
* @param \Psy\Shell $shell
* @param string $classMapPath
* @param array $includedAliases
* @param array $excludedAliases
* @return static
*/
public static function register(Shell $shell, $classMapPath)
public static function register(Shell $shell, $classMapPath, array $includedAliases = [], array $excludedAliases = [])
{
return tap(new static($shell, $classMapPath), function ($loader) {
return tap(new static($shell, $classMapPath, $includedAliases, $excludedAliases), function ($loader) {
spl_autoload_register([$loader, 'aliasClass']);
});
}
@@ -40,26 +63,21 @@ class ClassAliasAutoloader
*
* @param \Psy\Shell $shell
* @param string $classMapPath
* @param array $includedAliases
* @param array $excludedAliases
* @return void
*/
public function __construct(Shell $shell, $classMapPath)
public function __construct(Shell $shell, $classMapPath, array $includedAliases = [], array $excludedAliases = [])
{
$this->shell = $shell;
$vendorPath = dirname(dirname($classMapPath));
$this->vendorPath = dirname(dirname($classMapPath));
$this->includedAliases = collect($includedAliases);
$this->excludedAliases = collect($excludedAliases);
$classes = require $classMapPath;
$excludedAliases = collect(config('tinker.dont_alias', []));
foreach ($classes as $class => $path) {
if (! Str::contains($class, '\\') || Str::startsWith($path, $vendorPath)) {
continue;
}
if (! $excludedAliases->filter(function ($alias) use ($class) {
return Str::startsWith($class, $alias);
})->isEmpty()) {
if (! $this->isAliasable($class, $path)) {
continue;
}
@@ -83,9 +101,7 @@ class ClassAliasAutoloader
return;
}
$fullName = isset($this->classes[$class])
? $this->classes[$class]
: false;
$fullName = $this->classes[$class] ?? false;
if ($fullName) {
$this->shell->writeStdout("[!] Aliasing '{$class}' to '{$fullName}' for this Tinker session.\n");
@@ -113,4 +129,35 @@ class ClassAliasAutoloader
{
$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;
}
}

View File

@@ -2,11 +2,14 @@
namespace Laravel\Tinker\Console;
use Psy\Shell;
use Psy\Configuration;
use Illuminate\Console\Command;
use Illuminate\Support\Env;
use Laravel\Tinker\ClassAliasAutoloader;
use Psy\Configuration;
use Psy\Shell;
use Psy\VersionUpdater\Checker;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
class TinkerCommand extends Command
{
@@ -16,7 +19,7 @@ class TinkerCommand extends Command
* @var array
*/
protected $commandWhitelist = [
'clear-compiled', 'down', 'env', 'inspire', 'migrate', 'optimize', 'up',
'clear-compiled', 'down', 'env', 'inspire', 'migrate', 'migrate:install', 'optimize', 'up',
];
/**
@@ -36,36 +39,50 @@ class TinkerCommand extends Command
/**
* Execute the console command.
*
* @return void
* @return int
*/
public function handle()
{
$this->getApplication()->setCatchExceptions(false);
$config = new Configuration([
'updateCheck' => 'never',
]);
$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'));
if (isset($_ENV['COMPOSER_VENDOR_DIR'])) {
$path = $_ENV['COMPOSER_VENDOR_DIR'];
} else {
$path = $this->getLaravel()->basePath().DIRECTORY_SEPARATOR.'vendor';
}
$path = Env::get('COMPOSER_VENDOR_DIR', $this->getLaravel()->basePath().DIRECTORY_SEPARATOR.'vendor');
$path .= '/composer/autoload_classmap.php';
$loader = ClassAliasAutoloader::register($shell, $path);
$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 {
$shell->run();
return $shell->run();
} finally {
$loader->unregister();
}
@@ -86,8 +103,12 @@ class TinkerCommand extends Command
}
}
foreach (config('tinker.commands', []) as $command) {
$commands[] = $this->getApplication()->resolve($command);
$config = $this->getLaravel()->make('config');
foreach ($config->get('tinker.commands', []) as $command) {
$commands[] = $this->getApplication()->add(
$this->getLaravel()->make($command)
);
}
return $commands;
@@ -102,6 +123,8 @@ class TinkerCommand extends Command
{
$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')) {
@@ -112,7 +135,9 @@ class TinkerCommand extends Command
$casters['Illuminate\Foundation\Application'] = 'Laravel\Tinker\TinkerCaster::castApplication';
}
return $casters;
$config = $this->getLaravel()->make('config');
return array_merge($casters, (array) $config->get('tinker.casters', []));
}
/**
@@ -126,4 +151,16 @@ class TinkerCommand extends Command
['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'],
];
}
}

View File

@@ -68,6 +68,32 @@ class TinkerCaster
];
}
/**
* 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 model.
*
@@ -84,10 +110,30 @@ class TinkerCaster
$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 (array_intersect_key($attributes, $visible) as $key => $value) {
$results[(isset($visible[$key]) ? Caster::PREFIX_VIRTUAL : Caster::PREFIX_PROTECTED).$key] = $value;
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;

View File

@@ -2,20 +2,14 @@
namespace Laravel\Tinker;
use Illuminate\Support\ServiceProvider;
use Laravel\Tinker\Console\TinkerCommand;
use Laravel\Lumen\Application as LumenApplication;
use Illuminate\Contracts\Support\DeferrableProvider;
use Illuminate\Foundation\Application as LaravelApplication;
use Illuminate\Support\ServiceProvider;
use Laravel\Lumen\Application as LumenApplication;
use Laravel\Tinker\Console\TinkerCommand;
class TinkerServiceProvider extends ServiceProvider
class TinkerServiceProvider extends ServiceProvider implements DeferrableProvider
{
/**
* Indicates if loading of the provider is deferred.
*
* @var bool
*/
protected $defer = true;
/**
* Boot the service provider.
*