mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-03 22:32:40 +08:00
Fixes for issues found with Static Code Analysis with Php Inspections (EA Extended) (#13606)
* Php Inspections (EA Extended): language level migration fixes * Php Inspections (EA Extended): instanceof a trait always return false * Php Inspections (EA Extended): fixed preg_quote (/ is not escaped by default) * Php Inspections (EA Extended): fixed a greedy regex * Php Inspections (EA Extended): refereted instanceof self in a trait * Php Inspections (EA Extended): revert language level changes in requirements checker * Php Inspections (EA Extended): revert language level changes in requirements checker * Php Inspections (EA Extended): more greedy regexes fixed
This commit is contained in:
committed by
Alexander Makarov
parent
2de18cf9a5
commit
a182ce57fc
@ -172,7 +172,7 @@ class PhpDocController extends Controller
|
|||||||
$except[] = "/extensions/$ext$path";
|
$except[] = "/extensions/$ext$path";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} elseif (preg_match('~extensions/([\w\d-]+)[\\\\/]?$~', $root, $matches)) {
|
} elseif (preg_match('~extensions/([\w-]+)[\\\\/]?$~', $root, $matches)) {
|
||||||
|
|
||||||
$extensionPath = dirname(rtrim($root, '\\/'));
|
$extensionPath = dirname(rtrim($root, '\\/'));
|
||||||
$this->setUpExtensionAliases($extensionPath);
|
$this->setUpExtensionAliases($extensionPath);
|
||||||
@ -196,7 +196,7 @@ class PhpDocController extends Controller
|
|||||||
// if ($extension === 'composer') {
|
// if ($extension === 'composer') {
|
||||||
// return [];
|
// return [];
|
||||||
// }
|
// }
|
||||||
} elseif (preg_match('~apps/([\w\d-]+)[\\\\/]?$~', $root, $matches)) {
|
} elseif (preg_match('~apps/([\w-]+)[\\\\/]?$~', $root, $matches)) {
|
||||||
|
|
||||||
$extensionPath = dirname(dirname(rtrim($root, '\\/'))) . '/extensions';
|
$extensionPath = dirname(dirname(rtrim($root, '\\/'))) . '/extensions';
|
||||||
$this->setUpExtensionAliases($extensionPath);
|
$this->setUpExtensionAliases($extensionPath);
|
||||||
|
|||||||
@ -188,7 +188,7 @@ class QueryBuilder extends \yii\db\QueryBuilder
|
|||||||
public function checkIntegrity($check = true, $schema = '', $table = '')
|
public function checkIntegrity($check = true, $schema = '', $table = '')
|
||||||
{
|
{
|
||||||
$enable = $check ? 'ENABLE' : 'DISABLE';
|
$enable = $check ? 'ENABLE' : 'DISABLE';
|
||||||
$schema = $schema ? $schema : $this->db->getSchema()->defaultSchema;
|
$schema = $schema ?: $this->db->getSchema()->defaultSchema;
|
||||||
$tableNames = $table ? [$table] : $this->db->getSchema()->getTableNames($schema);
|
$tableNames = $table ? [$table] : $this->db->getSchema()->getTableNames($schema);
|
||||||
$viewNames = $this->db->getSchema()->getViewNames($schema);
|
$viewNames = $this->db->getSchema()->getViewNames($schema);
|
||||||
$tableNames = array_diff($tableNames, $viewNames);
|
$tableNames = array_diff($tableNames, $viewNames);
|
||||||
|
|||||||
@ -109,7 +109,7 @@ class I18N extends Component
|
|||||||
return $message;
|
return $message;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preg_match('~{\s*[\d\w]+\s*,~u', $message)) {
|
if (preg_match('~{\s*[\w]+\s*,~u', $message)) {
|
||||||
$formatter = $this->getMessageFormatter();
|
$formatter = $this->getMessageFormatter();
|
||||||
$result = $formatter->format($message, $params, $language);
|
$result = $formatter->format($message, $params, $language);
|
||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
|
|||||||
@ -480,7 +480,7 @@ class DbManager extends BaseManager
|
|||||||
{
|
{
|
||||||
$role = $this->getRole($roleName);
|
$role = $this->getRole($roleName);
|
||||||
|
|
||||||
if (is_null($role)) {
|
if ($role === null) {
|
||||||
throw new InvalidParamException("Role \"$roleName\" not found.");
|
throw new InvalidParamException("Role \"$roleName\" not found.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -410,7 +410,7 @@ class PhpManager extends BaseManager
|
|||||||
{
|
{
|
||||||
$role = $this->getRole($roleName);
|
$role = $this->getRole($roleName);
|
||||||
|
|
||||||
if (is_null($role)) {
|
if ($role === null) {
|
||||||
throw new InvalidParamException("Role \"$roleName\" not found.");
|
throw new InvalidParamException("Role \"$roleName\" not found.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -527,7 +527,7 @@ class IpValidator extends Validator
|
|||||||
*/
|
*/
|
||||||
private function getIpParsePattern()
|
private function getIpParsePattern()
|
||||||
{
|
{
|
||||||
return '/^(' . preg_quote(static::NEGATION_CHAR) . '?)(.+?)(\/(\d+))?$/';
|
return '/^(' . preg_quote(static::NEGATION_CHAR, '/') . '?)(.+?)(\/(\d+))?$/';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -132,7 +132,7 @@ class MultipartFormDataParser extends Object implements RequestParserInterface
|
|||||||
}
|
}
|
||||||
$boundary = $matches[1];
|
$boundary = $matches[1];
|
||||||
|
|
||||||
$bodyParts = preg_split('/\\R?-+' . preg_quote($boundary) . '/s', $rawBody);
|
$bodyParts = preg_split('/\\R?-+' . preg_quote($boundary, '/') . '/s', $rawBody);
|
||||||
array_pop($bodyParts); // last block always has no data, contains boundary ending like `--`
|
array_pop($bodyParts); // last block always has no data, contains boundary ending like `--`
|
||||||
|
|
||||||
$bodyParams = [];
|
$bodyParams = [];
|
||||||
|
|||||||
Reference in New Issue
Block a user