Skip to content

Commit

Permalink
Apply #[\Override] attribute on methods extended from Symfony (#49130)
Browse files Browse the repository at this point in the history
* Apply `#[\Override]` attribute when applicable.

Signed-off-by: Mior Muhammad Zaki <[email protected]>

* wip

Signed-off-by: Mior Muhammad Zaki <[email protected]>

---------

Signed-off-by: Mior Muhammad Zaki <[email protected]>
  • Loading branch information
crynobone authored Nov 26, 2023
1 parent be21757 commit b166e82
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Illuminate/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ public function output()
* @param \Symfony\Component\Console\Command\Command $command
* @return \Symfony\Component\Console\Command\Command|null
*/
#[\Override]
public function add(SymfonyCommand $command): ?SymfonyCommand
{
if ($command instanceof Command) {
Expand Down Expand Up @@ -285,6 +286,7 @@ public function setContainerCommandLoader()
*
* @return \Symfony\Component\Console\Input\InputDefinition
*/
#[\Override]
protected function getDefaultInputDefinition(): InputDefinition
{
return tap(parent::getDefaultInputDefinition(), function ($definition) {
Expand Down
1 change: 1 addition & 0 deletions src/Illuminate/Console/BufferedConsoleOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public function fetch()
/**
* {@inheritdoc}
*/
#[\Override]
protected function doWrite(string $message, bool $newline): void
{
$this->buffer .= $message;
Expand Down
4 changes: 4 additions & 0 deletions src/Illuminate/Console/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ protected function configureIsolation()
* @param \Symfony\Component\Console\Output\OutputInterface $output
* @return int
*/
#[\Override]
public function run(InputInterface $input, OutputInterface $output): int
{
$this->output = $output instanceof OutputStyle ? $output : $this->laravel->make(
Expand All @@ -191,6 +192,7 @@ public function run(InputInterface $input, OutputInterface $output): int
* @param \Symfony\Component\Console\Input\InputInterface $input
* @param \Symfony\Component\Console\Output\OutputInterface $output
*/
#[\Override]
protected function execute(InputInterface $input, OutputInterface $output): int
{
if ($this instanceof Isolatable && $this->option('isolated') !== false &&
Expand Down Expand Up @@ -257,6 +259,7 @@ protected function resolveCommand($command)
*
* @return bool
*/
#[\Override]
public function isHidden(): bool
{
return $this->hidden;
Expand All @@ -265,6 +268,7 @@ public function isHidden(): bool
/**
* {@inheritdoc}
*/
#[\Override]
public function setHidden(bool $hidden = true): static
{
parent::setHidden($this->hidden = $hidden);
Expand Down
4 changes: 4 additions & 0 deletions src/Illuminate/Console/OutputStyle.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public function __construct(InputInterface $input, OutputInterface $output)
/**
* {@inheritdoc}
*/
#[\Override]
public function askQuestion(Question $question): mixed
{
try {
Expand All @@ -64,6 +65,7 @@ public function askQuestion(Question $question): mixed
/**
* {@inheritdoc}
*/
#[\Override]
public function write(string|iterable $messages, bool $newline = false, int $options = 0): void
{
$this->newLinesWritten = $this->trailingNewLineCount($messages) + (int) $newline;
Expand All @@ -75,6 +77,7 @@ public function write(string|iterable $messages, bool $newline = false, int $opt
/**
* {@inheritdoc}
*/
#[\Override]
public function writeln(string|iterable $messages, int $type = self::OUTPUT_NORMAL): void
{
$this->newLinesWritten = $this->trailingNewLineCount($messages) + 1;
Expand All @@ -86,6 +89,7 @@ public function writeln(string|iterable $messages, int $type = self::OUTPUT_NORM
/**
* {@inheritdoc}
*/
#[\Override]
public function newLine(int $count = 1): void
{
$this->newLinesWritten += $count;
Expand Down
1 change: 1 addition & 0 deletions src/Illuminate/Console/QuestionHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class QuestionHelper extends SymfonyQuestionHelper
*
* @return void
*/
#[\Override]
protected function writePrompt(OutputInterface $output, Question $question): void
{
$text = OutputFormatter::escapeTrailingBackslash($question->getQuestion());
Expand Down
3 changes: 3 additions & 0 deletions src/Illuminate/Http/JsonResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public function __construct($data = null, $status = 200, $headers = [], $options
*
* @return static
*/
#[\Override]
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 @@ -70,6 +71,7 @@ public function getData($assoc = false, $depth = 512)
*
* @return static
*/
#[\Override]
public function setData($data = []): static
{
$this->original = $data;
Expand Down Expand Up @@ -116,6 +118,7 @@ protected function hasValidJson($jsonError)
*
* @return static
*/
#[\Override]
public function setEncodingOptions($options): static
{
$this->encodingOptions = (int) $options;
Expand Down
4 changes: 4 additions & 0 deletions src/Illuminate/Http/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ public function replace(array $input)
* @param mixed $default
* @return mixed
*/
#[\Override]
public function get(string $key, mixed $default = null): mixed
{
return parent::get($key, $default);
Expand Down Expand Up @@ -499,6 +500,7 @@ public static function createFromBase(SymfonyRequest $request)
*
* @return static
*/
#[\Override]
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 @@ -532,6 +534,7 @@ protected function filterFiles($files)
/**
* {@inheritdoc}
*/
#[\Override]
public function hasSession(bool $skipIfUninitialized = false): bool
{
return $this->session instanceof SymfonySessionDecorator;
Expand All @@ -540,6 +543,7 @@ public function hasSession(bool $skipIfUninitialized = false): bool
/**
* {@inheritdoc}
*/
#[\Override]
public function getSession(): SessionInterface
{
return $this->hasSession()
Expand Down
1 change: 1 addition & 0 deletions src/Illuminate/Http/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public function __construct($content = '', $status = 200, array $headers = [])
*
* @throws \InvalidArgumentException
*/
#[\Override]
public function setContent(mixed $content): static
{
$this->original = $content;
Expand Down

0 comments on commit b166e82

Please sign in to comment.