From 50fb47948ed668cfcaef2afc3ee0a07de655daea Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 22 Sep 2023 06:30:59 +0200 Subject: [PATCH] Docs: add missing return type void annotations --- src/Whip_MessageDismisser.php | 2 ++ src/Whip_MessagesManager.php | 4 ++++ src/Whip_RequirementsChecker.php | 6 ++++++ src/Whip_VersionRequirement.php | 2 ++ src/facades/wordpress.php | 2 ++ src/interfaces/Whip_MessagePresenter.php | 2 ++ src/messages/Whip_BasicMessage.php | 2 ++ src/presenters/Whip_WPMessagePresenter.php | 6 ++++++ tests/ConfigurationTest.php | 8 ++++++++ tests/MessageDismisserTest.php | 4 ++++ tests/MessageTest.php | 6 ++++++ tests/MessagesManagerTest.php | 2 ++ tests/RequirementsCheckerTest.php | 20 ++++++++++++++++++++ tests/VersionRequirementTest.php | 22 ++++++++++++++++++++++ tests/WPMessageDismissListenerTest.php | 2 ++ 15 files changed, 90 insertions(+) diff --git a/src/Whip_MessageDismisser.php b/src/Whip_MessageDismisser.php index 87c2327..8759b3d 100644 --- a/src/Whip_MessageDismisser.php +++ b/src/Whip_MessageDismisser.php @@ -46,6 +46,8 @@ public function __construct( $currentTime, $threshold, Whip_DismissStorage $stor /** * Saves the version number to the storage to indicate the message as being dismissed. + * + * @return void */ public function dismiss() { $this->storage->set( $this->currentTime ); diff --git a/src/Whip_MessagesManager.php b/src/Whip_MessagesManager.php index 1b0673c..da84e49 100644 --- a/src/Whip_MessagesManager.php +++ b/src/Whip_MessagesManager.php @@ -23,6 +23,8 @@ public function __construct() { * Adds a message to the Messages Manager. * * @param Whip_Message $message The message to add. + * + * @return void */ public function addMessage( Whip_Message $message ) { $whipVersion = require __DIR__ . '/configs/version.php'; @@ -50,6 +52,8 @@ public function listMessages() { /** * Deletes all messages. + * + * @return void */ public function deleteMessages() { unset( $GLOBALS['whip_messages'] ); diff --git a/src/Whip_RequirementsChecker.php b/src/Whip_RequirementsChecker.php index a4817cd..dabe06a 100644 --- a/src/Whip_RequirementsChecker.php +++ b/src/Whip_RequirementsChecker.php @@ -57,6 +57,8 @@ public function __construct( $configuration = array(), $textdomain = 'default' ) * Adds a requirement to the list of requirements if it doesn't already exist. * * @param Whip_Requirement $requirement The requirement to add. + * + * @return void */ public function addRequirement( Whip_Requirement $requirement ) { // Only allow unique entries to ensure we're not checking specific combinations multiple times. @@ -122,6 +124,8 @@ private function requirementIsFulfilled( Whip_Requirement $requirement ) { /** * Checks if all requirements are fulfilled and adds a message to the message manager if necessary. + * + * @return void */ public function check() { foreach ( $this->requirements as $requirement ) { @@ -140,6 +144,8 @@ public function check() { * Adds a message to the message manager for requirements that cannot be fulfilled. * * @param Whip_Requirement $requirement The requirement that cannot be fulfilled. + * + * @return void */ private function addMissingRequirementMessage( Whip_Requirement $requirement ) { switch ( $requirement->component() ) { diff --git a/src/Whip_VersionRequirement.php b/src/Whip_VersionRequirement.php index 2a9aefb..ec0cc0d 100644 --- a/src/Whip_VersionRequirement.php +++ b/src/Whip_VersionRequirement.php @@ -111,6 +111,8 @@ public static function fromCompareString( $component, $comparisonString ) { * @param string $version The component version. * @param string $operator The operator to use when comparing version. * + * @return void + * * @throws Whip_EmptyProperty When any of the parameters is empty. * @throws Whip_InvalidOperatorType When the $operator parameter is invalid. * @throws Whip_InvalidType When any of the parameters is not of the expected type. diff --git a/src/facades/wordpress.php b/src/facades/wordpress.php index 5906670..b5897b1 100644 --- a/src/facades/wordpress.php +++ b/src/facades/wordpress.php @@ -10,6 +10,8 @@ * Facade to quickly check if version requirements are met. * * @param array $requirements The requirements to check. + * + * @return void */ function whip_wp_check_versions( $requirements ) { // Only show for admin users. diff --git a/src/interfaces/Whip_MessagePresenter.php b/src/interfaces/Whip_MessagePresenter.php index 80b409e..c337071 100644 --- a/src/interfaces/Whip_MessagePresenter.php +++ b/src/interfaces/Whip_MessagePresenter.php @@ -12,6 +12,8 @@ interface Whip_MessagePresenter { /** * Renders the message. + * + * @return void */ public function renderMessage(); } diff --git a/src/messages/Whip_BasicMessage.php b/src/messages/Whip_BasicMessage.php index ae7b33f..1348e96 100644 --- a/src/messages/Whip_BasicMessage.php +++ b/src/messages/Whip_BasicMessage.php @@ -42,6 +42,8 @@ public function body() { * * @param string $body Message body. * + * @return void + * * @throws Whip_EmptyProperty When the $body parameter is empty. * @throws Whip_InvalidType When the $body parameter is not of the expected type. */ diff --git a/src/presenters/Whip_WPMessagePresenter.php b/src/presenters/Whip_WPMessagePresenter.php index 60ca54f..574ada1 100644 --- a/src/presenters/Whip_WPMessagePresenter.php +++ b/src/presenters/Whip_WPMessagePresenter.php @@ -48,6 +48,8 @@ public function __construct( Whip_Message $message, Whip_MessageDismisser $dismi * Registers hooks to WordPress. * * This is a separate function so you can control when the hooks are registered. + * + * @return void */ public function registerHooks() { add_action( 'admin_notices', array( $this, 'renderMessage' ) ); @@ -59,6 +61,8 @@ public function registerHooks() { * @deprecated 1.2.0 Use the Whip_WPMessagePresenter::registerHooks() method instead. * @codeCoverageIgnore * @phpcs:disable Generic.NamingConventions.CamelCapsFunctionName + * + * @return void */ public function register_hooks() { // phpcs:enable @@ -67,6 +71,8 @@ public function register_hooks() { /** * Renders the messages present in the global to notices. + * + * @return void */ public function renderMessage() { $dismissListener = new Whip_WPMessageDismissListener( $this->dismisser ); diff --git a/tests/ConfigurationTest.php b/tests/ConfigurationTest.php index 3635b44..a73daac 100644 --- a/tests/ConfigurationTest.php +++ b/tests/ConfigurationTest.php @@ -14,6 +14,8 @@ class ConfigurationTest extends Whip_TestCase { * Tests the creation of a Whip_Configuration with invalid input. * * @covers Whip_Configuration::__construct + * + * @return void */ public function testItThrowsAnErrorIfAFaultyConfigurationIsPassed() { $this->expectExceptionHelper( 'Whip_InvalidType', 'Configuration should be of type array. Found string.' ); @@ -25,6 +27,8 @@ public function testItThrowsAnErrorIfAFaultyConfigurationIsPassed() { * Tests if Whip_Configuration correctly returns -1 when passed an unknown requirement. * * @covers Whip_Configuration::configuredVersion + * + * @return void */ public function testItReturnsANegativeNumberIfRequirementCannotBeFound() { $configuration = new Whip_Configuration( array( 'php' => '5.6' ) ); @@ -44,6 +48,8 @@ public function testItReturnsANegativeNumberIfRequirementCannotBeFound() { * Tests if Whip_Configuration correctly returns the version number when passed a valid requirement. * * @covers Whip_Configuration::configuredVersion + * + * @return void */ public function testItReturnsAnEntryIfRequirementIsFound() { $configuration = new Whip_Configuration( array( 'php' => '5.6' ) ); @@ -63,6 +69,8 @@ public function testItReturnsAnEntryIfRequirementIsFound() { * Tests if hasRequirementConfigures correctly returns true/false when called with valid/invalid values. * * @covers Whip_Configuration::hasRequirementConfigured + * + * @return void */ public function testIfRequirementIsConfigured() { $configuration = new Whip_Configuration( array( 'php' => '5.6' ) ); diff --git a/tests/MessageDismisserTest.php b/tests/MessageDismisserTest.php index 56f361f..e7e60b8 100644 --- a/tests/MessageDismisserTest.php +++ b/tests/MessageDismisserTest.php @@ -15,6 +15,8 @@ class MessageDismisserTest extends Whip_TestCase { * * @covers Whip_MessageDismisser::__construct * @covers Whip_MessageDismisser::dismiss + * + * @return void */ public function testDismiss() { $currentTime = time(); @@ -39,6 +41,8 @@ public function testDismiss() { * @param int $savedTime The saved time. * @param int $currentTime The current time. * @param bool $expected The expected value. + * + * @return void */ public function testIsDismissibleWithVersions( $savedTime, $currentTime, $expected ) { $storage = new Whip_DismissStorageMock(); diff --git a/tests/MessageTest.php b/tests/MessageTest.php index 33a13b6..8e46ab5 100644 --- a/tests/MessageTest.php +++ b/tests/MessageTest.php @@ -14,6 +14,8 @@ class MessageTest extends Whip_TestCase { * Tests if Whip_BasicMessage correctly handles a string for its body argument. * * @covers Whip_BasicMessage::body + * + * @return void */ public function testMessageHasBody() { $message = new Whip_BasicMessage( 'This is a message' ); @@ -25,6 +27,8 @@ public function testMessageHasBody() { * Tests if an Exception is correctly thrown when an empty string is passed as argument. * * @covers Whip_BasicMessage::validateParameters + * + * @return void */ public function testMessageCannotBeEmpty() { $this->expectExceptionHelper( 'Whip_EmptyProperty', 'Message body cannot be empty.' ); @@ -36,6 +40,8 @@ public function testMessageCannotBeEmpty() { * Tests if an Exception is correctly thrown when an invalid type is passed as argument. * * @covers Whip_BasicMessage::validateParameters + * + * @return void */ public function testMessageMustBeString() { $this->expectExceptionHelper( 'Whip_InvalidType', 'Message body should be of type string. Found integer.' ); diff --git a/tests/MessagesManagerTest.php b/tests/MessagesManagerTest.php index 1a0278f..d96e313 100644 --- a/tests/MessagesManagerTest.php +++ b/tests/MessagesManagerTest.php @@ -15,6 +15,8 @@ class MessagesManagerTest extends Whip_TestCase { * without a message, true when given a message. * * @covers Whip_MessagesManager::hasMessages + * + * @return void */ public function testHasMessages() { $manager = new Whip_MessagesManager(); diff --git a/tests/RequirementsCheckerTest.php b/tests/RequirementsCheckerTest.php index 5657a15..2192260 100644 --- a/tests/RequirementsCheckerTest.php +++ b/tests/RequirementsCheckerTest.php @@ -15,6 +15,8 @@ class RequirementsCheckerTest extends Whip_TestCase { * * @covers Whip_RequirementsChecker::addRequirement * @covers Whip_RequirementsChecker::totalRequirements + * + * @return void */ public function testItReceivesAUsableRequirementObject() { $checker = new Whip_RequirementsChecker(); @@ -29,6 +31,8 @@ public function testItReceivesAUsableRequirementObject() { * * @covers Whip_RequirementsChecker::addRequirement * @requires PHP 7 + * + * @return void */ public function testItThrowsAnTypeErrorWhenInvalidRequirementIsPassed() { if ( version_compare( phpversion(), '7.0', '<' ) ) { @@ -52,6 +56,8 @@ public function testItThrowsAnTypeErrorWhenInvalidRequirementIsPassed() { * Tests if Whip_RequirementsChecker throws an error when passed an invalid requirement. * * @covers Whip_RequirementsChecker::addRequirement + * + * @return void */ public function testItThrowsAnTypeErrorWhenInvalidRequirementIsPassedInPHP5() { if ( version_compare( phpversion(), '7.0', '>=' ) ) { @@ -76,6 +82,8 @@ public function testItThrowsAnTypeErrorWhenInvalidRequirementIsPassedInPHP5() { * * @covers Whip_RequirementsChecker::addRequirement * @covers Whip_RequirementsChecker::totalRequirements + * + * @return void */ public function testItOnlyContainsUniqueComponents() { $checker = new Whip_RequirementsChecker(); @@ -97,6 +105,8 @@ public function testItOnlyContainsUniqueComponents() { * * @covers Whip_RequirementsChecker::addRequirement * @covers Whip_RequirementsChecker::requirementExistsForComponent + * + * @return void */ public function testIfRequirementExists() { $checker = new Whip_RequirementsChecker(); @@ -117,6 +127,8 @@ public function testIfRequirementExists() { * @covers Whip_RequirementsChecker::check * @covers Whip_RequirementsChecker::hasMessages * @covers Whip_RequirementsChecker::getMostRecentMessage + * + * @return void */ public function testCheckIfPHPRequirementIsNotFulfilled() { $checker = new Whip_RequirementsChecker( array( 'php' => 4 ) ); @@ -149,6 +161,8 @@ public function testCheckIfPHPRequirementIsNotFulfilled() { * @covers Whip_RequirementsChecker::addRequirement * @covers Whip_RequirementsChecker::check * @covers Whip_RequirementsChecker::getMostRecentMessage + * + * @return void */ public function testCheckIfRequirementIsFulfilled() { $checker = new Whip_RequirementsChecker( array( 'php' => phpversion() ) ); @@ -168,6 +182,8 @@ public function testCheckIfRequirementIsFulfilled() { * @covers Whip_RequirementsChecker::check * @covers Whip_RequirementsChecker::getMostRecentMessage * @covers Whip_RequirementsChecker::hasMessages + * + * @return void */ public function testCheckIfRequirementIsNotFulfilled() { $checker = new Whip_RequirementsChecker( array( 'mysql' => 4 ) ); @@ -192,6 +208,8 @@ public function testCheckIfRequirementIsNotFulfilled() { * @covers Whip_RequirementsChecker::addRequirement * @covers Whip_RequirementsChecker::check * @covers Whip_RequirementsChecker::hasMessages + * + * @return void */ public function testCheckIfRequirementIsFulfilledWithSpecificComparison() { $checker = new Whip_RequirementsChecker( array( 'php' => 4 ) ); @@ -208,6 +226,8 @@ public function testCheckIfRequirementIsFulfilledWithSpecificComparison() { * @covers Whip_RequirementsChecker::addRequirement * @covers Whip_RequirementsChecker::check * @covers Whip_RequirementsChecker::hasMessages + * + * @return void */ public function testCheckIfRequirementIsNotFulfilledWithSpecificComparison() { $checker = new Whip_RequirementsChecker( array( 'php' => 4 ) ); diff --git a/tests/VersionRequirementTest.php b/tests/VersionRequirementTest.php index df98194..1b699aa 100644 --- a/tests/VersionRequirementTest.php +++ b/tests/VersionRequirementTest.php @@ -16,6 +16,8 @@ class VersionRequirementTest extends Whip_TestCase { * * @covers Whip_VersionRequirement::component * @covers Whip_VersionRequirement::version + * + * @return void */ public function testNameAndVersionAreNotEmpty() { $requirement = new Whip_VersionRequirement( 'php', '5.2' ); @@ -29,6 +31,8 @@ public function testNameAndVersionAreNotEmpty() { * is created with an empty component. * * @covers Whip_VersionRequirement::validateParameters + * + * @return void */ public function testComponentCannotBeEmpty() { $this->expectExceptionHelper( 'Whip_EmptyProperty', 'Component cannot be empty.' ); @@ -41,6 +45,8 @@ public function testComponentCannotBeEmpty() { * is created with an empty version. * * @covers Whip_VersionRequirement::validateParameters + * + * @return void */ public function testVersionCannotBeEmpty() { $this->expectExceptionHelper( 'Whip_EmptyProperty', 'Version cannot be empty.' ); @@ -53,6 +59,8 @@ public function testVersionCannotBeEmpty() { * is created with a false type for a component. * * @covers Whip_VersionRequirement::validateParameters + * + * @return void */ public function testComponentMustBeString() { $this->expectExceptionHelper( 'Whip_InvalidType', 'Component should be of type string. Found integer.' ); @@ -65,6 +73,8 @@ public function testComponentMustBeString() { * is created with a false type for a version. * * @covers Whip_VersionRequirement::validateParameters + * + * @return void */ public function testVersionMustBeString() { $this->expectExceptionHelper( 'Whip_InvalidType', 'Version should be of type string. Found integer.' ); @@ -77,6 +87,8 @@ public function testVersionMustBeString() { * is created with an empty operator. * * @covers Whip_VersionRequirement::validateParameters + * + * @return void */ public function testOperatorCannotBeEmpty() { $this->expectExceptionHelper( 'Whip_EmptyProperty', 'Operator cannot be empty.' ); @@ -89,6 +101,8 @@ public function testOperatorCannotBeEmpty() { * is created with a false type for an operator. * * @covers Whip_VersionRequirement::validateParameters + * + * @return void */ public function testOperatorMustBeString() { $this->expectExceptionHelper( 'Whip_InvalidType', 'Operator should be of type string. Found integer.' ); @@ -101,6 +115,8 @@ public function testOperatorMustBeString() { * is created with an invalid operator. * * @covers Whip_VersionRequirement::validateParameters + * + * @return void */ public function testOperatorMustBeValid() { $this->expectExceptionHelper( @@ -117,6 +133,8 @@ public function testOperatorMustBeValid() { * @covers Whip_VersionRequirement::component * @covers Whip_VersionRequirement::version * @covers Whip_VersionRequirement::operator + * + * @return void */ public function testGettingComponentProperties() { $requirement = new Whip_VersionRequirement( 'php', '5.6' ); @@ -138,6 +156,8 @@ public function testGettingComponentProperties() { * @param string $expectation The expected output string. * @param string $component The component for this version requirement. * @param string $compareString The comparison string for this version requirement. + * + * @return void */ public function testFromCompareString( $expectation, $component, $compareString ) { $requirement = Whip_VersionRequirement::fromCompareString( $component, $compareString ); @@ -170,6 +190,8 @@ public function dataFromCompareString() { * with an invalid comparison string. * * @covers Whip_VersionRequirement::fromCompareString + * + * @return void */ public function testFromCompareStringException() { $this->expectExceptionHelper( diff --git a/tests/WPMessageDismissListenerTest.php b/tests/WPMessageDismissListenerTest.php index 20c6016..54dfef9 100644 --- a/tests/WPMessageDismissListenerTest.php +++ b/tests/WPMessageDismissListenerTest.php @@ -24,6 +24,8 @@ class WPMessageDismissListener extends Whip_TestCase { * @param int $verifyNonceTimes The times to call wp_verify_nonce. * @param bool $isCorrectNonce Whether the nonce is correct. * @param int $dismissTimes The times to call dismiss. + * + * @return void */ public function testDismiss( $action, $nonce, $verifyNonceTimes, $isCorrectNonce, $dismissTimes ) { $dismisser = $this->getMockBuilder( 'Whip_MessageDismisser' )