Skip to content

Commit 0839979

Browse files
authored
Merge pull request #1624 from spryker/bugfix/phpstan-lev4
Prepare for phpstan level 4
2 parents f1a1037 + 658692e commit 0839979

File tree

63 files changed

+448
-355
lines changed

Some content is hidden

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

63 files changed

+448
-355
lines changed

phpstan-baseline.neon

Lines changed: 1 addition & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Propel/Common/Config/ConfigurationManager.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class ConfigurationManager
3737
/**
3838
* Load and validate configuration values from a file.
3939
*
40-
* @param string $filename Configuration file name or directory in which resides the configuration file.
40+
* @param string|null $filename Configuration file name or directory in which resides the configuration file.
4141
* @param array $extraConf Array of configuration properties, to be merged with those loaded from file.
4242
* It's useful when passing configuration parameters from command line.
4343
*/
@@ -132,22 +132,22 @@ public function getConnectionParametersArray($section = 'runtime')
132132
* Only one configuration file is supposed to be found.
133133
* This method also looks for a '.dist' configuration file and loads it.
134134
*
135-
* @param string $fileName Configuration file name or directory in which resides the configuration file.
136-
* @param array $extraConf Array of configuration properties, to be merged with those loaded from file.
135+
* @param string|null $fileName Configuration file name or directory in which resides the configuration file.
136+
* @param array|null $extraConf Array of configuration properties, to be merged with those loaded from file.
137137
*/
138138
protected function load($fileName, $extraConf)
139139
{
140140
$dirs = $this->getDirs($fileName);
141141

142-
if ((null === $fileName) || (is_dir($fileName))) {
142+
if (!$fileName || is_dir($fileName)) {
143143
$fileName = self::CONFIG_FILE_NAME;
144144
}
145145

146146
if (null === $extraConf) {
147147
$extraConf = [];
148148
}
149149

150-
if (self::CONFIG_FILE_NAME === $fileName) {
150+
if (static::CONFIG_FILE_NAME === $fileName) {
151151
$files = $this->getFiles($dirs, $fileName);
152152
$distFiles = $this->getFiles($dirs, $fileName, true);
153153

@@ -250,18 +250,18 @@ private function loadFile($fileName)
250250
/**
251251
* Return the directories where to find the configuration file.
252252
*
253-
* @param string $fileName
253+
* @param string|null $fileName
254254
* @return array
255255
*/
256256
private function getDirs($fileName)
257257
{
258-
if (is_file($fileName)) {
258+
if ($fileName && is_file($fileName)) {
259259
return [];
260260
}
261261

262262
$currentDir = getcwd();
263263

264-
if (is_dir($fileName)) {
264+
if ($fileName && is_dir($fileName)) {
265265
$currentDir = $fileName;
266266
}
267267

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -124,20 +124,20 @@ protected function checkSupports($ext, $resource)
124124
return ($ext === $extension);
125125
}
126126

127-
if (is_array($ext)) {
128-
$supported = false;
127+
if (!is_array($ext)) {
128+
throw new \InvalidArgumentException('$ext must be string or string[]');
129+
}
129130

130-
foreach ($ext as $value) {
131-
if ($value === $extension) {
132-
$supported = true;
133-
break;
134-
}
135-
}
131+
$supported = false;
136132

137-
return $supported;
133+
foreach ($ext as $value) {
134+
if ($value === $extension) {
135+
$supported = true;
136+
break;
137+
}
138138
}
139139

140-
return false;
140+
return $supported;
141141
}
142142

143143
private function isResolved()
@@ -279,7 +279,7 @@ private function get($property_key)
279279
* Scan recursively an array to find a value of a given key.
280280
*
281281
* @param string $property_key The array key
282-
* @param array $config The array to scan
282+
* @param array|null $config The array to scan
283283
* @param boolean $found if the key was found
284284
*
285285
* @return mixed The value or null if not found

src/Propel/Generator/Behavior/Archivable/ArchivableBehavior.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ class ArchivableBehavior extends Behavior
3535
'archive_on_delete' => 'true',
3636
];
3737

38+
/**
39+
* @var Table|null
40+
*/
3841
protected $archiveTable;
3942
protected $objectBuilderModifier;
4043
protected $queryBuilderModifier;
@@ -130,7 +133,7 @@ protected function addArchiveTable()
130133
}
131134

132135
/**
133-
* @return Table
136+
* @return Table|null
134137
*/
135138
public function getArchiveTable()
136139
{

src/Propel/Generator/Behavior/Archivable/templates/objectRestoreFromArchive.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* @throws PropelException If the object has no corresponding archive.
99
*
10-
* @return $this|<?php echo $objectClassName ?> The current object (for fluent API support)
10+
* @return $this The current object (for fluent API support)
1111
*/
1212
public function restoreFromArchive(ConnectionInterface $con = null)
1313
{

src/Propel/Generator/Behavior/I18n/templates/objectRemoveTranslation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* @param string $locale Locale to use for the translation, e.g. 'fr_FR'
66
* @param ConnectionInterface $con an optional connection object
77
*
8-
* @return $this|<?php echo $objectClassName ?> The current object (for fluent API support)
8+
* @return $this The current object (for fluent API support)
99
*/
1010
public function removeTranslation($locale = '<?php echo $defaultLocale ?>', ConnectionInterface $con = null)
1111
{

src/Propel/Generator/Behavior/I18n/templates/objectSetLocale.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* @param string $locale Locale to use for the translation, e.g. 'fr_FR'
66
*
7-
* @return $this|<?php echo $objectClassName ?> The current object (for fluent API support)
7+
* @return $this The current object (for fluent API support)
88
*/
99
public function set<?php echo $localeColumnName ?>($locale = '<?php echo $defaultLocale ?>')
1010
{

src/Propel/Generator/Behavior/I18n/templates/objectSetTranslation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* @param <?php echo $i18nTablePhpName ?> $translation The translation object
66
* @param string $locale Locale to use for the translation, e.g. 'fr_FR'
77
*
8-
* @return $this|<?php echo $objectClassName ?> The current object (for fluent API support)
8+
* @return $this The current object (for fluent API support)
99
*/
1010
public function setTranslation($translation, $locale = '<?php echo $defaultLocale ?>')
1111
{

src/Propel/Generator/Behavior/I18n/templates/queryJoinWithI18n.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
77
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
88
*
9-
* @return $this|<?php echo $queryClass ?> The current query, for fluid interface
9+
* @return $this The current query, for fluid interface
1010
*/
1111
public function joinWithI18n($locale = '<?php echo $defaultLocale ?>', $joinType = Criteria::LEFT_JOIN)
1212
{

src/Propel/Generator/Behavior/Sluggable/SluggableBehavior.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class SluggableBehavior extends Behavior
2727
* @var ObjectBuilder
2828
*/
2929
private $builder;
30-
30+
3131
/**
3232
* @var array
3333
*/
@@ -63,15 +63,15 @@ public function modifyTable()
6363
}
6464
}
6565
}
66-
66+
6767
/**
6868
* Adds a unique constraint to the table to enforce uniqueness of the slug_column
6969
*
7070
* @param Table $table
7171
*/
7272
protected function addUniqueConstraint(Table $table)
7373
{
74-
$unique = new Unique($this->getColumnForParameter('slug_column'));
74+
$unique = new Unique();
7575
$unique->setName($table->getCommonName() . '_slug');
7676
$unique->addColumn($table->getColumn($this->getParameter('slug_column')));
7777
if ($this->getParameter('scope_column')) {

0 commit comments

Comments
 (0)