From a0a3a1c8d8cf92c121b9f816d641f0d704f332eb Mon Sep 17 00:00:00 2001 From: Jellyfrog Date: Thu, 1 Apr 2021 00:35:19 +0200 Subject: [PATCH] PHPDoc fixes (#12693) --- LibreNMS/Authentication/TwoFactor.php | 2 +- LibreNMS/Cache/PermissionsCache.php | 2 +- LibreNMS/DB/Eloquent.php | 2 +- LibreNMS/Data/Store/Datastore.php | 2 +- LibreNMS/Data/Store/Rrd.php | 2 +- .../Exceptions/FilePermissionsException.php | 2 +- .../MaximumExecutionTimeExceeded.php | 2 +- .../Exceptions/UnserializableRouteCache.php | 2 +- .../Interfaces/Authentication/Authorizer.php | 2 +- LibreNMS/Util/ModuleTestHelper.php | 2 +- app/Models/AlertSchedule.php | 3 +++ app/Models/Device.php | 1 + app/Models/Location.php | 3 +++ app/Models/User.php | 3 +++ tests/AuthSSOTest.php | 9 ++++++++ tests/MibTest.php | 22 +++++++++---------- tests/OSDiscoveryTest.php | 2 +- tests/Unit/Data/GraphiteStoreTest.php | 2 +- tests/Unit/Data/OpenTSDBStoreTest.php | 2 +- tests/YamlSchemaTest.php | 4 ++-- 20 files changed, 45 insertions(+), 26 deletions(-) diff --git a/LibreNMS/Authentication/TwoFactor.php b/LibreNMS/Authentication/TwoFactor.php index be4275b8b2..27b4068ed7 100644 --- a/LibreNMS/Authentication/TwoFactor.php +++ b/LibreNMS/Authentication/TwoFactor.php @@ -162,7 +162,7 @@ class TwoFactor * Generate HOTP (RFC 4226) * @param string $key Secret Key * @param int|bool $counter Optional Counter, Defaults to Timestamp - * @return int + * @return string */ private static function oathHOTP($key, $counter = false) { diff --git a/LibreNMS/Cache/PermissionsCache.php b/LibreNMS/Cache/PermissionsCache.php index e99b2cead0..c7d71d9791 100644 --- a/LibreNMS/Cache/PermissionsCache.php +++ b/LibreNMS/Cache/PermissionsCache.php @@ -247,7 +247,7 @@ class PermissionsCache } /** - * @param Demixed $device + * @param mixed $device * @return int */ private function getDeviceId($device) diff --git a/LibreNMS/DB/Eloquent.php b/LibreNMS/DB/Eloquent.php index 79f57bfa9c..75ea5053fc 100644 --- a/LibreNMS/DB/Eloquent.php +++ b/LibreNMS/DB/Eloquent.php @@ -103,7 +103,7 @@ class Eloquent * Access the Database Manager for Fluent style queries. Like the Laravel DB facade. * * @param string $name - * @return \Illuminate\Database\Connection + * @return \Illuminate\Database\Connection|null */ public static function DB($name = null) { diff --git a/LibreNMS/Data/Store/Datastore.php b/LibreNMS/Data/Store/Datastore.php index 626f26b09e..451e73fa74 100644 --- a/LibreNMS/Data/Store/Datastore.php +++ b/LibreNMS/Data/Store/Datastore.php @@ -35,7 +35,7 @@ class Datastore * Initialize and create the Datastore(s) * * @param array $options - * @return DatastoreContract + * @return Datastore */ public static function init($options = []) { diff --git a/LibreNMS/Data/Store/Rrd.php b/LibreNMS/Data/Store/Rrd.php index bdbb1faab3..d51abded7a 100644 --- a/LibreNMS/Data/Store/Rrd.php +++ b/LibreNMS/Data/Store/Rrd.php @@ -485,7 +485,7 @@ class Rrd extends BaseDatastore * * @param string $graph_file * @param string $options - * @return int + * @return string|int */ public function graph($graph_file, $options) { diff --git a/LibreNMS/Exceptions/FilePermissionsException.php b/LibreNMS/Exceptions/FilePermissionsException.php index 56524283e3..fef1fdca25 100644 --- a/LibreNMS/Exceptions/FilePermissionsException.php +++ b/LibreNMS/Exceptions/FilePermissionsException.php @@ -35,7 +35,7 @@ class FilePermissionsException extends \Exception implements UpgradeableExceptio * Try to convert the given Exception to a FilePermissionsException * * @param \Exception $exception - * @return static + * @return static|null */ public static function upgrade($exception) { diff --git a/LibreNMS/Exceptions/MaximumExecutionTimeExceeded.php b/LibreNMS/Exceptions/MaximumExecutionTimeExceeded.php index ebd6a23d26..97d18dfdfe 100644 --- a/LibreNMS/Exceptions/MaximumExecutionTimeExceeded.php +++ b/LibreNMS/Exceptions/MaximumExecutionTimeExceeded.php @@ -34,7 +34,7 @@ class MaximumExecutionTimeExceeded extends \Exception implements UpgradeableExce * Try to convert the given Exception to a FilePermissionsException * * @param \Exception $exception - * @return static + * @return static|null */ public static function upgrade($exception) { diff --git a/LibreNMS/Exceptions/UnserializableRouteCache.php b/LibreNMS/Exceptions/UnserializableRouteCache.php index 64856b0e52..6c1234a03b 100644 --- a/LibreNMS/Exceptions/UnserializableRouteCache.php +++ b/LibreNMS/Exceptions/UnserializableRouteCache.php @@ -43,7 +43,7 @@ class UnserializableRouteCache extends \Exception implements UpgradeableExceptio * Try to convert the given Exception to this exception * * @param \Exception $exception - * @return static + * @return static|null */ public static function upgrade($exception) { diff --git a/LibreNMS/Interfaces/Authentication/Authorizer.php b/LibreNMS/Interfaces/Authentication/Authorizer.php index 238bfead73..be8a35c2e1 100644 --- a/LibreNMS/Interfaces/Authentication/Authorizer.php +++ b/LibreNMS/Interfaces/Authentication/Authorizer.php @@ -54,7 +54,7 @@ interface Authorizer * can_modify_passwd * * @param int $user_id - * @return array + * @return array|bool */ public function getUser($user_id); diff --git a/LibreNMS/Util/ModuleTestHelper.php b/LibreNMS/Util/ModuleTestHelper.php index defc37c02c..bf9cc18e51 100644 --- a/LibreNMS/Util/ModuleTestHelper.php +++ b/LibreNMS/Util/ModuleTestHelper.php @@ -504,7 +504,7 @@ class ModuleTestHelper * * @param Snmpsim $snmpsim * @param bool $no_save - * @return array + * @return array|null * @throws FileNotFoundException */ public function generateTestData(Snmpsim $snmpsim, $no_save = false) diff --git a/app/Models/AlertSchedule.php b/app/Models/AlertSchedule.php index 10ac310552..aa88234da3 100644 --- a/app/Models/AlertSchedule.php +++ b/app/Models/AlertSchedule.php @@ -34,6 +34,9 @@ use Illuminate\Database\Eloquent\Relations\MorphToMany; use Illuminate\Support\Str; use LibreNMS\Enum\AlertScheduleStatus; +/** + * @method static \Database\Factories\AlertScheduleFactory factory(...$parameters) + */ class AlertSchedule extends Model { use HasFactory; diff --git a/app/Models/Device.php b/app/Models/Device.php index 3556fe8075..fbd026d13e 100644 --- a/app/Models/Device.php +++ b/app/Models/Device.php @@ -26,6 +26,7 @@ use Permissions; * @property-read int|null $ports_count * @property-read int|null $sensors_count * @property-read int|null $wirelessSensors_count + * @method static \Database\Factories\DeviceFactory factory(...$parameters) */ class Device extends BaseModel { diff --git a/app/Models/Location.php b/app/Models/Location.php index a58e5c3674..1670702bec 100644 --- a/app/Models/Location.php +++ b/app/Models/Location.php @@ -31,6 +31,9 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\HasMany; use LibreNMS\Util\Dns; +/** + * @method static \Database\Factories\LocationFactory factory(...$parameters) + */ class Location extends Model { use HasFactory; diff --git a/app/Models/User.php b/app/Models/User.php index d1f0c97197..bced5be296 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -14,6 +14,9 @@ use Illuminate\Support\Facades\Hash; use LibreNMS\Authentication\LegacyAuth; use Permissions; +/** + * @method static \Database\Factories\UserFactory factory(...$parameters) + */ class User extends Authenticatable { use Notifiable, HasFactory; diff --git a/tests/AuthSSOTest.php b/tests/AuthSSOTest.php index 57e04ff8fc..da8ddaf1a9 100644 --- a/tests/AuthSSOTest.php +++ b/tests/AuthSSOTest.php @@ -125,6 +125,7 @@ class AuthSSOTest extends DBTestCase public function testValidAuthCreateOnly() { $this->basicConfig(); + /** @var \LibreNMS\Authentication\SSOAuthorizer */ $a = LegacyAuth::reset(); Config::set('sso.create_users', true); @@ -158,6 +159,7 @@ class AuthSSOTest extends DBTestCase public function testValidAuthUpdate() { $this->basicConfig(); + /** @var \LibreNMS\Authentication\SSOAuthorizer */ $a = LegacyAuth::reset(); // Create a random username and store it with the defaults @@ -182,6 +184,7 @@ class AuthSSOTest extends DBTestCase public function testBadAuth() { $this->basicConfig(); + /** @var \LibreNMS\Authentication\SSOAuthorizer */ $a = LegacyAuth::reset(); $this->basicEnvironmentEnv(); @@ -201,6 +204,7 @@ class AuthSSOTest extends DBTestCase public function testNoAttribute() { $this->basicConfig(); + /** @var \LibreNMS\Authentication\SSOAuthorizer */ $a = LegacyAuth::reset(); $this->basicEnvironmentEnv(); @@ -233,6 +237,7 @@ class AuthSSOTest extends DBTestCase public function testGetExternalUserName() { $this->basicConfig(); + /** @var \LibreNMS\Authentication\SSOAuthorizer */ $a = LegacyAuth::reset(); $this->basicEnvironmentEnv(); @@ -266,6 +271,7 @@ class AuthSSOTest extends DBTestCase public function testGetAttr() { + /** @var \LibreNMS\Authentication\SSOAuthorizer */ $a = LegacyAuth::reset(); $_SERVER['HTTP_VALID_ATTR'] = 'string'; @@ -288,6 +294,7 @@ class AuthSSOTest extends DBTestCase public function testTrustedProxies() { + /** @var \LibreNMS\Authentication\SSOAuthorizer */ $a = LegacyAuth::reset(); Config::set('sso.trusted_proxies', ['127.0.0.1', '::1', '2001:630:50::/48', '8.8.8.0/25']); @@ -340,6 +347,7 @@ class AuthSSOTest extends DBTestCase public function testLevelCaulculationFromAttr() { + /** @var \LibreNMS\Authentication\SSOAuthorizer */ $a = LegacyAuth::reset(); Config::set('sso.mode', 'env'); @@ -383,6 +391,7 @@ class AuthSSOTest extends DBTestCase public function testGroupParsing() { $this->basicConfig(); + /** @var \LibreNMS\Authentication\SSOAuthorizer */ $a = LegacyAuth::reset(); $this->basicEnvironmentEnv(); diff --git a/tests/MibTest.php b/tests/MibTest.php index 153414e3c6..ee4e10354f 100644 --- a/tests/MibTest.php +++ b/tests/MibTest.php @@ -41,7 +41,7 @@ class MibTest extends TestCase * * @group mibs * @dataProvider mibDirs - * @param $dir + * @param string $dir */ public function testMibDirectory($dir) { @@ -56,9 +56,9 @@ class MibTest extends TestCase * * @group mibs * @dataProvider mibFiles - * @param $path - * @param $file - * @param $mib_name + * @param string $path + * @param string $file + * @param string $mib_name */ public function testDuplicateMibs($path, $file, $mib_name) { @@ -86,9 +86,9 @@ class MibTest extends TestCase * * @group mibs * @dataProvider mibFiles - * @param $path - * @param $file - * @param $mib_name + * @param string $path + * @param string $file + * @param string $mib_name */ public function testMibNameMatches($path, $file, $mib_name) { @@ -104,9 +104,9 @@ class MibTest extends TestCase * * @group mibs * @dataProvider mibFiles - * @param $path - * @param $file - * @param $mib_name + * @param string $path + * @param string $file + * @param string $mib_name */ public function testMibContents($path, $file, $mib_name) { @@ -165,7 +165,7 @@ class MibTest extends TestCase /** * Extract the mib name from a file * - * @param $file + * @param string $file * @return mixed * @throws Exception */ diff --git a/tests/OSDiscoveryTest.php b/tests/OSDiscoveryTest.php index 7cc333b9fd..cc996d731c 100644 --- a/tests/OSDiscoveryTest.php +++ b/tests/OSDiscoveryTest.php @@ -57,7 +57,7 @@ class OSDiscoveryTest extends TestCase * * @group os * @dataProvider osProvider - * @param $os_name + * @param string $os_name */ public function testOS($os_name) { diff --git a/tests/Unit/Data/GraphiteStoreTest.php b/tests/Unit/Data/GraphiteStoreTest.php index 8fabc391d1..f84dcacb76 100644 --- a/tests/Unit/Data/GraphiteStoreTest.php +++ b/tests/Unit/Data/GraphiteStoreTest.php @@ -90,7 +90,7 @@ class GraphiteStoreTest extends TestCase } /** - * @param $mockSocket + * @param mixed $mockSocket * @return Graphite */ private function mockGraphite($mockSocket) diff --git a/tests/Unit/Data/OpenTSDBStoreTest.php b/tests/Unit/Data/OpenTSDBStoreTest.php index d64e72e95d..c9fd5f86a1 100644 --- a/tests/Unit/Data/OpenTSDBStoreTest.php +++ b/tests/Unit/Data/OpenTSDBStoreTest.php @@ -107,7 +107,7 @@ class OpenTSDBStoreTest extends TestCase } /** - * @param $mockSocket + * @param mixed $mockSocket * @return OpenTSDB */ private function mockOpenTSDB($mockSocket) diff --git a/tests/YamlSchemaTest.php b/tests/YamlSchemaTest.php index 37b78a7819..3cad16dd2a 100644 --- a/tests/YamlSchemaTest.php +++ b/tests/YamlSchemaTest.php @@ -110,8 +110,8 @@ class YamlSchemaTest extends TestCase } /** - * @param $filePath - * @param $schema_file + * @param string $filePath + * @param string $schema_file */ private function validateFileAgainstSchema($filePath, $schema_file) {