127) { return true; } } return false; } /** * Check if function is disabled * * @param string[] $functions Functions to check * * @return bool Returns true if code has disabled function calls otherwise false is returned * * @since 1.0.0 */ public static function isDisabled(array $functions) : bool { $disabled = \ini_get('disable_functions'); if ($disabled === false) { return true; // @codeCoverageIgnore } $disabled = \str_replace(' ', '', $disabled); $disabled = \explode(',', $disabled); foreach ($functions as $function) { if (!\in_array($function, $disabled)) { return false; } } return true; // @codeCoverageIgnore } /** * Check if has deprecated functions * * @param string $source Source code * * @return bool Returns true if code contains deprecated functions otherwise false is returned * * @since 1.0.0 */ public static function hasDeprecatedFunction(string $source) : bool { foreach (self::$deprecatedFunctions as $function) { if (\preg_match('/' . $function . '\s*\(/', $source) === 1) { return true; } } return false; } /** * Validate file integrety * * @param string $source Source code path * @param string $hash Source hash (md5) * * @return bool Returns true if filee matches expected signature otherwise false is returned * * @since 1.0.0 */ public static function validateFileIntegrity(string $source, string $hash) : bool { return \md5_file($source) === $hash; } /** * Validate code integrety * * @param string $source Source code * @param string $remote Remote code * * @return bool Returns true if source code is the same as the expected code otherwise false is returned * * @since 1.0.0 */ public static function validateStringIntegrity(string $source, string $remote) : bool { return $source === $remote; } }