Skip to content

Commit 4e2f32f

Browse files
authored
Merge pull request #1632 from spryker/bugfix/phpstan-level5
Bugfix/phpstan level5
2 parents 77bd40b + 48a88b9 commit 4e2f32f

File tree

192 files changed

+4466
-1038
lines changed

Some content is hidden

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

192 files changed

+4466
-1038
lines changed

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
"require-dev": {
3030
"monolog/monolog": "^1.3",
3131
"phpstan/phpstan": "^0.12.4",
32-
"phpunit/phpunit": "^7.5.15"
32+
"phpunit/phpunit": "^7.5.15",
33+
"spryker/code-sniffer": "^0.15.4"
3334
},
3435
"suggest": {
3536
"monolog/monolog": "The recommended logging library to use with Propel."
@@ -43,6 +44,8 @@
4344
"bin/propel"
4445
],
4546
"scripts": {
47+
"cs-check": "phpcs -p -s --standard=vendor/spryker/code-sniffer/Spryker/ruleset.xml src/",
48+
"cs-fix": "phpcbf -p --standard=vendor/spryker/code-sniffer/Spryker/ruleset.xml src/",
4649
"stan": [
4750
"vendor/bin/phpstan analyze"
4851
]

phpstan-baseline.neon

Lines changed: 25 additions & 390 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phpstan.neon

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ includes:
22
- phpstan-baseline.neon
33
parameters:
44
level: 5
5+
checkGenericClassInNonGenericObjectType: false
6+
checkMissingIterableValueType: false
57
paths:
68
- '%rootDir%/../../../src/'
79
excludes_analyse:
@@ -20,4 +22,7 @@ parameters:
2022
ignoreErrors:
2123
- '#Call to an undefined method .+Collection::.+Array\(\)#'
2224
- '#Class .+TreeBuilder constructor invoked with 0 parameters, 1-3 required#'
25+
-
26+
message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\TreeBuilder\\:\\:root\\(\\)\\.$#"
27+
path: src/Propel/Common/Config/PropelConfiguration.php
2328
- '#PHPDoc tag @throws with type .+FileLoaderLoadException|.+LoaderLoadException is not subtype of Throwable#'

src/Propel/Common/Config/ConfigurationManager.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ public function getConnectionParametersArray($section = 'runtime')
134134
*
135135
* @param string|null $fileName Configuration file name or directory in which resides the configuration file.
136136
* @param array|null $extraConf Array of configuration properties, to be merged with those loaded from file.
137+
* @return void
137138
*/
138139
protected function load($fileName, $extraConf)
139140
{
@@ -180,11 +181,12 @@ protected function load($fileName, $extraConf)
180181
* @param array $extraConf Extra configuration to merge before processing. It's useful when a child class overwrite
181182
* the constructor to pass a built-in array of configuration, without load it from file. I.e.
182183
* Propel\Generator\Config\QuickGeneratorConfig class.
184+
* @return void
183185
*/
184186
protected function process($extraConf = null)
185187
{
186188
if (null === $extraConf && count($this->config) <= 0) {
187-
return null;
189+
return;
188190
}
189191

190192
$processor = new Processor();
@@ -278,6 +280,8 @@ private function getDirs($fileName)
278280

279281
/**
280282
* Remove empty `slaves` array from configured connections.
283+
*
284+
* @return void
281285
*/
282286
private function cleanupSlaveConnections()
283287
{
@@ -291,6 +295,8 @@ private function cleanupSlaveConnections()
291295
/**
292296
* If not defined, set `runtime` and `generator` connections, based on `database.connections` property.
293297
* Check if runtime and generator connections are correctly defined.
298+
*
299+
* @return void
294300
*/
295301
private function cleanupConnections()
296302
{

src/Propel/Common/Config/Loader/FileLoader.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ abstract class FileLoader extends BaseFileLoader
4646
/**
4747
* Constructor.
4848
*
49-
* @param FileLocatorInterface $locator A FileLocator instance
49+
* @param FileLocatorInterface|null $locator A FileLocator instance
5050
*/
5151
public function __construct(FileLocatorInterface $locator = null)
5252
{
@@ -61,11 +61,12 @@ public function __construct(FileLocatorInterface $locator = null)
6161
* Replaces parameter placeholders (%name%) by their values for all parameters.
6262
*
6363
* @param array $configuration The configuration array to resolve
64+
* @return array
6465
*/
6566
public function resolveParams(array $configuration)
6667
{
6768
if ($this->resolved) {
68-
return;
69+
return [];
6970
}
7071

7172
$this->config = $configuration;
@@ -84,7 +85,7 @@ public function resolveParams(array $configuration)
8485
/**
8586
* Get the pathof a given resource
8687
*
87-
* @param mixed $file The resource
88+
* @param string $file The resource
8889
*
8990
* @return array|string
9091
* @throws \InvalidArgumentException If the file is not found
@@ -106,6 +107,7 @@ protected function getPath($file)
106107
*
107108
* @param string|string[] $ext An extension or an array of extensions
108109
* @param string|false $resource A resource
110+
* @return bool
109111
*/
110112
protected function checkSupports($ext, $resource)
111113
{
@@ -140,9 +142,12 @@ protected function checkSupports($ext, $resource)
140142
return $supported;
141143
}
142144

145+
/**
146+
* @return bool
147+
*/
143148
private function isResolved()
144149
{
145-
return ($this->resolved);
150+
return $this->resolved;
146151
}
147152

148153
/**

src/Propel/Common/Config/Loader/IniFileLoader.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,10 @@ public function supports($resource, $type = null)
4747
/**
4848
* Loads a resource, merge it with the default configuration array and resolve its parameters.
4949
*
50-
* @param mixed $file The resource
51-
* @param string $type The resource type
50+
* @param string $file The resource
51+
* @param string|null $type The resource type
5252
* @return array The configuration array
5353
*
54-
* @return array
55-
*
5654
* @throws \InvalidArgumentException if configuration file not found
5755
* @throws \Propel\Common\Config\Exception\InvalidArgumentException When ini file is not valid
5856
* @throws \Propel\Common\Config\Exception\InputOutputException if configuration file is not readable
@@ -143,6 +141,8 @@ private function parseSection(array $section)
143141
* @param array $config
144142
*
145143
* @throws \Propel\Common\Config\Exception\IniParseException
144+
*
145+
* @return void
146146
*/
147147
private function parseKey($key, $value, array &$config)
148148
{

src/Propel/Common/Config/Loader/JsonFileLoader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ class JsonFileLoader extends FileLoader
2222
/**
2323
* Loads an Json file.
2424
*
25-
* @param mixed $file The resource
26-
* @param string $type The resource type
25+
* @param string $file The resource
26+
* @param string|null $type The resource type
2727
*
2828
* @return array
2929
*

src/Propel/Common/Config/Loader/PhpFileLoader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ class PhpFileLoader extends FileLoader
3131
/**
3232
* Loads a PHP file.
3333
*
34-
* @param mixed $file The resource
35-
* @param string $type The resource type
34+
* @param string $file The resource
35+
* @param string|null $type The resource type
3636
*
3737
* @return array
3838
*

src/Propel/Common/Config/Loader/XmlFileLoader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ class XmlFileLoader extends FileLoader
2222
/**
2323
* Loads an Xml file.
2424
*
25-
* @param mixed $file The resource
26-
* @param string $type The resource type
25+
* @param string $file The resource
26+
* @param string|null $type The resource type
2727
*
2828
* @return array
2929
*

src/Propel/Common/Config/Loader/YamlFileLoader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ class YamlFileLoader extends FileLoader
2424
/**
2525
* Loads a Yaml file.
2626
*
27-
* @param mixed $file The resource
28-
* @param string $type The resource type
27+
* @param string $file The resource
28+
* @param string|null $type The resource type
2929
*
3030
* @return array
3131
*

0 commit comments

Comments
 (0)