Repository navigation
feat: Rename to temp/fnc, curry head and tail, docblocks, phpstan level 8 - #12
Merged
Merged
Conversation
head() and tail() were the only list functions that weren't curried, so they had to be passed as head(...) in pipelines. Both now follow the usual pattern and, like last() and nth(), also work on strings. Calls with one array argument behave as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The docblocks of most functions were inside the function body, where IDEs and phpstan don't see them. They are now regular docblocks with a "Signature:" line for the curried parameters. @param/@return tags of the inner closures are dropped, as they don't match the real `mixed ...$args` signature and a narrower @return would be wrong for partial calls. Also adds docblocks to the functions that had none and fixes outdated texts (map, filter, prop, drop, take, always). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Curried functions that returned bool|callable (all, any, contains, equals, isEmpty, none, not) now declare mixed like the others; the union didn't help callers and made every invocation of a partial call an error. - Internal closures typed as bool no longer return equals()/not() results of type bool|callable. - split() throws InvalidArgumentException for an empty separator instead of explode()'s ValueError. - Tests: typed helper classes, removed an assertion that is always true. Level 9 and max would flag every call of a curried function's result (invoking mixed), which is inherent to the curried API. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The package name now matches the Fnc namespace. "fn" would have been nicer, but it's a PHP keyword (`use Fn;` is a syntax error). The namespace and all functions stay the same. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Also documents that string handling in head, tail, last, nth, take, drop and slice is byte-based. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
composer.json already declares MIT; the file was missing in the repo and the package. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Both packages autoload src/functions.php with the same Fnc namespace; installing both would fail with "Cannot redeclare function". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
temp
force-pushed
the
feat/curried-head-tail-docblocks-phpstan
branch
from
November 3, 2026 15:54
4c5c112 to
bf9b932
Compare
Feedback from migrating 4wheels-api to 1.0:
- ascend/descend compare with <=>, which compares numeric strings
numerically ('9999' < '10000'). ascendWith/descendWith take a
comparison function, e.g. strcmp(...), so strcmp-based usort chains
can be migrated to sortWith() without changing the order.
- remap: an omit() after remap() runs on the result, and unlike the
former converge(merge(), [applySpec, omit]) pattern the computed keys
win over record keys of the same name. Documented in the docblock,
README and CLAUDE.md.
Examples now also cover all, ascend and descend.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The comparison function's result is normalised with <=> 0, as usort() accepts any number or a bool; previously the int return type threw a TypeError. Documents that strcmp(...) needs string values. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
🎉 This PR is included in version 1.1.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to 1.0.0; expected release: 1.1.0.
Package renamed to
temp/fncThe package name now matches the
Fncnamespace (fnis a PHP keyword). Switch your require fromtemp/fnto"temp/fnc": "^1.1"; the namespace and all functions stay the same.temp/fncreplacestemp/fn, so Composer never installs both. Versions up to 1.0 remain available astemp/fnonly.Changes
strcmp(...);ascend/descenduse<=>, which compares numeric strings numerically. Allows migrating strcmp-basedusortchains tosortWith()without changing the order.last,nth,take,drop,slice). Calls with one array argument behave as before;pipe(pluck('id'), head())now works withouthead(...).Signature:line for the curried parameters and no@param/@returntags. Missing docblocks added, outdated texts fixed.Things to be aware of
remap(): computed keys win over record keys of the same name (withconverge(merge(), [applySpec, omit])the record key won), and anomit()afterremap()runs on the result.split('')throwsInvalidArgumentExceptioninstead ofValueError. Code catchingValueErrorno longer catches it.all,any,contains,equals,isEmpty,noneandnotdeclaremixedinstead ofbool|callableas return type. No runtime change, but static analysis in dependent projects may report new findings.🤖 Generated with Claude Code