Skip to content

Upgrade Symfony components to 6.x #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 28 commits into from
May 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
1112b15
upgrade symfony components to 6.3
rizqyhi Oct 1, 2023
8960a39
remove `symfony/debug`
rizqyhi Oct 1, 2023
63a5833
remove `stack/builder`, adopted to core
rizqyhi Oct 1, 2023
bb7af57
show php errors while running test
rizqyhi Oct 1, 2023
ba081ec
adjust session implementation with the upgraded contract
rizqyhi Oct 16, 2023
9aec110
add mocks to repair the tests
rizqyhi Oct 16, 2023
900b603
adjust return type from parent class
rizqyhi Oct 16, 2023
78787e3
fix methods compatibilities with upgraded symfony components
rizqyhi Oct 16, 2023
b4c9920
fix commands return value
rizqyhi Nov 3, 2023
7952168
fix tests
rizqyhi Nov 3, 2023
da38541
update assertion method
rizqyhi Nov 3, 2023
0a15aac
refactor `symfony/debug` to `symfony/error-handler`
rizqyhi Nov 3, 2023
e707d50
remove `SymfonyDisplayer`
rizqyhi Nov 3, 2023
a68bdfa
order dependencies
rizqyhi Nov 3, 2023
be51a6c
update classes path
rizqyhi Nov 3, 2023
38a6477
update `symfony/mime`
rizqyhi Nov 3, 2023
2728546
fix error handler
rizqyhi Nov 4, 2023
635ff0d
try to use `ErrorException` instead of `FataError`
rizqyhi Nov 4, 2023
71575a0
set default description as empty string
rizqyhi Nov 4, 2023
add9451
fix return type of built-in artisan commands
rizqyhi Nov 17, 2023
d1373b2
fix return type of built-in artisan commands
rizqyhi Nov 17, 2023
874fe91
fix incompatible method declaration
rizqyhi Nov 17, 2023
e4ee85c
fix incompatible method declaration
rizqyhi Nov 20, 2023
a8c8f66
force casting void-return command to integer
rizqyhi Nov 20, 2023
7ac4431
backport `laravel/framework#40609`
rizqyhi Nov 21, 2023
d7747b8
remove deprecated param, see laravel/framework#11675
rizqyhi Nov 21, 2023
8189acb
update to symfony 6.4 LTS
rizqyhi Dec 7, 2023
1a36900
update phpunit to 9.6
rizqyhi Dec 8, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pull-request-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
51 changes: 26 additions & 25 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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": [
Expand Down Expand Up @@ -104,5 +102,8 @@
"suggest": {
"doctrine/dbal": "Allow renaming columns and dropping SQLite columns."
},
"minimum-stability": "stable"
"minimum-stability": "stable",
"config": {
"sort-packages": true
}
}
4 changes: 4 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,8 @@
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<php>
<ini name="display_errors" value="On" />
<ini name="display_startup_errors" value="On" />
</php>
</phpunit>
4 changes: 2 additions & 2 deletions src/Illuminate/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
15 changes: 9 additions & 6 deletions src/Illuminate/Console/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Command extends \Symfony\Component\Console\Command\Command {
*
* @var string
*/
protected $description;
protected $description = '';

/**
* Create a new console command instance.
Expand Down Expand Up @@ -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;
Expand All @@ -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();
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Cookie/Guard.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Cookie/Queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 4 additions & 2 deletions src/Illuminate/Database/Console/Migrations/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,17 @@ public function __construct(MigrationRepositoryInterface $repository)
/**
* Execute the console command.
*
* @return void
*/
* @return int
*/
public function fire()
{
$this->repository->setSource($this->input->getOption('database'));

$this->repository->createRepository();

$this->info("Migration table created successfully.");

return 0;
}

/**
Expand Down
6 changes: 4 additions & 2 deletions src/Illuminate/Database/Console/Migrations/MigrateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -84,6 +84,8 @@ public function fire()
{
$this->call('db:seed', ['--force' => true]);
}

return 0;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -73,6 +73,8 @@ public function fire()
$this->writeMigration($name, $table, $create);

$this->call('dump-autoload');

return 0;
}

/**
Expand Down
6 changes: 4 additions & 2 deletions src/Illuminate/Database/Console/Migrations/RefreshCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ class RefreshCommand extends Command {
/**
* Execute the console command.
*
* @return void
*/
* @return int
*/
public function fire()
{
if ( ! $this->confirmToProceed()) return;
Expand All @@ -50,6 +50,8 @@ public function fire()
{
$this->runSeeder($database);
}

return 0;
}

/**
Expand Down
6 changes: 4 additions & 2 deletions src/Illuminate/Database/Console/Migrations/ResetCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ public function __construct(Migrator $migrator)
/**
* Execute the console command.
*
* @return void
*/
* @return int
*/
public function fire()
{
if ( ! $this->confirmToProceed()) return;
Expand All @@ -70,6 +70,8 @@ public function fire()

if ($count == 0) break;
}

return 0;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ public function __construct(Migrator $migrator)
/**
* Execute the console command.
*
* @return void
*/
* @return int
*/
public function fire()
{
if ( ! $this->confirmToProceed()) return;
Expand All @@ -65,6 +65,8 @@ public function fire()
{
$this->output->writeln($note);
}

return 0;
}

/**
Expand Down
6 changes: 4 additions & 2 deletions src/Illuminate/Database/Console/SeedCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,17 @@ public function __construct(Resolver $resolver)
/**
* Execute the console command.
*
* @return void
*/
* @return int
*/
public function fire()
{
if ( ! $this->confirmToProceed()) return;

$this->resolver->setDefaultConnection($this->getDatabase());

$this->getSeeder()->run();

return 0;
}

/**
Expand Down
25 changes: 18 additions & 7 deletions src/Illuminate/Exception/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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();
}
}

Expand Down Expand Up @@ -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);
Expand Down
Loading