Skip to content

Commit 1bb13df

Browse files
authored
fix simple schema merge (#1)
* fix simple schema merge * update composer * update test, update infection * fix ci
1 parent 0fbe22b commit 1bb13df

File tree

8 files changed

+22
-17
lines changed

8 files changed

+22
-17
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ fix-code-style:
2424

2525
infection-testing:
2626
make coverage
27-
${INFECTION} --coverage=build/logs/phpunit --min-msi=68 --threads=`nproc`
27+
${INFECTION} --coverage=build/logs/phpunit --min-msi=67 --threads=`nproc`
2828

2929
static-analysis:
3030
${PHPSTAN} analyse --memory-limit 256m --no-progress

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"phpstan/phpstan": "^0.12",
1818
"squizlabs/php_codesniffer": "^3.4.2",
1919
"friendsofphp/php-cs-fixer": "^2.15",
20-
"infection/infection": "^0.17",
20+
"infection/infection": "^0.20",
2121
"rregeer/phpunit-coverage-check": "^0.3"
2222
},
2323
"bin": [

docker/dev/php/Dockerfile

-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
FROM php:7.4-cli-alpine3.12
22

3-
# https://getcomposer.org/doc/03-cli.md#composer-allow-superuser
4-
ENV COMPOSER_ALLOW_SUPERUSER 1
53
ARG HOST_USER_ID
64
ARG HOST_USER
75

@@ -25,9 +23,6 @@ RUN mkdir /phpIni && \
2523
# COMPOSER: install binary
2624
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer
2725

28-
# COMPOSER: install dependencies
29-
RUN composer global require hirak/prestissimo
30-
3126
USER $HOST_USER
3227

3328
WORKDIR /var/www/html

phpstan.neon

+3-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ parameters:
33
paths: [ src ]
44
checkGenericClassInNonGenericObjectType: false
55
ignoreErrors:
6-
- "#Strict comparison using === between array<int, mixed> and ',' will always evaluate to false.#"
7-
- "#Strict comparison using === between array<int, mixed> and ';' will always evaluate to false.#"
8-
- '#Parameter \#1 \$path of method PhpKafka\\PhpAvroSchemaGenerator\\Command\\SubSchemaMergeCommand::getPath\(\) expects string, array<string>\|string\|null given.#'
9-
- '#Parameter \#1 \$path of method PhpKafka\\PhpAvroSchemaGenerator\\Command\\SchemaGenerateCommand::getPath\(\) expects string, array<string>\|string\|null given.#'
6+
- "#Call to function token_get_all\\(\\) on a separate line has no effect.#"
7+
- "#Strict comparison using === between array<int, mixed>&nonEmpty and ',' will always evaluate to false.#"
8+
- "#Strict comparison using === between array<int, mixed>&nonEmpty and ';' will always evaluate to false.#"

src/Command/SchemaGenerateCommand.php

+7-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,13 @@ public function execute(InputInterface $input, OutputInterface $output): int
2828
{
2929
$output->writeln('Generating schema files');
3030

31-
$classDirectory = $this->getPath($input->getArgument('classDirectory'));
32-
$outputDirectory = $this->getPath($input->getArgument('outputDirectory'));
31+
/** @var string $classDirectoryArg */
32+
$classDirectoryArg = $input->getArgument('classDirectory');
33+
/** @var string $outputDirectoryArg */
34+
$outputDirectoryArg = $input->getArgument('outputDirectory');
35+
36+
$classDirectory = $this->getPath($classDirectoryArg);
37+
$outputDirectory = $this->getPath($outputDirectoryArg);
3338

3439
$registry = (new ClassRegistry())
3540
->addClassDirectory($classDirectory)

src/Command/SubSchemaMergeCommand.php

+8-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,14 @@ protected function configure(): void
3535
public function execute(InputInterface $input, OutputInterface $output): int
3636
{
3737
$output->writeln('Merging schema files');
38-
$templateDirectory = $this->getPath($input->getArgument('templateDirectory'));
39-
$outputDirectory = $this->getPath($input->getArgument('outputDirectory'));
38+
39+
/** @var string $templateDirectoryArg */
40+
$templateDirectoryArg = $input->getArgument('templateDirectory');
41+
/** @var string $outputDirectoryArg */
42+
$outputDirectoryArg = $input->getArgument('outputDirectory');
43+
44+
$templateDirectory = $this->getPath($templateDirectoryArg);
45+
$outputDirectory = $this->getPath($outputDirectoryArg);
4046

4147
$registry = (new SchemaRegistry())
4248
->addSchemaTemplateDirectory($templateDirectory)

src/Registry/SchemaRegistry.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ private function registerSchemaFile(\SplFileInfo $fileInfo): void
147147
public function getSchemaId(array $schemaData, SchemaTemplateInterface $template): string
148148
{
149149
if (true === $template->isPrimitive()) {
150-
return $schemaData['type'];
150+
return str_replace('.' . Avro::FILE_EXTENSION, '', $template->getFilename());
151151
}
152152

153153
return $schemaData['namespace'] . '.' . $schemaData['name'];

tests/Integration/Registry/SchemaRegistryTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function testLoad()
3232
'com.example.Collection',
3333
'com.example.Page',
3434
'com.example.Library',
35-
'string'
35+
'primitive'
3636
];
3737

3838
$schemaDir = __DIR__ . '/../../../example/schemaTemplates';

0 commit comments

Comments
 (0)