Skip to content

Commit 0627823

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 0627823

32 files changed

+90
-67
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: 3 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 Safe\PhpStanFunctions\PhpStanFunction;
@@ -26,14 +28,13 @@ class Method
2628
/**
2729
* @var Parameter[]|null
2830
*/
29-
private $params = null;
3031
/**
3132
* @var int
3233
*/
3334
private $errorType;
35+
private ?array $params = null;
3436
/**
3537
* The function prototype from the phpstan internal documentation (functionMap.php)
36-
* @var PhpStanFunction|null
3738
*/
3839
private $phpstanSignarure;
3940
/**
@@ -225,8 +226,6 @@ public function getModuleName(): string
225226

226227
/**
227228
* 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
230229
*/
231230
public function isOverloaded(): bool
232231
{

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)