PackageTrack
Sign in Get early access

webmozart/assert

Assertions to validate method input/output with nice error messages.

2.4.1 954M downloads/mo #87 most downloaded on composer webmozarts/assert

What this package is like to depend on

Last release 2 months ago

15 Jun 2026

Ships unpredictably

gaps range from 9 days to 3.4 years

Nearly every release is documented

notes for 28 of 29 stable releases

Nothing withdrawn

no release was ever pulled

11 years old

31 releases · first in 2015

15 releases in the last 12 months

see the full history below

Release timeline

31 releases · Mar 2015 to Jun 2026
2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026
Release Pre-release

Releases

latest 31
  1. 2.4.1 15 Jun 2026
    Release notes

    See change log for changes.

    Open source →
    Release notes

    Fixed

    • Corrected uuid assertion to prevent braces and prefixes being inside the value.
    Open source →
  2. 2.4.0 20 May 2026
    Release notes

    See change log for changes.

    Open source →
    Release notes

    Changed

    • Updated docblocks for many methods, improving psalm support and type hints.
    Open source →
  3. 2.3.0 11 Apr 2026
    Release notes

    See change log for changes.

    Open source →
    Release notes

    Changed

    • Clarified documentation and testing of uniqueValues.

    Added

    • All assertions now support string|callable for the message.
    Open source →
  4. 2.2.0 09 Apr 2026
    Release notes

    See change log for changes.

    Open source →
    Release notes

    Added

    • Added isNotInstanceOfAny assertion.
    Open source →
  5. 2.1.6 27 Feb 2026
    Release notes

    See change log for changes.

    Open source →
    Release notes

    Fixed

    • Corrected docblocks for list* methods.
    Open source →
  6. 2.1.5 18 Feb 2026
    Release notes

    See change log for changes.

    Open source →
    Release notes

    Fixed

    • Fixed regression of instanceOf messages
    Open source →
  7. 2.1.4 17 Feb 2026
    Release notes

    See change log for changes.

    Open source →
    Release notes

    Fixed

    • Use custom message for more internal calls.
    Open source →
  8. 2.1.3 13 Feb 2026
    Release notes

    See change log for changes.

    Open source →
    Release notes

    Fixed

    • Corrected isList type documentation.
    • Corrected isAOf, isInstanceOf, etc type documentation.
    Open source →
  9. 2.1.2 13 Jan 2026
    Release notes

    See change log for changes.

    Open source →
    Release notes

    Fixed

    • Changed all* assertion values back to mixed.
    Open source →
  10. 2.1.1 08 Jan 2026
    Release notes

    See change log for changes.

    Open source →
    Release notes

    Fixed

    • Optimized stringNotEmpty by internally using notSame.
    Open source →
  11. 2.1.0 07 Jan 2026
    Release notes

    Fixed

    • Corrected @param declaration for isMap.
    • Pass custom message to internal assertion calls.
    Open source →
  12. 2.0.0 16 Dec 2025
    Release notes

    Changed

    • BREAKING Minimum PHP version is now 8.2 (was 7.2).
    • BREAKING Remove deprecated isTraversable, use isIterable or isInstanceOf instead.
    • BREAKING Added declare(strict_types=1) to all classes.
    • Updated CI/CD test matrix to test PHP 8.2, 8.3, 8.4, and 8.5.
    • Updated development tools (PHPUnit, Psalm, PHP-CS-Fixer) to supported versions.
    • Added explicit return types and parameter types to all methods in both source code and tests.

    Added

    • All assertion methods now return the checked value.
    • Added notInArray and notOneOf.
    • Added isInitialized, to check if a class property is initialized.
    • Added negativeInteger and notNegativeInteger
    • Added isStatic and notStatic

    Fixed

    • Corrected validation of emails with unicode characters.
    Open source →
  13. 2.0.0-beta 03 Dec 2025 pre-release

    Nothing published for this version

  14. 1.12.1 29 Oct 2025
    Release notes

    Fixed

    • Exclude tools from export.
    Open source →
  15. 1.12.0 20 Oct 2025
    Release notes

    Fixed

    • Corrected messages and typos in various assertions.
    • Document void return type.
    • Prevent UUIDs with trailing newlines from validating.
    • Assert values are strings before ctype checks.
    Open source →
  16. 1.11.0 03 Jun 2022
    Release notes

    Added

    • Added explicit (non-magic) allNullOr* methods, with @psalm-assert annotations, for better Psalm support.

    Changed

    • Trait methods will now check the assertion themselves, instead of using __callStatic
    • isList will now deal correctly with (modified) lists that contain NaN
    • reportInvalidArgument now has a return type of never.

    Removed

    • Removed symfony/polyfill-ctype as a dependency, and require ext-ctype instead.
      • You can still require the symfony/polyfill-ctype in your project if you need it, as it provides ext-ctype
    Open source →
  17. 1.10.0 09 Mar 2021
    Release notes

    Added

    • On invalid assertion, we throw a Webmozart\Assert\InvalidArgumentException
    • Added Assert::positiveInteger()

    Changed

    • Using a trait with real implementations of all*() and nullOr*() methods to improve psalm compatibility.

    Removed

    • Support for PHP <7.2
    Open source →
  18. 1.9.1 08 Jul 2020

    Nothing published for this version

  19. 1.9.0 16 Jun 2020
    Release notes
    • added better Psalm support for all* & nullOr* methods
    • These methods are now understood by Psalm through a mixin. You may need a newer version of Psalm in order to use this
    • added @psalm-pure annotation to Assert::notFalse()
    • added more @psalm-assert annotations where appropriate
    Open source →
  20. 1.8.0 18 Apr 2020
    Release notes

    Added

    • added Assert::notStartsWith()
    • added Assert::notEndsWith()
    • added Assert::inArray()
    • added @psalm-pure annotations to pure assertions

    Fixed

    • Exception messages of comparisons between DateTime(Immutable) objects now display their date & time.
    • Custom Exception messages for Assert::count() now use the values to render the exception message.
    Open source →
  21. 1.7.0 14 Feb 2020
    Release notes

    Added

    • added Assert::notFalse()
    • added Assert::isAOf()
    • added Assert::isAnyOf()
    • added Assert::isNotA()
    Open source →
  22. 1.6.0 24 Nov 2019
    Release notes

    Added

    • added Assert::validArrayKey()
    • added Assert::isNonEmptyList()
    • added Assert::isNonEmptyMap()
    • added @throws InvalidArgumentException annotations to all methods that throw.
    • added @psalm-assert for the list type to the isList assertion.

    Fixed

    • ResourceBundle & SimpleXMLElement now pass the isCountable assertions. They are countable, without implementing the Countable interface.
    • The doc block of range now has the proper variables.
    • An empty array will now pass isList and isMap. As it is a valid form of both. If a non-empty variant is needed, use isNonEmptyList or isNonEmptyMap.

    Changed

    • Removed some @psalm-assert annotations, that were 'side effect' assertions See:
    • If you use Psalm, the minimum version needed is 3.6.0. Which is enforced through a composer conflict. If you don't use Psalm, then this has no impact.
    Open source →
  23. 1.5.0 24 Aug 2019
    Release notes

    Added

    • added Assert::uniqueValues()
    • added Assert::unicodeLetters()
    • added: Assert::email()
    • added support for Psalm, by adding @psalm-assert annotations where appropriate.

    Fixed

    • Assert::endsWith() would not give the correct result when dealing with a multibyte suffix.
    • Assert::length(), minLength, maxLength, lengthBetween would not give the correct result when dealing with multibyte characters.

    NOTE: These 2 changes may break your assertions if you relied on the fact that multibyte characters didn't behave correctly.

    Changed

    • The names of some variables have been updated to better reflect what they are.
    • All function calls are now in their FQN form, slightly increasing performance.
    • Tests are now properly ran against HHVM-3.30 and PHP nightly.

    Deprecation

    • deprecated Assert::isTraversable() in favor of Assert::isIterable()
      • This was already done in 1.3.0, but it was only done through a silenced trigger_error. It is now annotated as well.
    Open source →
  24. 1.4.0 25 Dec 2018
    Release notes

    Added

    • added Assert::ip()
    • added Assert::ipv4()
    • added Assert::ipv6()
    • added Assert::notRegex()
    • added Assert::interfaceExists()
    • added Assert::isList()
    • added Assert::isMap()
    • added polyfill for ctype

    Fixed

    • Special case when comparing objects implementing __toString()
    Open source →
  25. 1.3.0 29 Jan 2018
    Release notes

    Added

    • added Assert::minCount()
    • added Assert::maxCount()
    • added Assert::countBetween()
    • added Assert::isCountable()
    • added Assert::notWhitespaceOnly()
    • added Assert::natural()
    • added Assert::notContains()
    • added Assert::isArrayAccessible()
    • added Assert::isInstanceOfAny()
    • added Assert::isIterable()

    Fixed

    • stringNotEmpty will no longer report "0" is an empty string

    Deprecation

    • deprecated Assert::isTraversable() in favor of Assert::isIterable()
    Open source →
  26. 1.2.0 23 Nov 2016
    Release notes
    • added Assert::throws()
    • added Assert::count()
    • added extension point Assert::reportInvalidArgument() for custom subclasses
    Open source →
  27. 1.1.0 09 Aug 2016
    Release notes
    • added Assert::object()
    • added Assert::propertyExists()
    • added Assert::propertyNotExists()
    • added Assert::methodExists()
    • added Assert::methodNotExists()
    • added Assert::uuid()
    Open source →
  28. 1.0.2 24 Aug 2015
    Release notes
    • integrated Style CI
    • add tests for minimum package dependencies on Travis CI
    Open source →
  29. 1.0.1 12 May 2015
    Release notes
    • added support for PHP 5.3.3
    Open source →
  30. 1.0.0 12 May 2015
    Release notes
    • first stable release
    Open source →
  31. 1.0.0-beta 19 Mar 2015 pre-release
    Release notes
    • first beta release
    Open source →

Every package, every release, already written down.

The archive is open and free. Watching your own project is what we are building next.

Browse the archive