From 0535c570f7e55f3ee5ddc4c3bee4ae2a174e5677 Mon Sep 17 00:00:00 2001 From: Ivan Fedorov Date: Sat, 27 Jun 2020 22:21:25 +0300 Subject: [PATCH] fix test for zero patch version --- Core/Core_c.php | 4 ++-- curl/curl_d.php | 2 +- sodium/sodium.php | 2 +- tests/Parsers/Utils.php | 7 ++++--- tests/StubsTest.php | 25 ++++++++++++------------- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Core/Core_c.php b/Core/Core_c.php index e0839070..a464a0a6 100644 --- a/Core/Core_c.php +++ b/Core/Core_c.php @@ -647,7 +647,7 @@ class WeakReference { * @link https://www.php.net/manual/en/weakreference.create.php * @param object $referent The object to be weakly referenced. * @return WeakReference the freshly instantiated object. - * @since 7.4.0 + * @since 7.4 */ public static function create(object $referent): WeakReference {} @@ -656,7 +656,7 @@ class WeakReference { * destroyed, NULL is returned. * @link https://www.php.net/manual/en/weakreference.get.php * @return object|null - * @since 7.4.0 + * @since 7.4 */ public function get(): ?object {} } diff --git a/curl/curl_d.php b/curl/curl_d.php index 7d228046..d4ebb532 100644 --- a/curl/curl_d.php +++ b/curl/curl_d.php @@ -1734,7 +1734,7 @@ define ('CURLOPT_FTP_SKIP_PASV_IP', 137); * TRUE to disable support for the @ prefix for uploading files in CURLOPT_POSTFIELDS, * which means that values starting with @ can be safely passed as fields. * @link https://www.php.net/manual/en/function.curl-setopt.php - * @since 5.5.0 + * @since 5.5 * @deprecated 7.0 Use CURLFile for uploads instead. */ define ('CURLOPT_SAFE_UPLOAD', -1); diff --git a/sodium/sodium.php b/sodium/sodium.php index 667fab18..edfda27a 100644 --- a/sodium/sodium.php +++ b/sodium/sodium.php @@ -836,7 +836,7 @@ function sodium_crypto_secretbox( * @param string $key * @return string|false * @throws SodiumException - * @since 7.2.0 + * @since 7.2 */ function sodium_crypto_secretbox_open( string $ciphertext, diff --git a/tests/Parsers/Utils.php b/tests/Parsers/Utils.php index 36292447..c38f9d81 100644 --- a/tests/Parsers/Utils.php +++ b/tests/Parsers/Utils.php @@ -7,6 +7,7 @@ use phpDocumentor\Reflection\DocBlock\Tags\Deprecated; use phpDocumentor\Reflection\DocBlock\Tags\Since; use RecursiveArrayIterator; use RecursiveIteratorIterator; +use StubTests\Model\Tags\RemovedTag; class Utils { @@ -16,11 +17,11 @@ class Utils } /** - * @param Since|Deprecated $tag + * @param Since|Deprecated|RemovedTag $tag * @return bool */ - public static function versionIsMajor($tag): bool + public static function tagDoesNotHaveZeroPatchVersion($tag): bool { - return (bool)preg_match('/[1-9]+\.\d+/',$tag->getVersion()); + return (bool)preg_match('/^[1-9]+\.\d+(\.[1-9]+\d*)*$/',$tag->getVersion()); //find version like any but 7.4.0 } } diff --git a/tests/StubsTest.php b/tests/StubsTest.php index 3055bc3b..fd7cf4ad 100644 --- a/tests/StubsTest.php +++ b/tests/StubsTest.php @@ -173,7 +173,9 @@ class StubsTest extends TestCase } foreach ($class->properties as $property) { $propertyName = $property->name; - if ($property->access === "private") continue; + if ($property->access === "private") { + continue; + } if (!$property->hasMutedProblem(StubProblemType::STUB_IS_MISSED)) { static::assertArrayHasKey( $propertyName, @@ -418,10 +420,9 @@ class StubsTest extends TestCase if ($sinceTag instanceof Since) { $version = $sinceTag->getVersion(); if ($version !== null) { - self::assertTrue(Utils::versionIsMajor($sinceTag), "$elementName has 'since' version $version. - 'Since' version for PHP Core functionallity should have X.X format due to functionallity usually - isn't added in patch updates. If you believe this is not correct, please submit an issue about your case at - https://youtrack.jetbrains.com/issues/WI"); + self::assertTrue(Utils::tagDoesNotHaveZeroPatchVersion($sinceTag), "$elementName has + 'since' version $version.'Since' version for PHP Core functionallity for style consistensy + should have X.X format for the case when patch version is '0'."); } } } @@ -429,10 +430,9 @@ class StubsTest extends TestCase if ($deprecatedTag instanceof Deprecated) { $version = $deprecatedTag->getVersion(); if ($version !== null) { - self::assertTrue(Utils::versionIsMajor($deprecatedTag), "$elementName has 'deprecated' version $version . - 'Deprecated' version for PHP Core functionallity should have X.X format due to functionallity usually - isn't deprecated in patch updates. If you believe this is not correct, please submit an issue about your case at - https://youtrack.jetbrains.com/issues/WI"); + self::assertTrue(Utils::tagDoesNotHaveZeroPatchVersion($deprecatedTag), "$elementName has + 'deprecated' version $version.'Deprecated' version for PHP Core functionallity for style consistensy + should have X.X format for the case when patch version is '0'."); } } } @@ -440,10 +440,9 @@ class StubsTest extends TestCase if ($removedTag instanceof RemovedTag) { $version = $removedTag->getVersion(); if ($version !== null) { - self::assertTrue(Utils::versionIsMajor($removedTag), "$elementName has 'removed' version $version . - 'removed' version for PHP Core functionallity should have X.X format due to functionallity usually - isn't removed in patch updates. If you believe this is not correct, please submit an issue about your case at - https://youtrack.jetbrains.com/issues/WI"); + self::assertTrue(Utils::tagDoesNotHaveZeroPatchVersion($removedTag), "$elementName has + 'removed' version $version.'Removed' version for PHP Core functionallity for style consistensy + should have X.X format for the case when patch version is '0'."); } } }