Skip to content

Commit

Permalink
Deprecate PatternList
Browse files Browse the repository at this point in the history
  • Loading branch information
danon committed Feb 23, 2024
1 parent 9b2ad2a commit 5c8de5d
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ Incoming
* Deprecate `Pattern.replace().atMost()`
* Deprecate `Pattern.replace().atLeast()`
* Deprecate `Pattern.replace().limit()`, use `$limit` argument in replace methods
* Deprecate factory methods unqualified for release candidate.
* Deprecate `Pattern.list()`
* Deprecate `PatternList`
* Deprecate `Pattern.mask()`

Added in 0.41.5
---------------
Expand Down
6 changes: 6 additions & 0 deletions src/CleanRegex/Internal/EntryPoints.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ public static function inject(string $pattern, array $texts, string $modifiers =
new FigureClusters($texts)));
}

/**
* @deprecated
*/
public static function mask(string $mask, array $keywords, string $modifiers = ''): Pattern
{
return new Pattern(new Mask(PcreAutoCapture::autoCapture(), $mask, new Flags($modifiers), $keywords));
Expand Down Expand Up @@ -58,6 +61,9 @@ public static function alteration(array $texts, string $modifiers = ''): Pattern
return new Pattern(new Alteration(PcreAutoCapture::autoCapture(), $texts, new Flags($modifiers)));
}

/**
* @deprecated
*/
public static function list(array $patterns): PatternList
{
return new PatternList(new PatternStrings(PcreAutoCapture::autoCapture(), $patterns));
Expand Down
24 changes: 24 additions & 0 deletions src/CleanRegex/PatternList.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
use TRegx\CleanRegex\Replace\ChainedReplace;
use TRegx\SafeRegex\preg;

/**
* @deprecated
*/
class PatternList
{
/** @var Predefinitions */
Expand All @@ -17,6 +20,9 @@ public function __construct(PatternStrings $patternStrings)
$this->predefinitions = $patternStrings->predefinitions();
}

/**
* @deprecated
*/
public function testAll(string $subject): bool
{
foreach ($this->predefinitions->definitions() as $definition) {
Expand All @@ -27,6 +33,9 @@ public function testAll(string $subject): bool
return true;
}

/**
* @deprecated
*/
public function testAny(string $subject): bool
{
foreach ($this->predefinitions->definitions() as $definition) {
Expand All @@ -37,26 +46,41 @@ public function testAny(string $subject): bool
return false;
}

/**
* @deprecated
*/
public function failAll(string $subject): bool
{
return !$this->testAny($subject);
}

/**
* @deprecated
*/
public function failAny(string $subject): bool
{
return !$this->testAll($subject);
}

/**
* @deprecated
*/
public function prune(string $subject): string
{
return $this->replace($subject)->withReferences('');
}

/**
* @deprecated
*/
public function replace(string $subject): ChainedReplace
{
return new ChainedReplace($this->predefinitions, new Subject($subject));
}

/**
* @deprecated
*/
public function count(string $string): int
{
preg::replace($this->predefinitions->patternStrings(), '', $string, -1, $count);
Expand Down

0 comments on commit 5c8de5d

Please sign in to comment.