Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.idea
composer.lock
vendor
41 changes: 41 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
## Changelog

### Version 4.0.2
### Fixed
- Fixed another type issue where int value was not always passed as the offest param to `HunspellResponse::__construct()`.

### Version 4.0.1
### Fixed
- Fixed type due to possibly passing non-int value to the `$offset` parameter when instantiating `HunspellResponse` objects.

### Version 4.0.0
### Updated
- Moved `getenv()` call to constructor and stored env data as a class property for caching to ensure the call is not made more than once per instance.
- Refactored `hunspellSuggest()` to work with space-separated list of words and return parsed result batch - This avoids needing to invoke the proc for each word which was a major performance issue.
- Updated `stem()`, `stemParse()` and `hunspellSuggest()` to ensure the stem branch of this library works correctly after the batch improvement.

### Version 3.0.0
#### Added
- New optional constructor argument `$custom_words_file` which takes a path to a custom word list to be merged with the dictionary at runtime.
- Windows/Linux environments now use the same process execution code.
- Hunspell process invocation is now handled through `proc_open` instead of `shell_exec`.
- Hunspell `stderr` output is now logged via `error_log()` call.
#### Changed
- Changed constructor argument `$encoding` default value from 'en_US.utf-8' to 'UTF-8'.

### Version 2.0.0
#### Added
- Added PHP8.0 typed class,
- Added constructor to main `HunspellPHP` class where the `$dictionary`, `$encoding` and `$dictionary_path` cal be set/overridden during initialization.
- Added `$dictionary_path` as a new argument were the dictionary files path may be specified (system default search locations are used otherwise). Additional `get()` and `set()`methods added.
- Added functionality to `findCommand` method via new `(bool)$stem_mode` argument.
#### Removed
- Removed `findStemCommand` method.
- Removed unused exception classes.
- Removed `HunspellPHP\Exceptions` namespace.
- Removed composer.lock from repo.
#### Fixed
- Renamed `$language` more appropriately `$dictionary` since that is what that property is referencing.
- Moved HunspellMatchTypeException up one directory to \HunspellPHP namespace.
- Fixed an issue where not all `$match` values were returned from the command response resulting in PHP warnings.
- Fixed a missing type `-` extraction from the matcher regex which resulted in PHP warnings and bad responses.
10 changes: 0 additions & 10 deletions README.MD

This file was deleted.

27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Hunspell PHP wrapper
Forked from [johnzuk/HunspellPHP](https://github.com/johnzuk/HunspellPHP)

### Version 4.x (Optimization +Batch Mode)
This version changes find() and possibly stem() (I'm not exactly sure how stem() functioned before as I did not use it, but I updated to be compatible with the changes made under the hood to `hunspellSuggest()`). The changes to `hunspellSuggest()` can now take a space-separated string of words to batch process. This change allows a single process call to handle many spell checks (and stems) rather than having to invoke the process once for each word. The update also ensures the 1000ms timeout "deadline" is not forcing the process to wait that time before ending which appeared to be the case in previous versions.

### Version 3.0.0 (Very minor backward breaking change)
This version updates the constructor signature with a different (better?) default value for `$encoding`, so if anyone was using that this would be a backward breaking change. Otherwise, a new constructor argument $custom_word_file (path) has been added and will bind your provided custom word list with your dictionary in real time.

The other change this version takes care of is using `proc_open` and better env/encoding handling in general. We also now emmit an `error_log()` call so stderr output from the hunspell process are logged properly.

### Version 2.x
Version 2.0.0 and above requires PHP ^8.0.0 and includes an important fix to the result matcher regex. If you need this for an older version of PHP I recommend that you fork 1.2 and update the regex matcher property of the Hunspell class to what is set in the current version of the code.

[View Changelog](CHANGELOG.md)

### The reason for this fork
This project was initially forked because the shell commands used were for a non-bash shell. This fork's main purpose was to convert the shell commands to a BASH compatible syntax and add support for Windows powershell. As such this fork will not work correctly outside of a bash or powershell environment.

An additional change was made to the parsing of the return value as the `PHP_EOL` value used in the original source was not working in my testing. This was changed to "\n" which resolved the issue.

Example
===================
```php
$hunspell = new \HunspellPHP\Hunspell();
var_dump($hunspell->find('otwórz'));
```
11 changes: 6 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
{
"name": "hunspell-php/hunspell-php",
"name": "belniakmedia/hunspell-php",
"description": "Hunspell PHP wrapper",
"minimum-stability": "dev",
"version": "4.0.2",
"license": "MIT",
"authors": [
{
"name": "Janusz Żukowicz",
"email": "john_zuk@wp.pl"
"name": "Richard Kukiela",
"email": "rick@belniakmedia.com"
}
],
"require": {
"php" : ">=5.6"
"php" : ">=8.0"
},
"autoload": {
"psr-4": {
"HunspellPHP\\": "src/HunspellPHP"
}
}
}
}
20 changes: 0 additions & 20 deletions composer.lock

This file was deleted.

8 changes: 0 additions & 8 deletions src/HunspellPHP/Exception/InvalidResultException.php

This file was deleted.

8 changes: 0 additions & 8 deletions src/HunspellPHP/Exception/WordNotFoundException.php

This file was deleted.

Loading