Skip to content

Commit

Permalink
Deprecate Detail methods
Browse files Browse the repository at this point in the history
  • Loading branch information
danon committed Feb 23, 2024
1 parent 408f831 commit a1c82f4
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 0 deletions.
19 changes: 19 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,25 @@ Incoming
* Deprecate `Matcher.groupNames()`
* Deprecate `Matcher.groupsCount()`
* Deprecate `Matcher.groupExists()`
* Deprecate `Detail` methods unqualified for release candidate.
* Deprecate `Detail.get()`, to be renamed to `.group()`
* Deprecate `Detail.group()`, to be refactored to return `string`
* Deprecate `Detail.groups()`
* Deprecate `Detail.namedGroups()`
* Deprecate `Detail.matched()`, to be renamed to `.groupMatched()`
* Deprecate `Detail.all()`
* Deprecate `Detail.groupNames()`
* Deprecate `Detail.groupsCount()`
* Deprecate `Detail.byteLength()`
* Deprecate `Detail.offset()`, to be renamed to `.start()`
* Deprecate `Detail.tail()`, to be renamed to `.end()`
* Deprecate `Detail.length()`
* Deprecate `Detail.byteOffset()`, to be renamed to `.byteStart()`
* Deprecate `Detail.byteTail()`, to be renamed to `.byteEnd()`
* Deprecate `Detail.byteLength()`
* Deprecate `Detail.toInt()`
* Deprecate `Detail.isInt()`
* Deprecate `Intable`

Added in 0.41.5
---------------
Expand Down
34 changes: 34 additions & 0 deletions src/CleanRegex/Internal/Match/Details/MatchDetail.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,33 @@ public function text(): string
return $this->scalars->matchedText();
}

/**
* @deprecated
*/
public function length(): int
{
return $this->coordinate->characterLength();
}

/**
* @deprecated
*/
public function byteLength(): int
{
return $this->coordinate->byteLength();
}

/**
* @deprecated
*/
public function toInt(int $base = 10): int
{
return $this->numericDetail->asInteger(new Base($base));
}

/**
* @deprecated
*/
public function isInt(int $base = 10): bool
{
return $this->numericDetail->isInteger(new Base($base));
Expand All @@ -90,6 +102,7 @@ public function isInt(int $base = 10): bool
/**
* @param string|int $nameOrIndex
* @return string
* @deprecated
*/
public function get($nameOrIndex): string
{
Expand All @@ -99,6 +112,7 @@ public function get($nameOrIndex): string
/**
* @param string|int $nameOrIndex
* @return Group
* @deprecated
*/
public function group($nameOrIndex): Group
{
Expand All @@ -117,6 +131,7 @@ public function groupExists($nameOrIndex): bool
/**
* @param string|int $nameOrIndex
* @return bool
* @deprecated
*/
public function matched($nameOrIndex): bool
{
Expand All @@ -125,19 +140,24 @@ public function matched($nameOrIndex): bool

/**
* @return (string|null)[]
* @deprecated
*/
public function groupNames(): array
{
return $this->groupNames->groupNames();
}

/**
* @deprecated
*/
public function groupsCount(): int
{
return $this->groupsCount->groupsCount();
}

/**
* @return Group[]
* @deprecated
*/
public function groups(): array
{
Expand All @@ -146,6 +166,7 @@ public function groups(): array

/**
* @return Group[]
* @deprecated
*/
public function namedGroups(): array
{
Expand All @@ -154,27 +175,40 @@ public function namedGroups(): array

/**
* @return string[]
* @deprecated
*/
public function all(): array
{
return $this->scalars->otherTexts();
}

/**
* @deprecated
*/
public function offset(): int
{
return $this->coordinate->characterOffset();
}

/**
* @deprecated
*/
public function tail(): int
{
return $this->coordinate->characterTail();
}

/**
* @deprecated
*/
public function byteOffset(): int
{
return $this->coordinate->byteOffset();
}

/**
* @deprecated
*/
public function byteTail(): int
{
return $this->coordinate->byteTail();
Expand Down
6 changes: 6 additions & 0 deletions src/CleanRegex/Internal/Match/Intable.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
<?php
namespace TRegx\CleanRegex\Internal\Match;

/**
* @deprecated
*/
interface Intable
{
/**
* @deprecated
*/
public function toInt(int $base = 10): int;
}
6 changes: 6 additions & 0 deletions src/CleanRegex/Match/Detail.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,39 @@ public function index(): int;
/**
* @param string|int $nameOrIndex
* @return string
* @deprecated
*/
public function get($nameOrIndex): string;

/**
* @param string|int $nameOrIndex
* @return Group
* @deprecated
*/
public function group($nameOrIndex): Group;

/**
* @return Group[]
* @deprecated
*/
public function groups(): array;

/**
* @return Group[]
* @deprecated
*/
public function namedGroups(): array;

/**
* @param string|int $nameOrIndex
* @return bool
* @deprecated
*/
public function matched($nameOrIndex): bool;

/**
* @return string[]
* @deprecated
*/
public function all(): array;

Expand Down
24 changes: 24 additions & 0 deletions src/CleanRegex/Match/Element.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,44 @@ interface Element extends Intable
{
public function text(): string;

/**
* @deprecated
*/
public function toInt(int $base = 10): int;

/**
* @deprecated
*/
public function isInt(int $base = 10): bool;

/**
* @deprecated
*/
public function offset(): int;

/**
* @deprecated
*/
public function tail(): int;

/**
* @deprecated
*/
public function length(): int;

/**
* @deprecated
*/
public function byteOffset(): int;

/**
* @deprecated
*/
public function byteTail(): int;

/**
* @deprecated
*/
public function byteLength(): int;

public function subject(): string;
Expand Down
4 changes: 4 additions & 0 deletions src/CleanRegex/Match/Structure.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ public function subject(): string;

/**
* @return (string|null)[]
* @deprecated
*/
public function groupNames(): array;

/**
* @deprecated
*/
public function groupsCount(): int;

/**
Expand Down

0 comments on commit a1c82f4

Please sign in to comment.