Skip to content

Commit

Permalink
Rename classes to avoid PHP7 conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
briedis committed Apr 29, 2016
1 parent 92e1419 commit 37fb92f
Show file tree
Hide file tree
Showing 14 changed files with 55 additions and 55 deletions.
2 changes: 1 addition & 1 deletion src/Briedis/ApiBuilder/Items/BaseItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace Briedis\ApiBuilder\Items;


class Boolean extends BaseItem{
class BooleanItem extends BaseItem{
const TYPE = 'boolean';

public function validateValue($value){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace Briedis\ApiBuilder\Items;


class Decimal extends BaseItem{
class DecimalItem extends BaseItem{
const TYPE = 'float';

public function validateValue($value){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace Briedis\ApiBuilder\Items;


class Integer extends BaseItem{
class IntegerItem extends BaseItem{
const TYPE = 'integer';

public function validateValue($value){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace Briedis\ApiBuilder\Items;


class Mixed extends BaseItem{
class MixedItem extends BaseItem{
const TYPE = 'mixed';

protected function validateValue($value){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace Briedis\ApiBuilder\Items;


class String extends BaseItem{
class StringItem extends BaseItem{
const TYPE = 'string';

public function validateValue($value){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Briedis\ApiBuilder\StructureBuilder;

class Structure extends BaseItem{
class StructureItem extends BaseItem{
/** @var StructureBuilder */
public $structure;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace Briedis\ApiBuilder\Items;


class Upload extends BaseItem{
class UploadItem extends BaseItem{
const TYPE = 'upload';

public function validateValue($value){
Expand Down
30 changes: 15 additions & 15 deletions src/Briedis/ApiBuilder/StructureBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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{
/**
Expand Down Expand Up @@ -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));
}

/**
Expand All @@ -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));
}

/**
Expand All @@ -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));
}

/**
Expand All @@ -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));
}

/**
Expand All @@ -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));
}

/**
Expand All @@ -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));
}

/**
Expand All @@ -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);
}
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/Briedis/ApiBuilder/StructureValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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{

Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/views/structure.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -25,7 +25,7 @@
</div>
<?php

if($v instanceof Structure){
if($v instanceof StructureItem){
?>
<div class="sub">
<?= Presenter::view('structure', ['structure' => $v->structure]); ?>
Expand Down
4 changes: 2 additions & 2 deletions tests/MultiDepthValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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');
}

Expand Down
10 changes: 5 additions & 5 deletions tests/SingleDepthValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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');
}

Expand All @@ -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');
}

Expand Down
Loading

0 comments on commit 37fb92f

Please sign in to comment.