From 37fb92f5f16a200fbf261b4d50366c128d30bafb Mon Sep 17 00:00:00 2001 From: "martins.briedis" Date: Fri, 29 Apr 2016 13:31:03 +0300 Subject: [PATCH] Rename classes to avoid PHP7 conflicts --- src/Briedis/ApiBuilder/Items/BaseItem.php | 2 +- .../Items/{Boolean.php => BooleanItem.php} | 2 +- .../Items/{Decimal.php => DecimalItem.php} | 2 +- .../Items/{Integer.php => IntegerItem.php} | 2 +- .../Items/{Mixed.php => MixedItem.php} | 2 +- .../Items/{String.php => StringItem.php} | 2 +- .../{Structure.php => StructureItem.php} | 2 +- .../Items/{Upload.php => UploadItem.php} | 2 +- src/Briedis/ApiBuilder/StructureBuilder.php | 30 ++++++------- src/Briedis/ApiBuilder/StructureValidator.php | 4 +- src/views/structure.php | 4 +- tests/MultiDepthValidatorTest.php | 4 +- tests/SingleDepthValidatorTest.php | 10 ++--- tests/TypeTest.php | 42 +++++++++---------- 14 files changed, 55 insertions(+), 55 deletions(-) rename src/Briedis/ApiBuilder/Items/{Boolean.php => BooleanItem.php} (87%) rename src/Briedis/ApiBuilder/Items/{Decimal.php => DecimalItem.php} (83%) rename src/Briedis/ApiBuilder/Items/{Integer.php => IntegerItem.php} (82%) rename src/Briedis/ApiBuilder/Items/{Mixed.php => MixedItem.php} (83%) rename src/Briedis/ApiBuilder/Items/{String.php => StringItem.php} (82%) rename src/Briedis/ApiBuilder/Items/{Structure.php => StructureItem.php} (86%) rename src/Briedis/ApiBuilder/Items/{Upload.php => UploadItem.php} (83%) diff --git a/src/Briedis/ApiBuilder/Items/BaseItem.php b/src/Briedis/ApiBuilder/Items/BaseItem.php index 3ab005c..7172dbc 100644 --- a/src/Briedis/ApiBuilder/Items/BaseItem.php +++ b/src/Briedis/ApiBuilder/Items/BaseItem.php @@ -59,7 +59,7 @@ public function __construct($name = '', $description = ''){ public function getDisplayTypeName(){ $type = static::TYPE; - if($this instanceof Structure){ + if($this instanceof StructureItem){ $type = $this->structure->getStructureName(); } diff --git a/src/Briedis/ApiBuilder/Items/Boolean.php b/src/Briedis/ApiBuilder/Items/BooleanItem.php similarity index 87% rename from src/Briedis/ApiBuilder/Items/Boolean.php rename to src/Briedis/ApiBuilder/Items/BooleanItem.php index 89caf0f..dc4b6cc 100644 --- a/src/Briedis/ApiBuilder/Items/Boolean.php +++ b/src/Briedis/ApiBuilder/Items/BooleanItem.php @@ -4,7 +4,7 @@ namespace Briedis\ApiBuilder\Items; -class Boolean extends BaseItem{ +class BooleanItem extends BaseItem{ const TYPE = 'boolean'; public function validateValue($value){ diff --git a/src/Briedis/ApiBuilder/Items/Decimal.php b/src/Briedis/ApiBuilder/Items/DecimalItem.php similarity index 83% rename from src/Briedis/ApiBuilder/Items/Decimal.php rename to src/Briedis/ApiBuilder/Items/DecimalItem.php index 83995a7..96d3e64 100644 --- a/src/Briedis/ApiBuilder/Items/Decimal.php +++ b/src/Briedis/ApiBuilder/Items/DecimalItem.php @@ -4,7 +4,7 @@ namespace Briedis\ApiBuilder\Items; -class Decimal extends BaseItem{ +class DecimalItem extends BaseItem{ const TYPE = 'float'; public function validateValue($value){ diff --git a/src/Briedis/ApiBuilder/Items/Integer.php b/src/Briedis/ApiBuilder/Items/IntegerItem.php similarity index 82% rename from src/Briedis/ApiBuilder/Items/Integer.php rename to src/Briedis/ApiBuilder/Items/IntegerItem.php index 4b862dc..d7b768e 100644 --- a/src/Briedis/ApiBuilder/Items/Integer.php +++ b/src/Briedis/ApiBuilder/Items/IntegerItem.php @@ -4,7 +4,7 @@ namespace Briedis\ApiBuilder\Items; -class Integer extends BaseItem{ +class IntegerItem extends BaseItem{ const TYPE = 'integer'; public function validateValue($value){ diff --git a/src/Briedis/ApiBuilder/Items/Mixed.php b/src/Briedis/ApiBuilder/Items/MixedItem.php similarity index 83% rename from src/Briedis/ApiBuilder/Items/Mixed.php rename to src/Briedis/ApiBuilder/Items/MixedItem.php index 1628ac3..f1873f1 100644 --- a/src/Briedis/ApiBuilder/Items/Mixed.php +++ b/src/Briedis/ApiBuilder/Items/MixedItem.php @@ -4,7 +4,7 @@ namespace Briedis\ApiBuilder\Items; -class Mixed extends BaseItem{ +class MixedItem extends BaseItem{ const TYPE = 'mixed'; protected function validateValue($value){ diff --git a/src/Briedis/ApiBuilder/Items/String.php b/src/Briedis/ApiBuilder/Items/StringItem.php similarity index 82% rename from src/Briedis/ApiBuilder/Items/String.php rename to src/Briedis/ApiBuilder/Items/StringItem.php index 8941175..10cd191 100644 --- a/src/Briedis/ApiBuilder/Items/String.php +++ b/src/Briedis/ApiBuilder/Items/StringItem.php @@ -4,7 +4,7 @@ namespace Briedis\ApiBuilder\Items; -class String extends BaseItem{ +class StringItem extends BaseItem{ const TYPE = 'string'; public function validateValue($value){ diff --git a/src/Briedis/ApiBuilder/Items/Structure.php b/src/Briedis/ApiBuilder/Items/StructureItem.php similarity index 86% rename from src/Briedis/ApiBuilder/Items/Structure.php rename to src/Briedis/ApiBuilder/Items/StructureItem.php index 79c3990..24ea7f9 100644 --- a/src/Briedis/ApiBuilder/Items/Structure.php +++ b/src/Briedis/ApiBuilder/Items/StructureItem.php @@ -6,7 +6,7 @@ use Briedis\ApiBuilder\StructureBuilder; -class Structure extends BaseItem{ +class StructureItem extends BaseItem{ /** @var StructureBuilder */ public $structure; diff --git a/src/Briedis/ApiBuilder/Items/Upload.php b/src/Briedis/ApiBuilder/Items/UploadItem.php similarity index 83% rename from src/Briedis/ApiBuilder/Items/Upload.php rename to src/Briedis/ApiBuilder/Items/UploadItem.php index c0d6750..6609867 100644 --- a/src/Briedis/ApiBuilder/Items/Upload.php +++ b/src/Briedis/ApiBuilder/Items/UploadItem.php @@ -4,7 +4,7 @@ namespace Briedis\ApiBuilder\Items; -class Upload extends BaseItem{ +class UploadItem extends BaseItem{ const TYPE = 'upload'; public function validateValue($value){ diff --git a/src/Briedis/ApiBuilder/StructureBuilder.php b/src/Briedis/ApiBuilder/StructureBuilder.php index 5ee7aea..c88e999 100644 --- a/src/Briedis/ApiBuilder/StructureBuilder.php +++ b/src/Briedis/ApiBuilder/StructureBuilder.php @@ -5,13 +5,13 @@ use Briedis\ApiBuilder\Items\BaseItem; -use Briedis\ApiBuilder\Items\Boolean; -use Briedis\ApiBuilder\Items\Decimal; -use Briedis\ApiBuilder\Items\Integer; -use Briedis\ApiBuilder\Items\Mixed; -use Briedis\ApiBuilder\Items\String; -use Briedis\ApiBuilder\Items\Structure; -use Briedis\ApiBuilder\Items\Upload; +use Briedis\ApiBuilder\Items\BooleanItem; +use Briedis\ApiBuilder\Items\DecimalItem; +use Briedis\ApiBuilder\Items\IntegerItem; +use Briedis\ApiBuilder\Items\MixedItem; +use Briedis\ApiBuilder\Items\StringItem; +use Briedis\ApiBuilder\Items\StructureItem; +use Briedis\ApiBuilder\Items\UploadItem; class StructureBuilder implements StructureInterface{ /** @@ -70,7 +70,7 @@ public function getItemByName($itemName){ * @return StructureBuilder */ public function int($name, $description = ''){ - return $this->addItem(new Integer($name, $description)); + return $this->addItem(new IntegerItem($name, $description)); } /** @@ -80,7 +80,7 @@ public function int($name, $description = ''){ * @return StructureBuilder */ public function str($name, $description = ''){ - return $this->addItem(new String($name, $description)); + return $this->addItem(new StringItem($name, $description)); } /** @@ -90,7 +90,7 @@ public function str($name, $description = ''){ * @return StructureBuilder */ public function float($name, $description = ''){ - return $this->addItem(new Decimal($name, $description)); + return $this->addItem(new DecimalItem($name, $description)); } /** @@ -100,7 +100,7 @@ public function float($name, $description = ''){ * @return StructureBuilder */ public function bool($name, $description = ''){ - return $this->addItem(new Boolean($name, $description)); + return $this->addItem(new BooleanItem($name, $description)); } /** @@ -110,7 +110,7 @@ public function bool($name, $description = ''){ * @return StructureBuilder */ public function upload($name, $description = ''){ - return $this->addItem(new Upload($name, $description)); + return $this->addItem(new UploadItem($name, $description)); } /** @@ -120,7 +120,7 @@ public function upload($name, $description = ''){ * @return StructureBuilder */ public function mixed($name, $description = ''){ - return $this->addItem(new Mixed($name, $description)); + return $this->addItem(new MixedItem($name, $description)); } /** @@ -131,7 +131,7 @@ public function mixed($name, $description = ''){ * @return StructureBuilder */ public function struct($name, StructureInterface $structure, $description = ''){ - $item = new Structure($name, $description); + $item = new StructureItem($name, $description); $item->structure = $structure->getStructure(); return $this->addItem($item); } @@ -151,7 +151,7 @@ public function optional(){ * @return self */ public function values(array $values){ - if($this->lastItem instanceof Structure || $this->lastItem instanceof Boolean){ + if($this->lastItem instanceof StructureItem || $this->lastItem instanceof BooleanItem){ throw new \InvalidArgumentException('Cannot mark this type as an enumerable'); } $this->lastItem->isFixedValues = true; diff --git a/src/Briedis/ApiBuilder/StructureValidator.php b/src/Briedis/ApiBuilder/StructureValidator.php index 9b35612..75601be 100644 --- a/src/Briedis/ApiBuilder/StructureValidator.php +++ b/src/Briedis/ApiBuilder/StructureValidator.php @@ -7,7 +7,7 @@ use Briedis\ApiBuilder\Exceptions\InvalidParameterTypeException; use Briedis\ApiBuilder\Exceptions\InvalidStructureException; use Briedis\ApiBuilder\Exceptions\UnexpectedParameterException; -use Briedis\ApiBuilder\Items\Structure; +use Briedis\ApiBuilder\Items\StructureItem; class StructureValidator{ @@ -82,7 +82,7 @@ public function validateParam($name, $value){ throw new UnexpectedParameterException; } - if($item instanceof Structure){ + if($item instanceof StructureItem){ // Recursive validation $validator = new self($item->structure, $this->parameterDepthStack); $validator->validate($value); diff --git a/src/views/structure.php b/src/views/structure.php index b12b832..4b95ad2 100644 --- a/src/views/structure.php +++ b/src/views/structure.php @@ -4,7 +4,7 @@ * @var \Briedis\ApiBuilder\StructureInterface $structure */ -use Briedis\ApiBuilder\Items\Structure; +use Briedis\ApiBuilder\Items\StructureItem; use Briedis\ApiBuilder\Presenter; $items = $structure->getStructure()->getItems(); @@ -25,7 +25,7 @@
$v->structure]); ?> diff --git a/tests/MultiDepthValidatorTest.php b/tests/MultiDepthValidatorTest.php index 0dff37a..19a8e3f 100644 --- a/tests/MultiDepthValidatorTest.php +++ b/tests/MultiDepthValidatorTest.php @@ -2,7 +2,7 @@ use Briedis\ApiBuilder\Exceptions\InvalidStructureException; -use Briedis\ApiBuilder\Items\Decimal; +use Briedis\ApiBuilder\Items\DecimalItem; use Briedis\ApiBuilder\StructureBuilder as SB; use Briedis\ApiBuilder\StructureValidator; @@ -64,7 +64,7 @@ public function testInvalidStructure(){ } catch(InvalidStructureException $e){ $caught = true; $fields = $e->getBadFields(); - $this->assertInstanceOf(get_class(new Decimal), $fields['s11.decimal'], 'Correct field is missing'); + $this->assertInstanceOf(get_class(new DecimalItem), $fields['s11.decimal'], 'Correct field is missing'); $this->assertEquals(1, count($fields), 'Bad parameter count matches'); } diff --git a/tests/SingleDepthValidatorTest.php b/tests/SingleDepthValidatorTest.php index 2d20625..66c6fad 100644 --- a/tests/SingleDepthValidatorTest.php +++ b/tests/SingleDepthValidatorTest.php @@ -2,8 +2,8 @@ use Briedis\ApiBuilder\Exceptions\InvalidStructureException; -use Briedis\ApiBuilder\Items\Decimal; -use Briedis\ApiBuilder\Items\Integer; +use Briedis\ApiBuilder\Items\DecimalItem; +use Briedis\ApiBuilder\Items\IntegerItem; use Briedis\ApiBuilder\StructureBuilder; use Briedis\ApiBuilder\StructureValidator; @@ -45,7 +45,7 @@ public function testMissingParam(){ } catch(InvalidStructureException $e){ $caught = true; $missing = $e->getMissingFields(); - $this->assertInstanceOf(get_class(new Integer), $missing['int'], 'Correct field is missing'); + $this->assertInstanceOf(get_class(new IntegerItem), $missing['int'], 'Correct field is missing'); $this->assertEquals(1, count($missing), 'Missing parameter count matches'); } @@ -72,8 +72,8 @@ public function testInvalidParam(){ $caught = true; $fields = $e->getBadFields(); - $this->assertInstanceOf(get_class(new Integer), $fields['id'], 'Correct field is invalid'); - $this->assertInstanceOf(get_class(new Decimal), $fields['decimal'], 'Correct field is invalid'); + $this->assertInstanceOf(get_class(new IntegerItem), $fields['id'], 'Correct field is invalid'); + $this->assertInstanceOf(get_class(new DecimalItem), $fields['decimal'], 'Correct field is invalid'); $this->assertEquals(2, count($fields), 'Bad parameter count matches'); } diff --git a/tests/TypeTest.php b/tests/TypeTest.php index 28568ac..fbc0a15 100644 --- a/tests/TypeTest.php +++ b/tests/TypeTest.php @@ -1,11 +1,11 @@ isArray = true; $this->itemAssertFalse([ 1, @@ -108,7 +108,7 @@ public function testIsNotIntegerArray(){ } public function testIsIntegerArray(){ - $item = new Integer; + $item = new IntegerItem; $item->isArray = true; $this->itemAssertTrue([ [], @@ -118,7 +118,7 @@ public function testIsIntegerArray(){ } public function testIsFixedValue(){ - $item = new Integer; + $item = new IntegerItem; $item->isFixedValues = true; $item->validValues = [1, 2, 3]; $this->itemAssertTrue([ @@ -130,7 +130,7 @@ public function testIsFixedValue(){ } public function testIsNotFixedValue(){ - $item = new Integer; + $item = new IntegerItem; $item->isFixedValues = true; $item->validValues = [1, 2, 3]; $this->itemAssertFalse([ @@ -142,7 +142,7 @@ public function testIsNotFixedValue(){ } public function testIsFixedValueArray(){ - $item = new Integer; + $item = new IntegerItem; $item->isFixedValues = true; $item->validValues = [1, 2, 3]; $item->isArray = true; @@ -155,7 +155,7 @@ public function testIsFixedValueArray(){ } public function testIsNotFixedValueArray(){ - $item = new Integer; + $item = new IntegerItem; $item->isFixedValues = true; $item->validValues = [1, 2, 3]; $item->isArray = true; @@ -169,7 +169,7 @@ public function testIsNotFixedValueArray(){ } public function testIsStringFixedValues(){ - $item = new String; + $item = new StringItem; $item->isFixedValues = true; $item->validValues = [1, 'a', 1.5]; $this->itemAssertTrue([ @@ -180,7 +180,7 @@ public function testIsStringFixedValues(){ } public function testIsMixed(){ - $item = new Mixed; + $item = new MixedItem; $this->itemAssertTrue([ 1, 'a',