simplesamlphp / assert
A wrapper around webmozart/assert to make it useful beyond checking method arguments
Installs: 4 741 887
Dependents: 61
Suggesters: 0
Security: 0
Stars: 4
Watchers: 6
Forks: 2
Open Issues: 0
Requires
- php: ^8.1
- ext-date: *
- ext-filter: *
- ext-pcre: *
- ext-spl: *
- league/uri-interfaces: ^7.4
- webmozart/assert: ^1.11
Requires (Dev)
- ext-intl: *
- simplesamlphp/simplesamlphp-test-framework: ^1.7
- v1.4.0
- v1.3.1
- v1.3.0
- v1.2.2
- v1.2.1
- v1.2.0
- v1.1.9
- v1.1.8
- v1.1.7
- v1.1.6
- v1.1.5
- v1.1.4
- v1.1.3
- v1.1.2
- v1.1.1
- v1.1.0
- v1.0.5
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
- v0.8.0
- v0.7.2
- v0.7.1
- v0.7.0
- v0.6.3
- v0.6.2
- v0.6.1
- v0.6.0
- v0.5.2
- v0.5.1
- v0.5.0
- v0.4.0
- v0.3.3
- v0.3.2
- v0.3.1
- v0.3.0
- v0.2.13
- v0.2.12
- v0.2.11
- v0.2.10
- v0.2.9
- v0.2.8
- v0.2.7
- v0.2.6
- v0.2.5
- v0.2.4
- v0.2.3
- v0.2.2
- v0.2.1
- v0.2.0
- v0.1.0
- v0.0.13
- v0.0.12
- v0.0.11
- v0.0.10
- v0.0.9
- v0.0.8
- v0.0.7
- v0.0.6
- v0.0.5
- v0.0.4
- v0.0.3
- v0.0.2
- v0.0.1
- dev-feature/saml-compliant-uri
- dev-feature/xs-datetime-regex
- dev-release-0.8
- dev-release-0.6
- dev-test_php82
- dev-master / 1.1.x-dev
This package is auto-updated.
Last update: 2024-10-28 22:10:57 UTC
README
Background
A wrapper around webmozart/assert to make it useful beyond checking method
arguments. One of the major reasons to come up with this fork was our
requirement to be able to throw custom exceptions, instead of everything
being thrown as a generic InvalidArgumentException
.
Using a __callStatic
wrapper we are able to wrap the webmozart-methods
allowing for an extra exception
parameter, and catch the
InvalidArgumentException
by the original library, then throw the desired
exception, or fall back to our custom AssertionFailedException
.
In practise, this means that every assertion provided by the original library
can be used an provided with an additional parameter. If you provide it, and it
translates into a Throwable
class, that is what will be thrown as soon as the
assertion fails. If you don't pass the the extra parameter, we will throw the
more generic AssertionFailedException
(which in our opinion is still better
than the even more generic InvalidArgumentException
).
We also felt that InvalidArgumentException
is incorrect to use in this case.
This exception was intended by PHP to be thrown when a function parameter is of
the wrong type. Our custom AssertionFailedException
therefore inherits from
UnexpectedValueException
which is intended to verify values against valid
value sets, possibly during the internal computations of a function. We deem
this much more appropriate for use in assertions.
Custom Assertions
Another reason to fork is the ability to add a few custom assertions that may only make sense for XML / SAML2 related things.
Currently this library provides the following additional assertions: