Skip to content

Commit

Permalink
Add method to detect difference between current and configuration set…
Browse files Browse the repository at this point in the history
  • Loading branch information
krakjoe committed Apr 22, 2019
1 parent dbf7b0d commit 61420aa
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/Runtime.php
Expand Up @@ -218,4 +218,34 @@ public function hasPCOV(): bool
{
return $this->isPHP() && \extension_loaded('pcov') && \ini_get('pcov.enabled');
}

/*
* Returns the current settings for the given set of php configuration values
*/
public function getCurrentSettings(array $values) : array {
$diff = [];
$files = [];

if (($file = \php_ini_loaded_file())) {
$files[] = $file;
}

if ($scanned = \php_ini_scanned_files()) {
$files = \array_merge($files, $scanned);
}

foreach ($files as $ini) {
$config = \parse_ini_file($ini, true);

foreach ($values as $value) {
$set = \ini_get($value);

if (isset($config[$value]) && $set != $config[$value]) {
$diff[] = sprintf("%s=%s", $value, $set);
}
}
}

return $diff;
}
}

0 comments on commit 61420aa

Please sign in to comment.