"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/Validation/Validation.php" between
cakephp-4.2.2.tar.gz and cakephp-4.2.3.tar.gz

About: CakePHP is a rapid development framework for PHP applications. Source code.

Validation.php  (cakephp-4.2.2):Validation.php  (cakephp-4.2.3)
skipping to change at line 458 skipping to change at line 458
/** /**
* Used when a custom regular expression is needed. * Used when a custom regular expression is needed.
* *
* @param mixed $check The value to check. * @param mixed $check The value to check.
* @param string|null $regex If $check is passed as a string, $regex must al so be set to valid regular expression * @param string|null $regex If $check is passed as a string, $regex must al so be set to valid regular expression
* @return bool Success * @return bool Success
*/ */
public static function custom($check, ?string $regex = null): bool public static function custom($check, ?string $regex = null): bool
{ {
if (!is_string($check)) { if (!is_scalar($check)) {
return false; return false;
} }
if ($regex === null) { if ($regex === null) {
static::$errors[] = 'You must define a regular expression for Valida tion::custom()'; static::$errors[] = 'You must define a regular expression for Valida tion::custom()';
return false; return false;
} }
return static::_check($check, $regex); return static::_check($check, $regex);
} }
/** /**
skipping to change at line 1268 skipping to change at line 1267
$mimeTypes[$key] = strtolower($val); $mimeTypes[$key] = strtolower($val);
} }
return in_array(strtolower($mime), $mimeTypes, true); return in_array(strtolower($mime), $mimeTypes, true);
} }
/** /**
* Helper for reading the file out of the various file implementations * Helper for reading the file out of the various file implementations
* we accept. * we accept.
* *
* @param string|array|\Psr\Http\Message\UploadedFileInterface $check The da ta to read a filename out of. * @param mixed $check The data to read a filename out of.
* @return string|false Either the filename or false on failure. * @return string|false Either the filename or false on failure.
*/ */
protected static function getFilename($check) protected static function getFilename($check)
{ {
if ($check instanceof UploadedFileInterface) { if ($check instanceof UploadedFileInterface) {
// Uploaded files throw exceptions on upload errors. // Uploaded files throw exceptions on upload errors.
try { try {
$uri = $check->getStream()->getMetadata('uri'); $uri = $check->getStream()->getMetadata('uri');
if (is_string($uri)) { if (is_string($uri)) {
return $uri; return $uri;
skipping to change at line 1466 skipping to change at line 1465
if ($validWidth !== null) { if ($validWidth !== null) {
return $validWidth; return $validWidth;
} }
throw new InvalidArgumentException('The 2nd argument is missing the `wid th` and / or `height` options.'); throw new InvalidArgumentException('The 2nd argument is missing the `wid th` and / or `height` options.');
} }
/** /**
* Validates the image width. * Validates the image width.
* *
* @param array $file The uploaded file data from PHP. * @param mixed $file The uploaded file data from PHP.
* @param string $operator Comparison operator. * @param string $operator Comparison operator.
* @param int $width Min or max width. * @param int $width Min or max width.
* @return bool * @return bool
*/ */
public static function imageWidth(array $file, string $operator, int $width) : bool public static function imageWidth($file, string $operator, int $width): bool
{ {
return self::imageSize($file, [ return self::imageSize($file, [
'width' => [ 'width' => [
$operator, $operator,
$width, $width,
], ],
]); ]);
} }
/** /**
* Validates the image width. * Validates the image width.
* *
* @param array $file The uploaded file data from PHP. * @param mixed $file The uploaded file data from PHP.
* @param string $operator Comparison operator. * @param string $operator Comparison operator.
* @param int $height Min or max width. * @param int $height Min or max width.
* @return bool * @return bool
*/ */
public static function imageHeight(array $file, string $operator, int $heigh t): bool public static function imageHeight($file, string $operator, int $height): bo ol
{ {
return self::imageSize($file, [ return self::imageSize($file, [
'height' => [ 'height' => [
$operator, $operator,
$height, $height,
], ],
]); ]);
} }
/** /**
 End of changes. 7 change blocks. 
7 lines changed or deleted 6 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)