Release Psalm 3.12, a static analyzer for the PHP language. Alpha release of PHP 8.0

Vimeo Company released new release of the static analyzer Psalm 3.12, which allows for the detection of both obvious and hard-to-find errors in PHP code, as well as automatically fixing certain types of errors. The system is suitable for identifying issues in both outdated code and code utilizing modern features introduced in new PHP branches. The project code is written in PHP and is distributed is licensed under the MIT License.

Psalm identifies most issues associated with incorrect type usage, as well as various common errors. For instance, it supports the output of warnings about mixing variables of different types in expressions, incorrect logical checks (such as "if ($a && $a) {}", "if ($a && !$a) {}" and "if ($a) {} elseif ($a) {}"), and incomplete initialization of object properties. The analyzer runs in multi-threaded mode. Incremental checks are possible, analyzing only the files that have changed since the last check.

Additionally, tools for safe programming are provided, allowing to use annotations in the Docblock format ("/** @var Type */") to provide information about variable types, return values, function parameters, and object properties. It also supports defining patterns for type usage and applying assert expressions. For example:

/** @var string|null */
$a = foo();

/** @var string $a */
echo strpos($a, 'hello');

/** @psalm-assert-if-true B $a */
function isValidB(A $a) : bool {
return $a instanceof B && $a->isValid();
}

To automate the resolution of identified issues, a utility called Psalter is provided, which supports plugins and , rather than taking focus. resolves typical problems in the code, adds type annotations, and performs operations such as moving classes from one namespace to another, moving methods between classes, renaming classes and methods.

In the new release of Psalm within the option «—taint-analysis», which allows tracking the connection between user-provided input parameters (for example, $_GET['name']) and their usage in places that require character escaping (for instance, echo «<h1>$name</h1>»), including through tracking chains of intermediate assignments and function calls. Sources of potentially dangerous data include the use of associative arrays $_GET, $_POST, and $_COOKIE, but it is also possible to definition own sources. The actions requiring escape tracking include output operations that generate content in HTML format, adding HTTP headers, or executing SQL queries.

The check is applied when using functions such as echo, exec, include, and header. When analyzing the need for escaping, data types such as text, SQL strings, HTML, and Shell code, as well as strings with authentication parameters, are taken into account. The proposed mode allows for detecting vulnerabilities in code that lead to cross-site scripting (XSS) or SQL injection.

Additionally, it can be noted the beginning alpha testing of the new PHP 8.0 branch. The release is scheduled for November 26. The new branch is expected to feature innovations, such as:

Source: opennet.ru

Buy reliable website hosting with DDoS protection, VPS VDS servers 🔥 Buy reliable website hosting with DDoS protection, VPS VDS servers | ProHoster