Skip to content

[9.x] Fix Symfony v6 breaking changes #38376

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 3 commits into from
Aug 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 3 additions & 2 deletions src/Illuminate/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Symfony\Component\Console\Exception\CommandNotFoundException;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputDefinition;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\StringInput;
Expand Down Expand Up @@ -84,7 +85,7 @@ public function __construct(Container $laravel, Dispatcher $events, $version)
/**
* {@inheritdoc}
*/
public function run(InputInterface $input = null, OutputInterface $output = null)
public function run(InputInterface $input = null, OutputInterface $output = null): int
{
$commandName = $this->getCommandName(
$input = $input ?: new ArgvInput
Expand Down Expand Up @@ -309,7 +310,7 @@ public function setContainerCommandLoader()
*
* @return \Symfony\Component\Console\Input\InputDefinition
*/
protected function getDefaultInputDefinition()
protected function getDefaultInputDefinition(): InputDefinition
{
return tap(parent::getDefaultInputDefinition(), function ($definition) {
$definition->addOption($this->getEnvironmentOption());
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Console/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ protected function configureUsingFluentDefinition()
* @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->output = $this->laravel->make(
OutputStyle::class, ['input' => $input, 'output' => $output]
Expand Down Expand Up @@ -164,7 +164,7 @@ protected function resolveCommand($command)
/**
* {@inheritdoc}
*/
public function isHidden()
public function isHidden(): bool
{
return $this->hidden;
}
Expand Down
7 changes: 4 additions & 3 deletions src/Illuminate/Console/ContainerCommandLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Illuminate\Console;

use Psr\Container\ContainerInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\CommandLoader\CommandLoaderInterface;
use Symfony\Component\Console\Exception\CommandNotFoundException;

Expand Down Expand Up @@ -43,7 +44,7 @@ public function __construct(ContainerInterface $container, array $commandMap)
*
* @throws \Symfony\Component\Console\Exception\CommandNotFoundException
*/
public function get(string $name)
public function get(string $name): Command
{
if (! $this->has($name)) {
throw new CommandNotFoundException(sprintf('Command "%s" does not exist.', $name));
Expand All @@ -58,7 +59,7 @@ public function get(string $name)
* @param string $name
* @return bool
*/
public function has(string $name)
public function has(string $name): bool
{
return $name && isset($this->commandMap[$name]);
}
Expand All @@ -68,7 +69,7 @@ public function has(string $name)
*
* @return string[]
*/
public function getNames()
public function getNames(): array
{
return array_keys($this->commandMap);
}
Expand Down
8 changes: 4 additions & 4 deletions src/Illuminate/Console/OutputStyle.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function __construct(InputInterface $input, OutputInterface $output)
*
* @return bool
*/
public function isQuiet()
public function isQuiet(): bool
{
return $this->output->isQuiet();
}
Expand All @@ -44,7 +44,7 @@ public function isQuiet()
*
* @return bool
*/
public function isVerbose()
public function isVerbose(): bool
{
return $this->output->isVerbose();
}
Expand All @@ -54,7 +54,7 @@ public function isVerbose()
*
* @return bool
*/
public function isVeryVerbose()
public function isVeryVerbose(): bool
{
return $this->output->isVeryVerbose();
}
Expand All @@ -64,7 +64,7 @@ public function isVeryVerbose()
*
* @return bool
*/
public function isDebug()
public function isDebug(): bool
{
return $this->output->isDebug();
}
Expand Down
6 changes: 3 additions & 3 deletions src/Illuminate/Http/JsonResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function __construct($data = null, $status = 200, $headers = [], $options
/**
* {@inheritdoc}
*/
public static function fromJsonString(?string $data = null, int $status = 200, array $headers = [])
public static function fromJsonString(?string $data = null, int $status = 200, array $headers = []): static
{
return new static($data, $status, $headers, 0, true);
}
Expand Down Expand Up @@ -66,7 +66,7 @@ public function getData($assoc = false, $depth = 512)
/**
* {@inheritdoc}
*/
public function setData($data = [])
public function setData($data = []): static
{
$this->original = $data;

Expand Down Expand Up @@ -110,7 +110,7 @@ protected function hasValidJson($jsonError)
/**
* {@inheritdoc}
*/
public function setEncodingOptions($options)
public function setEncodingOptions($options): static
{
$this->encodingOptions = (int) $options;

Expand Down
18 changes: 4 additions & 14 deletions src/Illuminate/Http/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ public function replace(array $input)
* @param mixed $default
* @return mixed
*/
public function get(string $key, $default = null)
public function get(string $key, mixed $default = null): mixed
{
return parent::get($key, $default);
}
Expand Down Expand Up @@ -404,7 +404,7 @@ public static function createFrom(self $from, $to = null)

$request->setJson($from->json());

if ($session = $from->getSession()) {
if ($from->hasSession() && $session = $from->getSession()) {
$request->setLaravelSession($session);
}

Expand Down Expand Up @@ -442,7 +442,7 @@ public static function createFromBase(SymfonyRequest $request)
/**
* {@inheritdoc}
*/
public function duplicate(array $query = null, array $request = null, array $attributes = null, array $cookies = null, array $files = null, array $server = null)
public function duplicate(array $query = null, array $request = null, array $attributes = null, array $cookies = null, array $files = null, array $server = null): static
{
return parent::duplicate($query, $request, $attributes, $cookies, $this->filterFiles($files), $server);
}
Expand Down Expand Up @@ -488,16 +488,6 @@ public function session()
return $this->session;
}

/**
* Get the session associated with the request.
*
* @return \Illuminate\Session\Store|null
*/
public function getSession()
{
return $this->session;
}

/**
* Set the session instance on the request.
*
Expand Down Expand Up @@ -625,7 +615,7 @@ public function setRouteResolver(Closure $callback)
*
* @return array
*/
public function toArray()
public function toArray(): array
{
return $this->all();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Http/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function __construct($content = '', $status = 200, array $headers = [])
*
* @throws \InvalidArgumentException
*/
public function setContent($content)
public function setContent(mixed $content): static
{
$this->original = $content;

Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Http/Testing/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public function mimeType($mimeType)
*
* @return string
*/
public function getMimeType()
public function getMimeType(): string
{
return $this->mimeTypeToReport ?: MimeType::from($this->name);
}
Expand Down