1
0
mirror of https://github.com/owncloudarchive/contacts.git synced 2024-12-01 13:24:10 +01:00

Scrutinizer fixes

This commit is contained in:
Thomas Tanghus 2014-03-17 23:48:16 +01:00
parent 1724c872ef
commit d7d8d3e998
3 changed files with 22 additions and 20 deletions

View File

@ -47,6 +47,8 @@ class Plugin extends \Sabre_CardDAV_Plugin {
// If it's a stream, we convert it to a string first.
if (is_resource($data)) {
$data = stream_get_contents($data);
} elseif (!is_string($data)) {
throw new \Exception(__METHOD__ . ' argument 1 only supports string or stream resource.');
}
try {

View File

@ -20,32 +20,32 @@ class UUID {
* @see http://en.wikipedia.org/wiki/UUID
* @return string A UUID, made up of 32 hex digits and 4 hyphens.
*/
function get() {
public function get() {
$pr_bits = false;
$prBits = false;
if (is_a($this, 'uuid')) {
if (is_resource($this->urand)) {
$pr_bits .= @fread($this->urand, 16);
$prBits .= @fread($this->urand, 16);
}
}
if (!$pr_bits) {
if (!$prBits) {
$fp = @fopen('/dev/urandom', 'rb');
if ($fp !== false) {
$pr_bits .= @fread($fp, 16);
$prBits .= @fread($fp, 16);
@fclose ( $fp );
} else {
// If /dev/urandom isn't available (eg: in non-unix systems), use mt_rand().
$pr_bits = "";
$prBits = "";
for($cnt = 0; $cnt < 16; $cnt ++) {
$pr_bits .= chr(mt_rand(0, 255));
$prBits .= chr(mt_rand(0, 255));
}
}
}
$time_low = bin2hex(substr($pr_bits, 0, 4));
$time_mid = bin2hex(substr($pr_bits, 4, 2));
$time_hi_and_version = bin2hex(substr($pr_bits, 6, 2));
$clock_seq_hi_and_reserved = bin2hex(substr($pr_bits, 8, 2));
$node = bin2hex(substr($pr_bits, 10, 6));
$timeLow = bin2hex(substr($prBits, 0, 4));
$timeMid = bin2hex(substr($prBits, 4, 2));
$timeHiAndVersion = bin2hex(substr($prBits, 6, 2));
$clockSeqHiAndReserved = bin2hex(substr($prBits, 8, 2));
$node = bin2hex(substr($prBits, 10, 6));
/**
* Set the four most significant bits (bits 12 through 15) of the
@ -53,19 +53,19 @@ class UUID {
* Section 4.1.3.
* @see http://tools.ietf.org/html/rfc4122#section-4.1.3
*/
$time_hi_and_version = hexdec($time_hi_and_version);
$time_hi_and_version = $time_hi_and_version >> 4;
$time_hi_and_version = $time_hi_and_version | 0x4000;
$timeHiAndVersion = hexdec($timeHiAndVersion);
$timeHiAndVersion = $timeHiAndVersion >> 4;
$timeHiAndVersion = $timeHiAndVersion | 0x4000;
/**
* Set the two most significant bits (bits 6 and 7) of the
* clock_seq_hi_and_reserved to zero and one, respectively.
*/
$clock_seq_hi_and_reserved = hexdec($clock_seq_hi_and_reserved);
$clock_seq_hi_and_reserved = $clock_seq_hi_and_reserved >> 2;
$clock_seq_hi_and_reserved = $clock_seq_hi_and_reserved | 0x8000;
$clockSeqHiAndReserved = hexdec($clockSeqHiAndReserved);
$clockSeqHiAndReserved = $clockSeqHiAndReserved >> 2;
$clockSeqHiAndReserved = $clockSeqHiAndReserved | 0x8000;
return sprintf('%08s-%04s-%04x-%04x-%012s', $time_low, $time_mid, $time_hi_and_version, $clock_seq_hi_and_reserved, $node);
return sprintf('%08s-%04s-%04x-%04x-%012s', $timeLow, $timeMid, $timeHiAndVersion, $clockSeqHiAndReserved, $node);
}
}

View File

@ -145,7 +145,7 @@ class VCard extends VObject\Component\VCard {
* Work around issue in older VObject sersions
* https://github.com/fruux/sabre-vobject/issues/24
*
* @param Sabre_VObject_Property $property Reference to a Sabre_VObject_Property.
* @param \Sabre\VObject\Property $property Reference to a \Sabre\VObject\Property.
*/
public function fixPropertyParameters(&$property) {
// Work around issue in older VObject sersions