inspection fixes
Some checks are pending
CI / general_module_workflow_php (push) Waiting to run

This commit is contained in:
Dennis Eichhorn 2024-05-17 14:15:52 +00:00
parent a7f9eab55a
commit 2ea1d0373d
26 changed files with 1070 additions and 295 deletions

View File

@ -85,7 +85,8 @@ class GeneticOptimization
* @param \Closure $fitness Fitness function calculates score/feasibility of solution * @param \Closure $fitness Fitness function calculates score/feasibility of solution
* @param \Closure $mutate Mutation function to change the parameters of an "object" * @param \Closure $mutate Mutation function to change the parameters of an "object"
* @param \Closure $crossover Crossover function to exchange parameter values between "objects". * @param \Closure $crossover Crossover function to exchange parameter values between "objects".
* Sometimes single parameters can be exchanged but sometimes interdependencies exist between parameters which is why this function is required. * Sometimes single parameters can be exchanged but sometimes interdependencies exist
* between parameters which is why this function is required.
* @param int $generations Number of generations to create * @param int $generations Number of generations to create
* @param float $mutationRate Rate at which parameters are changed. * @param float $mutationRate Rate at which parameters are changed.
* How this is used depends on the mutate function. * How this is used depends on the mutate function.

View File

@ -115,7 +115,13 @@ final class EUVATBffOnline implements EUVATInterface
} }
$request = new HttpRequest(new HttpUri( $request = new HttpRequest(new HttpUri(
'https://evatr.bff-online.de/evatrRPC?UstId_1=' . $ownVAT . '&UstId_2=' . $otherVAT . '&Firmenname=' . \urlencode($otherName) . '&Ort=' . \urlencode($otherCity) . '&PLZ=' . \urlencode($otherPostal) . '&Strasse=' . \urlencode($otherStreet)) 'https://evatr.bff-online.de/evatrRPC?UstId_1=' . $ownVAT
. '&UstId_2=' . $otherVAT
. '&Firmenname=' . \urlencode($otherName)
. '&Ort=' . \urlencode($otherCity)
. '&PLZ=' . \urlencode($otherPostal)
. '&Strasse=' . \urlencode($otherStreet)
)
); );
$request->setMethod(RequestMethod::GET); $request->setMethod(RequestMethod::GET);

View File

@ -155,7 +155,7 @@ abstract class ConnectionAbstract implements ConnectionInterface
/** /**
* Connect to database * Connect to database
* *
* @param null|array{db:string, database:string}|array{db:string, host:string, port:int, login:string, password:string, database:string} $dbdata the basic database information for establishing a connection * @param null|array{db:string, database:string}|array{db:string, host:string, port:int, login:string, password:string, database:string} $dbdata The basic database information for establishing a connection
* *
* @return void * @return void
* *

View File

@ -78,11 +78,27 @@ trait ISO3166Trait
]; ];
case ISO639x1Enum::_AR: case ISO639x1Enum::_AR:
return [ return [
self::_DZA, self::_BHR, self::_TCD, self::_COM, self::_DJI, self::_EGY, self::_ERI, self::_ETH, self::_IRQ, self::_ISR, self::_JOR, self::_KWT, self::_LBN, self::_LBY, self::_MRT, self::_MAR, self::_OMN, self::_PSE, self::_QAT, self::_SAU, self::_SOM, self::_SDN, self::_SYR, self::_TUN, self::_ARE, self::_ESH, self::_YEM, self::_DZA, self::_BHR, self::_TCD, self::_COM, self::_DJI, self::_EGY, self::_ERI,
self::_ETH, self::_IRQ, self::_ISR, self::_JOR, self::_KWT, self::_LBN, self::_LBY,
self::_MRT, self::_MAR, self::_OMN, self::_PSE, self::_QAT, self::_SAU, self::_SOM,
self::_SDN, self::_SYR, self::_TUN, self::_ARE, self::_ESH, self::_YEM,
]; ];
case ISO639x1Enum::_EN: case ISO639x1Enum::_EN:
return [ return [
self::_USA, self::_ASM, self::_AIA, self::_ATA, self::_ATG, self::_AUS, self::_BHS, self::_BRB, self::_BLZ, self::_BMU, self::_BES, self::_BWA, self::_IOT, self::_CMR, self::_CAN, self::_CYM, self::_CXR, self::_CCK, self::_COK, self::_CUW, self::_DMA, self::_ERI, self::_FLK, self::_FJI, self::_GMB, self::_GHA, self::_GIB, self::_GRD, self::_GUM, self::_GGY, self::_GUY, self::_HMD, self::_HKG, self::_IND, self::_IRL, self::_IMN, self::_JAM, self::_JEY, self::_KEN, self::_KIR, self::_LSO, self::_LBR, self::_MWI, self::_MLT, self::_MHL, self::_MUS, self::_FSM, self::_MSR, self::_NAM, self::_NRU, self::_NZL, self::_NGA, self::_NIU, self::_NFK, self::_MNP, self::_PAK, self::_PLW, self::_PNG, self::_PHL, self::_PCN, self::_PRI, self::_RWA, self::_SHN, self::_KNA, self::_LCA, self::_MAF, self::_VCT, self::_WSM, self::_SYC, self::_SLE, self::_SGP, self::_SXM, self::_SLB, self::_SOM, self::_ZAF, self::_SGS, self::_SSD, self::_LKA, self::_SDN, self::_SWZ, self::_TZA, self::_TKL, self::_TON, self::_TTO, self::_TCA, self::_TUV, self::_UGA, self::_GBR, self::_UMI, self::_VUT, self::_VGB, self::_VIR, self::_ZMB, self::_ZWE, self::_USA, self::_ASM, self::_AIA, self::_ATA, self::_ATG, self::_AUS, self::_BHS,
self::_BRB, self::_BLZ, self::_BMU, self::_BES, self::_BWA, self::_IOT, self::_CMR,
self::_CAN, self::_CYM, self::_CXR, self::_CCK, self::_COK, self::_CUW, self::_DMA,
self::_ERI, self::_FLK, self::_FJI, self::_GMB, self::_GHA, self::_GIB, self::_GRD,
self::_GUM, self::_GGY, self::_GUY, self::_HMD, self::_HKG, self::_IND, self::_IRL,
self::_IMN, self::_JAM, self::_JEY, self::_KEN, self::_KIR, self::_LSO, self::_LBR,
self::_MWI, self::_MLT, self::_MHL, self::_MUS, self::_FSM, self::_MSR, self::_NAM,
self::_NRU, self::_NZL, self::_NGA, self::_NIU, self::_NFK, self::_MNP, self::_PAK,
self::_PLW, self::_PNG, self::_PHL, self::_PCN, self::_PRI, self::_RWA, self::_SHN,
self::_KNA, self::_LCA, self::_MAF, self::_VCT, self::_WSM, self::_SYC, self::_SLE,
self::_SGP, self::_SXM, self::_SLB, self::_SOM, self::_ZAF, self::_SGS, self::_SSD,
self::_LKA, self::_SDN, self::_SWZ, self::_TZA, self::_TKL, self::_TON, self::_TTO,
self::_TCA, self::_TUV, self::_UGA, self::_GBR, self::_UMI, self::_VUT, self::_VGB,
self::_VIR, self::_ZMB, self::_ZWE,
]; ];
case ISO639x1Enum::_SM: case ISO639x1Enum::_SM:
return [ return [
@ -94,15 +110,20 @@ trait ISO3166Trait
]; ];
case ISO639x1Enum::_PT: case ISO639x1Enum::_PT:
return [ return [
self::_AGO, self::_BRA, self::_CPV, self::_GNQ, self::_GNB, self::_MAC, self::_MOZ, self::_PRT, self::_STP, self::_TLS, self::_AGO, self::_BRA, self::_CPV, self::_GNQ, self::_GNB, self::_MAC, self::_MOZ,
self::_PRT, self::_STP, self::_TLS,
]; ];
case ISO639x1Enum::_RU: case ISO639x1Enum::_RU:
return [ return [
self::_ATA, self::_ARM, self::_AZE, self::_BLR, self::_KAZ, self::_KGZ, self::_RUS, self::_TJK, self::_TKM, self::_UZB, self::_ATA, self::_ARM, self::_AZE, self::_BLR, self::_KAZ, self::_KGZ, self::_RUS,
self::_TJK, self::_TKM, self::_UZB,
]; ];
case ISO639x1Enum::_ES: case ISO639x1Enum::_ES:
return [ return [
self::_ARG, self::_BOL, self::_CHL, self::_COL, self::_CRI, self::_CUB, self::_DOM, self::_ECU, self::_SLV, self::_GNQ, self::_GUM, self::_GTM, self::_HND, self::_MEX, self::_NIC, self::_PAN, self::_PRY, self::_PER, self::_PRI, self::_ESP, self::_USA, self::_URY, self::_VEN, self::_ESH, self::_ARG, self::_BOL, self::_CHL, self::_COL, self::_CRI, self::_CUB, self::_DOM,
self::_ECU, self::_SLV, self::_GNQ, self::_GUM, self::_GTM, self::_HND, self::_MEX,
self::_NIC, self::_PAN, self::_PRY, self::_PER, self::_PRI, self::_ESP, self::_USA,
self::_URY, self::_VEN, self::_ESH,
]; ];
case ISO639x1Enum::_GN: case ISO639x1Enum::_GN:
return [ return [
@ -114,7 +135,8 @@ trait ISO3166Trait
]; ];
case ISO639x1Enum::_NL: case ISO639x1Enum::_NL:
return [ return [
self::_ABW, self::_BEL, self::_BES, self::_CUW, self::_NLD, self::_MAF, self::_SXM, self::_SUR, self::_ABW, self::_BEL, self::_BES, self::_CUW, self::_NLD, self::_MAF, self::_SXM,
self::_SUR,
]; ];
case ISO639x1Enum::_DE: case ISO639x1Enum::_DE:
return [ return [
@ -134,7 +156,13 @@ trait ISO3166Trait
]; ];
case ISO639x1Enum::_FR: case ISO639x1Enum::_FR:
return [ return [
self::_BEL, self::_BEN, self::_BFA, self::_BDI, self::_CMR, self::_CAN, self::_CAF, self::_TCD, self::_COM, self::_COG, self::_COD, self::_CIV, self::_DJI, self::_GNQ, self::_FRA, self::_GUF, self::_PYF, self::_ATF, self::_GAB, self::_GLP, self::_GGY, self::_GIN, self::_HTI, self::_JEY, self::_LBN, self::_LUX, self::_MDG, self::_MLI, self::_MTQ, self::_MRT, self::_MUS, self::_MYT, self::_MCO, self::_NCL, self::_NER, self::_REU, self::_RWA, self::_BLM, self::_MAF, self::_SPM, self::_SEN, self::_SYC, self::_CHE, self::_TGO, self::_VUT, self::_WLF, self::_BEL, self::_BEN, self::_BFA, self::_BDI, self::_CMR, self::_CAN, self::_CAF,
self::_TCD, self::_COM, self::_COG, self::_COD, self::_CIV, self::_DJI, self::_GNQ,
self::_FRA, self::_GUF, self::_PYF, self::_ATF, self::_GAB, self::_GLP, self::_GGY,
self::_GIN, self::_HTI, self::_JEY, self::_LBN, self::_LUX, self::_MDG, self::_MLI,
self::_MTQ, self::_MRT, self::_MUS, self::_MYT, self::_MCO, self::_NCL, self::_NER,
self::_REU, self::_RWA, self::_BLM, self::_MAF, self::_SPM, self::_SEN, self::_SYC,
self::_CHE, self::_TGO, self::_VUT, self::_WLF,
]; ];
case ISO639x1Enum::_DZ: case ISO639x1Enum::_DZ:
return [ return [

View File

@ -366,7 +366,7 @@ final class Functions
$x += $err / (1.12837916709551257 * \exp(-($x * $x)) - $x * $err); $x += $err / (1.12837916709551257 * \exp(-($x * $x)) - $x * $err);
} }
return ($p < 1.0? $x : -$x); return $p < 1.0 ? $x : -$x;
} }
/** /**

View File

@ -81,7 +81,9 @@ final class Average
* @var float[] * @var float[]
* @since 1.0.0 * @since 1.0.0
*/ */
public const MAH13 = [-0.019, -0.028, 0.0, 0.66, 0.147, 0.214, 0.240, 0.214, 0.147, 0.66, 0.0, -0.028, -0.019]; public const MAH13 = [
-0.019, -0.028, 0.0, 0.66, 0.147, 0.214, 0.240, 0.214, 0.147, 0.66, 0.0, -0.028, -0.019
];
/** /**
* Moving average weights * Moving average weights
@ -89,7 +91,10 @@ final class Average
* @var float[] * @var float[]
* @since 1.0.0 * @since 1.0.0
*/ */
public const MAH23 = [-0.004, -0.011, -0.016, -0.015, -0.005, 0.013, 0.039, 0.068, 0.097, 0.122, 0.138, 0.148, 0.138, 0.122, 0.097, 0.068, 0.039, 0.013, -0.005, -0.015, -0.016, -0.011, -0.004]; public const MAH23 = [
-0.004, -0.011, -0.016, -0.015, -0.005, 0.013, 0.039, 0.068, 0.097, 0.122, 0.138,
0.148, 0.138, 0.122, 0.097, 0.068, 0.039, 0.013, -0.005, -0.015, -0.016, -0.011, -0.004
];
/** /**
* Constructor. * Constructor.

View File

@ -63,7 +63,10 @@ final class NormalDistribution
*/ */
public static function getSampleSizeFromPopulation(float $zScore, float $errorMargin, int $populationSize, float $populationProportion) : float public static function getSampleSizeFromPopulation(float $zScore, float $errorMargin, int $populationSize, float $populationProportion) : float
{ {
return self::getSampleSizeFromInfinitePopulation($zScore, $errorMargin, $populationProportion) / (1 + $zScore ** 2 * $populationProportion * (1 - $populationProportion) / ($errorMargin ** 2 * $populationSize)); return self::getSampleSizeFromInfinitePopulation($zScore, $errorMargin, $populationProportion)
/ (1 + $zScore ** 2 * $populationProportion * (1 - $populationProportion)
/ ($errorMargin ** 2 * $populationSize)
);
} }
/** /**

View File

@ -176,7 +176,7 @@ final class MultiMap implements \Countable
/** /**
* Get data. * Get data.
* *
* @param int|string|array $key Key used to identify value * @param int|string|array<int|string> $key Key used to identify value
* *
* @return mixed * @return mixed
* *
@ -208,7 +208,7 @@ final class MultiMap implements \Countable
/** /**
* Get data. * Get data.
* *
* @param int|string|array $key Key used to identify value * @param int|string|array<int|string> $key Key used to identify value
* *
* @return mixed * @return mixed
* *
@ -241,8 +241,8 @@ final class MultiMap implements \Countable
/** /**
* Set existing key with data. * Set existing key with data.
* *
* @param int|string|array $key Key used to identify value * @param int|string|array<int|string> $key Key used to identify value
* @param mixed $value Value to store * @param mixed $value Value to store
* *
* @return bool * @return bool
* *
@ -260,8 +260,8 @@ final class MultiMap implements \Countable
/** /**
* Set existing key with data. * Set existing key with data.
* *
* @param int|string|array $key Key used to identify value * @param int|string|array<int|string> $key Key used to identify value
* @param mixed $value Value to store * @param mixed $value Value to store
* *
* @return bool * @return bool
* *
@ -311,7 +311,7 @@ final class MultiMap implements \Countable
/** /**
* Remove value and all sibling keys based on key. * Remove value and all sibling keys based on key.
* *
* @param int|string|array $key Key used to identify value * @param int|string|array<int|string> $key Key used to identify value
* *
* @return bool * @return bool
* *
@ -329,7 +329,7 @@ final class MultiMap implements \Countable
/** /**
* Remove value and all sibling keys based on key. * Remove value and all sibling keys based on key.
* *
* @param int|string|array $key Key used to identify value * @param int|string|array<int|string> $key Key used to identify value
* *
* @return bool * @return bool
* *
@ -343,7 +343,7 @@ final class MultiMap implements \Countable
return $this->removeSingle(\implode(':', $key)); return $this->removeSingle(\implode(':', $key));
} }
/** @var array $keys */ /** @var array<array<int|string>> $keys */
$keys = Permutation::permuteAll($key, [], false); $keys = Permutation::permuteAll($key, [], false);
$found = false; $found = false;
@ -460,7 +460,7 @@ final class MultiMap implements \Countable
* *
* @param int|string|array $key Key to find siblings for * @param int|string|array $key Key to find siblings for
* *
* @return array * @return array<int, mixed>
* *
* @since 1.0.0 * @since 1.0.0
*/ */
@ -478,19 +478,19 @@ final class MultiMap implements \Countable
* *
* @param int|string|array $key Key to find siblings for * @param int|string|array $key Key to find siblings for
* *
* @return array * @return array<int, mixed>
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public function getSiblingsMultiple(int | string | array $key) : array public function getSiblingsMultiple(int | string | array $key) : array
{ {
if ($this->orderType === OrderType::LOOSE) { if ($this->orderType !== OrderType::LOOSE) {
$key = \is_array($key) ? $key : [$key]; return [];
return Permutation::permuteAll($key, [], false);
} }
return []; $key = \is_array($key) ? $key : [$key];
return Permutation::permuteAll($key, [], false);
} }
/** /**
@ -498,7 +498,7 @@ final class MultiMap implements \Countable
* *
* @param int|string $key Key to find siblings for * @param int|string $key Key to find siblings for
* *
* @return array * @return array<int, mixed>
* *
* @since 1.0.0 * @since 1.0.0
*/ */

View File

@ -24,7 +24,11 @@ namespace phpOMS\System\File;
*/ */
final class FileUtils final class FileUtils
{ {
public const CODE_EXTENSION = ['cpp', 'c', 'h', 'hpp', 'cs', 'css', 'scss', 'htm', 'html', 'js', 'java', 'sh', 'vb', 'php', 'rb', 'rs', 'ts', 'swift', 'class', 'htaccess', 'sql', 'py', 'bat', 'xml']; public const CODE_EXTENSION = [
'cpp', 'c', 'h', 'hpp', 'cs',
'css', 'scss', 'htm', 'html', 'js', 'ts',
'java', 'sh', 'vb', 'php', 'rb', 'rs', 'swift', 'class', 'htaccess', 'sql', 'py', 'bat', 'xml'
];
public const TEXT_EXTENSION = ['log', 'txt', 'md', 'csv', 'tex', 'latex', 'cfg', 'json', 'config', 'conf', 'ini', 'yaml', 'yml']; public const TEXT_EXTENSION = ['log', 'txt', 'md', 'csv', 'tex', 'latex', 'cfg', 'json', 'config', 'conf', 'ini', 'yaml', 'yml'];

View File

@ -77,8 +77,8 @@ final class ColorUtils
* *
* Important: This is not how humans perceive color differences * Important: This is not how humans perceive color differences
* *
* @param array $rgb1 RGB 1 * @param array{r:int, g:int, b:int} $rgb1 RGB 1
* @param array $rgb2 RGB 2 * @param array{r:int, g:int, b:int} $rgb2 RGB 2
* *
* @return float * @return float
* *
@ -98,8 +98,8 @@ final class ColorUtils
/** /**
* Approximate the perceived color distance * Approximate the perceived color distance
* *
* @param array $rgb1 RGB 1 * @param array{r:int, g:int, b:int} $rgb1 RGB 1
* @param array $rgb2 RGB 2 * @param array{r:int, g:int, b:int} $rgb2 RGB 2
* *
* @return float * @return float
* *

View File

@ -51,7 +51,7 @@ abstract class FileSizeType extends Enum
* *
* @param float $size File size * @param float $size File size
* *
* @return array * @return array{0:float, 1:string}
* *
* @since 1.0.0 * @since 1.0.0
*/ */

View File

@ -24,6 +24,12 @@ namespace phpOMS\Utils\RnG;
*/ */
final class Name final class Name
{ {
/**
* Localized names
*
* @var array{western:array{female:string[], male:string[], family:string[]}, asian:array{female:string[], male:string[], family:string[]}}
* @since 1.0.0
*/
private static array $names = [ private static array $names = [
'western' => [ 'western' => [
'female' => [ 'female' => [

View File

@ -39,8 +39,8 @@ final class Phone
* *
* @param bool $isInt This number uses a country code * @param bool $isInt This number uses a country code
* @param string $struct Number layout * @param string $struct Number layout
* @param array<null|array> $size Digits per placeholder [min, max] * @param array<null|int[]> $size Digits per placeholder [min, max]
* @param null|array $countries Country codes * @param null|string[] $countries Country codes
* *
* @return string * @return string
* *

View File

@ -74,8 +74,8 @@ final class StringUtils
* The validation is done case sensitive. The function takes strings or an array of strings for the validation. * The validation is done case sensitive. The function takes strings or an array of strings for the validation.
* In case of an array the function will test if any of the needles is at the end of the haystack string. * In case of an array the function will test if any of the needles is at the end of the haystack string.
* *
* @param string $haystack Haystack * @param string $haystack Haystack
* @param array|string $needles needles to check if they are at the end of the haystack * @param string|string[] $needles needles to check if they are at the end of the haystack
* *
* @example StringUtils::endsWith('Test string', ['test1', 'string']); // true * @example StringUtils::endsWith('Test string', ['test1', 'string']); // true
* *
@ -104,8 +104,8 @@ final class StringUtils
* The validation is done case sensitive. The function takes strings or an array of strings for the validation. * The validation is done case sensitive. The function takes strings or an array of strings for the validation.
* In case of an array the function will test if any of the needles is at the beginning of the haystack string. * In case of an array the function will test if any of the needles is at the beginning of the haystack string.
* *
* @param string $haystack Haystack * @param string $haystack Haystack
* @param array|string $needles needles to check if they are at the beginning of the haystack * @param string|string[] $needles needles to check if they are at the beginning of the haystack
* *
* @example StringUtils::startsWith('Test string', ['Test', 'something']); // true * @example StringUtils::startsWith('Test string', ['Test', 'something']); // true
* @example StringUtils::startsWith('Test string', 'string'); // false * @example StringUtils::startsWith('Test string', 'string'); // false
@ -173,7 +173,7 @@ final class StringUtils
$entropy = 0.0; $entropy = 0.0;
$size = \strlen($value); $size = \strlen($value);
/** @var array $countChars */ /** @var int[] $countChars */
$countChars = \count_chars($value, 1); $countChars = \count_chars($value, 1);
/** @var int $v */ /** @var int $v */
@ -295,7 +295,7 @@ final class StringUtils
* @param string[] $from From/old strings * @param string[] $from From/old strings
* @param string[] $to To/new strings * @param string[] $to To/new strings
* *
* @return array * @return array{values:string[], mask:int[]}
* *
* @throws \Exception This exception is thrown if one of the parameters is empty * @throws \Exception This exception is thrown if one of the parameters is empty
* *

View File

@ -39,6 +39,10 @@ class CronJob extends TaskAbstract
*/ */
public static function createWith(array $jobData) : TaskAbstract public static function createWith(array $jobData) : TaskAbstract
{ {
if (!\is_string($jobData[0]) || !\is_string($jobData[1])) {
return new self('');
}
$interval = \array_splice($jobData, 1, 5); $interval = \array_splice($jobData, 1, 5);
return new self($jobData[0], $jobData[1], \implode(' ', $interval)); return new self($jobData[0], $jobData[1], \implode(' ', $interval));

View File

@ -57,7 +57,7 @@ class Interval implements SerializableInterface
/** /**
* Minute. * Minute.
* *
* @var array * @var array<int, array{start:?int, end:?int, step:?int}>
* @since 1.0.0 * @since 1.0.0
*/ */
private $minute = []; private $minute = [];
@ -65,7 +65,7 @@ class Interval implements SerializableInterface
/** /**
* Hour. * Hour.
* *
* @var array * @var array<int, array{start:?int, end:?int, step:?int}>
* @since 1.0.0 * @since 1.0.0
*/ */
private $hour = []; private $hour = [];
@ -73,7 +73,7 @@ class Interval implements SerializableInterface
/** /**
* Day of month. * Day of month.
* *
* @var array * @var array<int, array{start:?int, end:?int, step:?int}>
* @since 1.0.0 * @since 1.0.0
*/ */
private $dayOfMonth = []; private $dayOfMonth = [];
@ -81,7 +81,7 @@ class Interval implements SerializableInterface
/** /**
* Month. * Month.
* *
* @var array * @var array<int, array{start:?int, end:?int, step:?int}>
* @since 1.0.0 * @since 1.0.0
*/ */
private $month = []; private $month = [];
@ -89,7 +89,7 @@ class Interval implements SerializableInterface
/** /**
* Day of week. * Day of week.
* *
* @var array * @var array<int, array{start:?int, end:?int, step:?int}>
* @since 1.0.0 * @since 1.0.0
*/ */
private $dayOfWeek = []; private $dayOfWeek = [];
@ -97,7 +97,7 @@ class Interval implements SerializableInterface
/** /**
* Year. * Year.
* *
* @var array * @var array<int, array{start:?int, end:?int, step:?int}>
* @since 1.0.0 * @since 1.0.0
*/ */
private $year = []; private $year = [];
@ -204,7 +204,7 @@ class Interval implements SerializableInterface
/** /**
* Get minute. * Get minute.
* *
* @return array * @return array<int, array{start:?int, end:?int, step:?int}>
* *
* @since 1.0.0 * @since 1.0.0
*/ */
@ -257,7 +257,7 @@ class Interval implements SerializableInterface
/** /**
* Get hour. * Get hour.
* *
* @return array * @return array<int, array{start:?int, end:?int, step:?int}>
* *
* @since 1.0.0 * @since 1.0.0
*/ */
@ -310,7 +310,7 @@ class Interval implements SerializableInterface
/** /**
* Get day of month. * Get day of month.
* *
* @return array * @return array<int, array{start:?int, end:?int, step:?int}>
* *
* @since 1.0.0 * @since 1.0.0
*/ */
@ -363,7 +363,7 @@ class Interval implements SerializableInterface
/** /**
* Get day of week. * Get day of week.
* *
* @return array * @return array<int, array{start:?int, end:?int, step:?int}>
* *
* @since 1.0.0 * @since 1.0.0
*/ */
@ -416,7 +416,7 @@ class Interval implements SerializableInterface
/** /**
* Get month. * Get month.
* *
* @return array * @return array<int, array{start:?int, end:?int, step:?int}>
* *
* @since 1.0.0 * @since 1.0.0
*/ */
@ -469,7 +469,7 @@ class Interval implements SerializableInterface
/** /**
* Get year. * Get year.
* *
* @return array * @return array<int, array{start:?int, end:?int, step:?int}>
* *
* @since 1.0.0 * @since 1.0.0
*/ */
@ -553,7 +553,7 @@ class Interval implements SerializableInterface
*/ */
public function unserialize(mixed $serialized) : void public function unserialize(mixed $serialized) : void
{ {
/** @var array $data */ /** @var array{start:string, end:?string, maxDuration:int, minute:array<int, array{start:?int, end:?int, step:?int}>, hour:array<int, array{start:?int, end:?int, step:?int}>, dayOfMonth:array<int, array{start:?int, end:?int, step:?int}>, dayOfWeek:array<int, array{start:?int, end:?int, step:?int}>, year:array<int, array{start:?int, end:?int, step:?int}>} $data */
$data = \json_decode($serialized, true); $data = \json_decode($serialized, true);
$this->start = new \DateTime($data['start']); $this->start = new \DateTime($data['start']);

View File

@ -42,6 +42,12 @@ class Schedule extends TaskAbstract
*/ */
public static function createWith(array $jobData) : TaskAbstract public static function createWith(array $jobData) : TaskAbstract
{ {
if (!\is_string($jobData[1]) || !\is_string($jobData[8])
|| !\is_string($jobData[7]) || !\is_string($jobData[10])
) {
return new self('');
}
$job = new self($jobData[1], $jobData[8], $jobData[7]); $job = new self($jobData[1], $jobData[8], $jobData[7]);
$job->status = (int) $jobData[3]; $job->status = (int) $jobData[3];

View File

@ -204,13 +204,22 @@ abstract class SchedulerAbstract
return \str_replace("\r\n", "\n", $raw); return \str_replace("\r\n", "\n", $raw);
} }
/**
* Get all jobs/tasks
*
* @return TaskAbstract[]
*
* @since 1.0.0
*/
abstract public function getAll() : array;
/** /**
* Get all jobs/tasks by name * Get all jobs/tasks by name
* *
* @param string $name Name of the job * @param string $name Name of the job
* @param bool $exact Name has to be exact * @param bool $exact Name has to be exact
* *
* @return array * @return TaskAbstract[]
* *
* @since 1.0.0 * @since 1.0.0
*/ */

View File

@ -251,7 +251,7 @@ abstract class TaskAbstract
/** /**
* Create task based on job data * Create task based on job data
* *
* @param array $jobData Raw job data * @param array<int, mixed> $jobData Raw job data
* *
* @return TaskAbstract * @return TaskAbstract
* *

View File

@ -44,9 +44,9 @@ abstract class Json extends ValidatorAbstract
/** /**
* Validate array against a template array. * Validate array against a template array.
* *
* @param array $template Template structure * @param array<string, string> $template Template structure
* @param array $source Source structure * @param array<string, string> $source Source structure
* @param bool $perfect No additional elements in source allowed * @param bool $perfect No additional elements in source allowed
* *
* @return bool Returns true if the template validates the source otherwise false * @return bool Returns true if the template validates the source otherwise false
* *
@ -75,10 +75,10 @@ abstract class Json extends ValidatorAbstract
/** /**
* Create all viable paths and their values * Create all viable paths and their values
* *
* @param array $arr Array * @param array<string, string> $arr Array
* @param string $path Current path * @param string $path Current path
* *
* @return array * @return array<string, string>
* *
* @since 1.0.0 * @since 1.0.0
*/ */
@ -101,8 +101,8 @@ abstract class Json extends ValidatorAbstract
/** /**
* Check if source array has additional elements. * Check if source array has additional elements.
* *
* @param array $template Template structure * @param array<string, string> $template Template structure
* @param array $source Source structure * @param array<string, string> $source Source structure
* *
* @return bool Returns false in case of undefined elements * @return bool Returns false in case of undefined elements
* *
@ -116,10 +116,10 @@ abstract class Json extends ValidatorAbstract
$completePaths[$key] = $value; $completePaths[$key] = $value;
} }
foreach ($source as $sPath => $sValue) { foreach ($source as $sPath => $_) {
$hasDefinition = false; $hasDefinition = false;
foreach ($completePaths as $tPath => $tValue) { foreach ($completePaths as $tPath => $_2) {
if ($tPath === $sPath if ($tPath === $sPath
|| \preg_match('~' . \str_replace('/', '\\/', $tPath) . '~', $sPath) === 1 || \preg_match('~' . \str_replace('/', '\\/', $tPath) . '~', $sPath) === 1
) { ) {
@ -139,8 +139,8 @@ abstract class Json extends ValidatorAbstract
/** /**
* Check if source array is complete * Check if source array is complete
* *
* @param array $template Template structure * @param array<string, string> $template Template structure
* @param array $source Source structure * @param array<string, string> $source Source structure
* *
* @return bool Returns true if the source implements all required elements otherwise false is returned * @return bool Returns true if the source implements all required elements otherwise false is returned
* *
@ -176,8 +176,8 @@ abstract class Json extends ValidatorAbstract
/** /**
* Check if source array is correct * Check if source array is correct
* *
* @param array $template Template structure * @param array<string, string> $template Template structure
* @param array $source Source structure * @param array<string, string> $source Source structure
* *
* @return bool Returns true if the source is correct in relation to the template otherwise false is returned * @return bool Returns true if the source is correct in relation to the template otherwise false is returned
* *

View File

@ -27,16 +27,7 @@ use phpOMS\Utils\StringUtils;
final class Validator extends ValidatorAbstract final class Validator extends ValidatorAbstract
{ {
/** /**
* Validate variable based on multiple factors. * {@inheritdoc}
*
* @param mixed $var Variable to validate
* @param array $constraints Constraints for validation
*
* @return bool
*
* @throws \BadFunctionCallException this exception is thrown if the callback is not callable
*
* @since 1.0.0
*/ */
public static function isValid(mixed $var, ?array $constraints = null) : bool public static function isValid(mixed $var, ?array $constraints = null) : bool
{ {
@ -108,8 +99,8 @@ final class Validator extends ValidatorAbstract
/** /**
* Validate variable by substring. * Validate variable by substring.
* *
* @param string $var Variable to validate * @param string $var Variable to validate
* @param array|string $substr Substring * @param string|string[] $substr Substring
* *
* @return bool * @return bool
* *

View File

@ -27,8 +27,8 @@ interface ValidatorInterface
/** /**
* Check if value is valid. * Check if value is valid.
* *
* @param mixed $value Value to validate * @param mixed $value Value to validate
* @param null|array $constraints Constraints for validation * @param null|array<string, mixed[]> $constraints Constraints for validation
* *
* @return bool * @return bool
* *

View File

@ -385,8 +385,8 @@ class View extends ViewAbstract
/** /**
* Render user name based on format * Render user name based on format
* *
* @param string $format Format used in printf * @param string $format Format used in printf
* @param array $names Names to render according to the format * @param string[] $names Names to render according to the format
* *
* @return string * @return string
* *

View File

@ -232,7 +232,7 @@ abstract class ViewAbstract implements RenderableInterface
/** /**
* Arrayify view and it's sub-views. * Arrayify view and it's sub-views.
* *
* @return array * @return array<int|string, string|array<mixed>>
* *
* @since 1.0.0 * @since 1.0.0
*/ */

View File

@ -10,7 +10,7 @@
"require-dev": { "require-dev": {
"phpunit/phpunit": ">=11.0", "phpunit/phpunit": ">=11.0",
"friendsofphp/php-cs-fixer": ">=3.51", "friendsofphp/php-cs-fixer": ">=3.51",
"squizlabs/php_codesniffer": ">=3.7", "phpcsstandards/php_codesniffer": ">=3.7",
"phpmd/phpmd": ">=2.9", "phpmd/phpmd": ">=2.9",
"phpstan/phpstan": ">=1.10.62", "phpstan/phpstan": ">=1.10.62",
"phan/phan": ">=3.2.6", "phan/phan": ">=3.2.6",

1118
composer.lock generated

File diff suppressed because it is too large Load Diff