diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 3099a4c75c..e3a364ddaa 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -40,11 +40,6 @@ parameters: count: 1 path: src/Propel/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehavior.php - - - message: "#^Ternary operator condition is always false\\.$#" - count: 1 - path: src/Propel/Generator/Behavior/Sortable/SortableBehaviorObjectBuilderModifier.php - - message: "#^Access to an undefined property Propel\\\\Generator\\\\Model\\\\Table\\:\\:\\$isVersionTable\\.$#" count: 1 @@ -55,26 +50,11 @@ parameters: count: 1 path: src/Propel/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifier.php - - - message: "#^If condition is always true\\.$#" - count: 1 - path: src/Propel/Generator/Builder/DataModelBuilder.php - - - - message: "#^Left side of && is always true\\.$#" - count: 1 - path: src/Propel/Generator/Builder/DataModelBuilder.php - - message: "#^Parameter \\#1 \\$v of method Propel\\\\Generator\\\\Builder\\\\DataModelBuilder\\:\\:setGeneratorConfig\\(\\) expects Propel\\\\Generator\\\\Config\\\\GeneratorConfigInterface, \\$this\\(Propel\\\\Generator\\\\Builder\\\\DataModelBuilder\\) given\\.$#" count: 1 path: src/Propel/Generator/Builder/DataModelBuilder.php - - - message: "#^Unreachable statement \\- code above always terminates\\.$#" - count: 1 - path: src/Propel/Generator/Builder/DataModelBuilder.php - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Builder\\\\Om\\\\AbstractObjectBuilder\\:\\:addAddArrayElement\\(\\)\\.$#" count: 2 @@ -190,21 +170,6 @@ parameters: count: 1 path: src/Propel/Generator/Builder/Om/ObjectBuilder.php - - - message: "#^Left side of && is always true\\.$#" - count: 1 - path: src/Propel/Generator/Builder/Om/TableMapBuilder.php - - - - message: "#^Parameter \\#2 \\$shdl of function xml_set_element_handler expects callable\\(\\)\\: mixed, 'startElement' given\\.$#" - count: 1 - path: src/Propel/Generator/Builder/Util/SchemaReader.php - - - - message: "#^Parameter \\#3 \\$ehdl of function xml_set_element_handler expects callable\\(\\)\\: mixed, 'endElement' given\\.$#" - count: 1 - path: src/Propel/Generator/Builder/Util/SchemaReader.php - - message: "#^Variable \\$migration might not be defined\\.$#" count: 1 @@ -220,11 +185,6 @@ parameters: count: 1 path: src/Propel/Generator/Config/ArrayToPhpConverter.php - - - message: "#^Negated boolean expression is always false\\.$#" - count: 1 - path: src/Propel/Generator/Config/GeneratorConfig.php - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Config\\\\GeneratorConfigInterface\\:\\:get\\(\\)\\.$#" count: 2 @@ -275,21 +235,6 @@ parameters: count: 1 path: src/Propel/Generator/Manager/templates/migration_template.php - - - message: "#^Strict comparison using \\=\\=\\= between string and null will always evaluate to false\\.$#" - count: 1 - path: src/Propel/Generator/Model/Column.php - - - - message: "#^If condition is always true\\.$#" - count: 1 - path: src/Propel/Generator/Model/Database.php - - - - message: "#^Strict comparison using \\=\\=\\= between string and null will always evaluate to false\\.$#" - count: 1 - path: src/Propel/Generator/Model/Database.php - - message: "#^Unreachable statement \\- code above always terminates\\.$#" count: 1 @@ -300,71 +245,16 @@ parameters: count: 1 path: src/Propel/Generator/Model/Domain.php - - - message: "#^If condition is always true\\.$#" - count: 1 - path: src/Propel/Generator/Model/ForeignKey.php - - - - message: "#^If condition is always true\\.$#" - count: 1 - path: src/Propel/Generator/Model/Schema.php - - - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:isEarly\\(\\)\\.$#" - count: 1 - path: src/Propel/Generator/Model/Table.php - - message: "#^Strict comparison using \\=\\=\\= between array\\ and null will always evaluate to false\\.$#" count: 1 path: src/Propel/Generator/Model/Table.php - - - message: "#^If condition is always true\\.$#" - count: 1 - path: src/Propel/Generator/Platform/DefaultPlatform.php - - - - message: "#^Result of && is always false\\.$#" - count: 1 - path: src/Propel/Generator/Platform/DefaultPlatform.php - - - - message: "#^Strict comparison using \\=\\=\\= between int and null will always evaluate to false\\.$#" - count: 1 - path: src/Propel/Generator/Platform/DefaultPlatform.php - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Config\\\\GeneratorConfigInterface\\:\\:get\\(\\)\\.$#" count: 2 path: src/Propel/Generator/Platform/MysqlPlatform.php - - - message: "#^Left side of && is always true\\.$#" - count: 1 - path: src/Propel/Generator/Platform/MysqlPlatform.php - - - - message: "#^If condition is always true\\.$#" - count: 1 - path: src/Propel/Generator/Platform/PgsqlPlatform.php - - - - message: "#^Right side of && is always true\\.$#" - count: 2 - path: src/Propel/Generator/Platform/PgsqlPlatform.php - - - - message: "#^Left side of \\|\\| is always false\\.$#" - count: 1 - path: src/Propel/Generator/Platform/SqlitePlatform.php - - - - message: "#^Parameter \\#1 \\$str of function trim expects string, Propel\\\\Generator\\\\Model\\\\ColumnDefaultValue\\|null given\\.$#" - count: 1 - path: src/Propel/Generator/Platform/SqlitePlatform.php - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Config\\\\GeneratorConfigInterface\\:\\:get\\(\\)\\.$#" count: 1 @@ -385,11 +275,6 @@ parameters: count: 1 path: src/Propel/Generator/Reverse/SqliteSchemaParser.php - - - message: "#^If condition is always true\\.$#" - count: 1 - path: src/Propel/Generator/Reverse/SqliteSchemaParser.php - - message: "#^Variable \\$fk might not be defined\\.$#" count: 1 @@ -475,21 +360,11 @@ parameters: count: 1 path: src/Propel/Runtime/ActiveQuery/ModelCriteria.php - - - message: "#^Left side of && is always true\\.$#" - count: 1 - path: src/Propel/Runtime/ActiveQuery/ModelCriteria.php - - message: "#^Parameter \\#1 \\$join of method Propel\\\\Runtime\\\\ActiveQuery\\\\ModelJoin\\:\\:setPreviousJoin\\(\\) expects Propel\\\\Runtime\\\\ActiveQuery\\\\ModelJoin, Propel\\\\Runtime\\\\ActiveQuery\\\\Join given\\.$#" count: 1 path: src/Propel/Runtime/ActiveQuery/ModelCriteria.php - - - message: "#^Result of \\|\\| is always false\\.$#" - count: 1 - path: src/Propel/Runtime/Adapter/Pdo/MssqlAdapter.php - - message: "#^Call to an undefined method Propel\\\\Runtime\\\\Connection\\\\ConnectionInterface\\:\\:sqliteCreateFunction\\(\\)\\.$#" count: 1 @@ -540,26 +415,6 @@ parameters: count: 1 path: src/Propel/Runtime/Collection/ArrayCollection.php - - - message: "#^Return type \\(void\\) of method Propel\\\\Runtime\\\\Collection\\\\CollectionIterator\\:\\:asort\\(\\) should be compatible with return type \\(bool\\) of method ArrayIterator\\<\\(int\\|string\\),mixed\\>\\:\\:asort\\(\\)$#" - count: 1 - path: src/Propel/Runtime/Collection/CollectionIterator.php - - - - message: "#^Return type \\(void\\) of method Propel\\\\Runtime\\\\Collection\\\\CollectionIterator\\:\\:ksort\\(\\) should be compatible with return type \\(bool\\) of method ArrayIterator\\<\\(int\\|string\\),mixed\\>\\:\\:ksort\\(\\)$#" - count: 1 - path: src/Propel/Runtime/Collection/CollectionIterator.php - - - - message: "#^Return type \\(void\\) of method Propel\\\\Runtime\\\\Collection\\\\CollectionIterator\\:\\:natcasesort\\(\\) should be compatible with return type \\(bool\\) of method ArrayIterator\\<\\(int\\|string\\),mixed\\>\\:\\:natcasesort\\(\\)$#" - count: 1 - path: src/Propel/Runtime/Collection/CollectionIterator.php - - - - message: "#^Return type \\(void\\) of method Propel\\\\Runtime\\\\Collection\\\\CollectionIterator\\:\\:natsort\\(\\) should be compatible with return type \\(bool\\) of method ArrayIterator\\<\\(int\\|string\\),mixed\\>\\:\\:natsort\\(\\)$#" - count: 1 - path: src/Propel/Runtime/Collection/CollectionIterator.php - - message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:delete\\(\\)\\.$#" count: 1 @@ -660,11 +515,6 @@ parameters: count: 1 path: src/Propel/Runtime/Formatter/SimpleArrayFormatter.php - - - message: "#^Return type \\(array\\) of method Propel\\\\Runtime\\\\Formatter\\\\SimpleArrayFormatter\\:\\:formatRecord\\(\\) should be compatible with return type \\(Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\) of method Propel\\\\Runtime\\\\Formatter\\\\AbstractFormatter\\:\\:formatRecord\\(\\)$#" - count: 1 - path: src/Propel/Runtime/Formatter/SimpleArrayFormatter.php - - message: "#^Call to an undefined method Propel\\\\Runtime\\\\Adapter\\\\AdapterInterface\\:\\:ignoreCase\\(\\)\\.$#" count: 1 @@ -679,3 +529,4 @@ 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/src/Propel/Generator/Builder/DataModelBuilder.php b/src/Propel/Generator/Builder/DataModelBuilder.php index b2a4887536..e71b83b119 100644 --- a/src/Propel/Generator/Builder/DataModelBuilder.php +++ b/src/Propel/Generator/Builder/DataModelBuilder.php @@ -467,7 +467,8 @@ public function getPlatform(): ?PlatformInterface if ($this->platform === null) { // try to load the platform from the table $table = $this->table; - if ($table && $database = $table->getDatabase()) { + $database = $table->getDatabase(); + if ($database) { $this->setPlatform($database->getPlatform()); } } diff --git a/src/Propel/Generator/Config/GeneratorConfig.php b/src/Propel/Generator/Config/GeneratorConfig.php index d5af4034a0..9ace95c74d 100644 --- a/src/Propel/Generator/Config/GeneratorConfig.php +++ b/src/Propel/Generator/Config/GeneratorConfig.php @@ -269,7 +269,7 @@ public function getConnection(?string $database = null): ConnectionInterface */ public function getBehaviorLocator(): BehaviorLocator { - if (!$this->behaviorLocator) { + if ($this->behaviorLocator === null) { $this->behaviorLocator = new BehaviorLocator($this); } diff --git a/src/Propel/Generator/Model/Database.php b/src/Propel/Generator/Model/Database.php index 446396ab8b..040f079910 100644 --- a/src/Propel/Generator/Model/Database.php +++ b/src/Propel/Generator/Model/Database.php @@ -99,7 +99,7 @@ class Database extends ScopedMappingModel private $identifierQuoting = false; /** - * @var \Propel\Generator\Model\Schema + * @var \Propel\Generator\Model\Schema|null */ private $parentSchema; @@ -802,7 +802,7 @@ public function getDomain(string $name): ?Domain */ public function getGeneratorConfig(): ?GeneratorConfigInterface { - if ($this->parentSchema) { + if ($this->parentSchema !== null) { return $this->parentSchema->getGeneratorConfig(); } diff --git a/src/Propel/Generator/Model/ForeignKey.php b/src/Propel/Generator/Model/ForeignKey.php index c924e58646..f2b7f46e6e 100644 --- a/src/Propel/Generator/Model/ForeignKey.php +++ b/src/Propel/Generator/Model/ForeignKey.php @@ -178,7 +178,7 @@ protected function doNaming(): void $newName .= substr(md5(strtolower(implode(':', $hash))), 0, 6); - if ($this->parentTable) { + if ($this->parentTable !== null) { $newName = $this->parentTable->getCommonName() . '_' . $newName; } diff --git a/src/Propel/Generator/Platform/MysqlPlatform.php b/src/Propel/Generator/Platform/MysqlPlatform.php index ca6b19b937..c5a7678d5c 100644 --- a/src/Propel/Generator/Platform/MysqlPlatform.php +++ b/src/Propel/Generator/Platform/MysqlPlatform.php @@ -600,7 +600,7 @@ protected function getIndexType(Index $index): string { $type = ''; $vendorInfo = $index->getVendorInfoForType($this->getDatabaseType()); - if ($vendorInfo && $vendorInfo->getParameter('Index_type')) { + if ($vendorInfo->getParameter('Index_type')) { $type = $vendorInfo->getParameter('Index_type') . ' '; } elseif ($index->isUnique()) { $type = 'UNIQUE '; diff --git a/src/Propel/Generator/Platform/PgsqlPlatform.php b/src/Propel/Generator/Platform/PgsqlPlatform.php index b551a1f4ee..6a7c1f5dac 100755 --- a/src/Propel/Generator/Platform/PgsqlPlatform.php +++ b/src/Propel/Generator/Platform/PgsqlPlatform.php @@ -319,12 +319,10 @@ public function getForeignKeyDDL(ForeignKey $fk): string $script = parent::getForeignKeyDDL($fk); $pgVendorInfo = $fk->getVendorInfoForType('pgsql'); - if ($pgVendorInfo) { - if (filter_var($pgVendorInfo->getParameter('deferrable'), FILTER_VALIDATE_BOOLEAN)) { - $script .= ' DEFERRABLE'; - if (filter_var($pgVendorInfo->getParameter('initiallyDeferred'), FILTER_VALIDATE_BOOLEAN)) { - $script .= ' INITIALLY DEFERRED'; - } + if (filter_var($pgVendorInfo->getParameter('deferrable'), FILTER_VALIDATE_BOOLEAN)) { + $script .= ' DEFERRABLE'; + if (filter_var($pgVendorInfo->getParameter('initiallyDeferred'), FILTER_VALIDATE_BOOLEAN)) { + $script .= ' INITIALLY DEFERRED'; } } diff --git a/src/Propel/Runtime/Adapter/Pdo/MssqlAdapter.php b/src/Propel/Runtime/Adapter/Pdo/MssqlAdapter.php index 5b3103e27d..f2163eb185 100644 --- a/src/Propel/Runtime/Adapter/Pdo/MssqlAdapter.php +++ b/src/Propel/Runtime/Adapter/Pdo/MssqlAdapter.php @@ -14,7 +14,6 @@ use Propel\Runtime\Adapter\Exception\MalformedClauseException; use Propel\Runtime\Adapter\SqlAdapterInterface; use Propel\Runtime\Connection\ConnectionInterface; -use Propel\Runtime\Exception\InvalidArgumentException; use Propel\Runtime\Map\DatabaseMap; /** @@ -137,7 +136,6 @@ public function random(?string $seed = null): string * @param int $limit * @param \Propel\Runtime\ActiveQuery\Criteria|null $criteria * - * @throws \Propel\Runtime\Exception\InvalidArgumentException * @throws \Propel\Runtime\Adapter\Exception\ColumnNotFoundException * @throws \Propel\Runtime\Adapter\Exception\MalformedClauseException * @@ -145,11 +143,6 @@ public function random(?string $seed = null): string */ public function applyLimit(string &$sql, int $offset, int $limit, ?Criteria $criteria = null): void { - // make sure offset and limit are numeric - if (!is_numeric($offset) || !is_numeric($limit)) { - throw new InvalidArgumentException('MssqlAdapter::applyLimit() expects a number for argument 2 and 3'); - } - // split the select and from clauses out of the original query $selectStatement = ''; $fromStatement = '';