Skip to content

Commit

Permalink
Prepare for phpstan level 3.
Browse files Browse the repository at this point in the history
  • Loading branch information
dereuromark committed Jul 20, 2020
1 parent 70ca5a2 commit 02c6031
Show file tree
Hide file tree
Showing 50 changed files with 282 additions and 203 deletions.
10 changes: 0 additions & 10 deletions phpstan-baseline.neon

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
includes:
- phpstan-baseline.neon
parameters:
level: 2
level: 3
paths:
- '%rootDir%/../../../src/'
excludes_analyse:
Expand Down
2 changes: 1 addition & 1 deletion src/Propel/Common/Config/ConfigurationManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function get()
* It ca be useful to get, in example, only 'generator' values.
*
* @param string $section the section to be returned
* @return array
* @return array|null
*/
public function getSection($section)
{
Expand Down
15 changes: 7 additions & 8 deletions src/Propel/Common/Util/SetColumnConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,13 @@ class SetColumnConverter
*
* @param mixed $val
* @param array $valueSet
* @return int|null
* @return string|int
*
* @throws SetColumnConverterException
*/
public static function convertToInt($val, array $valueSet)
{
if ($val === null) {

return 0;
}
if (!is_array($val)) {
Expand All @@ -44,24 +43,24 @@ public static function convertToInt($val, array $valueSet)
}
$bitValueArr[array_search($value, $valueSet)] = '1';
}

return base_convert(implode(array_reverse($bitValueArr)), 2, 10);
}

/**
* Converts set column integer value to corresponding array.
*
* Converts set column integer value to corresponding array.
*
* @param mixed $val
* @param array $valueSet
*
*
* @return array
*
* @throws SetColumnConverterException
*/
public static function convertIntToArray($val, array $valueSet)
{
if ($val === null) {

return [];
}
$bitValueArr = array_reverse(str_split(base_convert($val, 10, 2)));
Expand All @@ -76,4 +75,4 @@ public static function convertIntToArray($val, array $valueSet)
}
return $valueArr;
}
}
}
80 changes: 56 additions & 24 deletions src/Propel/Generator/Builder/DataModelBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,43 +59,43 @@ abstract class DataModelBuilder

/**
* Object builder class for current table.
* @var DataModelBuilder
* @var ObjectBuilder
*/
private $objectBuilder;

/**
* Stub Object builder class for current table.
* @var DataModelBuilder
* @var ObjectBuilder
*/
private $stubObjectBuilder;

/**
* Query builder class for current table.
* @var DataModelBuilder
* @var ObjectBuilder
*/
private $queryBuilder;

/**
* Stub Query builder class for current table.
* @var DataModelBuilder
* @var ObjectBuilder
*/
private $stubQueryBuilder;

/**
* TableMap builder class for current table.
* @var DataModelBuilder
* @var TableMapBuilder
*/
protected $tablemapBuilder;

/**
* Stub Interface builder class for current table.
* @var DataModelBuilder
* @var ObjectBuilder
*/
private $interfaceBuilder;

/**
* Stub child object for current table.
* @var DataModelBuilder
* @var MultiExtendObjectBuilder
*/
private $multiExtendObjectBuilder;

Expand Down Expand Up @@ -140,7 +140,9 @@ public function getPluralizer()
public function getObjectBuilder()
{
if (!isset($this->objectBuilder)) {
$this->objectBuilder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'object');
/** @var ObjectBuilder $builder */
$builder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'object');
$this->objectBuilder = $builder;
}

return $this->objectBuilder;
Expand All @@ -153,7 +155,9 @@ public function getObjectBuilder()
public function getStubObjectBuilder()
{
if (!isset($this->stubObjectBuilder)) {
$this->stubObjectBuilder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'objectstub');
/** @var ObjectBuilder $builder */
$builder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'objectstub');
$this->stubObjectBuilder = $builder;
}

return $this->stubObjectBuilder;
Expand All @@ -166,7 +170,9 @@ public function getStubObjectBuilder()
public function getQueryBuilder()
{
if (!isset($this->queryBuilder)) {
$this->queryBuilder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'query');
/** @var ObjectBuilder $builder */
$builder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'query');
$this->queryBuilder = $builder;
}

return $this->queryBuilder;
Expand All @@ -179,7 +185,9 @@ public function getQueryBuilder()
public function getStubQueryBuilder()
{
if (!isset($this->stubQueryBuilder)) {
$this->stubQueryBuilder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'querystub');
/** @var ObjectBuilder $builder */
$builder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'querystub');
$this->stubQueryBuilder = $builder;
}

return $this->stubQueryBuilder;
Expand All @@ -192,7 +200,9 @@ public function getStubQueryBuilder()
public function getTableMapBuilder()
{
if (!isset($this->tablemapBuilder)) {
$this->tablemapBuilder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'tablemap');
/** @var TableMapBuilder $builder */
$builder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'tablemap');
$this->tablemapBuilder = $builder;
}

return $this->tablemapBuilder;
Expand All @@ -205,7 +215,9 @@ public function getTableMapBuilder()
public function getInterfaceBuilder()
{
if (!isset($this->interfaceBuilder)) {
$this->interfaceBuilder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'interface');
/** @var ObjectBuilder $builder */
$builder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'interface');
$this->interfaceBuilder = $builder;
}

return $this->interfaceBuilder;
Expand All @@ -218,7 +230,9 @@ public function getInterfaceBuilder()
public function getMultiExtendObjectBuilder()
{
if (!isset($this->multiExtendObjectBuilder)) {
$this->multiExtendObjectBuilder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'objectmultiextend');
/** @var MultiExtendObjectBuilder $builder */
$builder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'objectmultiextend');
$this->multiExtendObjectBuilder= $builder;
}

return $this->multiExtendObjectBuilder;
Expand Down Expand Up @@ -251,7 +265,10 @@ public function getNewBuilder(Table $table, $classname)
*/
public function getNewObjectBuilder(Table $table)
{
return $this->getGeneratorConfig()->getConfiguredBuilder($table, 'object');
/** @var ObjectBuilder $builder */
$builder = $this->getGeneratorConfig()->getConfiguredBuilder($table, 'object');

return $builder;
}

/**
Expand All @@ -265,7 +282,10 @@ public function getNewObjectBuilder(Table $table)
*/
public function getNewStubObjectBuilder(Table $table)
{
return $this->getGeneratorConfig()->getConfiguredBuilder($table, 'objectstub');
/** @var ObjectBuilder $builder */
$builder = $this->getGeneratorConfig()->getConfiguredBuilder($table, 'objectstub');

return $builder;
}

/**
Expand All @@ -279,7 +299,10 @@ public function getNewStubObjectBuilder(Table $table)
*/
public function getNewQueryBuilder(Table $table)
{
return $this->getGeneratorConfig()->getConfiguredBuilder($table, 'query');
/** @var QueryBuilder $builder */
$builder = $this->getGeneratorConfig()->getConfiguredBuilder($table, 'query');

return $builder;
}

/**
Expand All @@ -293,14 +316,17 @@ public function getNewQueryBuilder(Table $table)
*/
public function getNewStubQueryBuilder(Table $table)
{
return $this->getGeneratorConfig()->getConfiguredBuilder($table, 'querystub');
/** @var QueryBuilder $builder */
$builder = $this->getGeneratorConfig()->getConfiguredBuilder($table, 'querystub');

return $builder;
}

/**
* Returns new Query Inheritance builder class for this table.
*
* @param Inheritance $child
* @return ObjectBuilder
* @return QueryInheritanceBuilder
*/
public function getNewQueryInheritanceBuilder(Inheritance $child)
{
Expand All @@ -315,7 +341,7 @@ public function getNewQueryInheritanceBuilder(Inheritance $child)
* Returns new stub Query Inheritance builder class for this table.
*
* @param Inheritance $child
* @return ObjectBuilder
* @return QueryInheritanceBuilder
*/
public function getNewStubQueryInheritanceBuilder(Inheritance $child)
{
Expand All @@ -328,11 +354,17 @@ public function getNewStubQueryInheritanceBuilder(Inheritance $child)

/**
* Returns new stub Query Inheritance builder class for this table.
* @return TableMapBuilder
*
* @param \Propel\Generator\Model\Table $table
*
* @return \Propel\Generator\Builder\Om\TableMapBuilder
*/
public function getNewTableMapBuilder(Table $table)
{
return $this->getGeneratorConfig()->getConfiguredBuilder($table, 'tablemap');
/** @var \Propel\Generator\Builder\Om\TableMapBuilder $builder */
$builder = $this->getGeneratorConfig()->getConfiguredBuilder($table, 'tablemap');

return $builder;
}

/**
Expand All @@ -355,15 +387,15 @@ public function getGeneratorConfig()
* <code>'database.adapter.mysql.tableType</code>
*
* @param string $name
* @return string
* @return string|null
*/
public function getBuildProperty($name)
{
if ($this->getGeneratorConfig()) {
return $this->getGeneratorConfig()->getConfigProperty($name);
}

return null; // just to be explicit
return null;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ protected function hasDefaultValues()
* @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave"
* @return boolean
*/
public function hasBehaviorModifier($hookName, $modifier = null)
public function hasBehaviorModifier($hookName, $modifier = '')
{
return parent::hasBehaviorModifier($hookName, 'ObjectBuilderModifier');
}
Expand Down
2 changes: 1 addition & 1 deletion src/Propel/Generator/Builder/Om/ExtensionQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ protected function addClassClose(&$script)
* @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave"
* @return boolean
*/
public function hasBehaviorModifier($hookName, $modifier = null)
public function hasBehaviorModifier($hookName, $modifier = '')
{
return parent::hasBehaviorModifier($hookName, 'QueryBuilderModifier');
}
Expand Down
2 changes: 1 addition & 1 deletion src/Propel/Generator/Builder/Om/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -1714,7 +1714,7 @@ protected function basePostUpdate(\$affectedRows, ConnectionInterface \$con)
* @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave"
* @return boolean
*/
public function hasBehaviorModifier($hookName, $modifier = null)
public function hasBehaviorModifier($hookName, $modifier = '')
{
return parent::hasBehaviorModifier($hookName, 'QueryBuilderModifier');
}
Expand Down
4 changes: 2 additions & 2 deletions src/Propel/Generator/Builder/Om/TableMapBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -733,10 +733,10 @@ public function addClearRelatedInstancePool()
/**
* Checks whether any registered behavior on that table has a modifier for a hook
* @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave"
* @param null $modifier
* @param string $modifier
* @return boolean
*/
public function hasBehaviorModifier($hookName, $modifier = null)
public function hasBehaviorModifier($hookName, $modifier = '')
{
return parent::hasBehaviorModifier($hookName, 'TableMapBuilderModifier');
}
Expand Down
9 changes: 5 additions & 4 deletions src/Propel/Generator/Builder/Util/SchemaReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,13 @@ public function setGeneratorConfig(GeneratorConfigInterface $generatorConfig)
* populated Schema structure.
*
* @param string $xmlFile The input file to parse.
* @return Schema populated by <code>xmlFile</code>.
* @return Schema|null populated by <code>xmlFile</code>.
*/
public function parseFile($xmlFile)
{
// we don't want infinite recursion
if ($this->isAlreadyParsed($xmlFile)) {
return;
return null;
}

return $this->parseString(file_get_contents($xmlFile), $xmlFile);
Expand All @@ -128,14 +128,15 @@ public function parseFile($xmlFile)
*
* @param string $xmlString The input string to parse.
* @param string $xmlFile The input file name.
* @return Schema
* @return Schema|null
*/
public function parseString($xmlString, $xmlFile = null)
{
// we don't want infinite recursion
if ($this->isAlreadyParsed($xmlFile)) {
return;
return null;
}

// store current schema file path
$this->schemasTagsStack[$xmlFile] = [];
$this->currentXmlFile = $xmlFile;
Expand Down
Loading

0 comments on commit 02c6031

Please sign in to comment.