From 18ab6fdeceb33fa38746c171ad5e13405a947f29 Mon Sep 17 00:00:00 2001 From: Jacob Thomason Date: Sun, 5 Dec 2021 05:36:51 -0500 Subject: [PATCH] Upgrade PHPStan --- composer.json | 2 +- phpstan-baseline.neon | 2 +- phpstan.neon | 2 +- .../Common/Config/Loader/IniFileLoader.php | 4 +- .../Common/Config/XmlToArrayConverter.php | 2 + .../AggregateMultipleColumnsBehavior.php | 4 ++ .../Generator/Builder/DataModelBuilder.php | 64 ++++++++++--------- .../Generator/Builder/Om/ClassTools.php | 6 +- .../Generator/Builder/Util/PropelTemplate.php | 2 +- .../Generator/Builder/Util/SchemaReader.php | 18 ++---- src/Propel/Generator/Model/Database.php | 2 + src/Propel/Generator/Model/Domain.php | 2 +- src/Propel/Generator/Model/MappingModel.php | 2 +- .../Generator/Model/PhpNameGenerator.php | 6 +- .../Generator/Model/ScopedMappingModel.php | 16 ++--- .../Generator/Platform/DefaultPlatform.php | 2 +- .../Generator/Platform/SqlitePlatform.php | 2 +- .../Generator/Reverse/PgsqlSchemaParser.php | 2 +- src/Propel/Generator/Util/BehaviorLocator.php | 8 --- src/Propel/Runtime/Collection/Collection.php | 4 +- src/Propel/Runtime/Map/TableMap.php | 30 --------- src/Propel/Runtime/Parser/CsvParser.php | 12 ++-- 22 files changed, 83 insertions(+), 111 deletions(-) diff --git a/composer.json b/composer.json index 840a1501b5..4013aef08e 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,7 @@ "ext-pdo": "*", "ext-json": "*", "monolog/monolog": "^1.3", - "phpstan/phpstan": "^0.12.97", + "phpstan/phpstan": "^1.2", "phpunit/phpunit": "^8.0.0||^9.0.0", "spryker/code-sniffer": "^0.15.6", "psalm/phar": "4.9.3", diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 94c6a561c2..aaefe29561 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1,4 +1,5 @@ parameters: + reportUnmatchedIgnoredErrors: false ignoreErrors: - message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeParentInterface\\:\\:scalarNode\\(\\)\\.$#" @@ -669,4 +670,3 @@ parameters: message: "#^Access to an undefined property Symfony\\\\Component\\\\Validator\\\\Constraint\\:\\:\\$message\\.$#" count: 2 path: src/Propel/Runtime/Validator/Constraints/UniqueValidator.php - diff --git a/phpstan.neon b/phpstan.neon index ec86b4c26c..8db4fd68bc 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -6,7 +6,7 @@ parameters: checkMissingIterableValueType: false paths: - '%rootDir%/../../../src/' - excludes_analyse: + excludePaths: - '%rootDir%/../../../src/Propel/Generator/Command/templates/*' - '%rootDir%/../../../src/Propel/Generator/Behavior/AggregateColumn/templates/*' - '%rootDir%/../../../src/Propel/Generator/Behavior/AggregateMultipleColumns/templates/*' diff --git a/src/Propel/Common/Config/Loader/IniFileLoader.php b/src/Propel/Common/Config/Loader/IniFileLoader.php index 07d0ad3ad6..6a94ec1109 100644 --- a/src/Propel/Common/Config/Loader/IniFileLoader.php +++ b/src/Propel/Common/Config/Loader/IniFileLoader.php @@ -26,7 +26,7 @@ class IniFileLoader extends FileLoader * * @var string */ - private $nestSeparator = '.'; + private string $nestSeparator = '.'; /** * Returns true if this class supports the given resource. @@ -80,6 +80,7 @@ private function parse(array $data): array foreach ($data as $section => $value) { if (is_array($value)) { + // @phpstan-ignore-next-line $sections = explode($this->nestSeparator, $section); $config = array_merge_recursive($config, $this->buildNestedSection($sections, $value)); } else { @@ -149,6 +150,7 @@ private function parseKey(string $key, $rawValue, array &$config): void $value = (float)$rawValue; } } + // @phpstan-ignore-next-line $subKeys = explode($this->nestSeparator, $key); $subConfig = &$config; $lastIndex = count($subKeys) - 1; diff --git a/src/Propel/Common/Config/XmlToArrayConverter.php b/src/Propel/Common/Config/XmlToArrayConverter.php index 3b78e5451a..63452d298e 100644 --- a/src/Propel/Common/Config/XmlToArrayConverter.php +++ b/src/Propel/Common/Config/XmlToArrayConverter.php @@ -87,6 +87,7 @@ protected static function simpleXmlToArray(SimpleXMLElement $xml): array // if it's not an array, then it was empty, thus a value/string if ($child === []) { + // @phpstan-ignore-next-line $child = static::getConvertedXmlValue($v); } @@ -104,6 +105,7 @@ protected static function simpleXmlToArray(SimpleXMLElement $xml): array if (is_string($child)) { $child = []; } + // @phpstan-ignore-next-line $child[$ak] = static::getConvertedXmlValue($av); } } diff --git a/src/Propel/Generator/Behavior/AggregateMultipleColumns/AggregateMultipleColumnsBehavior.php b/src/Propel/Generator/Behavior/AggregateMultipleColumns/AggregateMultipleColumnsBehavior.php index 51b07e7a14..91f4d191e3 100644 --- a/src/Propel/Generator/Behavior/AggregateMultipleColumns/AggregateMultipleColumnsBehavior.php +++ b/src/Propel/Generator/Behavior/AggregateMultipleColumns/AggregateMultipleColumnsBehavior.php @@ -60,6 +60,7 @@ class AggregateMultipleColumnsBehavior extends Behavior */ public static function resetInsertedAggregationNames(): void { + // @phpstan-ignore-next-line static::$insertedAggregationNames = []; } @@ -93,10 +94,13 @@ private function buildAggregationName(): string $foreignTableName = $this->getForeignTable()->getPhpName(); $baseAggregationName = 'AggregatedColumnsFrom' . $foreignTableName; $tableName = $this->getTable()->getPhpName(); + // @phpstan-ignore-next-line if (!array_key_exists($tableName, static::$insertedAggregationNames)) { + // @phpstan-ignore-next-line static::$insertedAggregationNames[$tableName] = []; } + // @phpstan-ignore-next-line $existingNames = &static::$insertedAggregationNames[$tableName]; if (!in_array($baseAggregationName, $existingNames)) { $existingNames[] = $baseAggregationName; diff --git a/src/Propel/Generator/Builder/DataModelBuilder.php b/src/Propel/Generator/Builder/DataModelBuilder.php index 65f9a39f7d..b198931595 100644 --- a/src/Propel/Generator/Builder/DataModelBuilder.php +++ b/src/Propel/Generator/Builder/DataModelBuilder.php @@ -8,6 +8,12 @@ namespace Propel\Generator\Builder; +use Propel\Common\Pluralizer\PluralizerInterface; +use Propel\Generator\Builder\Om\AbstractObjectBuilder; +use Propel\Generator\Builder\Om\AbstractOMBuilder; +use Propel\Generator\Builder\Om\MultiExtendObjectBuilder; +use Propel\Generator\Builder\Om\ObjectBuilder; +use Propel\Generator\Builder\Om\TableMapBuilder; use Propel\Generator\Config\GeneratorConfigInterface; use Propel\Generator\Model\Inheritance; use Propel\Generator\Model\Table; @@ -33,84 +39,84 @@ abstract class DataModelBuilder * * @var \Propel\Generator\Model\Table */ - private $table; + private Table $table; /** * The generator config object holding build properties, etc. * - * @var \Propel\Generator\Config\GeneratorConfigInterface + * @var \Propel\Generator\Config\GeneratorConfigInterface|null */ - private $generatorConfig; + private ?GeneratorConfigInterface $generatorConfig = null; /** * An array of warning messages that can be retrieved for display. * * @var array string[] */ - private $warnings = []; + private array $warnings = []; /** * Object builder class for current table. * - * @var \Propel\Generator\Builder\Om\ObjectBuilder + * @var \Propel\Generator\Builder\Om\ObjectBuilder|null */ - private $objectBuilder; + private ?ObjectBuilder $objectBuilder = null; /** * Stub Object builder class for current table. * - * @var \Propel\Generator\Builder\Om\ObjectBuilder + * @var \Propel\Generator\Builder\Om\AbstractObjectBuilder|null */ - private $stubObjectBuilder; + private ?AbstractObjectBuilder $stubObjectBuilder = null; /** * Query builder class for current table. * - * @var \Propel\Generator\Builder\Om\ObjectBuilder + * @var \Propel\Generator\Builder\Om\AbstractOMBuilder|null */ - private $queryBuilder; + private ?AbstractOMBuilder $queryBuilder = null; /** * Stub Query builder class for current table. * - * @var \Propel\Generator\Builder\Om\ObjectBuilder + * @var \Propel\Generator\Builder\Om\AbstractOMBuilder|null */ - private $stubQueryBuilder; + private ?AbstractOMBuilder $stubQueryBuilder = null; /** * TableMap builder class for current table. * - * @var \Propel\Generator\Builder\Om\TableMapBuilder + * @var \Propel\Generator\Builder\Om\TableMapBuilder|null */ - protected $tablemapBuilder; + protected ?TableMapBuilder $tablemapBuilder = null; /** * Stub Interface builder class for current table. * - * @var \Propel\Generator\Builder\Om\ObjectBuilder + * @var \Propel\Generator\Builder\Om\AbstractOMBuilder|null */ - private $interfaceBuilder; + private ?AbstractOMBuilder $interfaceBuilder = null; /** * Stub child object for current table. * - * @var \Propel\Generator\Builder\Om\MultiExtendObjectBuilder + * @var \Propel\Generator\Builder\Om\MultiExtendObjectBuilder|null */ - private $multiExtendObjectBuilder; + private ?MultiExtendObjectBuilder $multiExtendObjectBuilder = null; /** * The Pluralizer class to use. * - * @var \Propel\Common\Pluralizer\PluralizerInterface + * @var \Propel\Common\Pluralizer\PluralizerInterface|null */ - private $pluralizer; + private ?PluralizerInterface $pluralizer = null; /** * The platform class * * @var \Propel\Generator\Platform\PlatformInterface */ - protected $platform; + protected ?PlatformInterface $platform = null; /** * Creates new instance of DataModelBuilder subclass. @@ -155,9 +161,9 @@ public function getObjectBuilder() /** * Returns new or existing stub Object builder class for this table. * - * @return \Propel\Generator\Builder\Om\ObjectBuilder + * @return \Propel\Generator\Builder\Om\AbstractObjectBuilder|null */ - public function getStubObjectBuilder() + public function getStubObjectBuilder(): ?AbstractObjectBuilder { if (!isset($this->stubObjectBuilder)) { /** @var \Propel\Generator\Builder\Om\ObjectBuilder $builder */ @@ -171,9 +177,9 @@ public function getStubObjectBuilder() /** * Returns new or existing Query builder class for this table. * - * @return \Propel\Generator\Builder\Om\ObjectBuilder + * @return \Propel\Generator\Builder\Om\AbstractOMBuilder|null */ - public function getQueryBuilder() + public function getQueryBuilder(): ?AbstractOMBuilder { if (!isset($this->queryBuilder)) { /** @var \Propel\Generator\Builder\Om\ObjectBuilder $builder */ @@ -187,9 +193,9 @@ public function getQueryBuilder() /** * Returns new or existing stub Query builder class for this table. * - * @return \Propel\Generator\Builder\Om\ObjectBuilder + * @return \Propel\Generator\Builder\Om\AbstractOMBuilder|null */ - public function getStubQueryBuilder() + public function getStubQueryBuilder(): ?AbstractOMBuilder { if (!isset($this->stubQueryBuilder)) { /** @var \Propel\Generator\Builder\Om\ObjectBuilder $builder */ @@ -219,9 +225,9 @@ public function getTableMapBuilder() /** * Returns new or existing stub Interface builder class for this table. * - * @return \Propel\Generator\Builder\Om\ObjectBuilder + * @return \Propel\Generator\Builder\Om\AbstractOMBuilder|null */ - public function getInterfaceBuilder() + public function getInterfaceBuilder(): ?AbstractOMBuilder { if (!isset($this->interfaceBuilder)) { /** @var \Propel\Generator\Builder\Om\ObjectBuilder $builder */ diff --git a/src/Propel/Generator/Builder/Om/ClassTools.php b/src/Propel/Generator/Builder/Om/ClassTools.php index 5a37373962..6f38757e18 100644 --- a/src/Propel/Generator/Builder/Om/ClassTools.php +++ b/src/Propel/Generator/Builder/Om/ClassTools.php @@ -20,11 +20,11 @@ class ClassTools /** * Gets just classname, given a dot-path to class. * - * @param string $qualifiedName + * @param string|null $qualifiedName * - * @return string + * @return string|null */ - public static function classname($qualifiedName) + public static function classname(?string $qualifiedName): ?string { if ($qualifiedName === null) { return null; diff --git a/src/Propel/Generator/Builder/Util/PropelTemplate.php b/src/Propel/Generator/Builder/Util/PropelTemplate.php index 2d3a329f54..e33c09634f 100644 --- a/src/Propel/Generator/Builder/Util/PropelTemplate.php +++ b/src/Propel/Generator/Builder/Util/PropelTemplate.php @@ -85,7 +85,7 @@ public function render($vars = []) extract($vars); ob_start(); - ob_implicit_flush(0); + ob_implicit_flush(false); try { if ($this->templateFile !== null) { diff --git a/src/Propel/Generator/Builder/Util/SchemaReader.php b/src/Propel/Generator/Builder/Util/SchemaReader.php index aa42818071..289dcf879f 100644 --- a/src/Propel/Generator/Builder/Util/SchemaReader.php +++ b/src/Propel/Generator/Builder/Util/SchemaReader.php @@ -14,6 +14,7 @@ use Propel\Generator\Model\Schema; use Propel\Generator\Model\Unique; use Propel\Generator\Platform\PlatformInterface; +use XMLParser; /** * A class that is used to parse an input xml schema file and creates a Schema @@ -36,9 +37,9 @@ class SchemaReader private $schema; /** - * @var resource + * @var \XMLParser|null */ - private $parser; + private ?XMLParser $parser = null; /** * @var \Propel\Generator\Model\Database @@ -105,13 +106,6 @@ class SchemaReader */ private $currParameterListCollector; - /** - * @deprecated Unused. - * - * @var string - */ - private $encoding; - /** * Two-dimensional array, * first dimension is for schemas(key is the path to the schema file), @@ -126,13 +120,11 @@ class SchemaReader * * @param \Propel\Generator\Platform\PlatformInterface|null $defaultPlatform The default database platform for the application. * @param string|null $defaultPackage the default PHP package used for the om - * @param string $encoding The database encoding. */ - public function __construct(?PlatformInterface $defaultPlatform = null, $defaultPackage = null, $encoding = 'iso-8859-1') + public function __construct(?PlatformInterface $defaultPlatform = null, $defaultPackage = null) { $this->schema = new Schema($defaultPlatform); $this->defaultPackage = $defaultPackage; - $this->encoding = $encoding; } /** @@ -191,7 +183,7 @@ public function parseString($xmlString, $xmlFile = null) $this->parser = xml_parser_create(); xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0); xml_set_object($this->parser, $this); - xml_set_element_handler($this->parser, 'startElement', 'endElement'); + xml_set_element_handler($this->parser, [$this, 'startElement'], [$this, 'endElement']); if (!xml_parse($this->parser, $xmlString)) { throw new SchemaException( sprintf( diff --git a/src/Propel/Generator/Model/Database.php b/src/Propel/Generator/Model/Database.php index 31d8ca17cb..6ae1fa6b64 100644 --- a/src/Propel/Generator/Model/Database.php +++ b/src/Propel/Generator/Model/Database.php @@ -688,6 +688,7 @@ public function setSchema($schema) } } elseif ($oldSchema) { if (strpos($k, $schemaDelimiter) !== false) { + // @phpstan-ignore-next-line $array[explode($schemaDelimiter, $k)[1]] = $v; unset($array[$k]); } @@ -891,6 +892,7 @@ public function doFinalInitialization() } // execute table behaviors (may add new tables and new behaviors) + // @phpstan-ignore-next-line while ($behavior = $this->getNextTableBehavior()) { $behavior->getTableModifier()->modifyTable(); $behavior->setTableModified(true); diff --git a/src/Propel/Generator/Model/Domain.php b/src/Propel/Generator/Model/Domain.php index d3b9b7f803..f2c1940cfb 100644 --- a/src/Propel/Generator/Model/Domain.php +++ b/src/Propel/Generator/Model/Domain.php @@ -379,7 +379,7 @@ public function replaceDefaultValue(?ColumnDefaultValue $value = null) /** * Returns the SQL type. * - * @return string + * @return string|null */ public function getSqlType() { diff --git a/src/Propel/Generator/Model/MappingModel.php b/src/Propel/Generator/Model/MappingModel.php index c9a61c3a61..0af20ce2a1 100644 --- a/src/Propel/Generator/Model/MappingModel.php +++ b/src/Propel/Generator/Model/MappingModel.php @@ -131,7 +131,7 @@ protected function getDefaultValueForArray(string $stringValue) } $value = implode(' | ', $values); - if (empty($value) || $value === ' | ') { + if ($value === ' | ') { return null; } diff --git a/src/Propel/Generator/Model/PhpNameGenerator.php b/src/Propel/Generator/Model/PhpNameGenerator.php index c0445644aa..ea0302f502 100644 --- a/src/Propel/Generator/Model/PhpNameGenerator.php +++ b/src/Propel/Generator/Model/PhpNameGenerator.php @@ -36,13 +36,13 @@ class PhpNameGenerator implements NameGeneratorInterface * * @see NameGenerator * - * @param string[] $inputs List expected to contain two (optional: three) parameters, + * @param (string|null)[] $inputs List expected to contain two (optional: three) parameters, * element 0 contains name to convert, element 1 contains method for conversion, * optional element 2 contains prefix to be striped from name * - * @return string The generated name. + * @return string|null The generated name. */ - public function generateName($inputs) + public function generateName($inputs): ?string { $schemaName = $inputs[0]; $method = $inputs[1]; diff --git a/src/Propel/Generator/Model/ScopedMappingModel.php b/src/Propel/Generator/Model/ScopedMappingModel.php index 495b80a4f1..f029f6cdbd 100644 --- a/src/Propel/Generator/Model/ScopedMappingModel.php +++ b/src/Propel/Generator/Model/ScopedMappingModel.php @@ -20,22 +20,22 @@ abstract class ScopedMappingModel extends MappingModel /** * @var string|null */ - protected $package; + protected ?string $package = null; /** * @var bool */ - protected $packageOverridden = false; + protected bool $packageOverridden = false; /** * @var string|null */ - protected $namespace; + protected ?string $namespace = null; /** * @var string|null */ - protected $schema; + protected ?string $schema = null; /** * Constructs a new scoped model object. @@ -92,11 +92,11 @@ public function getNamespace(bool $getAbsoluteNamespace = false): ?string /** * Sets the namespace. * - * @param string $namespace + * @param string|null $namespace * * @return void */ - public function setNamespace($namespace) + public function setNamespace(?string $namespace) { $namespace = $namespace === null ? '' @@ -173,9 +173,9 @@ public function setPackage($package) /** * Returns the schema name. * - * @return string + * @return string|null */ - public function getSchema() + public function getSchema(): ?string { return $this->schema; } diff --git a/src/Propel/Generator/Platform/DefaultPlatform.php b/src/Propel/Generator/Platform/DefaultPlatform.php index 7bbda6ad14..25a820b636 100644 --- a/src/Propel/Generator/Platform/DefaultPlatform.php +++ b/src/Propel/Generator/Platform/DefaultPlatform.php @@ -1405,7 +1405,7 @@ public function getPhpArrayString($stringValue) } $value = implode(' | ', $values); - if (empty($value) || $value === ' | ') { + if ($value === ' | ') { return null; } diff --git a/src/Propel/Generator/Platform/SqlitePlatform.php b/src/Propel/Generator/Platform/SqlitePlatform.php index 1e8141f46c..f837814c64 100644 --- a/src/Propel/Generator/Platform/SqlitePlatform.php +++ b/src/Propel/Generator/Platform/SqlitePlatform.php @@ -171,7 +171,7 @@ public function getModifyTableDDL(TableDiff $tableDiff) $column->getDefaultValue(), ['CURRENT_TIME', 'CURRENT_DATE', 'CURRENT_TIMESTAMP'] ) !== false - || substr(trim($column->getDefaultValue()), 0, 1) === '(' + || substr(trim($column->getDefaultValue()->getValue()), 0, 1) === '(' //If a NOT NULL constraint is specified, then the column must have a default value other than NULL. || ($column->isNotNull() && $column->getDefaultValue()->getValue() === 'NULL'); diff --git a/src/Propel/Generator/Reverse/PgsqlSchemaParser.php b/src/Propel/Generator/Reverse/PgsqlSchemaParser.php index 90edf7163e..032b1e0f9f 100755 --- a/src/Propel/Generator/Reverse/PgsqlSchemaParser.php +++ b/src/Propel/Generator/Reverse/PgsqlSchemaParser.php @@ -176,7 +176,7 @@ protected function parseTables(&$tableWraps, Database $database, ?Table $filterT $searchPath = implode(', ', $searchPath); $sql .= " AND n.nspname IN ($searchPath)"; - } elseif ($database->getSchema()) { + } else { $sql .= " AND n.nspname = ?"; $params[] = $database->getSchema(); diff --git a/src/Propel/Generator/Util/BehaviorLocator.php b/src/Propel/Generator/Util/BehaviorLocator.php index eec50bafae..1ae91f8d64 100644 --- a/src/Propel/Generator/Util/BehaviorLocator.php +++ b/src/Propel/Generator/Util/BehaviorLocator.php @@ -34,13 +34,6 @@ class BehaviorLocator */ private $composerDir; - /** - * @deprecated Unused. - * - * @var \Propel\Generator\Config\GeneratorConfigInterface - */ - private $generatorConfig; - /** * Creates the composer finder * @@ -48,7 +41,6 @@ class BehaviorLocator */ public function __construct(?GeneratorConfigInterface $config = null) { - $this->generatorConfig = $config; if ($config !== null) { $this->composerDir = $config->get()['paths']['composerDir']; } diff --git a/src/Propel/Runtime/Collection/Collection.php b/src/Propel/Runtime/Collection/Collection.php index e7b61e4f3d..22cc226ffc 100644 --- a/src/Propel/Runtime/Collection/Collection.php +++ b/src/Propel/Runtime/Collection/Collection.php @@ -118,11 +118,13 @@ public function offsetExists($offset): bool * * @return mixed */ - public function &offsetGet($offset): mixed + public function &offsetGet(mixed $offset): mixed { if (isset($this->data[$offset])) { return $this->data[$offset]; } + + return null; } /** diff --git a/src/Propel/Runtime/Map/TableMap.php b/src/Propel/Runtime/Map/TableMap.php index 0e34090053..6ce4fb92b3 100644 --- a/src/Propel/Runtime/Map/TableMap.php +++ b/src/Propel/Runtime/Map/TableMap.php @@ -13,7 +13,6 @@ use Propel\Runtime\Collection\ObjectCollection; use Propel\Runtime\Map\Exception\ColumnNotFoundException; use Propel\Runtime\Map\Exception\RelationNotFoundException; -use Propel\Runtime\Propel; /** * TableMap is used to model a table in a database. @@ -391,35 +390,6 @@ public function getPrimaryKeyMethodInfo() return $this->pkInfo; } - /** - * Helper method which returns the primary key contained - * in the given Criteria object. - * - * @param \Propel\Runtime\ActiveQuery\Criteria $criteria A Criteria. - * - * @return \Propel\Runtime\Map\ColumnMap If the Criteria object contains a primary key, or null if it doesn't. - */ - private static function getPrimaryKey(Criteria $criteria) - { - // Assume all the keys are for the same table. - $keys = $criteria->keys(); - $key = $keys[0]; - $table = $criteria->getTableName($key); - - $pk = null; - - if (!empty($table)) { - $dbMap = Propel::getServiceContainer()->getDatabaseMap($criteria->getDbName()); - - $pks = $dbMap->getTable($table)->getPrimaryKeys(); - if (!empty($pks)) { - $pk = array_shift($pks); - } - } - - return $pk; - } - /** * @param string $columnName * diff --git a/src/Propel/Runtime/Parser/CsvParser.php b/src/Propel/Runtime/Parser/CsvParser.php index dec4c8428b..71004083bd 100644 --- a/src/Propel/Runtime/Parser/CsvParser.php +++ b/src/Propel/Runtime/Parser/CsvParser.php @@ -25,22 +25,22 @@ class CsvParser extends AbstractParser /** * @var string */ - public $delimiter = ','; + public string $delimiter = ','; /** * @var string */ - public $lineTerminator = "\r\n"; + public string $lineTerminator = "\r\n"; /** * @var string */ - public $quotechar = '"'; + public string $quotechar = '"'; /** * @var string */ - public $escapechar = '\\'; + public string $escapechar = '\\'; /** * @var int @@ -215,10 +215,10 @@ public function toCSV($array, $isList = false, $includeHeading = true) */ public function toArray($data, $rootKey = null, $isList = false, $includeHeading = true) { - $rows = explode($this->lineTerminator, $data); + $rows = explode($this->lineTerminator, $data); // @phpstan-ignore-line if ($includeHeading) { $heading = array_shift($rows); - $keys = explode($this->delimiter, $heading); + $keys = explode($this->delimiter, $heading); // @phpstan-ignore-line } else { $keys = range(0, count($this->getColumns($rows[0])) - 1); }