Download the PHP package php-spellcheck/spellcheck-core without Composer
On this page you can find all versions of the php package php-spellcheck/spellcheck-core. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download php-spellcheck/spellcheck-core
More information about php-spellcheck/spellcheck-core
Files in php-spellcheck/spellcheck-core
Package spellcheck-core
Short Description Framework-agnostic PHP spell checking engine for source code and translation files. Hunspell, Aspell, pspell or pure PHP backends, character-accurate positions, PSR-6 caching.
License MIT
Homepage https://github.com/php-spellcheck/spellcheck-core
Informations about the package spellcheck-core
PHP Spellcheck Core — spell checker for PHP code and translation files
Framework-agnostic PHP spell checking engine for source code and translation catalogues. It finds typos in PHP identifiers, docblocks, comments and in Symfony translation catalogues, with Hunspell, Aspell, pspell or a pure PHP backend, character-accurate line and column positions, ICU MessageFormat support, a baseline for legacy projects and PSR-6 caching.
Use it to fail CI on typos, to lint a translation catalogue in the language it is actually written in, or to build your own spell checking tool on top of the pipeline.
For the Symfony integration (console commands, bundle configuration,
Translator support) use
php-spellcheck/spellcheck-symfony-bundle.
Features
- Spell check PHP source code — class, method, property, variable, constant and function names are split on camelCase, snake_case, SCREAMING_SNAKE and acronyms before being checked.
- Spell check translation catalogues per locale — each message is checked
in the language of its own catalogue, so
messages.it.yamlis checked in Italian andmessages.de.yamlin German. Keys are resolved back to file and line in YAML, XLIFF and PHP array files. - ICU MessageFormat aware — a built-in recursive descent parser walks
plural,selectandselectordinalbranches. Noext-intlrequired. - Placeholders are never reported —
%count%,{{ var }},{name},:attribute,sprintfdirectives, HTML tags, Markdown syntax, URLs and docblock tags are stripped before the words reach the speller. - Character-accurate positions — every reported misspelling points at the line and column in the original file, not in the cleaned-up text.
- Five backends — Hunspell and Aspell over the Ispell pipe protocol,
ext-pspell, a dependency-free pure PHP word list, or an automatic chain. - Baseline for legacy projects — suppress the existing typos with a line-shift resistant fingerprint and fail only on the new ones.
- Seven report formats — table, JSON, GitHub Actions annotations, Checkstyle, JUnit, GitLab Code Quality and CSV.
- Custom and built-in dictionaries — technical, PHP and Symfony word lists ship with the package; add your own per project or per locale.
- Flat memory usage — the whole pipeline is lazy, so a repository with thousands of files costs the same as one file.
Requirements
- PHP ≥ 8.1 with
ext-mbstring(tested up to PHP 8.5) nikic/php-parser4 or 5- No mandatory
ext-intl(the ICU parser is built in) - No mandatory system binary (the pure PHP
wordlistbackend always works)
Table of contents
- Why another spell checker
- Related packages
- Install
- Quick start
- Architecture
- Extending
- Tests
- Contributing
- Changelog
- License
Why
cspell does not know that messages.it.yaml must be checked in Italian, that
%count% is a placeholder or that {n, plural, one {...}} has textual
branches. tigitz/php-spellchecker is an excellent backend abstraction but
knows nothing about the domain. This library is the missing middle layer: it
turns catalogues and PHP identifiers into checkable text, accurately, and hands
the words to whichever backend you have.
| php-spellcheck/spellcheck-core | cspell | tigitz/php-spellchecker | |
|---|---|---|---|
| Per-locale translation catalogues | yes | no | no |
| ICU MessageFormat branches | yes | no | no |
Symfony/Twig/sprintf placeholder awareness |
yes | partial | no |
| PHP identifier splitting from the AST | yes | no | no |
| Positions mapped back to the original text | yes | n/a | no |
| Baseline for legacy projects | yes | no | no |
| Runs without Node.js | yes | no | yes |
Related packages
| Package | Purpose |
|---|---|
php-spellcheck/spellcheck-core |
This package: the framework-agnostic engine. |
php-spellcheck/spellcheck-symfony-bundle |
Symfony bundle: console commands, configuration, Translator integration. |
Install
Quick start
Architecture
| Layer | Contract | Built-in implementations |
|---|---|---|
| Source | SourceInterface |
PhpFileSource, ArrayFragmentSource, ChainSource |
| Processor | TextProcessorInterface |
placeholders, sprintf, HTML, markdown, URLs, ICU, legacy plurals, docblocks, apostrophes |
| Tokenizer | TokenizerInterface |
IdentifierSplitter, ProseTokenizer |
| Speller | SpellerInterface |
HunspellSpeller, AspellSpeller, PspellSpeller, WordListSpeller, ChainSpeller, CachingSpeller, NullSpeller |
| Filter | MisspellingFilterInterface |
dictionary, pattern, deduplication, baseline |
| Reporter | ReporterInterface |
table, json, github, checkstyle, junit, gitlab, csv |
Everything is a generator: memory stays flat regardless of how many files or messages are processed.
Accurate positions
Every processor that removes text records the correspondence in an OffsetMap,
and maps compose associatively. That is what makes the reported column point at
the position in the original message:
Ispell pipe protocol
PipeSpeller keeps one process alive per language for the whole run. Words are
sent one per line prefixed with ^, and the terminating blank line is the
synchronisation point. Terse mode (!) suppresses the * lines and cuts the
I/O by roughly 90%; if your binary does not emit the blank line in terse mode,
construct the backend with terseMode: false.
Baseline
The fingerprint is sha256(schema | contextSeed | lowercase word | type)
truncated to 16 hex characters. It deliberately excludes line and column, so
moving code around does not invalidate the baseline. Renaming a file does, and
that is documented behaviour.
Extending
Implement the relevant interface and pass it to the chain. In a Symfony application the bundle autoconfigures the six extension points; outside of it, compose the objects yourself as in the quick start above.
Tests
tests/smoke.php runs a subset of the suite with a hand written autoloader and
no composer at all: useful to verify a checkout in a bare container.
Contributing
Bug reports, feature requests and pull requests are welcome. Read CONTRIBUTING.md first: the offset and determinism rules are not negotiable.
Security
Report vulnerabilities as described in SECURITY.md. Do not open a public issue for them.
License
Released under the MIT License.
All versions of spellcheck-core with dependencies
ext-mbstring Version *
nikic/php-parser Version ^4.18 || ^5.0
psr/cache Version ^1.0 || ^2.0 || ^3.0
psr/log Version ^1.1 || ^2.0 || ^3.0
symfony/finder Version ^5.4 || ^6.4 || ^7.0 || ^8.0
symfony/process Version ^5.4 || ^6.4 || ^7.0 || ^8.0