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

Port TypeParser to Hoa\Compiler #900

Merged
merged 1 commit into from
May 1, 2018
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
9 changes: 7 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
"require": {
"php": "^7.2",
"jms/metadata": "~1.1",
"jms/parser-lib": "1.*",
"doctrine/annotations": "^1.0",
"doctrine/instantiator": "^1.0.3"
"doctrine/instantiator": "^1.0.3",
"hoa/compiler": "^3.17.08.08"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, which versioning scheme does HOA follows? Is this some kind of 3.x?

Copy link
Contributor Author

@Majkl578 Majkl578 Apr 30, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand correctly, it's <major>.<releaseyear>.<releasemonth>.<releaseday>. Looks pretty weird, but incidentally works with semver. 😂

},
"suggest": {
"symfony/yaml": "Required if you'd like to use the YAML metadata format.",
Expand All @@ -43,6 +43,11 @@
"symfony/expression-language": "^3.0|^4.0",
"phpunit/phpunit": "^7.1"
},
"conflict": {
"hoa/core": "*",
"hoa/consistency": "<1.17.05.02",
"hoa/iterator": "<2.16.03.15"
},
"autoload": {
"psr-4": {
"JMS\\Serializer\\": "src/"
Expand Down
8 changes: 4 additions & 4 deletions src/Builder/DefaultDriverFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
namespace JMS\Serializer\Builder;

use Doctrine\Common\Annotations\Reader;
use JMS\Parser\AbstractParser;
use JMS\Serializer\Metadata\Driver\AnnotationDriver;
use JMS\Serializer\Metadata\Driver\XmlDriver;
use JMS\Serializer\Metadata\Driver\YamlDriver;
use JMS\Serializer\Naming\PropertyNamingStrategyInterface;
use JMS\Serializer\TypeParser;
use JMS\Serializer\Type\Parser;
use JMS\Serializer\Type\ParserInterface;
use Metadata\Driver\DriverChain;
use Metadata\Driver\DriverInterface;
use Metadata\Driver\FileLocator;
Expand All @@ -23,9 +23,9 @@ final class DefaultDriverFactory implements DriverFactoryInterface
*/
private $propertyNamingStrategy;

public function __construct(PropertyNamingStrategyInterface $propertyNamingStrategy, AbstractParser $typeParser = null)
public function __construct(PropertyNamingStrategyInterface $propertyNamingStrategy, ParserInterface $typeParser = null)
{
$this->typeParser = $typeParser ?: new TypeParser();
$this->typeParser = $typeParser ?: new Parser();
$this->propertyNamingStrategy = $propertyNamingStrategy;
}

Expand Down
8 changes: 4 additions & 4 deletions src/Metadata/Driver/AbstractDoctrineTypeDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@

use Doctrine\Common\Persistence\ManagerRegistry;
use Doctrine\Common\Persistence\Mapping\ClassMetadata as DoctrineClassMetadata;
use JMS\Parser\AbstractParser;
use JMS\Serializer\Metadata\ClassMetadata;
use JMS\Serializer\Metadata\ExpressionPropertyMetadata;
use JMS\Serializer\Metadata\PropertyMetadata;
use JMS\Serializer\Metadata\StaticPropertyMetadata;
use JMS\Serializer\Metadata\VirtualPropertyMetadata;
use JMS\Serializer\TypeParser;
use JMS\Serializer\Type\Parser;
use JMS\Serializer\Type\ParserInterface;
use Metadata\Driver\DriverInterface;

/**
Expand Down Expand Up @@ -78,11 +78,11 @@ abstract class AbstractDoctrineTypeDriver implements DriverInterface

protected $typeParser;

public function __construct(DriverInterface $delegate, ManagerRegistry $registry, AbstractParser $typeParser = null)
public function __construct(DriverInterface $delegate, ManagerRegistry $registry, ParserInterface $typeParser = null)
{
$this->delegate = $delegate;
$this->registry = $registry;
$this->typeParser = $typeParser ?: new TypeParser();
$this->typeParser = $typeParser ?: new Parser();
}

public function loadMetadataForClass(\ReflectionClass $class)
Expand Down
8 changes: 4 additions & 4 deletions src/Metadata/Driver/AnnotationDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
namespace JMS\Serializer\Metadata\Driver;

use Doctrine\Common\Annotations\Reader;
use JMS\Parser\AbstractParser;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\AccessorOrder;
use JMS\Serializer\Annotation\AccessType;
Expand Down Expand Up @@ -59,7 +58,8 @@
use JMS\Serializer\Metadata\PropertyMetadata;
use JMS\Serializer\Metadata\VirtualPropertyMetadata;
use JMS\Serializer\Naming\PropertyNamingStrategyInterface;
use JMS\Serializer\TypeParser;
use JMS\Serializer\Type\Parser;
use JMS\Serializer\Type\ParserInterface;
use Metadata\Driver\DriverInterface;
use Metadata\MethodMetadata;

Expand All @@ -72,10 +72,10 @@ class AnnotationDriver implements DriverInterface
*/
private $namingStrategy;

public function __construct(Reader $reader, PropertyNamingStrategyInterface $namingStrategy, AbstractParser $typeParser = null)
public function __construct(Reader $reader, PropertyNamingStrategyInterface $namingStrategy, ParserInterface $typeParser = null)
{
$this->reader = $reader;
$this->typeParser = $typeParser ?: new TypeParser();
$this->typeParser = $typeParser ?: new Parser();
$this->namingStrategy = $namingStrategy;
}

Expand Down
8 changes: 4 additions & 4 deletions src/Metadata/Driver/XmlDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

namespace JMS\Serializer\Metadata\Driver;

use JMS\Parser\AbstractParser;
use JMS\Serializer\Annotation\ExclusionPolicy;
use JMS\Serializer\Exception\RuntimeException;
use JMS\Serializer\Exception\XmlErrorException;
Expand All @@ -29,7 +28,8 @@
use JMS\Serializer\Metadata\PropertyMetadata;
use JMS\Serializer\Metadata\VirtualPropertyMetadata;
use JMS\Serializer\Naming\PropertyNamingStrategyInterface;
use JMS\Serializer\TypeParser;
use JMS\Serializer\Type\Parser;
use JMS\Serializer\Type\ParserInterface;
use Metadata\Driver\AbstractFileDriver;
use Metadata\Driver\FileLocatorInterface;
use Metadata\MethodMetadata;
Expand All @@ -42,10 +42,10 @@ class XmlDriver extends AbstractFileDriver
*/
private $namingStrategy;

public function __construct(FileLocatorInterface $locator, PropertyNamingStrategyInterface $namingStrategy, AbstractParser $typeParser = null)
public function __construct(FileLocatorInterface $locator, PropertyNamingStrategyInterface $namingStrategy, ParserInterface $typeParser = null)
{
parent::__construct($locator);
$this->typeParser = $typeParser ?: new TypeParser();
$this->typeParser = $typeParser ?? new Parser();
$this->namingStrategy = $namingStrategy;
}

Expand Down
8 changes: 4 additions & 4 deletions src/Metadata/Driver/YamlDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@

namespace JMS\Serializer\Metadata\Driver;

use JMS\Parser\AbstractParser;
use JMS\Serializer\Annotation\ExclusionPolicy;
use JMS\Serializer\Exception\RuntimeException;
use JMS\Serializer\Metadata\ClassMetadata;
use JMS\Serializer\Metadata\ExpressionPropertyMetadata;
use JMS\Serializer\Metadata\PropertyMetadata;
use JMS\Serializer\Metadata\VirtualPropertyMetadata;
use JMS\Serializer\Naming\PropertyNamingStrategyInterface;
use JMS\Serializer\TypeParser;
use JMS\Serializer\Type\Parser;
use JMS\Serializer\Type\ParserInterface;
use Metadata\Driver\AbstractFileDriver;
use Metadata\Driver\FileLocatorInterface;
use Metadata\MethodMetadata;
Expand All @@ -42,10 +42,10 @@ class YamlDriver extends AbstractFileDriver
*/
private $namingStrategy;

public function __construct(FileLocatorInterface $locator, PropertyNamingStrategyInterface $namingStrategy, AbstractParser $typeParser = null)
public function __construct(FileLocatorInterface $locator, PropertyNamingStrategyInterface $namingStrategy, ParserInterface $typeParser = null)
{
parent::__construct($locator);
$this->typeParser = $typeParser ?: new TypeParser();
$this->typeParser = $typeParser ?? new Parser();
$this->namingStrategy = $namingStrategy;
}

Expand Down
9 changes: 5 additions & 4 deletions src/Serializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

namespace JMS\Serializer;

use JMS\Parser\AbstractParser;
use JMS\Serializer\ContextFactory\DefaultDeserializationContextFactory;
use JMS\Serializer\ContextFactory\DefaultSerializationContextFactory;
use JMS\Serializer\ContextFactory\DeserializationContextFactoryInterface;
Expand All @@ -31,6 +30,8 @@
use JMS\Serializer\GraphNavigator\Factory\GraphNavigatorFactoryInterface;
use JMS\Serializer\Visitor\Factory\DeserializationVisitorFactory;
use JMS\Serializer\Visitor\Factory\SerializationVisitorFactory;
use JMS\Serializer\Type\Parser;
use JMS\Serializer\Type\ParserInterface;
use Metadata\MetadataFactoryInterface;

/**
Expand Down Expand Up @@ -82,7 +83,7 @@ final class Serializer implements SerializerInterface, ArrayTransformerInterface
* @param DeserializationVisitorFactory[] $deserializationVisitors
* @param SerializationContextFactoryInterface|null $serializationContextFactory
* @param DeserializationContextFactoryInterface|null $deserializationContextFactory
* @param AbstractParser|null $typeParser
* @param ParserInterface|null $typeParser
*/
public function __construct(
MetadataFactoryInterface $factory,
Expand All @@ -91,14 +92,14 @@ public function __construct(
array $deserializationVisitors,
SerializationContextFactoryInterface $serializationContextFactory = null,
DeserializationContextFactoryInterface $deserializationContextFactory = null,
AbstractParser $typeParser = null
ParserInterface $typeParser = null
) {
$this->factory = $factory;
$this->graphNavigators = $graphNavigators;
$this->serializationVisitors = $serializationVisitors;
$this->deserializationVisitors = $deserializationVisitors;

$this->typeParser = $typeParser ?: new TypeParser();
$this->typeParser = $typeParser ?? new Parser();

$this->serializationContextFactory = $serializationContextFactory ?: new DefaultSerializationContextFactory();
$this->deserializationContextFactory = $deserializationContextFactory ?: new DefaultDeserializationContextFactory();
Expand Down
7 changes: 4 additions & 3 deletions src/SerializerBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
use Doctrine\Common\Annotations\CachedReader;
use Doctrine\Common\Annotations\Reader;
use Doctrine\Common\Cache\FilesystemCache;
use JMS\Parser\AbstractParser;
use JMS\Serializer\Accessor\AccessorStrategyInterface;
use JMS\Serializer\Accessor\DefaultAccessorStrategy;
use JMS\Serializer\Accessor\ExpressionAccessorStrategy;
Expand Down Expand Up @@ -53,6 +52,8 @@
use JMS\Serializer\Naming\CamelCaseNamingStrategy;
use JMS\Serializer\Naming\PropertyNamingStrategyInterface;
use JMS\Serializer\Naming\SerializedNameAnnotationStrategy;
use JMS\Serializer\Type\Parser;
use JMS\Serializer\Type\ParserInterface;
use JMS\Serializer\Visitor\Factory\DeserializationVisitorFactory;
use JMS\Serializer\Visitor\Factory\JsonDeserializationVisitorFactory;
use JMS\Serializer\Visitor\Factory\JsonSerializationVisitorFactory;
Expand Down Expand Up @@ -109,7 +110,7 @@ public static function create(...$args)

public function __construct(HandlerRegistryInterface $handlerRegistry = null, EventDispatcherInterface $eventDispatcher = null)
{
$this->typeParser = new TypeParser();
$this->typeParser = new Parser();
$this->handlerRegistry = $handlerRegistry ?: new HandlerRegistry();
$this->eventDispatcher = $eventDispatcher ?: new EventDispatcher();
$this->serializationVisitors = [];
Expand Down Expand Up @@ -148,7 +149,7 @@ public function setExpressionEvaluator(ExpressionEvaluatorInterface $expressionE
return $this;
}

public function setTypeParser(AbstractParser $parser): self
public function setTypeParser(ParserInterface $parser): self
{
$this->typeParser = $parser;

Expand Down
27 changes: 27 additions & 0 deletions src/Type/Exception/Exception.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);

/*
* Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

namespace JMS\Serializer\Type\Exception;

use JMS\Serializer\Exception\Exception as BaseException;

interface Exception extends BaseException
{
}
25 changes: 25 additions & 0 deletions src/Type/Exception/InvalidNode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);

/*
* Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

namespace JMS\Serializer\Type\Exception;

final class InvalidNode extends \LogicException implements Exception
{
}
25 changes: 25 additions & 0 deletions src/Type/Exception/SyntaxError.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);

/*
* Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

namespace JMS\Serializer\Type\Exception;

final class SyntaxError extends \RuntimeException implements Exception
{
}
Loading