Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
danog committed Oct 19, 2023
1 parent 34b4272 commit f3c6193
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ public static function analyze(
$context->vars_in_scope[$var_id] = $comment_type ?? Type::getMixed();
}

return false;
return null;
}

$context->inside_general_use = $was_inside_general_use;
Expand Down Expand Up @@ -480,7 +480,7 @@ public static function analyze(
),
$statements_analyzer->getSuppressedIssues(),
)) {
return false;
return null;
}

if (isset($context->protected_var_ids[$var_id])
Expand All @@ -507,9 +507,9 @@ public static function analyze(
$extended_var_id,
$var_comments,
$removed_taints,
) === false
) === null
) {
return false;
return null;
}

if ($var_id && isset($context->vars_in_scope[$var_id])) {
Expand Down Expand Up @@ -537,7 +537,7 @@ public static function analyze(
),
$statements_analyzer->getSuppressedIssues(),
)) {
return false;
return null;
}

$context->vars_in_scope[$var_id] = Type::getNever();
Expand Down Expand Up @@ -670,7 +670,7 @@ private static function analyzeAssignment(
$assign_var->class instanceof PhpParser\Node\Name
) {
if (ExpressionAnalyzer::analyze($statements_analyzer, $assign_var, $context) === false) {
return false;
return null;
}

if ($context->check_classes) {
Expand All @@ -681,7 +681,7 @@ private static function analyzeAssignment(
$assign_value_type,
$context,
) === null) {
return false;
return null;
}
}

Expand Down
50 changes: 29 additions & 21 deletions src/Psalm/Internal/Fork/PsalmRestarter.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use function implode;
use function in_array;
use function ini_get;
use function is_int;
use function preg_replace;
use function strlen;
use function strtolower;
Expand All @@ -26,9 +27,22 @@
final class PsalmRestarter extends XdebugHandler
{
private const REQUIRED_OPCACHE_SETTINGS = [
'enable_cli' => true,
'jit' => 1205,
'enable_cli' => 1,
'jit' => 1254,
'validate_timestamps' => 0,
'file_update_protection' => 0,
'jit_buffer_size' => 512 * 1024 * 1024,
'max_accelerated_files' => 1000000,
'interned_strings_buffer' => 64,
'jit_max_root_traces' => 30000000,
'jit_max_side_traces' => 30000000,
'jit_max_exit_counters' => 30000000,
'jit_hot_loop' => 1,
'jit_hot_func' => 1,
'jit_hot_return' => 1,
'jit_hot_side_exit' => 1,
'jit_blacklist_root_trace' => 255,
'jit_blacklist_side_trace' => 255,
'optimization_level' => '0x7FFEBFFF',
'preload' => '',
'log_verbosity_level' => 0,
Expand Down Expand Up @@ -69,17 +83,16 @@ protected function requiresRestart($default): bool

if ($opcache_loaded) {
// restart to enable JIT if it's not configured in the optimal way
$opcache_settings = [
'enable_cli' => in_array(ini_get('opcache.enable_cli'), ['1', 'true', true, 1]),
'jit' => (int) ini_get('opcache.jit'),
'log_verbosity_level' => (int) ini_get('opcache.log_verbosity_level'),
'optimization_level' => (string) ini_get('opcache.optimization_level'),
'preload' => (string) ini_get('opcache.preload'),
'jit_buffer_size' => self::toBytes((string) ini_get('opcache.jit_buffer_size')),
];

foreach (self::REQUIRED_OPCACHE_SETTINGS as $ini_name => $required_value) {
if ($opcache_settings[$ini_name] !== $required_value) {
$value = (string) ini_get("opcache.$ini_name");
if ($ini_name === 'jit_buffer_size') {
$value = self::toBytes($value);
} elseif ($ini_name === 'enable_cli') {
$value = in_array($value, ['1', 'true', true, 1]);
} elseif (is_int($required_value)) {
$required_value = (int) $required_value;
}
if ($value !== $required_value) {
return true;
}
}
Expand Down Expand Up @@ -142,16 +155,11 @@ protected function restart($command): void
// executed in the parent process (before restart)
// if it wasn't loaded then we apparently don't have opcache installed and there's no point trying
// to tweak it
// If we're running on 7.4 there's no JIT available
if ($opcache_loaded) {
$additional_options = [
'-dopcache.enable_cli=true',
'-dopcache.jit_buffer_size=512M',
'-dopcache.jit=tracing',
'-dopcache.optimization_level=0x7FFEBFFF',
'-dopcache.preload=',
'-dopcache.log_verbosity_level=0',
];
$additional_options = [];
foreach (self::REQUIRED_OPCACHE_SETTINGS as $key => $value) {
$additional_options []= "-dopcache.{$key}={$value}";
}
}

array_splice(
Expand Down

0 comments on commit f3c6193

Please sign in to comment.