Skip to content

Commit 1746756

Browse files
committed
Merge branch 'release/2.0.0'
2 parents 03494f3 + c8492e8 commit 1746756

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+708
-626
lines changed

.docker/Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM php:7.1-apache
2+
3+
RUN apt-get update \
4+
&& apt-get install -y git zip
5+
6+
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
7+
COPY . /var/www/html
8+
9+
WORKDIR /var/www/html

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
vendor/
22
composer.lock
33
phpunit.xml
4-
4+
.idea

.php_cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,19 @@
22

33
$finder = PhpCsFixer\Finder::create()
44
->exclude('vendor')
5-
->exclude('tests')
65
->in(__DIR__);
76

87
return PhpCsFixer\Config::create()
98
->setUsingCache(false)
10-
->setRules(array(
9+
->setRules([
1110
'@PSR2' => true,
11+
'array_syntax' => [
12+
'syntax' => 'short',
13+
],
1214
'binary_operator_spaces' => true,
1315
'no_whitespace_in_blank_line' => true,
1416
'ternary_operator_spaces' => true,
1517
'cast_spaces' => true,
1618
'trailing_comma_in_multiline_array' => true
17-
))
19+
])
1820
->setFinder($finder);

.travis.yml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,12 @@ language: php
33
sudo: false
44

55
php:
6-
- 5.3
7-
- 5.4
8-
- 5.5
9-
- 5.6
10-
- 7.0
11-
- 7.1
6+
- 7.1
7+
- 7.2
128

13-
before_install:
14-
- composer self-update
9+
cache:
10+
directories:
11+
- $HOME/.composer/cache
1512

1613
install:
1714
- composer install

CHANGELOG.md

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

3+
## 2.0.0
4+
- Use PHP 7.1 features
5+
- Refactore code
6+
- Fix typos
7+
38
## 1.2.1
49
- Review filemode, add SensioLabs Insight badge
510

README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
# WsdlToPhp Php Generator, a Real PHP source code generator
1+
# PhpGenerator, a Real PHP source code generator
2+
3+
> PhpGenerator helps generating PHP source code
4+
25
[![License](https://poser.pugx.org/wsdltophp/phpgenerator/license)](https://packagist.org/packages/wsdltophp/phpgenerator)
36
[![Latest Stable Version](https://poser.pugx.org/wsdltophp/phpgenerator/version.png)](https://packagist.org/packages/wsdltophp/phpgenerator)
47
[![Build Status](https://api.travis-ci.org/WsdlToPhp/PhpGenerator.svg)](https://travis-ci.org/WsdlToPhp/PhpGenerator)
5-
[![PHP 7 ready](http://php7ready.timesplinter.ch/WsdlToPhp/PhpGenerator/badge.svg)](https://travis-ci.org/WsdlToPhp/PhpGenerator)
68
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/WsdlToPhp/PhpGenerator/badges/quality-score.png)](https://scrutinizer-ci.com/g/WsdlToPhp/PhpGenerator/)
79
[![Code Coverage](https://scrutinizer-ci.com/g/WsdlToPhp/PhpGenerator/badges/coverage.png)](https://scrutinizer-ci.com/g/WsdlToPhp/PhpGenerator/)
8-
[![Dependency Status](https://www.versioneye.com/user/projects/5571b32b6634650018000011/badge.svg)](https://www.versioneye.com/user/projects/5571b32b6634650018000011)
910
[![StyleCI](https://styleci.io/repos/36832375/shield)](https://styleci.io/repos/36832375)
1011
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/e55e9115-5a3f-4d37-bfd5-b01c8de579f9/mini.png)](https://insight.sensiolabs.com/projects/e55e9115-5a3f-4d37-bfd5-b01c8de579f9)
1112

@@ -14,15 +15,15 @@ Even if this project is yet another PHP source code generator, its main goal is
1415
Rest assured that it is not tweaked for the purpose of the [PackageGenerator](https://github.com/WsdlToPhp/PackageGenerator) project.
1516

1617
## Main features
17-
This projet contains two main features:
18+
This project contains two main features:
1819

1920
- [Element](src/Element/README.md): generate basic elements
2021
- [Component](src/Component/README.md): generate structured complex elements
2122

2223
## Unit tests
2324
You can run the unit tests with the following command:
2425
```
25-
$ cd /path/to/src/WsdlToPhp/PhpGenerator/
26-
$ composer install
27-
$ phpunit
26+
$ cd /path/to/src/WsdlToPhp/PhpGenerator/
27+
$ composer install
28+
$ composer test
2829
```

composer.json

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,42 @@
11
{
22
"name" : "wsdltophp/phpgenerator",
33
"description" : "Generate php source file",
4+
"license" : "MIT",
5+
"keywords" : [ "php", "generator" ],
6+
"type" : "library",
7+
"support" : {
8+
"email" : "[email protected]"
9+
},
10+
"homepage" : "https://github.com/WsdlToPhp/PhpGenerator",
11+
"authors" : [
12+
{
13+
"name" : "Mikaël DELSOL",
14+
"email" : "[email protected]",
15+
"role" : "Owner"
16+
}
17+
],
18+
"scripts": {
19+
"test": "vendor/bin/phpunit",
20+
"lint": "vendor/bin/php-cs-fixer fix --ansi --diff --verbose"
21+
},
422
"require" : {
5-
"php" : ">=5.3.3"
23+
"php" : ">=7.1"
624
},
725
"require-dev": {
826
"friendsofphp/php-cs-fixer": "~2.0",
9-
"phpunit/phpunit": "~4.0"
27+
"phpunit/phpunit": "^4.8 || ^6.0"
1028
},
11-
"license" : "MIT",
12-
"keywords" : [ "php", "generator" ],
1329
"autoload" : {
1430
"psr-4" : {
15-
"WsdlToPhp\\PhpGenerator\\" : "src",
16-
"WsdlToPhp\\PhpGenerator\\Tests\\" : "tests"
31+
"WsdlToPhp\\PhpGenerator\\" : "src"
1732
}
1833
},
19-
"type" : "library",
20-
"support" : {
21-
"email" : "[email protected]"
34+
"autoload-dev": {
35+
"psr-4": {
36+
"WsdlToPhp\\PhpGenerator\\Tests\\": "tests"
37+
}
2238
},
23-
"homepage" : "https://github.com/WsdlToPhp/PhpGenerator",
24-
"authors" : [ {
25-
"name" : "Mikaël DELSOL",
26-
"email" : "[email protected]",
27-
"role" : "Owner"
28-
} ]
39+
"config": {
40+
"sort-packages": true
41+
}
2942
}

docker-compose.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: '3.4'
2+
3+
services:
4+
php:
5+
build:
6+
context: .
7+
dockerfile: .docker/Dockerfile
8+
volumes:
9+
- .:/var/www/html:rw
10+
container_name: php_generator

src/Component/AbstractComponent.php

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace WsdlToPhp\PhpGenerator\Component;
46

57
use WsdlToPhp\PhpGenerator\Element\AbstractElement;
@@ -8,19 +10,19 @@
810
use WsdlToPhp\PhpGenerator\Element\PhpConstant as PhpConstantElement;
911
use WsdlToPhp\PhpGenerator\Element\PhpAnnotationBlock as PhpAnnotationBlockElement;
1012

11-
abstract class AbstractComponent implements GenerableInterface
13+
abstract class AbstractComponent implements GenerateableInterface
1214
{
1315
/**
1416
* @var PhpFileElement|PhpClassElement
1517
*/
1618
protected $mainElement;
1719
/**
18-
* @see \WsdlToPhp\PhpGenerator\Component\GenerableInterface::toString()
20+
* @see \WsdlToPhp\PhpGenerator\Component\GenerateableInterface::toString()
1921
* @return string
2022
*/
21-
public function toString()
23+
public function toString(): string
2224
{
23-
$content = array();
25+
$content = [];
2426
foreach ($this->getElements() as $element) {
2527
$content[] = $this->getElementString($element);
2628
}
@@ -29,13 +31,13 @@ public function toString()
2931
/**
3032
* @return AbstractElement[]|string[]
3133
*/
32-
abstract public function getElements();
34+
abstract public function getElements(): array;
3335
/**
3436
* @throws \InvalidArgumentException
3537
* @param AbstractElement $element
36-
* @return \WsdlToPhp\PhpGenerator\Component\AbstractComponent
38+
* @return AbstractComponent
3739
*/
38-
public function setMainElement(AbstractElement $element)
40+
public function setMainElement(AbstractElement $element): AbstractComponent
3941
{
4042
if ($element instanceof PhpFileElement || $element instanceof PhpClassElement) {
4143
$this->mainElement = $element;
@@ -47,7 +49,7 @@ public function setMainElement(AbstractElement $element)
4749
/**
4850
* @return PhpFileElement|PhpClassElement
4951
*/
50-
public function getMainElement()
52+
public function getMainElement(): AbstractElement
5153
{
5254
return $this->mainElement;
5355
}
@@ -56,7 +58,7 @@ public function getMainElement()
5658
* @param string|AbstractElement $element
5759
* @return string
5860
*/
59-
protected function getElementString($element)
61+
protected function getElementString($element): string
6062
{
6163
$string = '';
6264
if (is_scalar($element)) {
@@ -70,7 +72,7 @@ protected function getElementString($element)
7072
* @param PhpConstantElement $constant
7173
* @return AbstractComponent
7274
*/
73-
public function addConstantElement(PhpConstantElement $constant)
75+
public function addConstantElement(PhpConstantElement $constant): AbstractComponent
7476
{
7577
if (!$constant->getClass() instanceof PhpClassElement && $this->mainElement instanceof PhpClassElement) {
7678
$constant->setClass($this->mainElement);
@@ -85,15 +87,15 @@ public function addConstantElement(PhpConstantElement $constant)
8587
* @param PhpClassElement $class
8688
* @return AbstractComponent
8789
*/
88-
public function addConstant($name, $value = null, PhpClassElement $class = null)
90+
public function addConstant($name, $value = null, PhpClassElement $class = null): AbstractComponent
8991
{
9092
return $this->addConstantElement(new PhpConstantElement($name, $value, $class));
9193
}
9294
/**
9395
* @param PhpAnnotationBlockElement $annotationBlock
9496
* @return AbstractComponent
9597
*/
96-
public function addAnnotationBlockElement(PhpAnnotationBlockElement $annotationBlock)
98+
public function addAnnotationBlockElement(PhpAnnotationBlockElement $annotationBlock): AbstractComponent
9799
{
98100
$this->mainElement->addChild($annotationBlock);
99101
return $this;
@@ -103,10 +105,10 @@ public function addAnnotationBlockElement(PhpAnnotationBlockElement $annotationB
103105
* @param array|string|PhpAnnotationElement $annotations
104106
* @return AbstractComponent
105107
*/
106-
public function addAnnotationBlock($annotations)
108+
public function addAnnotationBlock($annotations): AbstractComponent
107109
{
108-
return $this->addAnnotationBlockElement(new PhpAnnotationBlockElement(is_array($annotations) ? $annotations : array(
110+
return $this->addAnnotationBlockElement(new PhpAnnotationBlockElement(is_array($annotations) ? $annotations : [
109111
$annotations,
110-
)));
112+
]));
111113
}
112114
}
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace WsdlToPhp\PhpGenerator\Component;
46

5-
interface GenerableInterface
7+
interface GenerateableInterface
68
{
79
/**
810
* @var string
@@ -12,5 +14,5 @@ interface GenerableInterface
1214
* Must return the strict representation for the current element
1315
* @return string
1416
*/
15-
public function toString();
17+
public function toString(): string;
1618
}

0 commit comments

Comments
 (0)