Skip to content

Commit

Permalink
Docs: add missing return type void annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
jrfnl committed Sep 26, 2023
1 parent b41bb18 commit 76b256e
Show file tree
Hide file tree
Showing 15 changed files with 90 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Whip_MessageDismisser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
4 changes: 4 additions & 0 deletions src/Whip_MessagesManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -50,6 +52,8 @@ public function listMessages() {

/**
* Deletes all messages.
*
* @return void
*/
public function deleteMessages() {
unset( $GLOBALS['whip_messages'] );
Expand Down
6 changes: 6 additions & 0 deletions src/Whip_RequirementsChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 ) {
Expand All @@ -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() ) {
Expand Down
2 changes: 2 additions & 0 deletions src/Whip_VersionRequirement.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions src/facades/wordpress.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions src/interfaces/Whip_MessagePresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ interface Whip_MessagePresenter {

/**
* Renders the message.
*
* @return void
*/
public function renderMessage();
}
2 changes: 2 additions & 0 deletions src/messages/Whip_BasicMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
6 changes: 6 additions & 0 deletions src/presenters/Whip_WPMessagePresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) );
Expand All @@ -59,6 +61,8 @@ public function registerHooks() {
* @deprecated 1.2.0 Use the Whip_WPMessagePresenter::registerHooks() method instead.
* @codeCoverageIgnore
*
* @return void
*
* @phpcs:disable Generic.NamingConventions.CamelCapsFunctionName
*/
public function register_hooks() {
Expand All @@ -68,6 +72,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 );
Expand Down
8 changes: 8 additions & 0 deletions tests/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.' );
Expand All @@ -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' ) );
Expand All @@ -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' ) );
Expand All @@ -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' ) );
Expand Down
4 changes: 4 additions & 0 deletions tests/MessageDismisserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class MessageDismisserTest extends Whip_TestCase {
*
* @covers Whip_MessageDismisser::__construct
* @covers Whip_MessageDismisser::dismiss
*
* @return void
*/
public function testDismiss() {
$currentTime = time();
Expand All @@ -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();
Expand Down
6 changes: 6 additions & 0 deletions tests/MessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand All @@ -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.' );
Expand All @@ -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.' );
Expand Down
2 changes: 2 additions & 0 deletions tests/MessagesManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
20 changes: 20 additions & 0 deletions tests/RequirementsCheckerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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', '<' ) ) {
Expand All @@ -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', '>=' ) ) {
Expand All @@ -76,6 +82,8 @@ public function testItThrowsAnTypeErrorWhenInvalidRequirementIsPassedInPHP5() {
*
* @covers Whip_RequirementsChecker::addRequirement
* @covers Whip_RequirementsChecker::totalRequirements
*
* @return void
*/
public function testItOnlyContainsUniqueComponents() {
$checker = new Whip_RequirementsChecker();
Expand All @@ -97,6 +105,8 @@ public function testItOnlyContainsUniqueComponents() {
*
* @covers Whip_RequirementsChecker::addRequirement
* @covers Whip_RequirementsChecker::requirementExistsForComponent
*
* @return void
*/
public function testIfRequirementExists() {
$checker = new Whip_RequirementsChecker();
Expand All @@ -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 ) );
Expand Down Expand Up @@ -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() ) );
Expand All @@ -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 ) );
Expand All @@ -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 ) );
Expand All @@ -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 ) );
Expand Down
22 changes: 22 additions & 0 deletions tests/VersionRequirementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand All @@ -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.' );
Expand All @@ -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.' );
Expand All @@ -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.' );
Expand All @@ -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.' );
Expand All @@ -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.' );
Expand All @@ -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.' );
Expand All @@ -101,6 +115,8 @@ public function testOperatorMustBeString() {
* is created with an invalid operator.
*
* @covers Whip_VersionRequirement::validateParameters
*
* @return void
*/
public function testOperatorMustBeValid() {
$this->expectExceptionHelper(
Expand All @@ -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' );
Expand All @@ -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 );
Expand Down Expand Up @@ -170,6 +190,8 @@ public function dataFromCompareString() {
* with an invalid comparison string.
*
* @covers Whip_VersionRequirement::fromCompareString
*
* @return void
*/
public function testFromCompareStringException() {
$this->expectExceptionHelper(
Expand Down
Loading

0 comments on commit 76b256e

Please sign in to comment.