Skip to content
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

Update for PHP 8.2 #3

Merged
merged 1 commit into from
Oct 19, 2023
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
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -176,5 +176,5 @@ workflows:
- matrix-conditions:
matrix:
parameters:
version: ["7.4", "8.0", "8.1"]
version: ["7.4", "8.0", "8.1", "8.2"]
install-flags: ["", "--prefer-lowest"]
37 changes: 35 additions & 2 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,49 @@

declare(strict_types=1);

use Rector\CodeQuality\Rector\Class_\CompleteDynamicPropertiesRector;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;
use Rector\DeadCode\Rector\ClassMethod\RemoveUselessParamTagRector;
use Rector\DeadCode\Rector\ClassMethod\RemoveUselessReturnTagRector;
use Rector\DeadCode\Rector\Property\RemoveUselessVarTagRector;
use Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector;
use Rector\PHPUnit\Rector\MethodCall\GetMockBuilderGetMockToCreateMockRector;
use Rector\Set\ValueObject\SetList;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
__DIR__ . '/src',
__DIR__ . '/tests',
]);

$rectorConfig->rules([
CompleteDynamicPropertiesRector::class,
]);

$rectorConfig->sets([
LevelSetList::UP_TO_PHP_74,
// Please no dead code or unneeded variables.
SetList::DEAD_CODE,
// Try to figure out type hints.
SetList::TYPE_DECLARATION,
// Interestingly, LevelSetList::UP_TO_PHP_82 does not preserve PHP 7.4,
// so we have to specify all the PHP versions leading up to it if we
// want to keep 7.4 idioms.
SetList::PHP_74,
SetList::PHP_80,
SetList::PHP_81,
SetList::PHP_82,
]);

$rectorConfig->skip([
// Keep getMockBuilder() for now.
GetMockBuilderGetMockToCreateMockRector::class,
// Don't throw errors on JSON parse problems. Yet.
// @todo Throw errors and deal with them appropriately.
JsonThrowOnErrorRector::class,
// We like our tags.
RemoveUselessParamTagRector::class,
RemoveUselessVarTagRector::class,
RemoveUselessReturnTagRector::class,
]);

};
10 changes: 10 additions & 0 deletions src/Converter.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@
*/
class Converter implements ConverterInterface {

/**
* @var \PDLT\ParserInterface
*/
public $parser;

/**
* @var \PDLT\CompilerInterface
*/
public $compiler;

/**
* Build date format converter using the given parser and compiler.
*/
Expand Down
5 changes: 5 additions & 0 deletions src/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
*/
class Parser implements ParserInterface {

/**
* @var \PDLT\GrammarInterface
*/
public $grammar;

/**
* Creates a date format parser.
*
Expand Down
8 changes: 4 additions & 4 deletions tests/CompilerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace PDLT\Tests;

use PDLT\Compiler;
use PDLT\CompilationMapInterface;
use PDLT\CompilationMap\MySQL;
use PDLT\CompilationMapInterface;
use PDLT\Compiler;
use PDLT\DirectiveToken;
use PDLT\TokenInterface;
use PDLT\UnsupportedTokenException;
Expand All @@ -18,7 +18,7 @@ class CompilerTest extends TestCase {
/**
* @covers ::compileToken
*/
public function testCompileTokenException() {
public function testCompileTokenException(): void {
$this->expectException(UnsupportedTokenException::class);
$this->expectExceptionMessage('Unable to compile unsupported token type');

Expand All @@ -32,7 +32,7 @@ public function testCompileTokenException() {
/**
* @covers ::compileDirective
*/
public function testCompileDirectiveException() {
public function testCompileDirectiveException(): void {
$this->expectException(UnsupportedTokenException::class);
$this->expectExceptionMessage('Unable to compile unsupported directive "this-directive-should-not-exist"; not found in compilation map "PDLT\CompilationMap\MySQL".');

Expand Down
11 changes: 5 additions & 6 deletions tests/ConverterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,19 @@

namespace PDLT\Tests;

use PDLT\Converter;
use PDLT\Parser;
use PDLT\CompilationMap\MySQL;
use PDLT\Compiler;
use PDLT\Converter;
use PDLT\Grammar\Strptime;
use PDLT\CompilationMap\MySQL;

use PDLT\Parser;
use PHPUnit\Framework\TestCase;

/**
* Unit tests for Converter class.
*/
class ConverterTest extends TestCase {

public function provideFormats() {
public function provideFormats(): array {
return [
'from-readme' => ['%c/%e/%y', '%-m/%-d/%y'],
['%a', '%a'],
Expand Down Expand Up @@ -50,7 +49,7 @@ public function provideFormats() {
/**
* @dataProvider provideFormats
*/
public function testStrptimeToMySqlConverter($expected, $input_format) {
public function testStrptimeToMySqlConverter(string $expected, string $input_format): void {
$converter = new Converter(
new Parser(new Strptime()),
new Compiler(new MySQL())
Expand Down
2 changes: 1 addition & 1 deletion tests/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ParserTest extends TestCase {
* @covers ::lex
* @see https://www.php.net/manual/en/function.strftime.php
*/
public function testLexException() {
public function testLexException(): void {
$this->expectException(UnknownTokenException::class);
$this->expectExceptionMessage('Invalid format provided; token "%i" not found in grammar "PDLT\Grammar\Strptime".');

Expand Down