-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for php 8.1 features without breaking older php versions
- Refactor unit tests in order to remove php 8.1 specific tests from older php versions - Conditionally remove or add code to static analysis based on the current php version - Update minimum phpunit version
- Loading branch information
Showing
29 changed files
with
451 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
$config = []; | ||
|
||
if (version_compare(PHP_VERSION, '8.1') < 0) { | ||
$config['parameters']['excludePaths'] = [ | ||
'analyseAndScan' => [ | ||
'src/Objects/Schema/Generation/Attributes/', | ||
'src/Objects/Schema/Generation/AttributeReader.php' | ||
], | ||
]; | ||
} | ||
|
||
return $config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
includes: | ||
- phpstan-conditional.config.php | ||
parameters: | ||
level: 8 | ||
paths: [ src ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace FlixTech\AvroSerializer\Objects\Exceptions; | ||
|
||
use RuntimeException; | ||
|
||
class UnsupportedPhpVersionException extends RuntimeException | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace FlixTech\AvroSerializer\Test\Objects\Schema\Generation; | ||
|
||
use FlixTech\AvroSerializer\Objects\Exceptions\UnsupportedPhpVersionException; | ||
use FlixTech\AvroSerializer\Objects\Schema\Generation\AttributeReader; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class AttributeReaderTest extends TestCase | ||
{ | ||
/** | ||
* @test | ||
* @requires PHP < 8.1 | ||
*/ | ||
public function it_should_throw_exception_when_the_php_version_is_not_supported(): void | ||
{ | ||
$this->expectException(UnsupportedPhpVersionException::class); | ||
|
||
new AttributeReader(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
test/Objects/Schema/Generation/Fixture/Annotations/ArraysWithComplexType.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace FlixTech\AvroSerializer\Test\Objects\Schema\Generation\Fixture\Annotations; | ||
|
||
use FlixTech\AvroSerializer\Objects\Schema\Generation\Annotations as SerDe; | ||
|
||
/** | ||
* @SerDe\AvroType("record") | ||
* @SerDe\AvroName("ArraysWithComplexType") | ||
*/ | ||
class ArraysWithComplexType | ||
{ | ||
/** | ||
* @SerDe\AvroType("array", attributes={ | ||
* @SerDe\AvroItems({ | ||
* "string", | ||
* @SerDe\AvroType("array", attributes={@SerDe\AvroItems(@SerDe\AvroType("string"))}) | ||
* }) | ||
* }) | ||
*/ | ||
private $arrayWithUnion; | ||
|
||
/** | ||
* @SerDe\AvroType("array", attributes={ | ||
* @SerDe\AvroItems( | ||
* @SerDe\AvroType("map", attributes={@SerDe\AvroValues(@SerDe\AvroType("string"))}) | ||
* ) | ||
* }) | ||
*/ | ||
private $arrayWithMap; | ||
} |
16 changes: 16 additions & 0 deletions
16
test/Objects/Schema/Generation/Fixture/Annotations/EmptyRecord.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace FlixTech\AvroSerializer\Test\Objects\Schema\Generation\Fixture\Annotations; | ||
|
||
use FlixTech\AvroSerializer\Objects\Schema\Generation\Annotations as SerDe; | ||
|
||
/** | ||
* @SerDe\AvroName("EmptyRecord") | ||
* @SerDe\AvroNamespace("org.acme") | ||
* @SerDe\AvroType("record") | ||
*/ | ||
class EmptyRecord | ||
{ | ||
} |
33 changes: 33 additions & 0 deletions
33
test/Objects/Schema/Generation/Fixture/Annotations/MapsWithComplexType.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace FlixTech\AvroSerializer\Test\Objects\Schema\Generation\Fixture\Annotations; | ||
|
||
use FlixTech\AvroSerializer\Objects\Schema\Generation\Annotations as SerDe; | ||
|
||
/** | ||
* @SerDe\AvroType("record") | ||
* @SerDe\AvroName("MapsWithComplexType") | ||
*/ | ||
class MapsWithComplexType | ||
{ | ||
/** | ||
* @SerDe\AvroType("map", attributes={ | ||
* @SerDe\AvroValues({ | ||
* "string", | ||
* @SerDe\AvroType("array", attributes={@SerDe\AvroItems("string")}) | ||
* }) | ||
* }) | ||
*/ | ||
private $mapWithUnion; | ||
|
||
/** | ||
* @SerDe\AvroType("map", attributes={ | ||
* @SerDe\AvroValues( | ||
* @SerDe\AvroType("array", attributes={@SerDe\AvroItems("string")}) | ||
* ) | ||
* }) | ||
*/ | ||
private $mapWithArray; | ||
} |
Oops, something went wrong.