diff --git a/.github/workflows/pull-request-check.yml b/.github/workflows/pull-request-check.yml index 2695a7b46..a204bb083 100644 --- a/.github/workflows/pull-request-check.yml +++ b/.github/workflows/pull-request-check.yml @@ -18,11 +18,11 @@ jobs: - name: Installing dependencies uses: php-actions/composer@v6 with: - php_version: 8.1 + php_version: 8.2 - name: Running unit test uses: php-actions/phpunit@v3 with: version: 9.6 - php_version: 8.1 + php_version: 8.2 configuration: phpunit.xml diff --git a/composer.json b/composer.json index 6fd1f052e..f308fa4d1 100755 --- a/composer.json +++ b/composer.json @@ -10,12 +10,12 @@ } ], "require": { - "php": ">=8.1.0", + "php": ">=8.2.0", "d11wtq/boris": "~1.0", "filp/whoops": "~2.11", "ircmaxell/password-compat": "~1.0", "laravel/serializable-closure": "^1.2", - "monolog/monolog": "~1.6", + "monolog/monolog": "^2.10", "nesbot/carbon": "^2.71", "opis/closure": "~3.6", "pda/pheanstalk": "~4.0", @@ -70,8 +70,9 @@ }, "require-dev": { "mockery/mockery": "~1.3", - "phpunit/phpunit": "~9.6", "phpspec/prophecy-phpunit": "~2.0", + "phpunit/phpunit": "~9.6", + "rector/rector": "^2.1", "symfony/var-dumper": "~6.4" }, "autoload": { diff --git a/rector.php b/rector.php new file mode 100644 index 000000000..398554833 --- /dev/null +++ b/rector.php @@ -0,0 +1,18 @@ +withPaths([ + __DIR__ . '/src', + __DIR__ . '/tests', + ]) + ->withRules([ + \Rector\CodeQuality\Rector\Class_\CompleteDynamicPropertiesRector::class, + \Rector\Php82\Rector\FuncCall\Utf8DecodeEncodeToMbConvertEncodingRector::class, + \Rector\Php82\Rector\New_\FilesystemIteratorSkipDotsRector::class, + \Rector\Php82\Rector\Class_\ReadOnlyClassRector::class, + \Rector\Php82\Rector\Encapsed\VariableInStringInterpolationFixerRector::class, + ]); diff --git a/src/Illuminate/Database/Query/Builder.php b/src/Illuminate/Database/Query/Builder.php index ce8318311..2317535dd 100755 --- a/src/Illuminate/Database/Query/Builder.php +++ b/src/Illuminate/Database/Query/Builder.php @@ -1786,14 +1786,12 @@ public function getPaginationCount() * @param array $columns * @return \Illuminate\Pagination\Paginator */ - public function simplePaginate($perPage = null, $columns = array('*')) + public function simplePaginate($perPage = 15, $columns = array('*')) { $paginator = $this->connection->getPaginator(); $page = $paginator->getCurrentPage(); - $perPage = $perPage ?: $this->model->getPerPage(); - $this->skip(($page - 1) * $perPage)->take($perPage + 1); return $paginator->make($this->get($columns), $perPage); diff --git a/src/Illuminate/Database/QueryException.php b/src/Illuminate/Database/QueryException.php index e3f9cf2fe..9b5adaeac 100644 --- a/src/Illuminate/Database/QueryException.php +++ b/src/Illuminate/Database/QueryException.php @@ -5,6 +5,11 @@ class QueryException extends PDOException { /** + * @var \Exception + */ + protected $previous; + + /** * The SQL for the query. * * @var string diff --git a/src/Illuminate/Database/Schema/Grammars/Grammar.php b/src/Illuminate/Database/Schema/Grammars/Grammar.php index 96c6fb214..1cda678ad 100755 --- a/src/Illuminate/Database/Schema/Grammars/Grammar.php +++ b/src/Illuminate/Database/Schema/Grammars/Grammar.php @@ -11,7 +11,12 @@ abstract class Grammar extends BaseGrammar { - /** + /** + * @var array + */ + protected $modifiers; + + /** * Compile a rename column command. * * @param \Illuminate\Database\Schema\Blueprint $blueprint diff --git a/src/Illuminate/Foundation/Console/CommandMakeCommand.php b/src/Illuminate/Foundation/Console/CommandMakeCommand.php index 0882792c5..ad97016f8 100755 --- a/src/Illuminate/Foundation/Console/CommandMakeCommand.php +++ b/src/Illuminate/Foundation/Console/CommandMakeCommand.php @@ -7,7 +7,9 @@ class CommandMakeCommand extends Command { - /** + protected Filesystem $files; + + /** * The console command name. * * @var string diff --git a/src/Illuminate/Foundation/Console/KeyGenerateCommand.php b/src/Illuminate/Foundation/Console/KeyGenerateCommand.php index 564b5db61..32cb73d09 100755 --- a/src/Illuminate/Foundation/Console/KeyGenerateCommand.php +++ b/src/Illuminate/Foundation/Console/KeyGenerateCommand.php @@ -6,7 +6,9 @@ class KeyGenerateCommand extends Command { - /** + protected Filesystem $files; + + /** * The console command name. * * @var string diff --git a/src/Illuminate/Foundation/MigrationPublisher.php b/src/Illuminate/Foundation/MigrationPublisher.php index 75faab398..44a1f82aa 100644 --- a/src/Illuminate/Foundation/MigrationPublisher.php +++ b/src/Illuminate/Foundation/MigrationPublisher.php @@ -5,7 +5,9 @@ class MigrationPublisher { - /** + protected Filesystem $files; + + /** * A cache of migrations at a given destination. * * @var array diff --git a/src/Illuminate/Log/Writer.php b/src/Illuminate/Log/Writer.php index f91421346..4767ef645 100755 --- a/src/Illuminate/Log/Writer.php +++ b/src/Illuminate/Log/Writer.php @@ -275,8 +275,6 @@ public function __call($method, $parameters) call_user_func_array($this->fireLogEvent(...), array_merge(array($method), $parameters)); - $method = 'add'.ucfirst($method); - return $this->callMonolog($method, $parameters); } diff --git a/src/Illuminate/Queue/Queue.php b/src/Illuminate/Queue/Queue.php index e6cd428fa..6eb7a8b39 100755 --- a/src/Illuminate/Queue/Queue.php +++ b/src/Illuminate/Queue/Queue.php @@ -8,7 +8,9 @@ abstract class Queue { - /** + protected Encrypter $crypt; + + /** * The IoC container instance. * * @var \Illuminate\Container\Container diff --git a/src/Illuminate/Queue/QueueManager.php b/src/Illuminate/Queue/QueueManager.php index 223132731..c66efdc16 100755 --- a/src/Illuminate/Queue/QueueManager.php +++ b/src/Illuminate/Queue/QueueManager.php @@ -4,7 +4,12 @@ class QueueManager { - /** + /** + * @var array + */ + protected $connectors; + + /** * The application instance. * * @var \Illuminate\Foundation\Application diff --git a/src/Illuminate/Session/CookieSessionHandler.php b/src/Illuminate/Session/CookieSessionHandler.php index ab87162be..84f66dae2 100755 --- a/src/Illuminate/Session/CookieSessionHandler.php +++ b/src/Illuminate/Session/CookieSessionHandler.php @@ -5,7 +5,12 @@ class CookieSessionHandler implements \SessionHandlerInterface { - /** + /** + * The cookie lifetime in minutes. + */ + protected int $minutes; + + /** * The cookie jar instance. */ protected CookieJar $cookie; @@ -22,7 +27,7 @@ class CookieSessionHandler implements \SessionHandlerInterface { * @param int $minutes * @return void */ - public function __construct(CookieJar $cookie, $minutes) + public function __construct(CookieJar $cookie, int $minutes) { $this->cookie = $cookie; $this->minutes = $minutes; diff --git a/src/Illuminate/Translation/Translator.php b/src/Illuminate/Translation/Translator.php index cadb953b7..519b41630 100755 --- a/src/Illuminate/Translation/Translator.php +++ b/src/Illuminate/Translation/Translator.php @@ -6,7 +6,9 @@ class Translator extends NamespacedItemResolver implements TranslatorInterface { - /** + protected MessageSelector $selector; + + /** * The loader implementation. * * @var \Illuminate\Translation\LoaderInterface diff --git a/src/Illuminate/Validation/Validator.php b/src/Illuminate/Validation/Validator.php index 6417a7f9e..bf5d6c9a8 100755 --- a/src/Illuminate/Validation/Validator.php +++ b/src/Illuminate/Validation/Validator.php @@ -14,7 +14,12 @@ class Validator implements MessageProviderInterface { - /** + /** + * @var Container + */ + protected $container; + + /** * The Translator implementation. * * @var \Symfony\Contracts\Translation\TranslatorInterface diff --git a/tests/Html/FormBuilderTest.php b/tests/Html/FormBuilderTest.php index 205c66984..dc2e3dd39 100755 --- a/tests/Html/FormBuilderTest.php +++ b/tests/Html/FormBuilderTest.php @@ -12,14 +12,16 @@ class FormBuilderTest extends BackwardCompatibleTestCase { + private FormBuilder $formBuilder; + /** * Setup the test environment. */ protected function setUp(): void { - $this->urlGenerator = new UrlGenerator(new RouteCollection, Request::create('/foo', 'GET')); - $this->htmlBuilder = new HtmlBuilder($this->urlGenerator); - $this->formBuilder = new FormBuilder($this->htmlBuilder, $this->urlGenerator, ''); + $urlGenerator = new UrlGenerator(new RouteCollection, Request::create('/foo', 'GET')); + $htmlBuilder = new HtmlBuilder($urlGenerator); + $this->formBuilder = new FormBuilder($htmlBuilder, $urlGenerator, ''); } diff --git a/tests/Log/LogWriterTest.php b/tests/Log/LogWriterTest.php index 067c80a8b..784aebc53 100755 --- a/tests/Log/LogWriterTest.php +++ b/tests/Log/LogWriterTest.php @@ -45,16 +45,16 @@ public function testErrorLogHandlerCanBeAdded() public function testMagicMethodsPassErrorAdditionsToMonolog() { $writer = new Writer($monolog = m::mock(Logger::class)); - $monolog->shouldReceive('addError')->once()->with('foo')->andReturn('bar'); + $monolog->shouldReceive('error')->once()->with('foo'); - $this->assertEquals('bar', $writer->error('foo')); + $writer->error('foo'); } public function testWriterFiresEventsDispatcher() { $writer = new Writer($monolog = m::mock(Logger::class), $events = new Illuminate\Events\Dispatcher); - $monolog->shouldReceive('addError')->once()->with('foo'); + $monolog->shouldReceive('error')->once()->with('foo'); $events->listen('illuminate.log', function($level, $message, array $context = []) { diff --git a/tests/Queue/QueueSqsJobTest.php b/tests/Queue/QueueSqsJobTest.php index deeb40e82..b814e0742 100644 --- a/tests/Queue/QueueSqsJobTest.php +++ b/tests/Queue/QueueSqsJobTest.php @@ -12,6 +12,32 @@ class QueueSqsJobTest extends BackwardCompatibleTestCase { + private string $key; + private string $secret; + private string $service; + private string $region; + private string $account; + private string $queueName; + private string $baseUrl; + private Credentials $credentials; + private SignatureV4 $signature; + private Collection $config; + private string $queueUrl; + private \PHPUnit\Framework\MockObject\MockObject $mockedSqsClient; + private $mockedContainer; + private string $mockedJob; + /** + * @var string[] + */ + private array $mockedData; + /** + * @var bool|non-empty-string + */ + private string|bool $mockedPayload; + private string $mockedMessageId; + private string $mockedReceiptHandle; + private array $mockedJobData; + protected function setUp(): void { $this->markTestSkipped(); diff --git a/tests/Queue/QueueSqsQueueTest.php b/tests/Queue/QueueSqsQueueTest.php index 0d9e11f71..a6e477d83 100755 --- a/tests/Queue/QueueSqsQueueTest.php +++ b/tests/Queue/QueueSqsQueueTest.php @@ -11,6 +11,20 @@ class QueueSqsQueueTest extends BackwardCompatibleTestCase { + private $sqs; + private string $account; + private string $queueName; + private string $baseUrl; + private string $queueUrl; + private string $mockedJob; + private array $mockedData; + private string|false $mockedPayload; + private int $mockedDelay; + private string $mockedMessageId; + private string $mockedReceiptHandle; + private Model $mockedSendMessageResponseModel; + private Model $mockedReceiveMessageResponseModel; + protected function tearDown(): void { m::close(); diff --git a/tests/Support/SupportUtilTest.php b/tests/Support/SupportUtilTest.php index 9de72bfcc..016058b15 100644 --- a/tests/Support/SupportUtilTest.php +++ b/tests/Support/SupportUtilTest.php @@ -5,9 +5,9 @@ use Illuminate\Pagination\Factory; use Illuminate\Pagination\Paginator; use Illuminate\Support\Util; -use PHPUnit\Framework\TestCase; +use L4\Tests\BackwardCompatibleTestCase; -class SupportUtilTest extends TestCase +class SupportUtilTest extends BackwardCompatibleTestCase { public function testUnwrapIfClosure(): void { @@ -64,4 +64,4 @@ public function isEmptyOnNonEmptyPaginatorObject(): void $this->assertFalse(Util::isEmpty($pagination)); } -} \ No newline at end of file +}