namespace Adminer;
class Plugins {
+ /** @var true[] */ private static array $append = array('dumpFormat' => true, 'dumpOutput' => true, 'editRowPrint' => true, 'editFunctions' => true); // these hooks expect the value to be appended to the result
+
/** @var list<object> @visibility protected(set) */ public array $plugins;
/** @visibility protected(set) */ public string $error = ''; // HTML
- public $operators; //! delete
- private $hooks = array();
- private $append;
+ /** @var ?list<string> */ public ?array $operators; //! delete
+ /** @var list<object>[] */ private array $hooks = array();
/** Register plugins
* @param ?list<object> $plugins object instances or null to autoload plugins from adminer-plugins/
}
}
$this->plugins = $plugins;
- $this->append = array_flip(array('dumpFormat', 'dumpOutput', 'editRowPrint', 'editFunctions')); // these hooks expect the value to be appended to the result
$adminer = new Adminer;
$plugins[] = $adminer;
}
}
- function __call($name, $params) {
+ /**
+ * @param literal-string $name
+ * @param mixed[] $params
+ * @return mixed
+ */
+ function __call($name, array $params) {
$args = array();
foreach ($params as $key => $val) {
// some plugins accept params by reference - we don't need to propage it outside, just to the other plugins
foreach ($this->hooks[$name] as $plugin) {
$value = call_user_func_array(array($plugin, $name), $args);
if ($value !== null) {
- if (!isset($this->append[$name])) { // non-null value from non-appending method short-circuits the other plugins
+ if (!self::$append[$name]) { // non-null value from non-appending method short-circuits the other plugins
return $value;
}
$return = $value + (array) $return;
- "~^Function (set_magic_quotes_runtime|mysql_)~" # PHP < 7 functions
- "~an unknown class OCI-?Lob~" # this looks like PHPStan bug
- "~^Variable \\$(adminer|connection|driver|drivers|error|HTTPS|LANG|langs|permanent|has_token|token|translations|VERSION) might not be defined~" # declared in bootstrap.inc.php
- - "~^Method Adminer\\\\Plugins::\\w+\\(\\) with return type void~" # we use the same pattern for all methods
- "~expects int, float given~" # this will work
- "~expects bool~" # truthy values
- "~fread expects int<1, max>, 100000~" # 1e6
- identifier: booleanAnd.leftAlwaysTrue
- identifier: booleanAnd.rightAlwaysTrue
- identifier: booleanAnd.rightAlwaysFalse
- - identifier: booleanOr.alwaysTrue
- - identifier: booleanOr.leftAlwaysTrue
- identifier: ternary.alwaysTrue
- identifier: if.alwaysTrue
- identifier: while.alwaysTrue