Skip to content

Commit

Permalink
Merge pull request #21 from SignpostMarv/php-cs-fixer
Browse files Browse the repository at this point in the history
added & applied php-cs-fixer config for symfony sans yoda
  • Loading branch information
goetas committed Oct 28, 2017
2 parents a5882ed + bb953a5 commit 93cf61f
Show file tree
Hide file tree
Showing 48 changed files with 418 additions and 349 deletions.
3 changes: 0 additions & 3 deletions .editorconfig
Expand Up @@ -14,6 +14,3 @@ insert_final_newline = false

[.travis.yml]
indent_size = 2

[composer.json]
indent_style = tab
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -4,3 +4,4 @@ vendor/
/.buildpath
/.project
/.idea
/.php_cs.cache
14 changes: 14 additions & 0 deletions .php_cs.dist
@@ -0,0 +1,14 @@
<?php
/**
* PHP-CS-Fixer Config.
*/

namespace GoetasWebservices\CS;

require_once __DIR__.'/vendor/autoload.php';

return new Config([
__FILE__,
(__DIR__.'/src/'),
(__DIR__.'/tests/'),
]);
13 changes: 11 additions & 2 deletions .travis.yml
Expand Up @@ -5,8 +5,15 @@ php:
- 5.4
- 5.5
- 5.6
- 7.0
- 7.1
- 7.2
- hhvm

matrix:
allow_failures:
- php: hhvm

cache:
directories:
- vendor
Expand All @@ -19,9 +26,11 @@ before_script:
- travis_retry composer self-update
- travis_retry composer update $COMPOSER_FLAGS

script: vendor/bin/phpunit $PHPUNIT_FLAGS
script:
- vendor/bin/phpunit $PHPUNIT_FLAGS
- if [[ $TRAVIS_PHP_VERSION != '5.4' && $TRAVIS_PHP_VERSION != '5.5' ]]; then travis_retry composer require --dev friendsofphp/php-cs-fixer; fi
- if [[ $TRAVIS_PHP_VERSION != '5.4' && $TRAVIS_PHP_VERSION != '5.5' ]]; then php ./vendor/friendsofphp/php-cs-fixer/php-cs-fixer fix --verbose --dry-run; fi

after_script:
- wget https://scrutinizer-ci.com/ocular.phar
- if [[ $TRAVIS_PHP_VERSION = '5.6' ]] ; then php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi

80 changes: 41 additions & 39 deletions composer.json
@@ -1,41 +1,43 @@
{
"name" : "goetas-webservices/xsd-reader",
"description" : "Read any XML Schema (XSD) programmatically with PHP",
"keywords" : [
"xsd",
"xml",
"php",
"parser",
"xmlschema"
],
"license" : "MIT",
"authors" : [{
"name" : "Asmir Mustafic",
"email" : "goetas@lignano.it"
}
],
"require" : {
"php" : ">=5.4.0"
},
"require-dev" : {
"phpunit/phpunit" : "^4.8|^5.0"
},
"autoload" : {
"psr-4" : {
"GoetasWebservices\\XML\\XSDReader\\" : "src/"
}
},
"autoload-dev" : {
"psr-4" : {
"GoetasWebservices\\XML\\XSDReader\\Tests\\" : "tests/"
}
},
"extra" : {
"branch-alias" : {
"dev-master" : "0.2-dev"
}
},
"scripts": {
"test": "vendor/bin/phpunit"
}
"name" : "goetas-webservices/xsd-reader",
"description" : "Read any XML Schema (XSD) programmatically with PHP",
"keywords" : [
"xsd",
"xml",
"php",
"parser",
"xmlschema"
],
"license" : "MIT",
"authors" : [{
"name" : "Asmir Mustafic",
"email" : "goetas@lignano.it"
}
],
"require" : {
"php" : ">=5.4.0"
},
"require-dev" : {
"phpunit/phpunit" : "^4.8|^5.0"
},
"autoload" : {
"psr-4" : {
"GoetasWebservices\\XML\\XSDReader\\" : "src/"
}
},
"autoload-dev" : {
"psr-4" : {
"GoetasWebservices\\CS\\": "./php-cs-fixer/",
"GoetasWebservices\\XML\\XSDReader\\Tests\\" : "tests/"
}
},
"extra" : {
"branch-alias" : {
"dev-master" : "0.2-dev"
}
},
"scripts": {
"php-cs-fixer": "php-cs-fixer fix --verbose --dry-run",
"test": "vendor/bin/phpunit"
}
}
57 changes: 57 additions & 0 deletions php-cs-fixer/Config.php
@@ -0,0 +1,57 @@
<?php
/**
* @author SignpostMarv
*/
namespace GoetasWebservices\CS;

use PhpCsFixer\Config as BaseConfig;
use PhpCsFixer\Finder as DefaultFinder;

class Config extends BaseConfig
{
const DEFAULT_RULES = [
'@Symfony' => true,
'yoda_style' => false,
];

public function __construct(array $inPaths)
{
parent::__construct(
str_replace(
'\\',
' - ',
preg_replace(
'/([a-z0-9])([A-Z])/',
'$1 $2',
static::class
)
)
);

$this->setUsingCache(true);
$this->setRules(static::DEFAULT_RULES);

/**
* @var DefaultFinder $finder
*/
$finder = $this->getFinder();
$this->setFinder(array_reduce(
$inPaths,
function (DefaultFinder $finder, $directory) {
if (is_file($directory) === true) {
return $finder->append([$directory]);
}
return $finder->in($directory);
},
$finder->ignoreUnreadableDirs()
));
}

/**
* Resolve rules at runtime.
*/
protected static function RuntimeResolveRules()
{
return static::DEFAULT_RULES;
}
}
3 changes: 2 additions & 1 deletion src/Exception/IOException.php
@@ -1,6 +1,7 @@
<?php

namespace GoetasWebservices\XML\XSDReader\Exception;

class IOException extends \Exception
{
}
}
3 changes: 2 additions & 1 deletion src/Exception/TypeException.php
@@ -1,6 +1,7 @@
<?php

namespace GoetasWebservices\XML\XSDReader\Exception;

class TypeException extends \Exception
{
}
}
7 changes: 6 additions & 1 deletion src/Schema/Attribute/Attribute.php
@@ -1,11 +1,11 @@
<?php

namespace GoetasWebservices\XML\XSDReader\Schema\Attribute;

use GoetasWebservices\XML\XSDReader\Schema\Item;

class Attribute extends Item implements AttributeSingle
{

protected $fixed;

protected $default;
Expand All @@ -24,6 +24,7 @@ public function getFixed()
public function setFixed($fixed)
{
$this->fixed = $fixed;

return $this;
}

Expand All @@ -35,6 +36,7 @@ public function getDefault()
public function setDefault($default)
{
$this->default = $default;

return $this;
}

Expand All @@ -46,6 +48,7 @@ public function isQualified()
public function setQualified($qualified)
{
$this->qualified = $qualified;

return $this;
}

Expand All @@ -57,6 +60,7 @@ public function isNil()
public function setNil($nil)
{
$this->nil = $nil;

return $this;
}

Expand All @@ -68,6 +72,7 @@ public function getUse()
public function setUse($use)
{
$this->use = $use;

return $this;
}
}
2 changes: 1 addition & 1 deletion src/Schema/Attribute/AttributeContainer.php
@@ -1,11 +1,11 @@
<?php

namespace GoetasWebservices\XML\XSDReader\Schema\Attribute;

use GoetasWebservices\XML\XSDReader\Schema\SchemaItem;

interface AttributeContainer extends SchemaItem
{

public function addAttribute(AttributeItem $attribute);

public function getAttributes();
Expand Down
4 changes: 3 additions & 1 deletion src/Schema/Attribute/AttributeDef.php
@@ -1,11 +1,11 @@
<?php

namespace GoetasWebservices\XML\XSDReader\Schema\Attribute;

use GoetasWebservices\XML\XSDReader\Schema\Item;

class AttributeDef extends Item implements AttributeItem
{

protected $fixed;

protected $default;
Expand All @@ -18,6 +18,7 @@ public function getFixed()
public function setFixed($fixed)
{
$this->fixed = $fixed;

return $this;
}

Expand All @@ -29,6 +30,7 @@ public function getDefault()
public function setDefault($default)
{
$this->default = $default;

return $this;
}
}
1 change: 1 addition & 0 deletions src/Schema/Attribute/AttributeItem.php
@@ -1,4 +1,5 @@
<?php

namespace GoetasWebservices\XML\XSDReader\Schema\Attribute;

use GoetasWebservices\XML\XSDReader\Schema\SchemaItem;
Expand Down
8 changes: 5 additions & 3 deletions src/Schema/Attribute/AttributeRef.php
@@ -1,19 +1,18 @@
<?php

namespace GoetasWebservices\XML\XSDReader\Schema\Attribute;

use GoetasWebservices\XML\XSDReader\Schema\Item;

class AttributeRef extends Item implements AttributeSingle
{

protected $qualified = true;

protected $nil = false;

protected $use = self::USE_OPTIONAL;

/**
*
* @var Attribute
*/
protected $wrapped;
Expand All @@ -23,8 +22,8 @@ public function __construct(AttributeDef $att)
parent::__construct($att->getSchema(), $att->getName());
$this->wrapped = $att;
}

/**
*
* @return AttributeDef
*/
public function getReferencedAttribute()
Expand All @@ -45,6 +44,7 @@ public function isQualified()
public function setQualified($qualified)
{
$this->qualified = $qualified;

return $this;
}

Expand All @@ -56,6 +56,7 @@ public function isNil()
public function setNil($nil)
{
$this->nil = $nil;

return $this;
}

Expand All @@ -67,6 +68,7 @@ public function getUse()
public function setUse($use)
{
$this->use = $use;

return $this;
}
}

0 comments on commit 93cf61f

Please sign in to comment.