diff --git a/composer.json b/composer.json index b717c0b42..776ecfb48 100644 --- a/composer.json +++ b/composer.json @@ -66,6 +66,7 @@ "rector/rector": "^1.0.1", "squizlabs/php_codesniffer": "^3.9", "symfony/finder": "^6.4.0 || ^7.0", + "symplify/phpstan-rules": "^12.4", "vimeo/psalm": "^5.22" }, "suggest": { diff --git a/composer.lock b/composer.lock index d774cbd95..c2828232e 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "a7cf6b11204a6b5c064c2e132fba9dd6", + "content-hash": "927a266e578eb2559977a4113a86f043", "packages": [ { "name": "dflydev/dot-access-data", @@ -7624,6 +7624,61 @@ ], "time": "2023-08-08T10:16:24+00:00" }, + { + "name": "symplify/phpstan-rules", + "version": "12.4.8", + "source": { + "type": "git", + "url": "https://github.com/symplify/phpstan-rules.git", + "reference": "393656aaf9fd09d9dc40d658c57ef222dd1f082d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symplify/phpstan-rules/zipball/393656aaf9fd09d9dc40d658c57ef222dd1f082d", + "reference": "393656aaf9fd09d9dc40d658c57ef222dd1f082d", + "shasum": "" + }, + "require": { + "nette/utils": "^3.2 || ^4.0", + "nikic/php-parser": "^4.17.1", + "php": "^7.2|^8.0", + "phpstan/phpstan": "^1.10.30", + "webmozart/assert": "^1.11" + }, + "type": "phpstan-extension", + "extra": { + "phpstan": { + "includes": [ + "config/services/services.neon" + ] + } + }, + "autoload": { + "psr-4": { + "Symplify\\PHPStanRules\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Set of Symplify rules for PHPStan", + "support": { + "issues": "https://github.com/symplify/phpstan-rules/issues", + "source": "https://github.com/symplify/phpstan-rules/tree/12.4.8" + }, + "funding": [ + { + "url": "https://www.paypal.me/rectorphp", + "type": "custom" + }, + { + "url": "https://github.com/tomasvotruba", + "type": "github" + } + ], + "time": "2024-02-09T21:23:31+00:00" + }, { "name": "theseer/tokenizer", "version": "1.2.2", diff --git a/packages/guides-restructured-text/src/RestructuredText/Directives/SectionauthorDirective.php b/packages/guides-restructured-text/src/RestructuredText/Directives/SectionauthorDirective.php index 0f691946d..333ff7d4f 100644 --- a/packages/guides-restructured-text/src/RestructuredText/Directives/SectionauthorDirective.php +++ b/packages/guides-restructured-text/src/RestructuredText/Directives/SectionauthorDirective.php @@ -23,6 +23,7 @@ final class SectionauthorDirective extends BaseDirective { + /** @see https://regex101.com/r/vGy4Uu/1 */ public const NAME_EMAIL_REGEX = '/^(?P[\w\s]+)(?: <(?P[^>]+)>)?$/'; public function __construct( diff --git a/packages/guides-restructured-text/src/RestructuredText/Parser/Productions/ListRule.php b/packages/guides-restructured-text/src/RestructuredText/Parser/Productions/ListRule.php index 5091ccc4d..33547a1e9 100644 --- a/packages/guides-restructured-text/src/RestructuredText/Parser/Productions/ListRule.php +++ b/packages/guides-restructured-text/src/RestructuredText/Parser/Productions/ListRule.php @@ -44,10 +44,11 @@ final class ListRule implements Rule /** * A regex matching all bullet list markers and a subset of the enumerated list markers. * + * @see https://regex101.com/r/LBXWFV/1 * @see https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#bullet-lists * @see https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#enumerated-lists */ - private const LIST_MARKER = '/ + private const LIST_MARKER_REGEX = '/ ^( [-+*\x{2022}\x{2023}\x{2043}] # match bullet list markers: "*", "+", "-", "•", "‣", or "⁃" ) @@ -120,13 +121,13 @@ private function isListLine(string|null $line): bool return false; } - return preg_match(self::LIST_MARKER, $line) > 0; + return preg_match(self::LIST_MARKER_REGEX, $line) > 0; } /** @return array{marker: string, indenting: int} */ public function getItemConfig(string $line): array { - $isList = preg_match(self::LIST_MARKER, $line, $m) > 0; + $isList = preg_match(self::LIST_MARKER_REGEX, $line, $m) > 0; if (!$isList) { throw new InvalidArgumentException('Line is not a valid item line'); } @@ -143,7 +144,7 @@ private function isListItemStart(string|null $line, string|null $listMarker = nu return false; } - $isList = preg_match(self::LIST_MARKER, $line, $m) > 0; + $isList = preg_match(self::LIST_MARKER_REGEX, $line, $m) > 0; if (!$isList) { return false; } diff --git a/packages/guides/src/UriFactory.php b/packages/guides/src/UriFactory.php index 2200b6cdb..645de5aa0 100644 --- a/packages/guides/src/UriFactory.php +++ b/packages/guides/src/UriFactory.php @@ -30,7 +30,8 @@ //TODO remove this, as it is copied form phpDocumentor to make things work. final class UriFactory { - public const WINDOWS_URI_FORMAT = '~^(file:\/\/\/)?(?[a-zA-Z][:|\|])~'; + /** @see https://regex101.com/r/4UN6ZR/1 */ + public const WINDOWS_URI_FORMAT_REGEX = '~^(file:\/\/\/)?(?[a-zA-Z][:|\|])~'; public static function createUri(string $uriString): UriInterface { @@ -40,7 +41,7 @@ public static function createUri(string $uriString): UriInterface return self::createPharUri($uriString); } - if (preg_match(self::WINDOWS_URI_FORMAT, $uriString)) { + if (preg_match(self::WINDOWS_URI_FORMAT_REGEX, $uriString)) { if (str_starts_with($uriString, 'file:///')) { $uriString = substr($uriString, strlen('file:///')); } diff --git a/phpstan.neon b/phpstan.neon index 4bbe2ab44..dd4993788 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,5 +1,8 @@ includes: - phpstan-baseline.neon +rules: + - Symplify\PHPStanRules\Rules\AnnotateRegexClassConstWithRegexLinkRule + - Symplify\PHPStanRules\Rules\RegexSuffixInRegexConstantRule parameters: level: max