hamcrest/hamcrest-php

PHP Hamcrest implementation [Official]

View on GitHub ↗Jump to charts ↓

Summary Information

Updated 51 minutes ago
Added to GitGenius on September 9th, 2026
Created on December 31st, 2013
Open Issues & Pull Requests: 15 (+0)
GitHub issues: Enabled
Number of forks: 47
Total Stargazers: 6,993 (+0)
Total Subscribers: 15 (+0)

Repository Insights (GitGenius)

Median issue/PR response: 114.6 days
Mean response time: 805.4 days
90th percentile: 3468.8 days
Tracked items: 7

Charts & Analytics

Fetching additional details & charts...

Issue Activity (beta)

Open issues: 8
New in 7 days: 0
Closed in 7 days: 0
Avg open age: 959 days
Stale 30+ days: 8
Stale 90+ days: 8

Recent activity

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

Top labels

No label distribution available yet.

Most active issues this week

No issue events were indexed in the last 7 days.

Detailed Description

Hamcrest-php is a matching library for PHP that provides expressive assertions in unit tests.

The library solves the problem of writing readable test assertions by offering a fluent, composable set of matchers that describe expected values in natural language. Rather than relying on basic equality checks, developers use matchers like containsString, greaterThan, and hasKey to express test conditions. The tool works by providing matcher objects that can be combined and chained together, allowing complex assertions to be built from simple, reusable components.

Hamcrest-php suits projects where test readability and maintainability matter. It works well for teams already familiar with Hamcrest in other languages, since it follows the original Java API closely with only minor PHP-specific adjustments for language constraints. The library is particularly useful when tests need to verify complex conditions or when assertion messages should clearly communicate what was expected. Developers should be aware that some matchers from the original Java implementation are not ported because they lack semantic meaning in PHP, such as typeCompatibleWith and hasProperty. The tool provides matchers across several categories including arrays, collections, objects, numbers, type checking, and XML.

The project maintains a stable, focused scope with no pressure toward rapid expansion. Development activity shows consistent attention to the core matcher functionality without churn in the API surface. The tool receives maintenance updates that address issues and keep it compatible with current PHP practices, though the pace reflects a mature library serving an established need rather than one under active feature development.