# hamcrest/hamcrest-php

PHP Hamcrest implementation [Official]

Repository: https://github.com/hamcrest/hamcrest-php
Canonical: https://ross.abutalabs.com/products/hamcrest-php
Language: PHP
License: NOASSERTION
License Family: other
Last push: 2026-06-17T07:23:22+00:00

## Health v2 (maintenance only)
Score: 80/100 (v2, computed 2026-09-02T17:46:02.011165+00:00)
- activity 88, release rhythm 57, longevity 100
- inputs: {"age_days": 4628, "days_push": 77, "days_rel": 78, "gap_med": 206.0, "n_releases_24m": 3}
- flags: no_license
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 6994, forks 47 (observed 2026-08-28T04:09:52.397112+00:00)

## What it is
The official PHP port of the Hamcrest matcher library, providing a fluent set of matchers for writing expressive assertions in tests. It follows the original Java API closely and integrates with PHPUnit via MatcherAssert and global proxy functions.

## Use cases
- write readable assertions in phpunit tests
- match values with expressive matchers like equalTo or containsString
- combine matchers with both/andAlso and either/orElse
- avoid risky test warnings by counting hamcrest assertions
- port java hamcrest test styles to php

## When to choose
- you want declarative, composable matchers instead of plain assert calls
- you are already using PHPUnit and want richer assertion expressiveness
- you are porting Hamcrest-based tests from Java or other languages to PHP

## When to avoid
- you prefer PHPUnit's built-in assertions without extra dependencies
- you need collection matchers that have not been ported yet
- your project does not use PHP

## Facets
- artifact type: library
- maturity: stable
- function: testing, mocking
- domain: testing, developer-tools
- platform: php
- tags: hamcrest, matchers, assertions, unit-testing, phpunit

## Member repositories
- hamcrest/hamcrest-php (main) score 80

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:09:52.397112+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-29T17:41:06.772257+00:00, confidence not recorded.
  - readme: https://github.com/hamcrest/hamcrest-php (fetched 2026-08-28T04:09:52.397112+00:00, sha dc1922a338fc)
- Data as of 2026-08-30T08:39:29.467469+00:00.
