Skip to content

Commit 724e515

Browse files
committed
enable strict_types in generator
(Continuing with pulling the changes from shish/safe into tcm/safe in small hopefully easy-to-review chunks)
1 parent d43727a commit 724e515

32 files changed

+98
-96
lines changed

generator/src/ComposerJsonEditor.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
declare(strict_types=1);
34

45
namespace Safe;
56

generator/src/DeprecateCommand.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
declare(strict_types=1);
34

45
namespace Safe;
56

@@ -23,7 +24,7 @@ protected function configure(): void
2324
;
2425
}
2526

26-
protected function execute(InputInterface $input, OutputInterface $output)
27+
protected function execute(InputInterface $input, OutputInterface $output): int
2728
{
2829
/** @var string $moduleName */
2930
$moduleName = $input->getArgument('module');

generator/src/DocPage.php

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

3+
declare(strict_types=1);
4+
35
namespace Safe;
46

57
use function explode;
@@ -236,8 +238,6 @@ public function getMethodSynopsis(): array
236238

237239
/**
238240
* Loads the XML file, resolving all DTD declared entities.
239-
*
240-
* @return \SimpleXMLElement
241241
*/
242242
public function loadAndResolveFile(): \SimpleXMLElement
243243
{
@@ -268,8 +268,6 @@ public function loadAndResolveFile(): \SimpleXMLElement
268268

269269
/**
270270
* Returns the module name in Camelcase.
271-
*
272-
* @return string
273271
*/
274272
public function getModule(): string
275273
{

generator/src/EmptyTypeException.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
declare(strict_types=1);
34

45
namespace Safe;
56

generator/src/FileCreator.php

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

3+
declare(strict_types=1);
4+
35
namespace Safe;
46

57
use Rector\Config\RectorConfig;
@@ -14,7 +16,6 @@ class FileCreator
1416
* This function generate an improved php lib function in a php file
1517
*
1618
* @param Method[] $functions
17-
* @param string $path
1819
*/
1920
public function generatePhpFile(array $functions, string $path): void
2021
{
@@ -64,7 +65,6 @@ private function getFunctionsNameList(array $functions): array
6465
* This function generate a PHP file containing the list of functions we can handle.
6566
*
6667
* @param Method[] $functions
67-
* @param string $path
6868
*/
6969
public function generateFunctionsList(array $functions, string $path): void
7070
{
@@ -86,7 +86,6 @@ public function generateFunctionsList(array $functions, string $path): void
8686
* Generates a configuration file for replacing all functions when using rector/rector.
8787
*
8888
* @param Method[] $functions
89-
* @param string $path
9089
*/
9190
public function generateRectorFile(array $functions, string $path): void
9291
{
@@ -148,9 +147,6 @@ public static function createFromPhpError(): self
148147

149148
/**
150149
* Generates the name of the exception class
151-
*
152-
* @param string $moduleName
153-
* @return string
154150
*/
155151
public static function toExceptionName(string $moduleName): string
156152
{

generator/src/GenerateCommand.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
declare(strict_types=1);
34

45
namespace Safe;
56

@@ -18,7 +19,7 @@ protected function configure(): void
1819
;
1920
}
2021

21-
protected function execute(InputInterface $input, OutputInterface $output)
22+
protected function execute(InputInterface $input, OutputInterface $output): int
2223
{
2324

2425
$this->rmGenerated();

generator/src/Method.php

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

3+
declare(strict_types=1);
4+
35
namespace Safe;
46

57
use Safe\PhpStanFunctions\PhpStanFunction;
@@ -11,35 +13,19 @@ class Method
1113
const FALSY_TYPE = 1;
1214
const NULLSY_TYPE = 2;
1315
const EMPTY_TYPE = 3;
14-
/**
15-
* @var \SimpleXMLElement
16-
*/
17-
private $functionObject;
18-
/**
19-
* @var \SimpleXMLElement
20-
*/
21-
private $rootEntity;
22-
/**
23-
* @var string
24-
*/
25-
private $moduleName;
16+
private \SimpleXMLElement $functionObject;
17+
private \SimpleXMLElement $rootEntity;
18+
private string $moduleName;
2619
/**
2720
* @var Parameter[]|null
2821
*/
29-
private $params = null;
30-
/**
31-
* @var int
32-
*/
33-
private $errorType;
22+
private ?array $params = null;
23+
private int $errorType;
3424
/**
3525
* The function prototype from the phpstan internal documentation (functionMap.php)
36-
* @var PhpStanFunction|null
37-
*/
38-
private $phpstanSignarure;
39-
/**
40-
* @var PhpStanType
4126
*/
42-
private $returnType;
27+
private ?PhpStanFunction $phpstanSignarure;
28+
private PhpStanType $returnType;
4329

4430
public function __construct(\SimpleXMLElement $_functionObject, \SimpleXMLElement $rootEntity, string $moduleName, PhpStanFunctionMapReader $phpStanFunctionMapReader, int $errorType)
4531
{
@@ -225,8 +211,6 @@ public function getModuleName(): string
225211

226212
/**
227213
* The function is overloaded if at least one parameter is optional with no default value and this parameter is not by reference.
228-
*
229-
* @return bool
230214
*/
231215
public function isOverloaded(): bool
232216
{

generator/src/Parameter.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
<?php
2+
3+
declare(strict_types=1);
4+
25
namespace Safe;
36

47
use Safe\PhpStanFunctions\PhpStanFunction;
@@ -58,8 +61,6 @@ public function isByReference(): bool
5861
/**
5962
* Some parameters can be optional with no default value. In this case, the function is "overloaded" (which is not
6063
* possible in user-land but possible in core...)
61-
*
62-
* @return bool
6364
*/
6465
public function isOptionalWithNoDefault(): bool
6566
{

generator/src/PhpStanFunctions/PhpStanFunction.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
declare(strict_types=1);
34

45
namespace Safe\PhpStanFunctions;
56

@@ -13,7 +14,7 @@ class PhpStanFunction
1314
/**
1415
* @var PhpStanParameter[]
1516
*/
16-
private $parameters = [];
17+
private array $parameters = [];
1718

1819
/**
1920
* @param string[] $signature

generator/src/PhpStanFunctions/PhpStanFunctionMapReader.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
declare(strict_types=1);
34

45
namespace Safe\PhpStanFunctions;
56

0 commit comments

Comments
 (0)