diff --git a/.github/workflows/pull-request-check.yml b/.github/workflows/pull-request-check.yml index 845a36664..2695a7b46 100644 --- a/.github/workflows/pull-request-check.yml +++ b/.github/workflows/pull-request-check.yml @@ -23,6 +23,6 @@ jobs: - name: Running unit test uses: php-actions/phpunit@v3 with: - version: 9.5 + version: 9.6 php_version: 8.1 configuration: phpunit.xml diff --git a/composer.json b/composer.json index 982ab940b..998111cd0 100755 --- a/composer.json +++ b/composer.json @@ -12,32 +12,31 @@ "require": { "php": ">=8.1.0", "d11wtq/boris": "~1.0", + "filp/whoops": "~2.11", "ircmaxell/password-compat": "~1.0", + "laravel/serializable-closure": "^1.2", "monolog/monolog": "~1.6", - "nesbot/carbon": "~2.0", + "nesbot/carbon": "^2.71", + "opis/closure": "~3.6", + "pda/pheanstalk": "~4.0", "phpseclib/phpseclib": "~2.0", "predis/predis": "^1.1", - "stack/builder": "~1.0", "swiftmailer/swiftmailer": "^6.0", - "symfony/browser-kit": "~4.4", - "symfony/console": "~4.4", - "symfony/css-selector": "~4.4", - "symfony/dom-crawler": "~4.4", - "symfony/finder": "~4.4", - "symfony/http-foundation": "~4.4", - "symfony/http-kernel": "~4.4", - "symfony/process": "~4.4", - "symfony/routing": "~4.4", - "symfony/security-core": "~4.4", - "symfony/translation": "~4.4", - "symfony/event-dispatcher": "~4.4", - "symfony/mime": "~5.0.0", - "symfony/error-handler": "~4.4", - "pda/pheanstalk": "~4.0", - "opis/closure": "~3.6", - "voku/portable-ascii": "~1.5", - "filp/whoops": "~2.11", - "laravel/serializable-closure": "^1.2" + "symfony/browser-kit": "~6.4", + "symfony/console": "~6.4", + "symfony/css-selector": "~6.4", + "symfony/dom-crawler": "~6.4", + "symfony/error-handler": "~6.4", + "symfony/event-dispatcher": "~6.4", + "symfony/finder": "~6.4", + "symfony/http-foundation": "~6.4", + "symfony/http-kernel": "~6.4", + "symfony/mime": "~6.4", + "symfony/process": "~6.4", + "symfony/routing": "~6.4", + "symfony/security-core": "~6.4", + "symfony/translation": "~6.4", + "voku/portable-ascii": "~1.5" }, "replace": { "illuminate/auth": "self.version", @@ -71,10 +70,9 @@ }, "require-dev": { "mockery/mockery": "~1.3", - "phpunit/phpunit": "~9.5", + "phpunit/phpunit": "~9.6", "phpspec/prophecy-phpunit": "~2.0", - "symfony/debug": "~4.4", - "symfony/var-dumper": "~4.4" + "symfony/var-dumper": "~6.4" }, "autoload": { "classmap": [ @@ -104,5 +102,8 @@ "suggest": { "doctrine/dbal": "Allow renaming columns and dropping SQLite columns." }, - "minimum-stability": "stable" + "minimum-stability": "stable", + "config": { + "sort-packages": true + } } diff --git a/phpunit.xml b/phpunit.xml index 42bc2297a..9d97e0efc 100755 --- a/phpunit.xml +++ b/phpunit.xml @@ -29,4 +29,8 @@ ./tests + + + + diff --git a/src/Illuminate/Console/Application.php b/src/Illuminate/Console/Application.php index eab05b5fc..0e3ba45c7 100755 --- a/src/Illuminate/Console/Application.php +++ b/src/Illuminate/Console/Application.php @@ -160,8 +160,8 @@ public function resolveCommands($commands) * * @return \Symfony\Component\Console\Input\InputDefinition */ - protected function getDefaultInputDefinition() - { + protected function getDefaultInputDefinition(): \Symfony\Component\Console\Input\InputDefinition + { $definition = parent::getDefaultInputDefinition(); $definition->addOption($this->getEnvironmentOption()); diff --git a/src/Illuminate/Console/Command.php b/src/Illuminate/Console/Command.php index 8903c902d..004a8938a 100755 --- a/src/Illuminate/Console/Command.php +++ b/src/Illuminate/Console/Command.php @@ -44,7 +44,7 @@ class Command extends \Symfony\Component\Console\Command\Command { * * @var string */ - protected $description; + protected $description = ''; /** * Create a new console command instance. @@ -91,8 +91,8 @@ protected function specifyParameters() * @param \Symfony\Component\Console\Output\OutputInterface $output * @return int */ - public function run(InputInterface $input, OutputInterface $output) - { + public function run(InputInterface $input, OutputInterface $output): int + { $this->input = $input; $this->output = $output; @@ -107,9 +107,12 @@ public function run(InputInterface $input, OutputInterface $output) * @param \Symfony\Component\Console\Output\OutputInterface $output * @return mixed */ - protected function execute(InputInterface $input, OutputInterface $output) - { - return $this->fire(); + protected function execute(InputInterface $input, OutputInterface $output): mixed + { + // Symfony 5 removed support of returning null, so we cast the returned value as integer. + // In this case, void-returned fire() method will be casted to 0. + // @see https://github.com/symfony/console/blob/6.3/CHANGELOG.md#500 + return (int) $this->fire(); } /** diff --git a/src/Illuminate/Cookie/Guard.php b/src/Illuminate/Cookie/Guard.php index 1aafbef78..efe1fde86 100644 --- a/src/Illuminate/Cookie/Guard.php +++ b/src/Illuminate/Cookie/Guard.php @@ -46,8 +46,8 @@ public function __construct(HttpKernelInterface $app, Encrypter $encrypter) * @param bool $catch * @return \Symfony\Component\HttpFoundation\Response */ - public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true) - { + public function handle(Request $request, $type = HttpKernelInterface::MAIN_REQUEST, $catch = true): Response + { return $this->encrypt($this->app->handle($this->decrypt($request), $type, $catch)); } diff --git a/src/Illuminate/Cookie/Queue.php b/src/Illuminate/Cookie/Queue.php index 65354cbb0..970c79d68 100644 --- a/src/Illuminate/Cookie/Queue.php +++ b/src/Illuminate/Cookie/Queue.php @@ -42,8 +42,8 @@ public function __construct(HttpKernelInterface $app, CookieJar $cookies) * @param bool $catch * @return \Symfony\Component\HttpFoundation\Response */ - public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true) - { + public function handle(Request $request, $type = HttpKernelInterface::MAIN_REQUEST, $catch = true): \Symfony\Component\HttpFoundation\Response + { $response = $this->app->handle($request, $type, $catch); foreach ($this->cookies->getQueuedCookies() as $cookie) diff --git a/src/Illuminate/Database/Console/Migrations/InstallCommand.php b/src/Illuminate/Database/Console/Migrations/InstallCommand.php index d89c0c4af..23f57c237 100755 --- a/src/Illuminate/Database/Console/Migrations/InstallCommand.php +++ b/src/Illuminate/Database/Console/Migrations/InstallCommand.php @@ -43,8 +43,8 @@ public function __construct(MigrationRepositoryInterface $repository) /** * Execute the console command. * - * @return void - */ + * @return int + */ public function fire() { $this->repository->setSource($this->input->getOption('database')); @@ -52,6 +52,8 @@ public function fire() $this->repository->createRepository(); $this->info("Migration table created successfully."); + + return 0; } /** diff --git a/src/Illuminate/Database/Console/Migrations/MigrateCommand.php b/src/Illuminate/Database/Console/Migrations/MigrateCommand.php index 035192fd8..31807713a 100755 --- a/src/Illuminate/Database/Console/Migrations/MigrateCommand.php +++ b/src/Illuminate/Database/Console/Migrations/MigrateCommand.php @@ -52,8 +52,8 @@ public function __construct(Migrator $migrator, $packagePath) /** * Execute the console command. * - * @return void - */ + * @return int + */ public function fire() { if ( ! $this->confirmToProceed()) return; @@ -84,6 +84,8 @@ public function fire() { $this->call('db:seed', ['--force' => true]); } + + return 0; } /** diff --git a/src/Illuminate/Database/Console/Migrations/MigrateMakeCommand.php b/src/Illuminate/Database/Console/Migrations/MigrateMakeCommand.php index 5fc6933eb..2b800a5c4 100644 --- a/src/Illuminate/Database/Console/Migrations/MigrateMakeCommand.php +++ b/src/Illuminate/Database/Console/Migrations/MigrateMakeCommand.php @@ -52,8 +52,8 @@ public function __construct(MigrationCreator $creator, $packagePath) /** * Execute the console command. * - * @return void - */ + * @return int + */ public function fire() { // It's possible for the developer to specify the tables to modify in this @@ -73,6 +73,8 @@ public function fire() $this->writeMigration($name, $table, $create); $this->call('dump-autoload'); + + return 0; } /** diff --git a/src/Illuminate/Database/Console/Migrations/RefreshCommand.php b/src/Illuminate/Database/Console/Migrations/RefreshCommand.php index 2adc6e82e..aebaf9349 100755 --- a/src/Illuminate/Database/Console/Migrations/RefreshCommand.php +++ b/src/Illuminate/Database/Console/Migrations/RefreshCommand.php @@ -25,8 +25,8 @@ class RefreshCommand extends Command { /** * Execute the console command. * - * @return void - */ + * @return int + */ public function fire() { if ( ! $this->confirmToProceed()) return; @@ -50,6 +50,8 @@ public function fire() { $this->runSeeder($database); } + + return 0; } /** diff --git a/src/Illuminate/Database/Console/Migrations/ResetCommand.php b/src/Illuminate/Database/Console/Migrations/ResetCommand.php index f81fa907d..3dc040140 100755 --- a/src/Illuminate/Database/Console/Migrations/ResetCommand.php +++ b/src/Illuminate/Database/Console/Migrations/ResetCommand.php @@ -46,8 +46,8 @@ public function __construct(Migrator $migrator) /** * Execute the console command. * - * @return void - */ + * @return int + */ public function fire() { if ( ! $this->confirmToProceed()) return; @@ -70,6 +70,8 @@ public function fire() if ($count == 0) break; } + + return 0; } /** diff --git a/src/Illuminate/Database/Console/Migrations/RollbackCommand.php b/src/Illuminate/Database/Console/Migrations/RollbackCommand.php index c11198f6f..028d9ab44 100755 --- a/src/Illuminate/Database/Console/Migrations/RollbackCommand.php +++ b/src/Illuminate/Database/Console/Migrations/RollbackCommand.php @@ -46,8 +46,8 @@ public function __construct(Migrator $migrator) /** * Execute the console command. * - * @return void - */ + * @return int + */ public function fire() { if ( ! $this->confirmToProceed()) return; @@ -65,6 +65,8 @@ public function fire() { $this->output->writeln($note); } + + return 0; } /** diff --git a/src/Illuminate/Database/Console/SeedCommand.php b/src/Illuminate/Database/Console/SeedCommand.php index cba115b47..476ebb104 100755 --- a/src/Illuminate/Database/Console/SeedCommand.php +++ b/src/Illuminate/Database/Console/SeedCommand.php @@ -46,8 +46,8 @@ public function __construct(Resolver $resolver) /** * Execute the console command. * - * @return void - */ + * @return int + */ public function fire() { if ( ! $this->confirmToProceed()) return; @@ -55,6 +55,8 @@ public function fire() $this->resolver->setDefaultConnection($this->getDatabase()); $this->getSeeder()->run(); + + return 0; } /** diff --git a/src/Illuminate/Exception/Handler.php b/src/Illuminate/Exception/Handler.php index ca7c42d71..9c1370b6e 100755 --- a/src/Illuminate/Exception/Handler.php +++ b/src/Illuminate/Exception/Handler.php @@ -3,10 +3,9 @@ use Closure; use ErrorException; use ReflectionFunction; -use Symfony\Component\Debug\Exception\FatalThrowableError; use Illuminate\Support\Contracts\ResponsePreparerInterface; +use Symfony\Component\ErrorHandler\Error\FatalError; use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface; -use Symfony\Component\Debug\Exception\FatalErrorException as FatalError; class Handler { @@ -188,11 +187,9 @@ public function handleShutdown() // code so it can be displayed back out to the developer for information. if ( ! is_null($error)) { - extract($error); + if ( ! $this->isFatal($error['type'])) return; - if ( ! $this->isFatal($type)) return; - - $this->handleException(new FatalError($message, $type, 0, $file, $line))->send(); + $this->handleException(new FatalError($error['message'], 0, $error, 0))->send(); } } @@ -272,7 +269,21 @@ protected function displayException($exception) $displayer = $this->debug ? $this->debugDisplayer : $this->plainDisplayer; if (! $exception instanceof \Exception) { - $exception = new FatalThrowableError($exception); + if ($exception instanceof \ParseError) { + $severity = \E_PARSE; + } elseif ($exception instanceof \TypeError) { + $severity = \E_RECOVERABLE_ERROR; + } else { + $severity = \E_ERROR; + } + + $exception = new ErrorException( + $exception->getMessage(), + $exception->getCode(), + $severity, + $exception->getFile(), + $exception->getLine(), + ); } return $displayer->display($exception); diff --git a/src/Illuminate/Exception/SymfonyDisplayer.php b/src/Illuminate/Exception/SymfonyDisplayer.php deleted file mode 100755 index 6f358ea95..000000000 --- a/src/Illuminate/Exception/SymfonyDisplayer.php +++ /dev/null @@ -1,56 +0,0 @@ -symfony = $symfony; - $this->returnJson = $returnJson; - } - - /** - * Display the given exception to the user. - * - * @param \Exception $exception - * @return \Symfony\Component\HttpFoundation\Response - */ - public function display(Exception $exception) - { - if ($this->returnJson) - { - return new JsonResponse(array( - 'error' => $exception->getMessage(), - 'file' => $exception->getFile(), - 'line' => $exception->getLine(), - ), 500); - } - - return $this->symfony->createResponse($exception); - } - -} diff --git a/src/Illuminate/Foundation/Application.php b/src/Illuminate/Foundation/Application.php index e25e072e0..f2deb35e6 100755 --- a/src/Illuminate/Foundation/Application.php +++ b/src/Illuminate/Foundation/Application.php @@ -2,8 +2,8 @@ use Closure; use Illuminate\Container\BindingResolutionException; +use Illuminate\Foundation\Http\MiddlewareBuilder; use ReflectionException; -use Stack\Builder; use Illuminate\Http\Request; use Illuminate\Http\Response; use Illuminate\Config\FileLoader; @@ -14,10 +14,10 @@ use Illuminate\Routing\RoutingServiceProvider; use Illuminate\Exception\ExceptionServiceProvider; use Illuminate\Config\FileEnvironmentVariablesLoader; +use Symfony\Component\ErrorHandler\Error\FatalError; use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\TerminableInterface; use Symfony\Component\HttpKernel\Exception\HttpException; -use Symfony\Component\Debug\Exception\FatalErrorException; use Illuminate\Support\Contracts\ResponsePreparerInterface; use Symfony\Component\HttpFoundation\Request as SymfonyRequest; use Symfony\Component\HttpFoundation\Response as SymfonyResponse; @@ -664,7 +664,7 @@ protected function getStackedClient() { $sessionReject = $this->bound('session.reject') ? $this['session.reject'] : null; - $client = (new Builder) + $client = (new MiddlewareBuilder()) ->push('Illuminate\Cookie\Guard', $this['encrypter']) ->push('Illuminate\Cookie\Queue', $this['cookie']) ->push('Illuminate\Session\Middleware', $this['session'], $sessionReject); @@ -674,13 +674,13 @@ protected function getStackedClient() return $client->resolve($this); } - /** - * Merge the developer defined middlewares onto the stack. - * - * @param \Stack\Builder - * @return void - */ - protected function mergeCustomMiddlewares(Builder $stack) + /** + * Merge the developer defined middlewares onto the stack. + * + * @param MiddlewareBuilder $stack + * @return void + */ + protected function mergeCustomMiddlewares(MiddlewareBuilder $stack) { foreach ($this->middlewares as $middleware) { @@ -744,8 +744,8 @@ public function forgetMiddleware($class) * * @throws \Exception */ - public function handle(SymfonyRequest $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true) - { + public function handle(SymfonyRequest $request, $type = HttpKernelInterface::MAIN_REQUEST, $catch = true): SymfonyResponse + { try { $this->refreshRequest($request = Request::createFromBase($request)); @@ -972,7 +972,7 @@ public function pushError(Closure $callback) */ public function fatal(Closure $callback) { - $this->error(function(FatalErrorException $e) use ($callback) + $this->error(function(FatalError $e) use ($callback) { return call_user_func($callback, $e); }); diff --git a/src/Illuminate/Foundation/Console/AssetPublishCommand.php b/src/Illuminate/Foundation/Console/AssetPublishCommand.php index d9cbf9d3f..f15cc4730 100755 --- a/src/Illuminate/Foundation/Console/AssetPublishCommand.php +++ b/src/Illuminate/Foundation/Console/AssetPublishCommand.php @@ -45,14 +45,16 @@ public function __construct(AssetPublisher $assets) /** * Execute the console command. * - * @return void - */ + * @return int + */ public function fire() { foreach ($this->getPackages() as $package) { $this->publishAssets($package); } + + return 0; } /** diff --git a/src/Illuminate/Foundation/Console/AutoloadCommand.php b/src/Illuminate/Foundation/Console/AutoloadCommand.php index df321773c..bf5ad7d0b 100755 --- a/src/Illuminate/Foundation/Console/AutoloadCommand.php +++ b/src/Illuminate/Foundation/Console/AutoloadCommand.php @@ -43,8 +43,8 @@ public function __construct(Composer $composer) /** * Execute the console command. * - * @return void - */ + * @return int + */ public function fire() { $this->call('optimize'); @@ -55,6 +55,8 @@ public function fire() $this->composer->setWorkingPath($workbench['path'])->dumpOptimized(); } + + return 0; } /** diff --git a/src/Illuminate/Foundation/Console/ChangesCommand.php b/src/Illuminate/Foundation/Console/ChangesCommand.php index 698094e6d..0d2ce218e 100755 --- a/src/Illuminate/Foundation/Console/ChangesCommand.php +++ b/src/Illuminate/Foundation/Console/ChangesCommand.php @@ -22,8 +22,8 @@ class ChangesCommand extends Command { /** * Execute the console command. * - * @return void - */ + * @return int + */ public function fire() { list($version, $changes) = $this->getChangeVersion($this->getChangesArray()); @@ -34,6 +34,8 @@ public function fire() { $this->line($this->formatMessage($change)); } + + return 0; } /** diff --git a/src/Illuminate/Foundation/Console/ClearCompiledCommand.php b/src/Illuminate/Foundation/Console/ClearCompiledCommand.php index 43e0c046f..be9e7c35b 100755 --- a/src/Illuminate/Foundation/Console/ClearCompiledCommand.php +++ b/src/Illuminate/Foundation/Console/ClearCompiledCommand.php @@ -21,8 +21,8 @@ class ClearCompiledCommand extends Command { /** * Execute the console command. * - * @return void - */ + * @return int + */ public function fire() { if (file_exists($path = $this->laravel['path.base'].'/bootstrap/compiled.php')) @@ -34,6 +34,8 @@ public function fire() { @unlink($path); } + + return 0; } } diff --git a/src/Illuminate/Foundation/Console/CommandMakeCommand.php b/src/Illuminate/Foundation/Console/CommandMakeCommand.php index ee03af918..0882792c5 100755 --- a/src/Illuminate/Foundation/Console/CommandMakeCommand.php +++ b/src/Illuminate/Foundation/Console/CommandMakeCommand.php @@ -37,8 +37,8 @@ public function __construct(Filesystem $files) /** * Execute the console command. * - * @return void - */ + * @return int + */ public function fire() { $path = $this->getPath(); @@ -51,6 +51,8 @@ public function fire() $file = $path.'/'.$this->input->getArgument('name').'.php'; $this->writeCommand($file, $stub); + + return 0; } /** diff --git a/src/Illuminate/Foundation/Console/ConfigPublishCommand.php b/src/Illuminate/Foundation/Console/ConfigPublishCommand.php index d7e9d1ae3..d3722b80f 100755 --- a/src/Illuminate/Foundation/Console/ConfigPublishCommand.php +++ b/src/Illuminate/Foundation/Console/ConfigPublishCommand.php @@ -47,8 +47,8 @@ public function __construct(ConfigPublisher $config) /** * Execute the console command. * - * @return void - */ + * @return int + */ public function fire() { $package = $this->input->getArgument('package'); @@ -70,6 +70,8 @@ public function fire() } $this->output->writeln('Configuration published for package: '.$package); + + return 0; } /** diff --git a/src/Illuminate/Foundation/Console/DownCommand.php b/src/Illuminate/Foundation/Console/DownCommand.php index 50e1a367f..21afba391 100755 --- a/src/Illuminate/Foundation/Console/DownCommand.php +++ b/src/Illuminate/Foundation/Console/DownCommand.php @@ -21,13 +21,15 @@ class DownCommand extends Command { /** * Execute the console command. * - * @return void - */ + * @return int + */ public function fire() { touch($this->laravel['config']['app.manifest'].'/down'); $this->comment('Application is now in maintenance mode.'); + + return 0; } } diff --git a/src/Illuminate/Foundation/Console/EnvironmentCommand.php b/src/Illuminate/Foundation/Console/EnvironmentCommand.php index 5a12976c0..b6036203d 100755 --- a/src/Illuminate/Foundation/Console/EnvironmentCommand.php +++ b/src/Illuminate/Foundation/Console/EnvironmentCommand.php @@ -21,11 +21,13 @@ class EnvironmentCommand extends Command { /** * Execute the console command. * - * @return void - */ + * @return int + */ public function fire() { $this->line('Current application environment: '.$this->laravel['env'].''); + + return 0; } } diff --git a/src/Illuminate/Foundation/Console/KeyGenerateCommand.php b/src/Illuminate/Foundation/Console/KeyGenerateCommand.php index ab92271d6..564b5db61 100755 --- a/src/Illuminate/Foundation/Console/KeyGenerateCommand.php +++ b/src/Illuminate/Foundation/Console/KeyGenerateCommand.php @@ -36,8 +36,8 @@ public function __construct(Filesystem $files) /** * Execute the console command. * - * @return void - */ + * @return int + */ public function fire() { list($path, $contents) = $this->getKeyFile(); @@ -51,6 +51,8 @@ public function fire() $this->laravel['config']['app.key'] = $key; $this->info("Application key [$key] set successfully."); + + return 0; } /** diff --git a/src/Illuminate/Foundation/Console/MigratePublishCommand.php b/src/Illuminate/Foundation/Console/MigratePublishCommand.php index 141b8275a..6e9edebee 100644 --- a/src/Illuminate/Foundation/Console/MigratePublishCommand.php +++ b/src/Illuminate/Foundation/Console/MigratePublishCommand.php @@ -22,8 +22,8 @@ class MigratePublishCommand extends Command { /** * Execute the console command. * - * @return void - */ + * @return int + */ public function fire() { $published = $this->laravel['migration.publisher']->publish( @@ -34,6 +34,8 @@ public function fire() { $this->line('Published: '.basename((string) $migration)); } + + return 0; } /** diff --git a/src/Illuminate/Foundation/Console/Optimize/config.php b/src/Illuminate/Foundation/Console/Optimize/config.php index 171c27808..169c3a93c 100755 --- a/src/Illuminate/Foundation/Console/Optimize/config.php +++ b/src/Illuminate/Foundation/Console/Optimize/config.php @@ -24,7 +24,7 @@ $basePath.'/vendor/symfony/http-foundation/Session/Storage/MetadataBag.php', $basePath.'/vendor/symfony/http-foundation/AcceptHeaderItem.php', $basePath.'/vendor/symfony/http-foundation/AcceptHeader.php', - $basePath.'/vendor/symfony/debug/ExceptionHandler.php', + $basePath.'/vendor/symfony/error-handler/ErrorHandler.php', $basePath.'/vendor/laravel/framework/src/Illuminate/Support/ServiceProvider.php', $basePath.'/vendor/laravel/framework/src/Illuminate/Exception/ExceptionServiceProvider.php', $basePath.'/vendor/laravel/framework/src/Illuminate/Routing/RoutingServiceProvider.php', @@ -33,7 +33,6 @@ $basePath.'/vendor/laravel/framework/src/Illuminate/Support/Traits/MacroableTrait.php', $basePath.'/vendor/laravel/framework/src/Illuminate/Support/Arr.php', $basePath.'/vendor/laravel/framework/src/Illuminate/Support/Str.php', - $basePath.'/vendor/symfony/debug/ErrorHandler.php', $basePath.'/vendor/laravel/framework/src/Illuminate/Config/Repository.php', $basePath.'/vendor/laravel/framework/src/Illuminate/Support/NamespacedItemResolver.php', $basePath.'/vendor/laravel/framework/src/Illuminate/Config/FileLoader.php', @@ -114,6 +113,6 @@ $basePath.'/vendor/filp/whoops/src/Whoops/Handler/HandlerInterface.php', $basePath.'/vendor/filp/whoops/src/Whoops/Handler/Handler.php', $basePath.'/vendor/filp/whoops/src/Whoops/Handler/JsonResponseHandler.php', - $basePath.'/vendor/stack/builder/src/Stack/Builder.php', - $basePath.'/vendor/stack/builder/src/Stack/StackedHttpKernel.php', + $basePath.'/vendor/laravel/framework/src/Illuminate/Foundation/Http/MiddlewareBuilder.php', + $basePath.'/vendor/laravel/framework/src/Illuminate/Foundation/Http/StackedHttpKernel.php', )); diff --git a/src/Illuminate/Foundation/Console/OptimizeCommand.php b/src/Illuminate/Foundation/Console/OptimizeCommand.php index 9a9fe77a4..8f9177aea 100644 --- a/src/Illuminate/Foundation/Console/OptimizeCommand.php +++ b/src/Illuminate/Foundation/Console/OptimizeCommand.php @@ -44,8 +44,8 @@ public function __construct(Composer $composer) /** * Execute the console command. * - * @return void - */ + * @return int + */ public function fire() { $this->info('Generating optimized class loader'); @@ -75,6 +75,8 @@ public function fire() { $this->call('clear-compiled'); } + + return 0; } /** diff --git a/src/Illuminate/Foundation/Console/RoutesCommand.php b/src/Illuminate/Foundation/Console/RoutesCommand.php index 210a6458f..a13f6f0c3 100755 --- a/src/Illuminate/Foundation/Console/RoutesCommand.php +++ b/src/Illuminate/Foundation/Console/RoutesCommand.php @@ -63,8 +63,8 @@ public function __construct(Router $router) /** * Execute the console command. * - * @return void - */ + * @return int + */ public function fire() { if (count($this->routes) == 0) @@ -73,6 +73,8 @@ public function fire() } $this->displayRoutes($this->getRoutes()); + + return 0; } /** diff --git a/src/Illuminate/Foundation/Console/ServeCommand.php b/src/Illuminate/Foundation/Console/ServeCommand.php index 998105fd7..c94c344f7 100755 --- a/src/Illuminate/Foundation/Console/ServeCommand.php +++ b/src/Illuminate/Foundation/Console/ServeCommand.php @@ -22,8 +22,8 @@ class ServeCommand extends Command { /** * Execute the console command. * - * @return void - */ + * @return int + */ public function fire() { $this->checkPhpVersion(); @@ -39,6 +39,8 @@ public function fire() $this->info("Laravel development server started on http://{$host}:{$port}"); passthru('"'.PHP_BINARY.'"'." -S {$host}:{$port} -t \"{$public}\" server.php"); + + return 0; } /** diff --git a/src/Illuminate/Foundation/Console/TailCommand.php b/src/Illuminate/Foundation/Console/TailCommand.php index 9976c5952..9dee85f33 100644 --- a/src/Illuminate/Foundation/Console/TailCommand.php +++ b/src/Illuminate/Foundation/Console/TailCommand.php @@ -24,8 +24,8 @@ class TailCommand extends Command { /** * Execute the console command. * - * @return void - */ + * @return int + */ public function fire() { $path = $this->getPath($this->argument('connection')); @@ -38,6 +38,8 @@ public function fire() { $this->error('Could not determine path to log file.'); } + + return 0; } /** diff --git a/src/Illuminate/Foundation/Console/TinkerCommand.php b/src/Illuminate/Foundation/Console/TinkerCommand.php index 8cb48c260..3e7b41a84 100755 --- a/src/Illuminate/Foundation/Console/TinkerCommand.php +++ b/src/Illuminate/Foundation/Console/TinkerCommand.php @@ -22,8 +22,8 @@ class TinkerCommand extends Command { /** * Execute the console command. * - * @return void - */ + * @return int + */ public function fire() { if ($this->supportsBoris()) @@ -36,6 +36,8 @@ public function fire() $this->runPlainShell(); } + + return 0; } /** diff --git a/src/Illuminate/Foundation/Console/UpCommand.php b/src/Illuminate/Foundation/Console/UpCommand.php index dd8455248..7787994b0 100755 --- a/src/Illuminate/Foundation/Console/UpCommand.php +++ b/src/Illuminate/Foundation/Console/UpCommand.php @@ -21,13 +21,15 @@ class UpCommand extends Command { /** * Execute the console command. * - * @return void - */ + * @return int + */ public function fire() { @unlink($this->laravel['config']['app.manifest'].'/down'); $this->info('Application is now live.'); + + return 0; } } diff --git a/src/Illuminate/Foundation/Console/ViewPublishCommand.php b/src/Illuminate/Foundation/Console/ViewPublishCommand.php index 43536191e..99242f751 100755 --- a/src/Illuminate/Foundation/Console/ViewPublishCommand.php +++ b/src/Illuminate/Foundation/Console/ViewPublishCommand.php @@ -44,8 +44,8 @@ public function __construct(ViewPublisher $view) /** * Execute the console command. * - * @return void - */ + * @return int + */ public function fire() { $package = $this->input->getArgument('package'); @@ -60,6 +60,8 @@ public function fire() } $this->output->writeln('Views published for package: '.$package); + + return 0; } /** diff --git a/src/Illuminate/Foundation/Http/MiddlewareBuilder.php b/src/Illuminate/Foundation/Http/MiddlewareBuilder.php new file mode 100644 index 000000000..1a42dccdf --- /dev/null +++ b/src/Illuminate/Foundation/Http/MiddlewareBuilder.php @@ -0,0 +1,65 @@ +specs = new SplStack(); + } + + public function unshift(/*$kernelClass, $args...*/) + { + if (func_num_args() === 0) { + throw new \InvalidArgumentException("Missing argument(s) when calling unshift"); + } + + $spec = func_get_args(); + $this->specs->unshift($spec); + + return $this; + } + + public function push(/*$kernelClass, $args...*/) + { + if (func_num_args() === 0) { + throw new \InvalidArgumentException("Missing argument(s) when calling push"); + } + + $spec = func_get_args(); + $this->specs->push($spec); + + return $this; + } + + public function resolve(HttpKernelInterface $app) + { + $middlewares = array($app); + + foreach ($this->specs as $spec) { + $args = $spec; + $firstArg = array_shift($args); + + if (is_callable($firstArg)) { + $app = $firstArg($app); + } else { + $kernelClass = $firstArg; + array_unshift($args, $app); + + $reflection = new ReflectionClass($kernelClass); + $app = $reflection->newInstanceArgs($args); + } + + array_unshift($middlewares, $app); + } + + return new StackedHttpKernel($app, $middlewares); + } +} diff --git a/src/Illuminate/Foundation/Http/StackedHttpKernel.php b/src/Illuminate/Foundation/Http/StackedHttpKernel.php new file mode 100644 index 000000000..b010093eb --- /dev/null +++ b/src/Illuminate/Foundation/Http/StackedHttpKernel.php @@ -0,0 +1,39 @@ +app = $app; + $this->middlewares = $middlewares; + } + + public function handle(Request $request, $type = HttpKernelInterface::MAIN_REQUEST, $catch = true): Response + { + return $this->app->handle($request, $type, $catch); + } + + public function terminate(Request $request, Response $response) + { + $prevKernel = null; + + foreach ($this->middlewares as $kernel) { + // if prev kernel was terminable we can assume this middleware has already been called + if (!$prevKernel instanceof TerminableInterface && $kernel instanceof TerminableInterface) { + $kernel->terminate($request, $response); + } + + $prevKernel = $kernel; + } + } +} diff --git a/src/Illuminate/Foundation/Testing/Client.php b/src/Illuminate/Foundation/Testing/Client.php index 6a5b7dd45..89cb540c3 100755 --- a/src/Illuminate/Foundation/Testing/Client.php +++ b/src/Illuminate/Foundation/Testing/Client.php @@ -10,10 +10,9 @@ class Client extends HttpKernelBrowser { * Convert a BrowserKit request into a Illuminate request. * * @param \Symfony\Component\BrowserKit\Request $request - * @return \Illuminate\Http\Request */ - protected function filterRequest(DomRequest $request) - { + protected function filterRequest(DomRequest $request): \Symfony\Component\HttpFoundation\Request + { $httpRequest = Application::onRequest('create', $this->getRequestParameters($request)); $httpRequest->files->replace($this->filterFiles($httpRequest->files->all())); diff --git a/src/Illuminate/Http/FrameGuard.php b/src/Illuminate/Http/FrameGuard.php index 9237605e5..010dff479 100644 --- a/src/Illuminate/Http/FrameGuard.php +++ b/src/Illuminate/Http/FrameGuard.php @@ -33,8 +33,8 @@ public function __construct(HttpKernelInterface $app) * @param bool $catch * @return \Symfony\Component\HttpFoundation\Response */ - public function handle(SymfonyRequest $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true) - { + public function handle(SymfonyRequest $request, $type = HttpKernelInterface::MAIN_REQUEST, $catch = true): \Symfony\Component\HttpFoundation\Response + { $response = $this->app->handle($request, $type, $catch); $response->headers->set('X-Frame-Options', 'SAMEORIGIN', false); diff --git a/src/Illuminate/Http/JsonResponse.php b/src/Illuminate/Http/JsonResponse.php index a9c030c90..971d76227 100755 --- a/src/Illuminate/Http/JsonResponse.php +++ b/src/Illuminate/Http/JsonResponse.php @@ -43,8 +43,8 @@ public function getData($assoc = false, $depth = 512) /** * {@inheritdoc} */ - public function setData($data = array()) - { + public function setData($data = array()): static + { $this->data = $data instanceof JsonableInterface ? $data->toJson($this->jsonOptions) : json_encode($data, $this->jsonOptions); diff --git a/src/Illuminate/Http/Request.php b/src/Illuminate/Http/Request.php index cefee4378..092c7c727 100755 --- a/src/Illuminate/Http/Request.php +++ b/src/Illuminate/Http/Request.php @@ -2,6 +2,7 @@ use Illuminate\Support\Str; use SplFileInfo; +use Symfony\Component\HttpFoundation\InputBag; use Symfony\Component\HttpFoundation\ParameterBag; use Symfony\Component\HttpFoundation\Request as SymfonyRequest; @@ -464,12 +465,15 @@ public function flush() */ protected function retrieveItem($source, $key, $default) { - if (is_null($key)) - { + if (is_null($key)) { return $this->$source->all(); } - return $this->$source->get($key, $default, true); + if ($this->$source instanceof InputBag) { + return $this->$source->all()[$key] ?? $default; + } + + return $this->$source->get($key, $default); } /** diff --git a/src/Illuminate/Http/Response.php b/src/Illuminate/Http/Response.php index 712b63721..4d3a6f059 100755 --- a/src/Illuminate/Http/Response.php +++ b/src/Illuminate/Http/Response.php @@ -46,8 +46,8 @@ public function __construct($content = '', int $status = 200, array $headers = [ * @param mixed $content * @return $this */ - public function setContent($content) - { + public function setContent($content): static + { $this->original = $content; // If the content is "JSONable" we will set the appropriate header and convert diff --git a/src/Illuminate/Queue/Console/FailedTableCommand.php b/src/Illuminate/Queue/Console/FailedTableCommand.php index 0b485ddce..6cbf86320 100644 --- a/src/Illuminate/Queue/Console/FailedTableCommand.php +++ b/src/Illuminate/Queue/Console/FailedTableCommand.php @@ -42,8 +42,8 @@ public function __construct(Filesystem $files) /** * Execute the console command. * - * @return void - */ + * @return int + */ public function fire() { $fullPath = $this->createBaseMigration(); @@ -51,6 +51,8 @@ public function fire() $this->files->put($fullPath, $this->files->get(__DIR__.'/stubs/failed_jobs.stub')); $this->info('Migration created successfully!'); + + return 0; } /** diff --git a/src/Illuminate/Queue/Console/FlushFailedCommand.php b/src/Illuminate/Queue/Console/FlushFailedCommand.php index 0ece99b52..91f6fba91 100644 --- a/src/Illuminate/Queue/Console/FlushFailedCommand.php +++ b/src/Illuminate/Queue/Console/FlushFailedCommand.php @@ -21,7 +21,6 @@ class FlushFailedCommand extends Command { /** * Execute the console command. * - * @return void */ public function fire() { diff --git a/src/Illuminate/Queue/Console/ForgetFailedCommand.php b/src/Illuminate/Queue/Console/ForgetFailedCommand.php index fef76f081..d2c1e7ae3 100644 --- a/src/Illuminate/Queue/Console/ForgetFailedCommand.php +++ b/src/Illuminate/Queue/Console/ForgetFailedCommand.php @@ -22,8 +22,8 @@ class ForgetFailedCommand extends Command { /** * Execute the console command. * - * @return void - */ + * @return int + */ public function fire() { if ($this->laravel['queue.failer']->forget($this->argument('id'))) @@ -34,6 +34,8 @@ public function fire() { $this->error('No failed job matches the given ID.'); } + + return 0; } /** diff --git a/src/Illuminate/Queue/Console/ListFailedCommand.php b/src/Illuminate/Queue/Console/ListFailedCommand.php index 469015e7a..328c97b9d 100644 --- a/src/Illuminate/Queue/Console/ListFailedCommand.php +++ b/src/Illuminate/Queue/Console/ListFailedCommand.php @@ -21,8 +21,8 @@ class ListFailedCommand extends Command { /** * Execute the console command. * - * @return void - */ + * @return int + */ public function fire() { $rows = array(); @@ -34,7 +34,8 @@ public function fire() if (count($rows) == 0) { - return $this->info('No failed jobs!'); + $this->info('No failed jobs!'); + return 0; } $table = $this->getHelperSet()->get('table'); @@ -42,6 +43,8 @@ public function fire() $table->setHeaders(array('ID', 'Connection', 'Queue', 'Class', 'Failed At')) ->setRows($rows) ->render($this->output); + + return 0; } /** diff --git a/src/Illuminate/Queue/Console/ListenCommand.php b/src/Illuminate/Queue/Console/ListenCommand.php index f138b3c46..32f67cd00 100755 --- a/src/Illuminate/Queue/Console/ListenCommand.php +++ b/src/Illuminate/Queue/Console/ListenCommand.php @@ -44,8 +44,8 @@ public function __construct(Listener $listener) /** * Execute the console command. * - * @return void - */ + * @return int + */ public function fire() { $this->setListenerOptions(); @@ -69,6 +69,8 @@ public function fire() $this->listener->listen( $connection, $queue, $delay, $memory, $timeout ); + + return 0; } /** diff --git a/src/Illuminate/Queue/Console/RestartCommand.php b/src/Illuminate/Queue/Console/RestartCommand.php index de02cd7da..80313e09e 100644 --- a/src/Illuminate/Queue/Console/RestartCommand.php +++ b/src/Illuminate/Queue/Console/RestartCommand.php @@ -21,13 +21,15 @@ class RestartCommand extends Command { /** * Execute the console command. * - * @return void - */ + * @return int + */ public function fire() { $this->laravel['cache']->forever('illuminate:queue:restart', time()); $this->info('Broadcasting queue restart signal.'); + + return 0; } } diff --git a/src/Illuminate/Queue/Console/RetryCommand.php b/src/Illuminate/Queue/Console/RetryCommand.php index 454b56d2f..8f1102019 100644 --- a/src/Illuminate/Queue/Console/RetryCommand.php +++ b/src/Illuminate/Queue/Console/RetryCommand.php @@ -22,8 +22,8 @@ class RetryCommand extends Command { /** * Execute the console command. * - * @return void - */ + * @return int + */ public function fire() { $failed = $this->laravel['queue.failer']->find($this->argument('id')); @@ -42,6 +42,8 @@ public function fire() { $this->error('No failed job matches the given ID.'); } + + return 0; } /** diff --git a/src/Illuminate/Queue/Console/SubscribeCommand.php b/src/Illuminate/Queue/Console/SubscribeCommand.php index 89c4209e0..ce68fc3a3 100755 --- a/src/Illuminate/Queue/Console/SubscribeCommand.php +++ b/src/Illuminate/Queue/Console/SubscribeCommand.php @@ -32,8 +32,8 @@ class SubscribeCommand extends Command { /** * Execute the console command. * - * @return void - * + * @return int + * * @throws \RuntimeException */ public function fire() @@ -48,6 +48,8 @@ public function fire() $iron->getIron()->updateQueue($this->argument('queue'), $this->getQueueOptions()); $this->line('Queue subscriber added: '.$this->argument('url').''); + + return 0; } /** diff --git a/src/Illuminate/Queue/Console/WorkCommand.php b/src/Illuminate/Queue/Console/WorkCommand.php index 859cc63e8..6acf44e1d 100755 --- a/src/Illuminate/Queue/Console/WorkCommand.php +++ b/src/Illuminate/Queue/Console/WorkCommand.php @@ -45,11 +45,11 @@ public function __construct(Worker $worker) /** * Execute the console command. * - * @return void - */ + * @return int + */ public function fire() { - if ($this->downForMaintenance() && ! $this->option('daemon')) return; + if ($this->downForMaintenance() && ! $this->option('daemon')) return 0; $queue = $this->option('queue'); @@ -73,6 +73,8 @@ public function fire() { $this->writeOutput($response['job'], $response['failed']); } + + return 0; } /** diff --git a/src/Illuminate/Routing/Console/MakeControllerCommand.php b/src/Illuminate/Routing/Console/MakeControllerCommand.php index 8c4c692c8..c54a7851e 100755 --- a/src/Illuminate/Routing/Console/MakeControllerCommand.php +++ b/src/Illuminate/Routing/Console/MakeControllerCommand.php @@ -53,11 +53,13 @@ public function __construct(ControllerGenerator $generator, $path) /** * Execute the console command. * - * @return void - */ + * @return int + */ public function fire() { $this->generateController(); + + return 0; } /** diff --git a/src/Illuminate/Routing/Router.php b/src/Illuminate/Routing/Router.php index eabb62a0e..06a1595b4 100755 --- a/src/Illuminate/Routing/Router.php +++ b/src/Illuminate/Routing/Router.php @@ -1792,8 +1792,8 @@ public function getPatterns() * * @return Response */ - public function handle(SymfonyRequest $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true) - { + public function handle(SymfonyRequest $request, $type = HttpKernelInterface::MAIN_REQUEST, $catch = true): SymfonyResponse + { return $this->dispatch(Request::createFromBase($request)); } diff --git a/src/Illuminate/Session/Middleware.php b/src/Illuminate/Session/Middleware.php index 9d8347df7..7bad30c04 100644 --- a/src/Illuminate/Session/Middleware.php +++ b/src/Illuminate/Session/Middleware.php @@ -55,8 +55,8 @@ public function __construct(HttpKernelInterface $app, SessionManager $manager, C * @param bool $catch * @return \Symfony\Component\HttpFoundation\Response */ - public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true) - { + public function handle(Request $request, $type = HttpKernelInterface::MAIN_REQUEST, $catch = true): Response + { $this->checkRequestForArraySessions($request); // If a session driver has been configured, we will need to start the session here diff --git a/src/Illuminate/Session/Store.php b/src/Illuminate/Session/Store.php index 2b2ea70d9..5204a6611 100755 --- a/src/Illuminate/Session/Store.php +++ b/src/Illuminate/Session/Store.php @@ -83,7 +83,7 @@ public function __construct($name, SessionHandlerInterface $handler, $id = null) /** * {@inheritdoc} */ - public function start() + public function start(): bool { $this->loadSession(); @@ -135,8 +135,8 @@ protected function initializeLocalBag($bag) /** * {@inheritdoc} */ - public function getId() - { + public function getId(): string + { return $this->id; } @@ -177,8 +177,8 @@ protected function generateSessionId(): string /** * {@inheritdoc} */ - public function getName() - { + public function getName(): string + { return $this->name; } @@ -193,8 +193,8 @@ public function setName($name) /** * {@inheritdoc} */ - public function invalidate($lifetime = null) - { + public function invalidate($lifetime = null): bool + { $this->attributes = array(); $this->migrate(); @@ -205,8 +205,8 @@ public function invalidate($lifetime = null) /** * {@inheritdoc} */ - public function migrate($destroy = false, $lifetime = null) - { + public function migrate($destroy = false, $lifetime = null): bool + { if ($destroy) $this->handler->destroy($this->getId()); $this->setExists(false); @@ -269,16 +269,16 @@ public function ageFlashData() /** * {@inheritdoc} */ - public function has($name) - { + public function has($name): bool + { return ! is_null($this->get($name)); } /** * {@inheritdoc} */ - public function get($name, $default = null) - { + public function get($name, $default = null): mixed + { return array_get($this->attributes, $name, $default); } @@ -446,8 +446,8 @@ protected function removeFromOldFlashData(array $keys) /** * {@inheritdoc} */ - public function all() - { + public function all(): array + { return $this->attributes; } @@ -465,8 +465,8 @@ public function replace(array $attributes) /** * {@inheritdoc} */ - public function remove($name) - { + public function remove($name): mixed + { return array_pull($this->attributes, $name); } @@ -507,8 +507,8 @@ public function flush() /** * {@inheritdoc} */ - public function isStarted() - { + public function isStarted(): bool + { return $this->started; } @@ -523,8 +523,8 @@ public function registerBag(SessionBagInterface $bag) /** * {@inheritdoc} */ - public function getBag($name) - { + public function getBag($name): SessionBagInterface + { return array_get($this->bags, $name, function() { throw new \InvalidArgumentException("Bag not registered."); @@ -534,8 +534,8 @@ public function getBag($name) /** * {@inheritdoc} */ - public function getMetadataBag() - { + public function getMetadataBag(): MetadataBag + { return $this->metaBag; } diff --git a/src/Illuminate/Translation/Translator.php b/src/Illuminate/Translation/Translator.php index 172cd754d..cadb953b7 100755 --- a/src/Illuminate/Translation/Translator.php +++ b/src/Illuminate/Translation/Translator.php @@ -176,8 +176,8 @@ public function choice($key, $number, array $replace = array(), $locale = null): * @param string $locale * @return string */ - public function trans($id, array $parameters = array(), $domain = 'messages', $locale = null) - { + public function trans($id, array $parameters = array(), $domain = 'messages', $locale = null): string + { return $this->get($id, $parameters, $locale); } diff --git a/src/Illuminate/View/Engines/CompilerEngine.php b/src/Illuminate/View/Engines/CompilerEngine.php index 9b278a1c4..784f62136 100755 --- a/src/Illuminate/View/Engines/CompilerEngine.php +++ b/src/Illuminate/View/Engines/CompilerEngine.php @@ -1,7 +1,6 @@ getMessage($e), 0, 1, $e->getFile(), $e->getLine(), $e); diff --git a/tests/Auth/AuthGuardTest.php b/tests/Auth/AuthGuardTest.php index b29d058eb..04c63619a 100755 --- a/tests/Auth/AuthGuardTest.php +++ b/tests/Auth/AuthGuardTest.php @@ -42,6 +42,11 @@ public function testBasicReturnsNullOnValidAttempt() $request = Request::create('/', 'GET', [], [], [], ['PHP_AUTH_USER' => 'foo@bar.com', 'PHP_AUTH_PW' => 'secret'] ) ); + + $this->session->migrate(true)->willReturn(true); + $this->session->get(Argument::type('string'))->willReturn(true); + $this->session->put(Argument::type('string'), null)->shouldBeCalledOnce(); + $this->userProvider->retrieveById(Argument::any())->shouldBeCalledOnce(); $this->userProvider ->retrieveByCredentials(['email' => 'foo@bar.com', 'password' => 'secret']) ->willReturn($this->prophesize(UserInterface::class)->reveal()); @@ -62,6 +67,11 @@ public function testUserIsAuthenticatedWhenBasicAttemptIsValid() $request = Request::create('/', 'GET', [], [], [], ['PHP_AUTH_USER' => 'foo@bar.com', 'PHP_AUTH_PW' => 'secret'] ) ); + + $this->session->migrate(true)->willReturn(true); + $this->session->get(Argument::type('string'))->willReturn(true); + $this->session->put(Argument::type('string'), null)->shouldBeCalledOnce(); + $this->userProvider->retrieveById(Argument::any())->shouldBeCalledOnce(); $this->userProvider ->retrieveByCredentials(['email' => 'foo@bar.com', 'password' => 'secret']) ->willReturn($this->prophesize(UserInterface::class)->reveal()); @@ -84,6 +94,11 @@ public function testBasicReturnsNullWhenAlreadyLoggedIn() $request = Request::create('/', 'GET', [], [], [], ['PHP_AUTH_USER' => 'foo@bar.com', 'PHP_AUTH_PW' => 'secret'] ) ); + + $this->session->migrate(true)->willReturn(true); + $this->session->get(Argument::type('string'))->willReturn(true); + $this->session->put(Argument::type('string'), null)->shouldBeCalledOnce(); + $guard->login($this->prophesize(UserInterface::class)->reveal()); $this->assertNull($guard->basic('email', $request)); @@ -97,6 +112,10 @@ public function testBasicReturnsResponseOnFailure() $request = Request::create('/', 'GET', [], [], [], ['PHP_AUTH_USER' => 'foo@bar.com', 'PHP_AUTH_PW' => 'secret'] ) ); + + $this->session->migrate(true)->willReturn(true); + $this->session->get(Argument::type('string'))->willReturn(true); + $this->userProvider->retrieveById(Argument::any())->shouldBeCalledOnce(); $this->userProvider ->retrieveByCredentials(['email' => 'foo@bar.com', 'password' => 'secret']) ->willReturn($this->prophesize(UserInterface::class)->reveal()); @@ -173,6 +192,9 @@ public function testLoginFiresLoginEvent() $user = $this->prophesize(UserInterface::class); $user->getAuthIdentifier()->willReturn('foo'); + $this->session->migrate(true)->willReturn(true); + $this->session->put(Argument::type('string'), 'foo')->shouldBeCalledOnce(); + $events->fire('auth.login', [$user, false])->shouldBeCalledTimes(1); $guard->login($user->reveal()); @@ -285,6 +307,9 @@ public function testLoginMethodQueuesCookieWhenRemembering() $cookieJar->forever($guard->getRecallerName(), 'foo|recaller')->willReturn($foreverCookie); $cookieJar->queue($foreverCookie)->shouldBeCalledTimes(1); + $this->session->migrate(true)->willReturn(true); + $this->session->put(Argument::type('string'), 'foo')->shouldBeCalledOnce(); + $guard->login($user->reveal(), true); } @@ -299,6 +324,9 @@ public function testLoginMethodCreatesRememberTokenIfOneDoesntExist() $user->setRememberToken(Argument::type('string'))->shouldBeCalledTimes(1); $this->userProvider->updateRememberToken($user->reveal(), Argument::type('string'))->shouldBeCalledTimes(1); + $this->session->migrate(true)->willReturn(true); + $this->session->put(Argument::type('string'), 'foo')->shouldBeCalledOnce(); + $guard->login($user->reveal(), true); } @@ -321,6 +349,9 @@ public function testLoginUsingIdReturnsLoggedInUser() { $guard = new Guard($this->userProvider->reveal(), $this->session->reveal(), new Request()); + $this->session->migrate(true)->willReturn(true); + $this->session->put(Argument::type('string'), 10)->shouldBeCalledOnce(); + $this->session->put(Argument::type('string'), null)->shouldBeCalledOnce(); $this->userProvider ->retrieveById(10) ->willReturn(($user = $this->prophesize(UserInterface::class))->reveal()); diff --git a/tests/Database/DatabaseEloquentModelTest.php b/tests/Database/DatabaseEloquentModelTest.php index 0cf8a8a40..93f292bc1 100755 --- a/tests/Database/DatabaseEloquentModelTest.php +++ b/tests/Database/DatabaseEloquentModelTest.php @@ -797,8 +797,8 @@ public function testCloneModelMakesAFreshCopyOfTheModel(): void $this->assertFalse($clone->exists); $this->assertEquals('taylor', $clone->first); $this->assertEquals('otwell', $clone->last); - $this->assertObjectNotHasAttribute('created_at', $clone); - $this->assertObjectNotHasAttribute('updated_at', $clone); + $this->assertObjectNotHasProperty('created_at', $clone); + $this->assertObjectNotHasProperty('updated_at', $clone); $this->assertEquals(['bar'], $clone->foo); } diff --git a/tests/Foundation/FoundationApplicationTest.php b/tests/Foundation/FoundationApplicationTest.php index 7da9aa53a..046b4370e 100755 --- a/tests/Foundation/FoundationApplicationTest.php +++ b/tests/Foundation/FoundationApplicationTest.php @@ -138,7 +138,7 @@ public function testHandleRespectsCatchArgument() $app['env'] = 'temporarilynottesting'; $app->handle( new Symfony\Component\HttpFoundation\Request(), - Symfony\Component\HttpKernel\HttpKernelInterface::MASTER_REQUEST, + Symfony\Component\HttpKernel\HttpKernelInterface::MAIN_REQUEST, false ); } diff --git a/tests/Foundation/FoundationComposerTest.php b/tests/Foundation/FoundationComposerTest.php index 6608d7e04..d35d9c48c 100755 --- a/tests/Foundation/FoundationComposerTest.php +++ b/tests/Foundation/FoundationComposerTest.php @@ -21,8 +21,10 @@ public function testDumpAutoloadRunsTheCorrectCommand() ['getProcess'], [$files = m::mock(Filesystem::class), __DIR__] ); +// public function __construct(array $command, string $cwd = null, array $env = null, mixed $input = null, ?float $timeout = 60) + $files->shouldReceive('exists')->once()->with(__DIR__ . '/composer.phar')->andReturn(true); - $process = $this->getMock(Process::class, ['run'], ['composer.phar dump-autoload', __DIR__ . '/composer.phar']); + $process = $this->getMock(Process::class, ['run'], [['composer.phar dump-autoload'], __DIR__ . '/composer.phar']); $composer->expects($this->once())->method('getProcess')->willReturn($process); $process->expects($this->once())->method('run'); @@ -38,7 +40,7 @@ public function testDumpAutoloadRunsTheCorrectCommandWhenComposerIsntPresent() ), __DIR__ ]); $files->shouldReceive('exists')->once()->with(__DIR__.'/composer.phar')->andReturn(false); - $process = $this->getMock(Process::class, ['run'], ['composer dump-autoload', __DIR__ . '/composer.phar']); + $process = $this->getMock(Process::class, ['run'], [['composer dump-autoload'], __DIR__ . '/composer.phar']); $composer->expects($this->once())->method('getProcess')->willReturn($process); $process->expects($this->once())->method('run'); diff --git a/tests/Http/HttpRequestTest.php b/tests/Http/HttpRequestTest.php index 0698aa76f..840aa6cfd 100755 --- a/tests/Http/HttpRequestTest.php +++ b/tests/Http/HttpRequestTest.php @@ -196,6 +196,14 @@ public function testQueryMethod() $this->assertEquals('Bob', $request->query('foo', 'Bob')); $all = $request->query(null); $this->assertEquals('Taylor', $all['name']); + + $request = Request::create('/', 'GET', ['hello' => 'world', 'user' => ['Taylor', 'Mohamed Said']]); + $this->assertSame(['Taylor', 'Mohamed Said'], $request->query('user')); + $this->assertSame(['hello' => 'world', 'user' => ['Taylor', 'Mohamed Said']], $request->query->all()); + + $request = Request::create('/?hello=world&user[]=Taylor&user[]=Mohamed%20Said', 'GET', []); + $this->assertSame(['Taylor', 'Mohamed Said'], $request->query('user')); + $this->assertSame(['hello' => 'world', 'user' => ['Taylor', 'Mohamed Said']], $request->query->all()); } diff --git a/tests/Session/SessionMiddlewareTest.php b/tests/Session/SessionMiddlewareTest.php index 14c28527d..0cac3622a 100644 --- a/tests/Session/SessionMiddlewareTest.php +++ b/tests/Session/SessionMiddlewareTest.php @@ -37,7 +37,7 @@ public function testSessionIsProperlyStartedAndClosed() $manager->shouldReceive('driver')->andReturn($driver = m::mock(Store::class)->makePartial()); $driver->shouldReceive('setRequestOnHandler')->once()->with($request); $driver->shouldReceive('start')->once(); - $app->shouldReceive('handle')->once()->with($request, Symfony\Component\HttpKernel\HttpKernelInterface::MASTER_REQUEST, true)->andReturn($response); + $app->shouldReceive('handle')->once()->with($request, Symfony\Component\HttpKernel\HttpKernelInterface::MAIN_REQUEST, true)->andReturn($response); $driver->shouldReceive('save')->once(); $driver->shouldReceive('getHandler')->andReturn($handler = m::mock('StdClass')); $handler->shouldReceive('gc')->once()->with(120 * 60); @@ -63,7 +63,7 @@ public function testSessionIsNotUsedWhenNoDriver() $manager->shouldReceive('getSessionConfig')->andReturn([ 'driver' => null, ]); - $app->shouldReceive('handle')->once()->with($request, Symfony\Component\HttpKernel\HttpKernelInterface::MASTER_REQUEST, true)->andReturn($response); + $app->shouldReceive('handle')->once()->with($request, Symfony\Component\HttpKernel\HttpKernelInterface::MAIN_REQUEST, true)->andReturn($response); $middleResponse = $middle->handle($request); $this->assertSame($response, $middleResponse);