Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ jobs:
- php: '8.4'
skip_tests: true

# Run a couple of builds with custom extensions to allow for testing ini handling within PHPCS.
# Ref: https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/416
- php: '7.3'
os: 'ubuntu-latest'
extensions: ':mysqli' # Run with mysqli disabled.
- php: '8.2'
os: 'ubuntu-latest'
extensions: ':mysqli' # Run with mysqli disabled.

# The default libxml library on Ubuntu images is a little out of date.
# To safeguard support for the latest libxml we need to update the library on the fly.
# This only needs to be tested with one PHP version for each libxml minor to verify support.
Expand Down Expand Up @@ -183,6 +192,7 @@ jobs:
with:
php-version: ${{ matrix.php }}
ini-values: ${{ steps.set_ini.outputs.PHP_INI }}
extensions: ${{ matrix.extensions }}
coverage: none
tools: cs2pr

Expand Down Expand Up @@ -269,10 +279,12 @@ jobs:
custom_ini: [false]

include:
# Also run one coverage build with custom ini settings.
# Also run one coverage build with custom ini settings for testing the DisallowShortOpenTag sniff.
# Also run with a disabled extension for testing the handling of unsettable ini settings by PHPCS.
- php: '8.1'
os: 'ubuntu-latest'
custom_ini: true
extensions: ':mysqli' # Run with mysqli disabled.

# yamllint disable-line rule:line-length
name: "Coverage: ${{ matrix.php }} ${{ matrix.custom_ini && ' with custom ini settings' || '' }} (${{ matrix.os == 'ubuntu-latest' && 'Linux' || 'Win' }})"
Expand All @@ -297,6 +309,7 @@ jobs:
with:
php-version: ${{ matrix.php }}
ini-values: error_reporting=-1, display_errors=On${{ steps.set_ini.outputs.PHP_INI }}
extensions: ${{ matrix.extensions }}
coverage: xdebug

# Install dependencies and handle caching in one go.
Expand Down
21 changes: 17 additions & 4 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -739,10 +739,23 @@ public function processShortArgument($arg, $pos)
case 'd' :
$ini = explode('=', $this->cliArgs[($pos + 1)]);
$this->cliArgs[($pos + 1)] = '';
if (isset($ini[1]) === true) {
ini_set($ini[0], $ini[1]);
} else {
ini_set($ini[0], true);
if (isset($ini[1]) === false) {
// Set to true.
$ini[1] = '1';
}

$current = ini_get($ini[0]);
if ($current === false) {
// Ini setting which doesn't exist, or is from an unavailable extension.
// Silently ignore it.
break;
}

$changed = ini_set($ini[0], $ini[1]);
if ($changed === false && ini_get($ini[0]) !== $ini[1]) {
$error = sprintf('ERROR: Ini option "%s" cannot be changed at runtime.', $ini[0]).PHP_EOL;
$error .= $this->printShortUsage(true);
throw new DeepExitException($error, 3);
}
break;
case 'n' :
Expand Down
Loading