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

Introduce own exception for assertions #222

Merged
merged 3 commits into from
Mar 7, 2021
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
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This library contains efficient assertions to test the input and output of
your methods. With these assertions, you can greatly reduce the amount of coding
needed to write a safe implementation.

All assertions in the [`Assert`] class throw an `\InvalidArgumentException` if
All assertions in the [`Assert`] class throw an `Webmozart\Assert\InvalidArgumentException` if
they fail.

FAQ
Expand Down Expand Up @@ -68,11 +68,11 @@ If you create an employee with an invalid ID, an exception is thrown:

```php
new Employee('foobar');
// => InvalidArgumentException:
// => Webmozart\Assert\InvalidArgumentException:
// The employee ID must be an integer. Got: string

new Employee(-10);
// => InvalidArgumentException:
// => Webmozart\Assert\InvalidArgumentException:
// The employee ID must be a positive integer. Got: -10
```

Expand Down
2 changes: 0 additions & 2 deletions bin/src/MixinGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use ArrayAccess;
use Closure;
use Countable;
use InvalidArgumentException;
use ReflectionClass;
use ReflectionException;
use ReflectionMethod;
Expand Down Expand Up @@ -70,7 +69,6 @@ private function namespace(): string
$namespace .= sprintf("use %s;\n", ArrayAccess::class);
$namespace .= sprintf("use %s;\n", Closure::class);
$namespace .= sprintf("use %s;\n", Countable::class);
$namespace .= sprintf("use %s;\n", InvalidArgumentException::class);
$namespace .= sprintf("use %s;\n", Throwable::class);
$namespace .= "\n";

Expand Down
1 change: 0 additions & 1 deletion src/Assert.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
use DateTime;
use DateTimeImmutable;
use Exception;
use InvalidArgumentException;
use ResourceBundle;
use SimpleXMLElement;
use Throwable;
Expand Down
16 changes: 16 additions & 0 deletions src/InvalidArgumentException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

/*
* This file is part of the webmozart/assert package.
*
* (c) Bernhard Schussek <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Webmozart\Assert;

class InvalidArgumentException extends \InvalidArgumentException
{
}
1 change: 0 additions & 1 deletion src/Mixin.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use ArrayAccess;
use Closure;
use Countable;
use InvalidArgumentException;
use Throwable;

interface Mixin
Expand Down