Skip to content
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
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
.PHONY: clean code-style coverage help static-analysis update-dependencies install-dependencies infection-testing
.PHONY: clean code-style coverage fix-code-style help static-analysis update-dependencies install-dependencies infection-testing
.DEFAULT_GOAL := coverage

PHPUNIT = ./vendor/bin/phpunit -c ./phpunit.xml
PHPSTAN = ./vendor/bin/phpstan
PHPCS = ./vendor/bin/phpcs --extensions=php
PHPCBF = ./vendor/bin/
PHPCBF = ./vendor/bin/phpcbf
INFECTION = ./vendor/bin/infection
CONSOLE = ./bin/console
COVCHECK = ./vendor/bin/coverage-check
Expand Down
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
"license": "MIT",
"require": {
"ext-json": "*",
"symfony/console": "^4.3|^5.1",
"flix-tech/avro-php": "^3.0|^4.0"
"flix-tech/avro-php": "^3.0|^4.0",
"symfony/console": "^4.3|^5.1"
},
"require-dev": {
"phpunit/phpunit": "^9.3",
"phpstan/phpstan": "^0.12",
"squizlabs/php_codesniffer": "^3.4.2",
"friendsofphp/php-cs-fixer": "^2.15",
"infection/infection": "^0.20.2",
"rregeer/phpunit-coverage-check": "^0.3"
"infection/infection": "^0.25",
"phpstan/phpstan": "^1.2",
"phpunit/phpunit": "^9.3",
"rregeer/phpunit-coverage-check": "^0.3",
"squizlabs/php_codesniffer": "^3.4.2"
},
"bin": [
"bin/avro-cli"
Expand Down
4 changes: 2 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ parameters:
checkGenericClassInNonGenericObjectType: false
ignoreErrors:
- "#Call to function token_get_all\\(\\) on a separate line has no effect.#"
- "#Strict comparison using === between array<int, mixed>&nonEmpty and ',' will always evaluate to false.#"
- "#Strict comparison using === between array<int, mixed>&nonEmpty and ';' will always evaluate to false.#"
- "#Strict comparison using === between non-empty-array<int, mixed> and ',' will always evaluate to false.#"
- "#Strict comparison using === between non-empty-array<int, mixed> and ';' will always evaluate to false.#"
- "#Method PhpKafka\\\\\\PhpAvroSchemaGenerator\\\\\\Optimizer\\\\\\OptimizerInterface::optimize\\(\\) invoked with 2 parameters, 1 required.#"
2 changes: 2 additions & 0 deletions src/Command/SubSchemaMergeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use PhpKafka\PhpAvroSchemaGenerator\Optimizer\FieldOrderOptimizer;
use PhpKafka\PhpAvroSchemaGenerator\Optimizer\FullNameOptimizer;
use PhpKafka\PhpAvroSchemaGenerator\Optimizer\OptimizerInterface;
use PhpKafka\PhpAvroSchemaGenerator\Optimizer\PrimitiveSchemaOptimizer;
use PhpKafka\PhpAvroSchemaGenerator\Registry\SchemaRegistry;
use PhpKafka\PhpAvroSchemaGenerator\Merger\SchemaMerger;
Expand Down Expand Up @@ -76,6 +77,7 @@ public function execute(InputInterface $input, OutputInterface $output): int

$merger = new SchemaMerger($registry, $outputDirectory);

/** @var OptimizerInterface $optimizerClass */
foreach ($this->optimizerOptionMapping as $optionName => $optimizerClass) {
if (true === (bool) $input->getOption($optionName)) {
$merger->addOptimizer(new $optimizerClass());
Expand Down
1 change: 0 additions & 1 deletion src/Generator/SchemaGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

final class SchemaGenerator implements SchemaGeneratorInterface
{

/**
* @var int[]
*/
Expand Down
1 change: 0 additions & 1 deletion src/Merger/SchemaMergerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

interface SchemaMergerInterface
{

/**
* @return SchemaRegistryInterface
*/
Expand Down
13 changes: 10 additions & 3 deletions src/Parser/TokenParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class TokenParser
/**
* @var string
*/
private $className;
private string $className;

/**
* @var string
Expand Down Expand Up @@ -143,6 +143,7 @@ public function getNamespace(): string
*
* @return array<string|int,mixed> A list with all found use statements.
* @codeCoverageIgnore
* @infection-ignore-all
*/
public function parseUseStatements($namespaceName)
{
Expand Down Expand Up @@ -196,12 +197,15 @@ public function getProperties(string $classPath): array
* @throws \RuntimeException
* @return string|null Type of the property (content of var annotation)
* @codeCoverageIgnore
* @infection-ignore-all
*/
public function getPropertyClass(ReflectionProperty $property, bool $ignorePrimitive = true)
{
$type = null;
$phpVersion = false === phpversion() ? '7.0.0' : phpversion();
// Get is explicit type decralation if possible
/** @var false|string $phpVersionResult */
$phpVersionResult = phpversion();
$phpVersion = false === $phpVersionResult ? '7.0.0' : $phpVersionResult;
// Get is explicit type declaration if possible
if (version_compare($phpVersion, '7.4.0', '>=') && null !== $property->getType()) {
$reflectionType = $property->getType();

Expand Down Expand Up @@ -281,6 +285,7 @@ public function getPropertyClass(ReflectionProperty $property, bool $ignorePrimi
*
* @return string|null Fully qualified name of the type, or null if it could not be resolved
* @codeCoverageIgnore
* @infection-ignore-all
*/
private function tryResolveFqn($type, ReflectionClass $class, Reflector $member)
{
Expand Down Expand Up @@ -324,6 +329,7 @@ private function tryResolveFqn($type, ReflectionClass $class, Reflector $member)
*
* @return string|null Fully qualified name of the type, or null if it could not be resolved
* @codeCoverageIgnore
* @infection-ignore-all
*/
private function tryResolveFqnInTraits($type, ReflectionClass $class, Reflector $member)
{
Expand Down Expand Up @@ -389,6 +395,7 @@ private function next($docCommentIsComment = true)
*
* @return array<string,class-string> A list with all found class names for a use statement.
* @codeCoverageIgnore
* @infection-ignore-all
*/
private function parseUseStatement()
{
Expand Down
1 change: 0 additions & 1 deletion src/PhpClass/PhpClassProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

class PhpClassProperty implements PhpClassPropertyInterface
{

/**
* @var string
*/
Expand Down
1 change: 0 additions & 1 deletion src/Registry/ClassRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

final class ClassRegistry implements ClassRegistryInterface
{

/**
* @var array<string,int>
*/
Expand Down
1 change: 0 additions & 1 deletion src/Registry/ClassRegistryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

interface ClassRegistryInterface
{

/**
* @param string $classDirectory
* @return ClassRegistryInterface
Expand Down
1 change: 0 additions & 1 deletion src/Registry/SchemaRegistryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

interface SchemaRegistryInterface
{

/**
* @param string $schemaTemplateDirectory
* @return SchemaRegistryInterface
Expand Down
3 changes: 2 additions & 1 deletion tests/Unit/Merger/SchemaMergerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,9 @@ public function testMerge()
$optimizer->expects(self::once())->method('optimize')->with($definition)->willReturn($definition);
$merger = new SchemaMerger($schemaRegistry, '/tmp/foobar');
$merger->addOptimizer($optimizer);
$merger->merge(true);
$mergedFiles = $merger->merge(true);

self::assertEquals(1, $mergedFiles);
self::assertFileExists('/tmp/foobar/com.example.Book.avsc');
unlink('/tmp/foobar/com.example.Book.avsc');
rmdir('/tmp/foobar');
Expand Down