Skip to content

Commit 6d05ada

Browse files
committed
Merge branch 'release/1.2.0'
2 parents 837760a + 77f50b0 commit 6d05ada

19 files changed

+154
-37
lines changed

.php_cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
<?php
22

3-
$finder = Symfony\CS\Finder\DefaultFinder::create()
3+
$finder = PhpCsFixer\Finder::create()
44
->exclude('vendor')
55
->exclude('tests')
66
->in(__DIR__);
77

8-
return Symfony\CS\Config\Config::create()
9-
->level(Symfony\CS\FixerInterface::PSR2_LEVEL)
10-
->finder($finder);
8+
return PhpCsFixer\Config::create()
9+
->setUsingCache(false)
10+
->setRules(array(
11+
'@PSR2' => true,
12+
'binary_operator_spaces' => true,
13+
'no_whitespace_in_blank_line' => true,
14+
'ternary_operator_spaces' => true,
15+
'cast_spaces' => true,
16+
'trailing_comma_in_multiline_array' => true
17+
))
18+
->setFinder($finder);

.travis.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,17 @@ php:
77
- 5.4
88
- 5.5
99
- 5.6
10-
- 7
10+
- 7.0
11+
- 7.1
1112

1213
before_install:
1314
- composer self-update
1415

1516
install:
16-
- composer install --no-dev
17+
- composer install
1718

1819
script:
19-
- phpunit --coverage-text --coverage-clover=coverage.clover
20+
- ./vendor/phpunit/phpunit/phpunit --coverage-text --coverage-clover=coverage.clover
2021

2122
after_script:
2223
- wget https://scrutinizer-ci.com/ocular.phar

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# CHANGELOG
22

3+
## 1.2.0
4+
- issue #7 - Improve Exception message
5+
36
## 1.1.0
47
- issue #5 - No autocomplete because of return type on a new line after @return in annotation
58

composer.json

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,29 @@
11
{
2-
"name": "wsdltophp/phpgenerator",
3-
"description": "Generate php source file",
4-
"type": "library",
5-
"keywords" : ["php","generator"],
6-
"homepage" : "https://github.com/WsdlToPhp/PhpGenerator",
7-
"license" : "MIT",
8-
"authors" : [
9-
{
10-
"name": "Mikaël DELSOL",
11-
"email": "[email protected]",
12-
"role": "Owner"
13-
}
14-
],
15-
"support" : {
16-
"email" : "[email protected]"
17-
},
18-
"require": {
2+
"name" : "wsdltophp/phpgenerator",
3+
"description" : "Generate php source file",
4+
"require" : {
195
"php" : ">=5.3.3"
206
},
217
"require-dev": {
22-
"fabpot/php-cs-fixer": "~1.8"
8+
"friendsofphp/php-cs-fixer": "~2.0",
9+
"phpunit/phpunit": "~4.0"
2310
},
24-
"autoload": {
25-
"psr-4": {
26-
"WsdlToPhp\\PhpGenerator\\": "src",
27-
"WsdlToPhp\\PhpGenerator\\Tests\\": "tests"
11+
"license" : "MIT",
12+
"keywords" : [ "php", "generator" ],
13+
"autoload" : {
14+
"psr-4" : {
15+
"WsdlToPhp\\PhpGenerator\\" : "src",
16+
"WsdlToPhp\\PhpGenerator\\Tests\\" : "tests"
2817
}
29-
}
18+
},
19+
"type" : "library",
20+
"support" : {
21+
"email" : "[email protected]"
22+
},
23+
"homepage" : "https://github.com/WsdlToPhp/PhpGenerator",
24+
"authors" : [ {
25+
"name" : "Mikaël DELSOL",
26+
"email" : "[email protected]",
27+
"role" : "Owner"
28+
} ]
3029
}

src/Element/AbstractAssignedValueElement.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function __construct($name, $value = null, $access = parent::ACCESS_PUBLI
3131
public function setValue($value)
3232
{
3333
if ($this->getAcceptNonScalarValue() === false && !is_scalar($value) && $value !== null) {
34-
throw new \InvalidArgumentException(sprintf('Value of type "%s" is not a valid scalar value', gettype($value)));
34+
throw new \InvalidArgumentException(sprintf('Value of type "%s" is not a valid scalar value for %s object', gettype($value), $this->getCalledClass()));
3535
}
3636
$this->value = $value;
3737
return $this;

src/Element/AbstractElement.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function __construct($name)
3232
public function setName($name)
3333
{
3434
if (!self::nameIsValid($name)) {
35-
throw new \InvalidArgumentException(sprintf('Name "%s" is invalid, please provide a valid name', $name));
35+
throw new \InvalidArgumentException(sprintf('Name "%s" is invalid when instantiating %s object', $name, $this->getCalledClass()));
3636
}
3737
$this->name = $name;
3838
return $this;
@@ -196,7 +196,7 @@ protected function childIsValid($child)
196196
$valid |= (gettype($child) === $authorizedType) || self::objectIsValid($child, $authorizedType);
197197
}
198198
}
199-
return (bool)$valid;
199+
return (bool) $valid;
200200
}
201201
/**
202202
* @return AbstractElement[]|mixed[]
@@ -324,9 +324,16 @@ public function getIndentationString($indentation = null)
324324
public function getIndentedString($string, $indentation = null)
325325
{
326326
$strings = explode(self::BREAK_LINE_CHAR, $string);
327-
foreach ($strings as $i=>$s) {
327+
foreach ($strings as $i => $s) {
328328
$strings[$i] = sprintf('%s%s', $this->getIndentationString($indentation), $s);
329329
}
330330
return implode(self::BREAK_LINE_CHAR, $strings);
331331
}
332+
/**
333+
* @return string
334+
*/
335+
final public function getCalledClass()
336+
{
337+
return substr(get_called_class(), strrpos(get_called_class(), '\\') + 1);
338+
}
332339
}

src/Element/PhpAnnotationBlock.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ protected static function annotationsAreValid(array $annotations)
6464
foreach ($annotations as $annotation) {
6565
$valid &= self::annotationIsValid($annotation);
6666
}
67-
return (bool)$valid;
67+
return (bool) $valid;
6868
}
6969
/**
7070
* @param string|array|PhpAnnotation $annotation

src/Element/PhpClass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public static function interfacesAreValid(array $interfaces = array())
131131
foreach ($interfaces as $interface) {
132132
$valid &= self::interfaceIsValid($interface);
133133
}
134-
return (bool)$valid;
134+
return (bool) $valid;
135135
}
136136
/**
137137
* @param string|PhpClass $interface

src/Element/PhpFunction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public static function parametersAreValid(array $parameters)
6565
foreach ($parameters as $parameter) {
6666
$valid &= self::parameterIsValid($parameter);
6767
}
68-
return (bool)$valid;
68+
return (bool) $valid;
6969
}
7070
/**
7171
* @param string|array|PhpFunctionParameter $parameter

tests/Element/PhpAnnotationTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,13 @@ public function testHasContent()
6868

6969
$this->assertTrue($annotation->hasContent());
7070
}
71+
72+
public function testExceptionMessageOnName()
73+
{
74+
try {
75+
new PhpAnnotation(0, '');
76+
} catch (\InvalidArgumentException $e) {
77+
$this->assertSame('Name "0" is invalid when instantiating PhpAnnotation object', $e->getMessage());
78+
}
79+
}
7180
}

0 commit comments

Comments
 (0)