function SubversionPropertiesSniff::getProperties
Returns the Subversion properties which are actually set on a path.
Returns NULL if the file is not under version control.
Parameters
string $path The path to return Subversion properties on.:
Return value
array|null
Throws
\PHP_CodeSniffer\Exceptions\RuntimeException If Subversion properties file could not be opened.
1 call to SubversionPropertiesSniff::getProperties()
- SubversionPropertiesSniff::process in vendor/
squizlabs/ php_codesniffer/ src/ Standards/ Generic/ Sniffs/ VersionControl/ SubversionPropertiesSniff.php - Processes this test, when one of its tokens is encountered.
File
-
vendor/
squizlabs/ php_codesniffer/ src/ Standards/ Generic/ Sniffs/ VersionControl/ SubversionPropertiesSniff.php, line 120
Class
Namespace
PHP_CodeSniffer\Standards\Generic\Sniffs\VersionControlCode
protected function getProperties($path) {
$properties = [];
$paths = [];
$paths[] = dirname($path) . '/.svn/props/' . basename($path) . '.svn-work';
$paths[] = dirname($path) . '/.svn/prop-base/' . basename($path) . '.svn-base';
$foundPath = false;
foreach ($paths as $path) {
if (file_exists($path) === true) {
$foundPath = true;
$handle = fopen($path, 'r');
if ($handle === false) {
$error = 'Error opening file; could not get Subversion properties';
throw new RuntimeException($error);
}
while (feof($handle) === false) {
// Read a key length line. Might be END, though.
$buffer = trim(fgets($handle));
// Check for the end of the hash.
if ($buffer === 'END') {
break;
}
// Now read that much into a buffer.
$key = fread($handle, substr($buffer, 2));
// Suck up extra newline after key data.
fgetc($handle);
// Read a value length line.
$buffer = trim(fgets($handle));
// Now read that much into a buffer.
$length = substr($buffer, 2);
if ($length === '0') {
// Length of value is ZERO characters, so
// value is actually empty.
$value = '';
}
else {
$value = fread($handle, $length);
}
// Suck up extra newline after value data.
fgetc($handle);
$properties[$key] = $value;
}
//end while
fclose($handle);
}
//end if
}
//end foreach
if ($foundPath === false) {
return null;
}
return $properties;
}