Skip to content

Commit 2a61679

Browse files
committed
Move some namespaces on Exceptions
1 parent ae389bf commit 2a61679

21 files changed

+235
-91
lines changed

src/Bundle/Controller/ResourceController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
use Doctrine\Persistence\ObjectManager;
1717
use FOS\RestBundle\View\View;
1818
use Sylius\Bundle\ResourceBundle\Event\ResourceControllerEvent;
19-
use Sylius\Component\Resource\Exception\DeleteHandlingException;
20-
use Sylius\Component\Resource\Exception\UpdateHandlingException;
2119
use Sylius\Resource\Doctrine\Persistence\RepositoryInterface;
20+
use Sylius\Resource\Exception\DeleteHandlingException;
21+
use Sylius\Resource\Exception\UpdateHandlingException;
2222
use Sylius\Resource\Factory\FactoryInterface;
2323
use Sylius\Resource\Metadata\MetadataInterface;
2424
use Sylius\Resource\Model\ResourceInterface;

src/Bundle/Form/EventSubscriber/AddCodeFormSubscriber.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
namespace Sylius\Bundle\ResourceBundle\Form\EventSubscriber;
1515

16-
use Sylius\Component\Resource\Exception\UnexpectedTypeException;
16+
use Sylius\Resource\Exception\UnexpectedTypeException;
1717
use Sylius\Resource\Model\CodeAwareInterface;
1818
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
1919
use Symfony\Component\Form\Extension\Core\Type\TextType;

src/Bundle/spec/Controller/ResourceControllerSpec.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
use Sylius\Bundle\ResourceBundle\Controller\StateMachineInterface;
3434
use Sylius\Bundle\ResourceBundle\Controller\ViewHandlerInterface;
3535
use Sylius\Bundle\ResourceBundle\Event\ResourceControllerEvent;
36-
use Sylius\Component\Resource\Exception\DeleteHandlingException;
3736
use Sylius\Resource\Doctrine\Persistence\RepositoryInterface;
37+
use Sylius\Resource\Exception\DeleteHandlingException;
3838
use Sylius\Resource\Factory\FactoryInterface;
3939
use Sylius\Resource\Metadata\MetadataInterface;
4040
use Sylius\Resource\Model\ResourceInterface;

src/Bundle/spec/Form/EventSubscriber/AddCodeFormSubscriberSpec.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
use PhpSpec\ObjectBehavior;
1717
use Prophecy\Argument;
18-
use Sylius\Component\Resource\Exception\UnexpectedTypeException;
18+
use Sylius\Resource\Exception\UnexpectedTypeException;
1919
use Sylius\Resource\Model\CodeAwareInterface;
2020
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
2121
use Symfony\Component\Form\Extension\Core\Type\FormType;

src/Component/legacy/spec/Exception/RaceConditionExceptionSpec.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
namespace spec\Sylius\Component\Resource\Exception;
1515

1616
use PhpSpec\ObjectBehavior;
17-
use Sylius\Component\Resource\Exception\UpdateHandlingException;
17+
use Sylius\Resource\Exception\UpdateHandlingException;
1818

1919
final class RaceConditionExceptionSpec extends ObjectBehavior
2020
{

src/Component/legacy/src/Exception/DeleteHandlingException.php

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,32 +13,10 @@
1313

1414
namespace Sylius\Component\Resource\Exception;
1515

16-
class DeleteHandlingException extends \Exception
17-
{
18-
protected string $flash;
16+
class_exists(\Sylius\Resource\Exception\DeleteHandlingException::class);
1917

20-
protected int $apiResponseCode;
21-
22-
public function __construct(
23-
string $message = 'Ups, something went wrong during deleting a resource, please try again.',
24-
string $flash = 'something_went_wrong_error',
25-
int $apiResponseCode = 500,
26-
int $code = 0,
27-
?\Exception $previous = null,
28-
) {
29-
parent::__construct($message, $code, $previous);
30-
31-
$this->flash = $flash;
32-
$this->apiResponseCode = $apiResponseCode;
33-
}
34-
35-
public function getFlash(): string
36-
{
37-
return $this->flash;
38-
}
39-
40-
public function getApiResponseCode(): int
18+
if (false) {
19+
class DeleteHandlingException extends \Sylius\Resource\Exception\DeleteHandlingException
4120
{
42-
return $this->apiResponseCode;
4321
}
4422
}

src/Component/legacy/src/Exception/RaceConditionException.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,10 @@
1313

1414
namespace Sylius\Component\Resource\Exception;
1515

16-
class RaceConditionException extends UpdateHandlingException
17-
{
18-
public function __construct(?\Exception $previous = null)
16+
class_exists(\Sylius\Resource\Exception\RaceConditionException::class);
17+
18+
if (false) {
19+
class RaceConditionException extends \Sylius\Resource\Exception\RaceConditionException
1920
{
20-
parent::__construct(
21-
'Operated entity was previously modified.',
22-
'race_condition_error',
23-
409,
24-
null !== $previous ? (int) $previous->getCode() : 0,
25-
$previous,
26-
);
2721
}
2822
}

src/Component/legacy/src/Exception/UnexpectedTypeException.php

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,10 @@
1313

1414
namespace Sylius\Component\Resource\Exception;
1515

16-
class UnexpectedTypeException extends \InvalidArgumentException
17-
{
18-
/**
19-
* @param mixed $value
20-
*/
21-
public function __construct($value, string $expectedType)
16+
class_exists(\Sylius\Resource\Exception\UnexpectedTypeException::class);
17+
18+
if (false) {
19+
class UnexpectedTypeException extends \Sylius\Resource\Exception\UnexpectedTypeException
2220
{
23-
parent::__construct(sprintf(
24-
'Expected argument of type "%s", "%s" given.',
25-
$expectedType,
26-
is_object($value) ? get_class($value) : gettype($value),
27-
));
2821
}
2922
}

src/Component/legacy/src/Exception/UnsupportedMethodException.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,10 @@
1313

1414
namespace Sylius\Component\Resource\Exception;
1515

16-
class UnsupportedMethodException extends \Exception
17-
{
18-
public function __construct(string $methodName)
16+
class_exists(\Sylius\Resource\Exception\UnsupportedMethodException::class);
17+
18+
if (false) {
19+
class UnsupportedMethodException extends \Sylius\Resource\Exception\UnsupportedMethodException
1920
{
20-
parent::__construct(sprintf(
21-
'The method "%s" is not supported.',
22-
$methodName,
23-
));
2421
}
2522
}

src/Component/legacy/src/Exception/UpdateHandlingException.php

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,32 +13,10 @@
1313

1414
namespace Sylius\Component\Resource\Exception;
1515

16-
class UpdateHandlingException extends \Exception
17-
{
18-
protected string $flash;
16+
class_exists(\Sylius\Resource\Exception\UpdateHandlingException::class);
1917

20-
protected int $apiResponseCode;
21-
22-
public function __construct(
23-
string $message = 'Ups, something went wrong during updating a resource, please try again.',
24-
string $flash = 'something_went_wrong_error',
25-
int $apiResponseCode = 400,
26-
int $code = 0,
27-
?\Exception $previous = null,
28-
) {
29-
parent::__construct($message, $code, $previous);
30-
31-
$this->flash = $flash;
32-
$this->apiResponseCode = $apiResponseCode;
33-
}
34-
35-
public function getFlash(): string
36-
{
37-
return $this->flash;
38-
}
39-
40-
public function getApiResponseCode(): int
18+
if (false) {
19+
class UpdateHandlingException extends \Sylius\Resource\Exception\UpdateHandlingException
4120
{
42-
return $this->apiResponseCode;
4321
}
4422
}

0 commit comments

Comments
 (0)