function Config::__get
Get the value of an inaccessible property.
Parameters
string $name The name of the property.:
Return value
mixed
Throws
\PHP_CodeSniffer\Exceptions\RuntimeException If the setting name is invalid.
File
-
vendor/
squizlabs/ php_codesniffer/ src/ Config.php, line 210
Class
- Config
- Stores the configuration used to run PHPCS and PHPCBF.
Namespace
PHP_CodeSnifferCode
public function __get($name) {
if (array_key_exists($name, $this->settings) === false) {
throw new RuntimeException("ERROR: unable to get value of property \"{$name}\"");
}
// Figure out what the terminal width needs to be for "auto".
if ($name === 'reportWidth' && $this->settings[$name] === 'auto') {
if (function_exists('shell_exec') === true) {
$dimensions = shell_exec('stty size 2>&1');
if (is_string($dimensions) === true && preg_match('|\\d+ (\\d+)|', $dimensions, $matches) === 1) {
$this->settings[$name] = (int) $matches[1];
}
}
if ($this->settings[$name] === 'auto') {
// If shell_exec wasn't available or didn't yield a usable value, set to the default.
// This will prevent subsequent retrievals of the reportWidth from making another call to stty.
$this->settings[$name] = self::DEFAULT_REPORT_WIDTH;
}
}
return $this->settings[$name];
}