From c6c80838285db6cbbe6ae5659964bd2e8f64722f Mon Sep 17 00:00:00 2001 From: Pavel Alexeev Date: Sat, 8 Jan 2022 17:30:06 +0300 Subject: [PATCH] #33 Remove accidentally committed AvroClassPropertyParser.php (that should act as example of extending and override) --- src/Parser/AvroClassPropertyParser.php | 39 ------------------- .../Registry/ClassRegistryTest.php | 25 ------------ 2 files changed, 64 deletions(-) delete mode 100644 src/Parser/AvroClassPropertyParser.php diff --git a/src/Parser/AvroClassPropertyParser.php b/src/Parser/AvroClassPropertyParser.php deleted file mode 100644 index 1bf9d3e..0000000 --- a/src/Parser/AvroClassPropertyParser.php +++ /dev/null @@ -1,39 +0,0 @@ -getPropertyName(), 'o_') or str_starts_with($prop->getPropertyName(), '_') - or in_array($prop->getPropertyName(), ['omitMandatoryCheck', 'allLazyKeysMarkedAsLoaded'])) { - throw new SkipPropertyException(); - } -// return $prop; - $prop_ = new PhpClassProperty( - $prop->getPropertyName(), - // make type nullable. Can't now in array. See https://github.com/php-kafka/php-avro-schema-generator/issues/33#issuecomment-1007490595 - $prop->getPropertyType()->isNullable() ? $prop->getPropertyType() : new PhpClassPropertyType(new PhpClassPropertyTypeItem('null'), ...$prop->getPropertyType()->getTypeItems()), -// 'null|' . $prop->getPropertyType(), // make type nullable // See https://github.com/php-kafka/php-avro-schema-generator/issues/33#issuecomment-1007551821 - // and only in string work. See https://github.com/php-kafka/php-avro-schema-generator/issues/33#issuecomment-1007490595 - ($prop->getPropertyDefault() != PhpClassPropertyInterface::NO_DEFAULT ?: null), - $prop->getPropertyDoc(), - $prop->getPropertyLogicalType() - ); - return $prop_; - } -} diff --git a/tests/Integration/Registry/ClassRegistryTest.php b/tests/Integration/Registry/ClassRegistryTest.php index d451aae..7cef762 100644 --- a/tests/Integration/Registry/ClassRegistryTest.php +++ b/tests/Integration/Registry/ClassRegistryTest.php @@ -56,31 +56,6 @@ public function testLoad() } } - public function testLoadMinimal() { - $classDir = __DIR__ . '/../../../example/classes_minimal'; - -// $propertyParser = new ClassPropertyParser(new DocCommentParser()); - $propertyParser = new AvroClassPropertyParser(new DocCommentParser()); - $parser = new ClassParser((new ParserFactory())->create(ParserFactory::PREFER_PHP7), $propertyParser); - $converter = new PhpClassConverter($parser); - $registry = (new ClassRegistry($converter))->addClassDirectory($classDir)->load(); - - self::assertInstanceOf(ClassRegistryInterface::class, $registry); - - $classes = $registry->getClasses(); - - self::assertCount(1, $classes); - - foreach ($classes as $class) { - self::assertInstanceOf(PhpClassInterface::class, $class); - } - - $generator = new SchemaGenerator(''); - $generator->setClassRegistry($registry); - $schemas = $generator->generate(); - self::assertCount(1, $schemas); - } - public function testRegisterSchemaFileThatDoesntExist() { $fileInfo = new SplFileInfo('somenonexistingfile');