From 90fd1531d00338660f66bebfaa2fd23f39f4a8d8 Mon Sep 17 00:00:00 2001 From: Ben Ramsey Date: Sat, 8 Nov 2014 14:53:12 -0500 Subject: [PATCH] Fixing PSR2 standards violations reported by PHP_CodeSniffer --- composer.json | 1 + phpcs.xml | 15 +++++++++++++++ src/Console/Command/DecodeCommand.php | 3 +-- src/Console/Command/GenerateCommand.php | 6 ++++-- src/Converter/NumberConverterInterface.php | 2 +- src/DegradedUuid.php | 9 +++++---- src/FeatureSet.php | 11 +++++++---- src/RandomGenerator.php | 2 +- src/Uuid.php | 3 ++- src/UuidInterface.php | 1 - 10 files changed, 37 insertions(+), 16 deletions(-) create mode 100644 phpcs.xml diff --git a/composer.json b/composer.json index 41c32a4..b57eaf8 100644 --- a/composer.json +++ b/composer.json @@ -27,6 +27,7 @@ "symfony/console": "~2.3", "doctrine/dbal": ">=2.3", "phpunit/phpunit": "~4.1", + "squizlabs/php_codesniffer": "2.0.0RC4", "satooshi/php-coveralls": "~0.6" }, "bin": ["bin/uuid"], diff --git a/phpcs.xml b/phpcs.xml new file mode 100644 index 0000000..6aa2b59 --- /dev/null +++ b/phpcs.xml @@ -0,0 +1,15 @@ + + + + Coding standard rules for Rhumsaa\Uuid + + */build/* + */tests/* + */vendor/* + + + + + + + diff --git a/src/Console/Command/DecodeCommand.php b/src/Console/Command/DecodeCommand.php index e557310..f1ed843 100644 --- a/src/Console/Command/DecodeCommand.php +++ b/src/Console/Command/DecodeCommand.php @@ -66,8 +66,7 @@ class DecodeCommand extends Command $table->addRows(array( array('decode:', 'variant:', 'Not an RFC 4122 UUID'), )); - } - else { + } else { $this->dumpUuid($table, $uuid); } diff --git a/src/Console/Command/GenerateCommand.php b/src/Console/Command/GenerateCommand.php index 4dc20a9..78a1669 100644 --- a/src/Console/Command/GenerateCommand.php +++ b/src/Console/Command/GenerateCommand.php @@ -159,9 +159,11 @@ class GenerateCommand extends Command return $namespace; } - throw new Exception('Invalid namespace. ' + throw new Exception( + 'Invalid namespace. ' . 'May be either a UUID in string representation or an identifier ' . 'for internally pre-defined namespace UUIDs (currently known ' - . 'are "ns:DNS", "ns:URL", "ns:OID", and "ns:X500").'); + . 'are "ns:DNS", "ns:URL", "ns:OID", and "ns:X500").' + ); } } diff --git a/src/Converter/NumberConverterInterface.php b/src/Converter/NumberConverterInterface.php index 5a3ae89..b111a8f 100644 --- a/src/Converter/NumberConverterInterface.php +++ b/src/Converter/NumberConverterInterface.php @@ -7,4 +7,4 @@ interface NumberConverterInterface public function fromHex($hex); public function toHex($integer); -} \ No newline at end of file +} diff --git a/src/DegradedUuid.php b/src/DegradedUuid.php index 9c9ff80..df7a841 100644 --- a/src/DegradedUuid.php +++ b/src/DegradedUuid.php @@ -22,7 +22,8 @@ class DegradedUuid extends Uuid * * @return \DateTime A PHP DateTime representation of the date * @throws Exception\UnsupportedOperationException If this UUID is not a version 1 UUID - * @throws Exception\UnsatisfiedDependencyException if called on a 32-bit system and Moontoast\Math\BigNumber is not present + * @throws Exception\UnsatisfiedDependencyException if called on a 32-bit system and + * Moontoast\Math\BigNumber is not present */ public function getDateTime() { @@ -63,9 +64,9 @@ class DegradedUuid extends Uuid public function getFields() { throw new Exception\UnsatisfiedDependencyException( - 'Cannot call ' . __METHOD__ . ' on a 32-bit system, since some ' - . 'values overflow the system max integer value' - . '; consider calling getFieldsHex instead' + 'Cannot call ' . __METHOD__ . ' on a 32-bit system, since some ' + . 'values overflow the system max integer value' + . '; consider calling getFieldsHex instead' ); } diff --git a/src/FeatureSet.php b/src/FeatureSet.php index cfbc8ba..4a29f88 100644 --- a/src/FeatureSet.php +++ b/src/FeatureSet.php @@ -45,8 +45,12 @@ class FeatureSet private $timeProvider; - public function __construct($useGuids = false, $force32Bit = false, $forceNoBigNumber = false, $ignoreSystemNode = false) - { + public function __construct( + $useGuids = false, + $force32Bit = false, + $forceNoBigNumber = false, + $ignoreSystemNode = false + ) { $this->disableBigNumber = $forceNoBigNumber; $this->disable64Bit = $force32Bit; $this->ignoreSystemNode = $ignoreSystemNode; @@ -134,8 +138,7 @@ class FeatureSet { if ($this->is64BitSystem()) { return new PhpTimeConverter(); - } - elseif ($this->hasBigNumber()) { + } elseif ($this->hasBigNumber()) { return new BigNumberTimeConverter(); } diff --git a/src/RandomGenerator.php b/src/RandomGenerator.php index d703d04..5f7521c 100644 --- a/src/RandomGenerator.php +++ b/src/RandomGenerator.php @@ -9,5 +9,5 @@ interface RandomGenerator * * @return string */ - function generate($length); + public function generate($length); } diff --git a/src/Uuid.php b/src/Uuid.php index 75acb84..88b18eb 100644 --- a/src/Uuid.php +++ b/src/Uuid.php @@ -319,7 +319,8 @@ class Uuid implements UuidInterface, \JsonSerializable * * @return \DateTime A PHP DateTime representation of the date * @throws Exception\UnsupportedOperationException If this UUID is not a version 1 UUID - * @throws Exception\UnsatisfiedDependencyException if called on a 32-bit system and Moontoast\Math\BigNumber is not present + * @throws Exception\UnsatisfiedDependencyException if called on a 32-bit system and + * Moontoast\Math\BigNumber is not present */ public function getDateTime() { diff --git a/src/UuidInterface.php b/src/UuidInterface.php index 20ba807..4670e7e 100644 --- a/src/UuidInterface.php +++ b/src/UuidInterface.php @@ -108,5 +108,4 @@ interface UuidInterface * @return string */ public function toString(); - }