Release 0.9.2 - You're in for a treat!
๐ T-Regx The Dinosaur is really proud to announce its first beta version! Despite the beta suffix, it's 100% suitable for production use. It doesn't have any known bugs - check out the issues. There is a few breaking changes (since that's a 0.* version), but there are also a looot of improvements and new feautres. What's new in this release:
Here's a release on github: https://github.com/T-Regx/T-Regx/releases/tag/v0.9.2 (see Changelog.md).
- Breaking changes
- Methods
pattern()
/Pattern::of()
no longer "magically" guess whether a pattern is delimited or not.Pattern::of()
assumes pattern is delimited, newPattern::pcre()
takes an old-school delimited pattern. - Constructor
new Pattern()
is no longer a part of T-Regx API. UsePattern::of()
/pattern()
- Renamed
Match.parseInt()
toMatch.toInt()
(the same forMatchGroup
) - Removed
pattern()->match()->test()
/fails()
. From now on, usepattern()->test()
/fails()
- Removed
is()
:is()->delimited()
is()->usable()
is()->valid()
is changed tovalid()
- Removed
split()->ex()
, changedsplit()->inc()
tosplit()
- Methods
- Features
- Added
Match.group().replace()
๐ฅ - Added
pattern()->match()->fluent()
๐ฅ - Added
pattern()->match()->asInt()
- Added
pattern()->match()->distinct()
(leaves only unique matches) - Added prepared pattern method
Pattern::inject()
/Pattern::bind()
(see below) - In
pattern()->match()->groups()
:- Added
groups()->forEach()
/iterate()
- Added
groups()->flatMap()
- Added
groups()->map()
- Added
group()->fluent()
- Added
groups()->names()
(andnamedGroups()->names()
) - Added
groups()->count()
(andnamedGroups()->count()
)
- Added
- Added
match()->offsets()->fluent()
- Added
match()->group(string)->offsets()->fluent()
- Added
pattern()->forArray()->strict()
which throws for invalid values, instead of filtering them out
- Added
- SafeRegex
- Added
preg::grep_keys()
๐ฅ, that works exactly likepreg::grep()
, but filters by keys (also acceptsPREG_GREP_INVERT
)
- Added
- Enhancements/updates
- Method
by()->group()->orElse()
now receives lazy-loadedMatch
, instead of a subject - Added
withReferences()
toCompositePattern.chainedReplace()
- Previously named
Pattern::inject()
is renamed toPattern::bind()
- The
Pattern::bind()
(oldPattern::inject()
) still accepts values as an associative array, but newPattern::inject()
receives values without regard for the keys. - Fixed passing invalid types to
forArray()
. Previously, caused fatal error due to internalpreg_grep()
implementation.
- Method
- Other
- Now
MalformedPatternException
is thrown, instead ofCompileSafeRegexException
, when using invalid PCRE syntax. - Returning
Match
fromreplace()->callback()
(instead ofMatch.text()
asstring
) - Match
+12
is no longer considered a valid integer forisInt()
/toInt()
- Unnamed group will be represented as
null
inMatch.groupNames()
, instead of being simply ignored helper()
method,Pattern
andPatternBuilder
now return interfacePatternInterface
, instead ofPattern
class.Pattern
class now only holds static utility methods, andPatternImpl
holds the pattern implementation.
- Now
- Maintenance
- PhpUnit throws different exceptions because of PHP
__toString()
exception policy change.
- PhpUnit throws different exceptions because of PHP
Footnote:
- Apart from PHP type hints, every version up to this point could be run on PHP 5.3 (if one removes type hints from
code, one can run T-Regx on PHP 5.3). Every error, exception, malfunction, inconsistency was handled correctly by
T-Regx. From this version on (
0.9.2
), handling of the errors and inconsistencies is dropped, since T-Regx now only supports PHP 7.1.
Hope you guys will like and enjoy it!