Skip to content

Commit 2aa34ae

Browse files
committed
first shot at php 7.2
1 parent 5a561df commit 2aa34ae

File tree

78 files changed

+536
-424
lines changed

Some content is hidden

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

78 files changed

+536
-424
lines changed

.project

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
</buildSpec>
3434
<natures>
3535
<nature>org.eclipse.php.core.PHPNature</nature>
36-
<nature>com.dubture.composer.core.composerNature</nature>
3736
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
3837
</natures>
3938
</projectDescription>

.settings/org.eclipse.php.core.prefs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
eclipse.preferences.version=1
2-
phpVersion=php5.6
2+
phpVersion=php7.2
33
useShortTags=false
4+
use_asp_tags_as_php=false

.settings/org.eclipse.php.ui.prefs

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.php.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates/>
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<faceted-project>
33
<installed facet="php.core.component" version="1"/>
4-
<installed facet="php.component" version="7.1"/>
54
<installed facet="php.composer.component" version="1"/>
5+
<installed facet="php.component" version="7.2"/>
66
</faceted-project>

.travis.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@ language: php
33
dist: trusty
44

55
php:
6-
- 5.6
7-
- 7.0
8-
- 7.1
96
- 7.2
7+
- 7.3
108
# - hhvm # broken with nikic/php-parser
119

1210
install:

composer.json

+4-5
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,17 @@
2525
}
2626
},
2727
"require" : {
28-
"php" : ">=5.6",
28+
"php" : ">=7.2",
2929
"gossi/docblock" : "~1",
3030
"gossi/php-code-profiles" : "dev-master",
3131
"gossi/php-code-formatter" : "dev-master",
32-
"symfony/options-resolver" : "^4|^3",
32+
"symfony/options-resolver" : "^4.1.7",
3333
"phootwork/file" : "~0",
3434
"phootwork/tokenizer" : "~0",
35-
"nikic/php-parser" : "^4|^3|^2|^1"
35+
"nikic/php-parser" : "^4.1.0"
3636
},
3737
"require-dev" : {
38-
"phpunit/phpunit" : "^5.7",
39-
"sami/sami" : "^4|^3"
38+
"phpunit/phpunit" : "^7.4.4"
4039
},
4140
"scripts" : {
4241
"test" : "phpunit",

phpunit.xml.dist

-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
convertWarningsToExceptions="true"
99
processIsolation="false"
1010
stopOnFailure="false"
11-
syntaxCheck="false"
1211
bootstrap="vendor/autoload.php"
1312
>
1413
<testsuites>
@@ -18,10 +17,6 @@
1817
</testsuites>
1918

2019
<filter>
21-
<blacklist>
22-
<directory>tests/</directory>
23-
<directory>vendor/</directory>
24-
</blacklist>
2520
<whitelist processUncoveredFilesFromWhitelist="true">
2621
<directory suffix=".php">src/</directory>
2722
</whitelist>

src/model/AbstractModel.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<?php
2+
declare(strict_types=1);
3+
24
namespace gossi\codegen\model;
35

46
/**
@@ -16,7 +18,7 @@ abstract class AbstractModel {
1618
*
1719
* @return string
1820
*/
19-
public function getDescription() {
21+
public function getDescription(): ?string {
2022
return $this->description;
2123
}
2224

src/model/AbstractPhpMember.php

+11-9
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17+
declare(strict_types=1);
18+
1719
namespace gossi\codegen\model;
1820

1921
use gossi\codegen\model\parts\DocblockPart;
@@ -70,7 +72,7 @@ abstract class AbstractPhpMember extends AbstractModel implements DocblockInterf
7072
*
7173
* @param string $name the name of the member
7274
*/
73-
public function __construct($name) {
75+
public function __construct(string $name) {
7476
$this->setName($name);
7577
$this->docblock = new Docblock();
7678
}
@@ -84,7 +86,7 @@ public function __construct($name) {
8486
* @param string $visibility the new visibility
8587
* @return $this
8688
*/
87-
public function setVisibility($visibility) {
89+
public function setVisibility(string $visibility) {
8890
if ($visibility !== self::VISIBILITY_PRIVATE
8991
&& $visibility !== self::VISIBILITY_PROTECTED
9092
&& $visibility !== self::VISIBILITY_PUBLIC) {
@@ -101,18 +103,18 @@ public function setVisibility($visibility) {
101103
*
102104
* @return string the visibility
103105
*/
104-
public function getVisibility() {
106+
public function getVisibility(): string {
105107
return $this->visibility;
106108
}
107109

108110
/**
109111
* Sets whether or not this member is static
110112
*
111-
* @param bool $bool
113+
* @param bool $static
112114
* @return $this
113115
*/
114-
public function setStatic($bool) {
115-
$this->static = (boolean) $bool;
116+
public function setStatic(bool $static) {
117+
$this->static = $static;
116118

117119
return $this;
118120
}
@@ -122,7 +124,7 @@ public function setStatic($bool) {
122124
*
123125
* @return bool `true` if static and `false` if not
124126
*/
125-
public function isStatic() {
127+
public function isStatic(): bool {
126128
return $this->static;
127129
}
128130

@@ -133,7 +135,7 @@ public function isStatic() {
133135
* @param AbstractPhpStruct|null $parent
134136
* @return $this
135137
*/
136-
public function setParent($parent) {
138+
public function setParent(?AbstractPhpStruct $parent) {
137139
$this->parent = $parent;
138140
return $this;
139141
}
@@ -144,7 +146,7 @@ public function setParent($parent) {
144146
* @internal
145147
* @return AbstractPhpStruct
146148
*/
147-
public function getParent() {
149+
public function getParent(): ?AbstractPhpStruct {
148150
return $this->parent;
149151
}
150152
}

src/model/AbstractPhpStruct.php

+21-19
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17+
declare(strict_types=1);
18+
1719
namespace gossi\codegen\model;
1820

1921
use gossi\codegen\model\parts\DocblockPart;
@@ -50,7 +52,7 @@ abstract class AbstractPhpStruct extends AbstractModel implements NamespaceInter
5052
* @param string $name the fqcn
5153
* @return static
5254
*/
53-
public static function create($name = null) {
55+
public static function create(?string $name = null) {
5456
return new static($name);
5557
}
5658

@@ -59,7 +61,7 @@ public static function create($name = null) {
5961
*
6062
* @param string $name the fqcn
6163
*/
62-
public function __construct($name = null) {
64+
public function __construct(?string $name = null) {
6365
$this->setQualifiedName($name);
6466
$this->docblock = new Docblock();
6567
$this->useStatements = new Map();
@@ -85,7 +87,7 @@ public function setRequiredFiles(array $files) {
8587
* @param string $file
8688
* @return $this
8789
*/
88-
public function addRequiredFile($file) {
90+
public function addRequiredFile(string $file) {
8991
$this->requiredFiles->add($file);
9092

9193
return $this;
@@ -96,7 +98,7 @@ public function addRequiredFile($file) {
9698
*
9799
* @return Set collection of filenames
98100
*/
99-
public function getRequiredFiles() {
101+
public function getRequiredFiles(): Set {
100102
return $this->requiredFiles;
101103
}
102104

@@ -124,7 +126,7 @@ public function setUseStatements(array $useStatements) {
124126
* @param null|string $alias
125127
* @return $this
126128
*/
127-
public function addUseStatement($qualifiedName, $alias = null) {
129+
public function addUseStatement(string $qualifiedName, string $alias = null) {
128130
if (!is_string($alias)) {
129131
if (false === strpos($qualifiedName, '\\')) {
130132
$alias = $qualifiedName;
@@ -137,15 +139,15 @@ public function addUseStatement($qualifiedName, $alias = null) {
137139

138140
return $this;
139141
}
140-
142+
141143
/**
142144
* Clears all use statements
143-
*
145+
*
144146
* @return $this
145147
*/
146148
public function clearUseStatements() {
147149
$this->useStatements->clear();
148-
150+
149151
return $this;
150152
}
151153

@@ -155,8 +157,8 @@ public function clearUseStatements() {
155157
* @param ... use statements multiple qualified names
156158
* @return $this
157159
*/
158-
public function declareUses() {
159-
foreach (func_get_args() as $name) {
160+
public function declareUses(string ...$uses) {
161+
foreach ($uses as $name) {
160162
$this->declareUse($name);
161163
}
162164
return $this;
@@ -173,7 +175,7 @@ public function declareUses() {
173175
* @param null|string $alias
174176
* @return string the used alias
175177
*/
176-
public function declareUse($qualifiedName, $alias = null) {
178+
public function declareUse(string $qualifiedName, string $alias = null) {
177179
$qualifiedName = trim($qualifiedName, '\\');
178180
if (!$this->hasUseStatement($qualifiedName)) {
179181
$this->addUseStatement($qualifiedName, $alias);
@@ -187,7 +189,7 @@ public function declareUse($qualifiedName, $alias = null) {
187189
* @param string $qualifiedName
188190
* @return bool
189191
*/
190-
public function hasUseStatement($qualifiedName) {
192+
public function hasUseStatement(string $qualifiedName): bool {
191193
return $this->useStatements->contains($qualifiedName);
192194
}
193195

@@ -197,7 +199,7 @@ public function hasUseStatement($qualifiedName) {
197199
* @param string $qualifiedName
198200
* @return string the alias
199201
*/
200-
public function getUseAlias($qualifiedName) {
202+
public function getUseAlias(string $qualifiedName): string {
201203
return $this->useStatements->getKey($qualifiedName);
202204
}
203205

@@ -207,7 +209,7 @@ public function getUseAlias($qualifiedName) {
207209
* @param string $qualifiedName
208210
* @return $this
209211
*/
210-
public function removeUseStatement($qualifiedName) {
212+
public function removeUseStatement(string $qualifiedName) {
211213
$this->useStatements->remove($this->useStatements->getKey($qualifiedName));
212214
return $this;
213215
}
@@ -217,7 +219,7 @@ public function removeUseStatement($qualifiedName) {
217219
*
218220
* @return Map collection of use statements
219221
*/
220-
public function getUseStatements() {
222+
public function getUseStatements(): Map {
221223
return $this->useStatements;
222224
}
223225

@@ -281,7 +283,7 @@ public function removeMethod($nameOrMethod) {
281283
* @param string|PhpMethod $nameOrMethod method name or Method instance
282284
* @return bool `true` if it exists and `false` if not
283285
*/
284-
public function hasMethod($nameOrMethod) {
286+
public function hasMethod($nameOrMethod): bool {
285287
if ($nameOrMethod instanceof PhpMethod) {
286288
$nameOrMethod = $nameOrMethod->getName();
287289
}
@@ -296,7 +298,7 @@ public function hasMethod($nameOrMethod) {
296298
* @throws \InvalidArgumentException if the method cannot be found
297299
* @return PhpMethod
298300
*/
299-
public function getMethod($nameOrMethod) {
301+
public function getMethod($nameOrMethod): PhpMethod {
300302
if ($nameOrMethod instanceof PhpMethod) {
301303
$nameOrMethod = $nameOrMethod->getName();
302304
}
@@ -313,7 +315,7 @@ public function getMethod($nameOrMethod) {
313315
*
314316
* @return Map collection of methods
315317
*/
316-
public function getMethods() {
318+
public function getMethods(): Map {
317319
return $this->methods;
318320
}
319321

@@ -322,7 +324,7 @@ public function getMethods() {
322324
*
323325
* @return Set
324326
*/
325-
public function getMethodNames() {
327+
public function getMethodNames(): Set {
326328
return $this->methods->keys();
327329
}
328330

src/model/ConstantsInterface.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<?php
2+
declare(strict_types=1);
3+
24
namespace gossi\codegen\model;
35

46
/**
@@ -25,7 +27,7 @@ public function setConstants(array $constants);
2527
* @param string $value
2628
* @return $this
2729
*/
28-
public function setConstant($nameOrConstant, $value = null);
30+
public function setConstant($nameOrConstant, string $value = null, bool $isExpression = false);
2931

3032
/**
3133
* Removes a constant

src/model/DocblockInterface.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<?php
2+
declare(strict_types=1);
3+
24
namespace gossi\codegen\model;
35

46
use gossi\docblock\Docblock;
@@ -25,8 +27,8 @@ public function setDocblock($doc);
2527
*
2628
* @return Docblock
2729
*/
28-
public function getDocblock();
29-
30+
public function getDocblock(): Docblock;
31+
3032
/**
3133
* Generates a docblock from provided information
3234
*

src/model/GenerateableInterface.php

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<?php
2+
declare(strict_types=1);
3+
24
namespace gossi\codegen\model;
35

46
/**

src/model/NamespaceInterface.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<?php
2+
declare(strict_types=1);
3+
24
namespace gossi\codegen\model;
35

46
/**
@@ -14,12 +16,12 @@ interface NamespaceInterface {
1416
* @param string $namespace
1517
* @return $this
1618
*/
17-
public function setNamespace($namespace);
19+
public function setNamespace(string $namespace);
1820

1921
/**
2022
* Returns the namespace
2123
*
2224
* @return string
2325
*/
24-
public function getNamespace();
26+
public function getNamespace(): ?string;
2527
}

0 commit comments

Comments
 (0)