webmozarts/assert

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

View on GitHub ↗Jump to charts ↓

Summary Information

Updated 7 minutes ago
Added to GitGenius on September 8th, 2026
Created on March 11th, 2015
Open Issues & Pull Requests: 30 (+0)
GitHub issues: Enabled
Number of forks: 167
Total Stargazers: 7,650 (+0)
Total Subscribers: 31 (+0)

Repository Insights (GitGenius)

Median issue/PR response: 38.1 days
Mean response time: 191.9 days
90th percentile: 449.5 days
Tracked items: 30

Most active contributors

Sign in to see contributor activity.

How this project is maintained

Around half of the issues opened in the past year never receive a reply. Only 5% of issues opened in the past year have been closed. Three people close 92% of everything that gets resolved.

Charts & Analytics

Fetching additional details & charts...

Issue Activity (beta)

Open issues: 9
New in 7 days: 0
Closed in 7 days: 0
Avg open age: 1,458 days
Stale 30+ days: 9
Stale 90+ days: 9

Recent activity

Opened in 7 days: 0
Closed in 7 days: 0
Comments in 7 days: 0
Events in 7 days: 0

Top labels

  • help wanted (8)
  • bug (6)
  • enhancement (5)
  • feature (3)
  • question (3)
  • symmetry (2)
  • invalid (1)

Most active issues this week

No issue events were indexed in the last 7 days.

Detailed Description

Webmozart Assert is a PHP library that provides assertions to validate method input and output with clear error messages.

The library solves the problem of writing repetitive validation code by offering a set of efficient assertions that throw InvalidArgumentException when they fail. Rather than manually checking conditions and constructing error messages throughout your codebase, you call assertion methods that handle both validation and messaging in a single step. The approach centers on consistent, readable error messages where placeholders follow a uniform pattern across all assertions: the first placeholder always represents the tested value, while subsequent numbered placeholders contain assertion-specific details like bounds or allowed values.

Developers should choose this tool when they want to reduce boilerplate validation code while maintaining clear, debuggable error messages. It suits any PHP project where method contracts need enforcement, from libraries to applications. The README explicitly compares it to beberlei/assert, noting that while both libraries serve similar purposes, Webmozart Assert addresses a usability issue with error message formatting. The key difference is consistent placeholder ordering: beberlei/assert varies the position of %s placeholders depending on the assertion type, whereas this library standardizes the pattern so %s always represents the tested value and additional placeholders follow predictably. This consistency makes it easier to write and understand custom error messages across different assertions.

The project maintains a steady stream of commits addressing bug fixes and minor improvements. Pull requests receive timely review and feedback from maintainers. Issues are actively triaged and responded to, with maintainers providing guidance on usage questions and evaluating feature requests against the library's scope. The codebase shows attention to code quality through consistent review practices.