Skip to content

Commit

Permalink
exception: move to Exception namespace & PSR-4 structure (BC break!)
Browse files Browse the repository at this point in the history
  • Loading branch information
hrach committed Aug 16, 2020
1 parent 880df94 commit 6a702c4
Show file tree
Hide file tree
Showing 89 changed files with 311 additions and 180 deletions.
3 changes: 3 additions & 0 deletions .phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ parameters:
treatPhpDocTypesAsCertain: false
ignoreErrors:
- '#Call to static method Tester\\Assert::type\(\).+will always evaluate to true\.#'
-
message: '~.*~'
path: "src/compatibility.php"

services:
-
Expand Down
4 changes: 1 addition & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@
"psr-4": {
"Nextras\\Orm\\": "src/"
},
"classmap": [
"src/exceptions.php"
]
"files": ["src/compatibility.php"]
},
"autoload-dev": {
"classmap": [
Expand Down
2 changes: 1 addition & 1 deletion doc/model.texy
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ $model->refreshAll();
// $book is updated with the latest data from database
\--

Also, some entities may be changed but not persisted. Calling `refreshAll()` in such case will throw an `Nextras\Orm\InvalidStateException` exception. You may allow data override by passing `true` argument to the method.
Also, some entities may be changed but not persisted. Calling `refreshAll()` in such case will throw an `Nextras\Orm\Exception\InvalidStateException` exception. You may allow data override by passing `true` argument to the method.

/--php
$book = $model->books->getById(1);
Expand Down
2 changes: 1 addition & 1 deletion src/Bridges/NetteDI/DIRepositoryFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Nette\DI\ContainerBuilder;
use Nette\DI\Definitions\FactoryDefinition;
use Nette\DI\Definitions\ServiceDefinition;
use Nextras\Orm\InvalidStateException;
use Nextras\Orm\Exception\InvalidStateException;
use Nextras\Orm\Repository\IRepository;


Expand Down
2 changes: 1 addition & 1 deletion src/Bridges/NetteDI/OrmExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Nextras\Dbal\IConnection;
use Nextras\Orm\Entity\Reflection\IMetadataParserFactory;
use Nextras\Orm\Entity\Reflection\MetadataParser;
use Nextras\Orm\InvalidStateException;
use Nextras\Orm\Exception\InvalidStateException;
use Nextras\Orm\Mapper\Dbal\DbalMapperCoordinator;
use Nextras\Orm\Model\MetadataStorage;
use Nextras\Orm\Model\Model;
Expand Down
4 changes: 2 additions & 2 deletions src/Bridges/NetteDI/PhpDocRepositoryFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

use Nette\DI\ContainerBuilder;
use Nette\Utils\Reflection;
use Nextras\Orm\InvalidStateException;
use Nextras\Orm\Exception\InvalidStateException;
use Nextras\Orm\Exception\RuntimeException;
use Nextras\Orm\Model\Model;
use Nextras\Orm\Repository\IRepository;
use Nextras\Orm\RuntimeException;
use ReflectionClass;


Expand Down
6 changes: 3 additions & 3 deletions src/Collection/ArrayCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
use Nextras\Orm\Collection\Helpers\ArrayCollectionHelper;
use Nextras\Orm\Collection\Helpers\FetchPairsHelper;
use Nextras\Orm\Entity\IEntity;
use Nextras\Orm\InvalidArgumentException;
use Nextras\Orm\Exception\InvalidArgumentException;
use Nextras\Orm\Exception\MemberAccessException;
use Nextras\Orm\Exception\NoResultException;
use Nextras\Orm\Mapper\IRelationshipMapper;
use Nextras\Orm\MemberAccessException;
use Nextras\Orm\NoResultException;
use Nextras\Orm\Repository\IRepository;
use function array_values;

Expand Down
4 changes: 2 additions & 2 deletions src/Collection/DbalCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
use Nextras\Orm\Collection\Helpers\DbalQueryBuilderHelper;
use Nextras\Orm\Collection\Helpers\FetchPairsHelper;
use Nextras\Orm\Entity\IEntity;
use Nextras\Orm\Exception\MemberAccessException;
use Nextras\Orm\Exception\NoResultException;
use Nextras\Orm\Mapper\Dbal\DbalMapper;
use Nextras\Orm\Mapper\IRelationshipMapper;
use Nextras\Orm\MemberAccessException;
use Nextras\Orm\NoResultException;
use function count;
use function is_array;

Expand Down
2 changes: 1 addition & 1 deletion src/Collection/EmptyCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
use EmptyIterator;
use Iterator;
use Nextras\Orm\Entity\IEntity;
use Nextras\Orm\Exception\NoResultException;
use Nextras\Orm\Mapper\IRelationshipMapper;
use Nextras\Orm\NoResultException;


class EmptyCollection implements ICollection
Expand Down
2 changes: 1 addition & 1 deletion src/Collection/EntityIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Nette\Utils\Arrays;
use Nextras\Orm\Entity\IEntity;
use Nextras\Orm\Entity\IEntityHasPreloadContainer;
use Nextras\Orm\InvalidStateException;
use Nextras\Orm\Exception\InvalidStateException;


/**
Expand Down
2 changes: 1 addition & 1 deletion src/Collection/Functions/BaseAggregateFunction.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Nextras\Orm\Collection\Helpers\DbalExpressionResult;
use Nextras\Orm\Collection\Helpers\DbalQueryBuilderHelper;
use Nextras\Orm\Entity\IEntity;
use Nextras\Orm\InvalidArgumentException;
use Nextras\Orm\Exception\InvalidArgumentException;
use function assert;
use function count;
use function is_array;
Expand Down
2 changes: 1 addition & 1 deletion src/Collection/Functions/CompareLikeFunction.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Nextras\Orm\Collection\Helpers\DbalExpressionResult;
use Nextras\Orm\Collection\Helpers\DbalQueryBuilderHelper;
use Nextras\Orm\Entity\IEntity;
use Nextras\Orm\InvalidStateException;
use Nextras\Orm\Exception\InvalidStateException;
use function preg_quote;
use function str_replace;

Expand Down
4 changes: 2 additions & 2 deletions src/Collection/HasManyCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
use Iterator;
use Nextras\Orm\Collection\Helpers\FetchPairsHelper;
use Nextras\Orm\Entity\IEntity;
use Nextras\Orm\Exception\MemberAccessException;
use Nextras\Orm\Exception\NoResultException;
use Nextras\Orm\Mapper\IRelationshipMapper;
use Nextras\Orm\MemberAccessException;
use Nextras\Orm\NoResultException;
use Nextras\Orm\Repository\IRepository;
use function array_map;
use function count;
Expand Down
5 changes: 2 additions & 3 deletions src/Collection/Helpers/ArrayCollectionHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@
use Nextras\Orm\Entity\Reflection\EntityMetadata;
use Nextras\Orm\Entity\Reflection\PropertyMetadata;
use Nextras\Orm\Entity\Reflection\PropertyRelationshipMetadata;
use Nextras\Orm\InvalidArgumentException;
use Nextras\Orm\InvalidStateException;
use Nextras\Orm\Mapper\IMapper;
use Nextras\Orm\Exception\InvalidArgumentException;
use Nextras\Orm\Exception\InvalidStateException;
use Nextras\Orm\Repository\IRepository;
use function array_map;
use function array_shift;
Expand Down
4 changes: 2 additions & 2 deletions src/Collection/Helpers/ConditionParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
use Nextras\Orm\Collection\Functions\CompareSmallerThanEqualsFunction;
use Nextras\Orm\Collection\Functions\CompareSmallerThanFunction;
use Nextras\Orm\Entity\IEntity;
use Nextras\Orm\InvalidArgumentException;
use Nextras\Orm\InvalidStateException;
use Nextras\Orm\Exception\InvalidArgumentException;
use Nextras\Orm\Exception\InvalidStateException;
use function array_shift;
use function explode;
use function is_subclass_of;
Expand Down
4 changes: 2 additions & 2 deletions src/Collection/Helpers/DbalQueryBuilderHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
use Nextras\Orm\Entity\Reflection\EntityMetadata;
use Nextras\Orm\Entity\Reflection\PropertyMetadata;
use Nextras\Orm\Entity\Reflection\PropertyRelationshipMetadata as Relationship;
use Nextras\Orm\InvalidArgumentException;
use Nextras\Orm\Exception\InvalidArgumentException;
use Nextras\Orm\Exception\NotSupportedException;
use Nextras\Orm\Mapper\Dbal\Conventions\IConventions;
use Nextras\Orm\Mapper\Dbal\DbalMapper;
use Nextras\Orm\Model\IModel;
use Nextras\Orm\NotSupportedException;
use Nextras\Orm\Repository\IRepository;
use function array_map;
use function array_merge;
Expand Down
4 changes: 2 additions & 2 deletions src/Collection/Helpers/FetchPairsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
use Nextras\Dbal\Utils\DateTimeImmutable;
use Nextras\Orm\Entity\Embeddable\IEmbeddable;
use Nextras\Orm\Entity\IEntity;
use Nextras\Orm\InvalidArgumentException;
use Nextras\Orm\InvalidStateException;
use Nextras\Orm\Exception\InvalidArgumentException;
use Nextras\Orm\Exception\InvalidStateException;
use Traversable;
use function array_shift;
use function assert;
Expand Down
2 changes: 1 addition & 1 deletion src/Collection/ICollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
use Nextras\Orm\Collection\Functions\ConjunctionOperatorFunction;
use Nextras\Orm\Collection\Functions\DisjunctionOperatorFunction;
use Nextras\Orm\Entity\IEntity;
use Nextras\Orm\Exception\NoResultException;
use Nextras\Orm\Mapper\IRelationshipMapper;
use Nextras\Orm\NoResultException;


/**
Expand Down
2 changes: 1 addition & 1 deletion src/Collection/MultiEntityIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Nette\Utils\Arrays;
use Nextras\Orm\Entity\IEntity;
use Nextras\Orm\Entity\IEntityHasPreloadContainer;
use Nextras\Orm\InvalidStateException;
use Nextras\Orm\Exception\InvalidStateException;


/**
Expand Down
8 changes: 4 additions & 4 deletions src/Entity/AbstractEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
use Nextras\Orm\Entity\Embeddable\EmbeddableContainer;
use Nextras\Orm\Entity\Reflection\EntityMetadata;
use Nextras\Orm\Entity\Reflection\PropertyMetadata;
use Nextras\Orm\InvalidArgumentException;
use Nextras\Orm\InvalidStateException;
use Nextras\Orm\LogicException;
use Nextras\Orm\NullValueException;
use Nextras\Orm\Exception\InvalidArgumentException;
use Nextras\Orm\Exception\InvalidStateException;
use Nextras\Orm\Exception\LogicException;
use Nextras\Orm\Exception\NullValueException;
use Nextras\Orm\Relationships\IRelationshipCollection;
use Nextras\Orm\Relationships\IRelationshipContainer;
use Nextras\Orm\Repository\IRepository;
Expand Down
8 changes: 4 additions & 4 deletions src/Entity/Embeddable/Embeddable.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
use Nextras\Orm\Entity\IProperty;
use Nextras\Orm\Entity\IPropertyContainer;
use Nextras\Orm\Entity\Reflection\PropertyMetadata;
use Nextras\Orm\InvalidArgumentException;
use Nextras\Orm\InvalidStateException;
use Nextras\Orm\LogicException;
use Nextras\Orm\NotSupportedException;
use Nextras\Orm\Exception\InvalidArgumentException;
use Nextras\Orm\Exception\InvalidStateException;
use Nextras\Orm\Exception\LogicException;
use Nextras\Orm\Exception\NotSupportedException;
use function assert;
use function call_user_func;
use function count;
Expand Down
4 changes: 2 additions & 2 deletions src/Entity/Embeddable/EmbeddableContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
use Nextras\Orm\Entity\IEntityAwareProperty;
use Nextras\Orm\Entity\IPropertyContainer;
use Nextras\Orm\Entity\Reflection\PropertyMetadata;
use Nextras\Orm\InvalidArgumentException;
use Nextras\Orm\Exception\InvalidArgumentException;
use Nextras\Orm\Exception\NullValueException;
use Nextras\Orm\Model\MetadataStorage;
use Nextras\Orm\NullValueException;
use ReflectionClass;
use function array_filter;
use function assert;
Expand Down
2 changes: 1 addition & 1 deletion src/Entity/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


use Nextras\Orm\Collection\IEntityPreloadContainer;
use Nextras\Orm\NotSupportedException;
use Nextras\Orm\Exception\NotSupportedException;


class Entity extends AbstractEntity implements IEntityHasPreloadContainer
Expand Down
4 changes: 2 additions & 2 deletions src/Entity/ImmutableDataTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

use Nextras\Orm\Entity\Reflection\EntityMetadata;
use Nextras\Orm\Entity\Reflection\PropertyMetadata;
use Nextras\Orm\InvalidArgumentException;
use Nextras\Orm\InvalidStateException;
use Nextras\Orm\Exception\InvalidArgumentException;
use Nextras\Orm\Exception\InvalidStateException;
use Nextras\Orm\Model\MetadataStorage;


Expand Down
2 changes: 1 addition & 1 deletion src/Entity/Reflection/EntityMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

use Nette\SmartObject;
use Nextras\Orm\Entity\Helpers\Typos;
use Nextras\Orm\InvalidArgumentException;
use Nextras\Orm\Exception\InvalidArgumentException;


/**
Expand Down
11 changes: 11 additions & 0 deletions src/Entity/Reflection/InvalidModifierDefinitionException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace Nextras\Orm\Entity\Reflection;


use Nextras\Orm\Exception;


class InvalidModifierDefinitionException extends Exception\InvalidArgumentException
{
}
5 changes: 2 additions & 3 deletions src/Entity/Reflection/MetadataParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@
use Nextras\Orm\Entity\Embeddable\IEmbeddable;
use Nextras\Orm\Entity\IEntity;
use Nextras\Orm\Entity\IProperty;
use Nextras\Orm\InvalidModifierDefinitionException;
use Nextras\Orm\InvalidStateException;
use Nextras\Orm\NotSupportedException;
use Nextras\Orm\Exception\InvalidStateException;
use Nextras\Orm\Exception\NotSupportedException;
use Nextras\Orm\Relationships\HasMany;
use Nextras\Orm\Relationships\ManyHasMany;
use Nextras\Orm\Relationships\ManyHasOne;
Expand Down
2 changes: 1 addition & 1 deletion src/Entity/Reflection/MetadataValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Nextras\Orm\Entity\Reflection;


use Nextras\Orm\InvalidStateException;
use Nextras\Orm\Exception\InvalidStateException;
use Nextras\Orm\Model\IRepositoryLoader;


Expand Down
3 changes: 1 addition & 2 deletions src/Entity/Reflection/ModifierParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
use Nette\Tokenizer\Token;
use Nette\Tokenizer\Tokenizer;
use Nette\Utils\Reflection;
use Nextras\Orm\InvalidModifierDefinitionException;
use Nextras\Orm\InvalidStateException;
use Nextras\Orm\Exception\InvalidStateException;
use ReflectionClass;


Expand Down
2 changes: 1 addition & 1 deletion src/Entity/Reflection/PropertyMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use DateTimeZone;
use Nette\SmartObject;
use Nextras\Orm\Entity\IProperty;
use Nextras\Orm\InvalidStateException;
use Nextras\Orm\Exception\InvalidStateException;


class PropertyMetadata
Expand Down
8 changes: 8 additions & 0 deletions src/Exception/IOException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php declare(strict_types = 1);

namespace Nextras\Orm\Exception;


class IOException extends RuntimeException
{
}
8 changes: 8 additions & 0 deletions src/Exception/InvalidArgumentException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php declare(strict_types = 1);

namespace Nextras\Orm\Exception;


class InvalidArgumentException extends \InvalidArgumentException
{
}
8 changes: 8 additions & 0 deletions src/Exception/InvalidStateException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php declare(strict_types = 1);

namespace Nextras\Orm\Exception;


class InvalidStateException extends RuntimeException
{
}
8 changes: 8 additions & 0 deletions src/Exception/LogicException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php declare(strict_types = 1);

namespace Nextras\Orm\Exception;


class LogicException extends \LogicException
{
}
8 changes: 8 additions & 0 deletions src/Exception/MemberAccessException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php declare(strict_types = 1);

namespace Nextras\Orm\Exception;


class MemberAccessException extends LogicException
{
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php declare(strict_types = 1);

namespace Nextras\Orm;
namespace Nextras\Orm\Exception;


class NoResultException extends RuntimeException
Expand Down
8 changes: 8 additions & 0 deletions src/Exception/NotImplementedException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php declare(strict_types = 1);

namespace Nextras\Orm\Exception;


class NotImplementedException extends LogicException
{
}
8 changes: 8 additions & 0 deletions src/Exception/NotSupportedException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php declare(strict_types = 1);

namespace Nextras\Orm\Exception;


class NotSupportedException extends LogicException
{
}
Loading

0 comments on commit 6a702c4

Please sign in to comment.