1
|
|
|
<?php namespace Xoopsmodules\randomquote\common; |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
You may not change or alter any portion of this comment or credits |
5
|
|
|
of supporting developers from this source code or any supporting source code |
6
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
7
|
|
|
|
8
|
|
|
This program is distributed in the hope that it will be useful, |
9
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
10
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
11
|
|
|
*/ |
12
|
|
|
/** |
13
|
|
|
* Module: randomquote |
14
|
|
|
* |
15
|
|
|
* @category Module |
16
|
|
|
* @package randomquote |
17
|
|
|
* @author XOOPS Development Team <[email protected]> - <https://xoops.org> |
18
|
|
|
* @copyright {@link https://xoops.org/ XOOPS Project} |
19
|
|
|
* @license GPL 2.0 or later |
20
|
|
|
* @link https://xoops.org/ |
21
|
|
|
* @since 1.0.0 |
22
|
|
|
*/ |
23
|
|
|
trait VersionChecks |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* |
27
|
|
|
* Verifies XOOPS version meets minimum requirements for this module |
28
|
|
|
* @static |
29
|
|
|
* @param \XoopsModule $module |
|
|
|
|
30
|
|
|
* |
31
|
|
|
* @param null|string $requiredVer |
32
|
|
|
* @return bool true if meets requirements, false if not |
33
|
|
|
*/ |
34
|
|
|
public static function checkVerXoops(\XoopsModule $module = null, $requiredVer = null) |
35
|
|
|
{ |
36
|
|
|
$moduleDirName = basename(dirname(dirname(__DIR__))); |
37
|
|
|
$moduleDirNameUpper = strtoupper($moduleDirName); |
38
|
|
|
if (null === $module) { |
39
|
|
|
$module = \XoopsModule::getByDirname($moduleDirName); |
40
|
|
|
} |
41
|
|
|
xoops_loadLanguage('admin', $moduleDirName); |
42
|
|
|
|
43
|
|
|
//check for minimum XOOPS version |
44
|
|
|
$currentVer = substr(XOOPS_VERSION, 6); // get the numeric part of string |
45
|
|
|
if (null === $requiredVer) { |
46
|
|
|
$requiredVer = '' . $module->getInfo('min_xoops'); //making sure it's a string |
47
|
|
|
} |
48
|
|
|
$success = true; |
49
|
|
|
|
50
|
|
View Code Duplication |
if (version_compare($currentVer, $requiredVer, '<')) { |
|
|
|
|
51
|
|
|
$success = false; |
52
|
|
|
$module->setErrors(sprintf(constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_XOOPS'), $requiredVer, $currentVer)); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
return $success; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* |
60
|
|
|
* Verifies PHP version meets minimum requirements for this module |
61
|
|
|
* @static |
62
|
|
|
* @param \XoopsModule $module |
63
|
|
|
* |
64
|
|
|
* @return bool true if meets requirements, false if not |
65
|
|
|
*/ |
66
|
|
|
public static function checkVerPhp(\XoopsModule $module) |
67
|
|
|
{ |
68
|
|
|
$moduleDirName = basename(dirname(dirname(__DIR__))); |
69
|
|
|
$moduleDirNameUpper = strtoupper($moduleDirName); |
70
|
|
|
xoops_loadLanguage('admin', $module->dirname()); |
71
|
|
|
// check for minimum PHP version |
72
|
|
|
$success = true; |
73
|
|
|
$verNum = PHP_VERSION; |
74
|
|
|
$reqVer = $module->getInfo('min_php'); |
75
|
|
|
if (false !== $reqVer && '' !== $reqVer) { |
76
|
|
View Code Duplication |
if (version_compare($verNum, $reqVer, '<')) { |
|
|
|
|
77
|
|
|
$module->setErrors(sprintf(constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_PHP'), $reqVer, $verNum)); |
78
|
|
|
$success = false; |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
return $success; |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
|
This check looks for
@param
annotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.