Skip to content

feat: import namespaces over src #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
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
3 changes: 2 additions & 1 deletion src/PHPStan/InvalidRegexPatternRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Composer\Pcre\PHPStan;

use PhpParser\Node\Identifier;
use Composer\Pcre\Preg;
use Composer\Pcre\Regex;
use Composer\Pcre\PcreException;
Expand Down Expand Up @@ -58,7 +59,7 @@ private function extractPatterns(StaticCall $node, Scope $scope): array
if (!$isRegex && !$isPreg) {
return [];
}
if (!$node->name instanceof Node\Identifier || !Preg::isMatch('{^(match|isMatch|grep|replace|split)}', $node->name->name)) {
if (!$node->name instanceof Identifier || !Preg::isMatch('{^(match|isMatch|grep|replace|split)}', $node->name->name)) {
return [];
}

Expand Down
3 changes: 2 additions & 1 deletion src/PHPStan/UnsafeStrictGroupsCallRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Composer\Pcre\PHPStan;

use PhpParser\Node\Identifier;
use Composer\Pcre\Preg;
use Composer\Pcre\Regex;
use PhpParser\Node;
Expand Down Expand Up @@ -48,7 +49,7 @@ public function processNode(Node $node, Scope $scope): array
if (!$isRegex && !$isPreg) {
return [];
}
if (!$node->name instanceof Node\Identifier || !in_array($node->name->name, ['matchStrictGroups', 'isMatchStrictGroups', 'matchAllStrictGroups', 'isMatchAllStrictGroups'], true)) {
if (!$node->name instanceof Identifier || !in_array($node->name->name, ['matchStrictGroups', 'isMatchStrictGroups', 'matchAllStrictGroups', 'isMatchAllStrictGroups'], true)) {
return [];
}

Expand Down
4 changes: 3 additions & 1 deletion src/PcreException.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@

namespace Composer\Pcre;

class PcreException extends \RuntimeException
use RuntimeException;

class PcreException extends RuntimeException
{
/**
* @param string $function
Expand Down
6 changes: 4 additions & 2 deletions src/Regex.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

namespace Composer\Pcre;

use InvalidArgumentException;

class Regex
{
/**
Expand Down Expand Up @@ -163,14 +165,14 @@ public static function replaceCallbackArray(array $pattern, $subject, int $limit
private static function checkOffsetCapture(int $flags, string $useFunctionName): void
{
if (($flags & PREG_OFFSET_CAPTURE) !== 0) {
throw new \InvalidArgumentException('PREG_OFFSET_CAPTURE is not supported as it changes the return type, use '.$useFunctionName.'() instead');
throw new InvalidArgumentException('PREG_OFFSET_CAPTURE is not supported as it changes the return type, use '.$useFunctionName.'() instead');
}
}

private static function checkSetOrder(int $flags): void
{
if (($flags & PREG_SET_ORDER) !== 0) {
throw new \InvalidArgumentException('PREG_SET_ORDER is not supported as it changes the return type');
throw new InvalidArgumentException('PREG_SET_ORDER is not supported as it changes the return type');
}
}
}
4 changes: 3 additions & 1 deletion src/UnexpectedNullMatchException.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@

namespace Composer\Pcre;

use LogicException;

class UnexpectedNullMatchException extends PcreException
{
public static function fromFunction($function, $pattern)
{
throw new \LogicException('fromFunction should not be called on '.self::class.', use '.PcreException::class);
throw new LogicException('fromFunction should not be called on '.self::class.', use '.PcreException::class);
}
}