diff --git a/CHANGELOG.md b/CHANGELOG.md
index e9e07c17d..504654098 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,9 @@
+# [4.0.6](https://github.com/phalcon/cphalcon/releases/tag/v4.0.6)
+## Fixed
+- Fixed model findFirst return type error [#1478](https://github.com/phalcon/phalcon-devtools/issues/1478)
+- Added trailing semicolon to scaffolding crud views getters [#1477](https://github.com/phalcon/phalcon-devtools/issues/1477)
+- Fixed optional options (namespace, abstract) checks on model create [#1491](https://github.com/phalcon/phalcon-devtools/issues/1491)
+
# [4.0.5](https://github.com/phalcon/cphalcon/releases/tag/v4.0.5) (2021-03-14)
## Fixed
- Fixed model creation failure in webtools due to wrong variable mutation [#1415](https://github.com/phalcon/phalcon-devtools/issues/1415)
diff --git a/src/Builder/Component/Model.php b/src/Builder/Component/Model.php
index e43177aa2..b526cba37 100644
--- a/src/Builder/Component/Model.php
+++ b/src/Builder/Component/Model.php
@@ -172,7 +172,7 @@ public function build(): void
}
$entityNamespace = '';
- if ($this->modelOptions->getOption('namespace')) {
+ if ($this->modelOptions->hasOption('namespace')) {
$entityNamespace = $this->modelOptions->getOption('namespace')."\\";
}
@@ -190,7 +190,7 @@ public function build(): void
foreach ($db->describeReferences($this->modelOptions->getOption('name'), $schema) as $reference) {
$entityNamespace = '';
- if ($this->modelOptions->getOption('namespace')) {
+ if ($this->modelOptions->hasOption('namespace')) {
$entityNamespace = $this->modelOptions->getOption('namespace');
}
diff --git a/src/Builder/Component/Scaffold.php b/src/Builder/Component/Scaffold.php
index efeb1fcd0..3bcfe4ded 100644
--- a/src/Builder/Component/Scaffold.php
+++ b/src/Builder/Component/Scaffold.php
@@ -309,33 +309,33 @@ private function makeField(string $attribute, int $dataType, $relationField, arr
$code .= "\t\t" . 'tag->select(["' . $attribute . '", $' .
$selectDefinition[$attribute]['varName'] . ', "using" => "' .
$selectDefinition[$attribute]['primaryKey'] . ',' . $selectDefinition[$attribute]['detail'] .
- '", "useDummy" => true), "class" => "form-control", "id" => "' . $id . '"] ?>';
+ '", "useDummy" => true), "class" => "form-control", "id" => "' . $id . '"]; ?>';
} else {
switch ($dataType) {
case Column::TYPE_ENUM: // enum
$code .= "\t\t" . 'tag->selectStatic(["' . $attribute .
- '", [], "class" => "form-control", "id" => "' . $id . '"]) ?>';
+ '", [], "class" => "form-control", "id" => "' . $id . '"]); ?>';
break;
case Column::TYPE_CHAR:
$code .= "\t\t" . 'tag->textField(["' . $attribute .
- '", "class" => "form-control", "id" => "' . $id . '"]) ?>';
+ '", "class" => "form-control", "id" => "' . $id . '"]); ?>';
break;
case Column::TYPE_DECIMAL:
case Column::TYPE_INTEGER:
$code .= "\t\t" . 'tag->textField(["' . $attribute .
- '", "type" => "number", "class" => "form-control", "id" => "' . $id . '"]) ?>';
+ '", "type" => "number", "class" => "form-control", "id" => "' . $id . '"]); ?>';
break;
case Column::TYPE_DATE:
$code .= "\t\t" . 'tag->textField(["' . $attribute .
- '", "type" => "date", "class" => "form-control", "id" => "' . $id . '"]) ?>';
+ '", "type" => "date", "class" => "form-control", "id" => "' . $id . '"]); ?>';
break;
case Column::TYPE_TEXT:
$code .= "\t\t" . 'tag->textArea(["' . $attribute .
- '", "cols" => 30, "rows" => 4, "class" => "form-control", "id" => "' . $id . '"]) ?>';
+ '", "cols" => 30, "rows" => 4, "class" => "form-control", "id" => "' . $id . '"]); ?>';
break;
default:
$code .= "\t\t" . 'tag->textField(["' . $attribute .
- '", "size" => 30, "class" => "form-control", "id" => "' . $id . '"]) ?>';
+ '", "size" => 30, "class" => "form-control", "id" => "' . $id . '"]); ?>';
break;
}
}
@@ -565,8 +565,8 @@ private function makeLayouts()
// View model layout
$code = '';
if ($this->options->has('theme')) {
- $code .= 'tag->stylesheetLink("themes/lightness/style") ?>'.PHP_EOL;
- $code .= 'tag->stylesheetLink("themes/base") ?>'.PHP_EOL;
+ $code .= 'tag->stylesheetLink("themes/lightness/style"); ?>'.PHP_EOL;
+ $code .= 'tag->stylesheetLink("themes/base"); ?>'.PHP_EOL;
$code .= '
' . PHP_EOL;
} else {
$code .= '
' . PHP_EOL;
@@ -733,9 +733,9 @@ private function makeViewSearch(): void
} else {
$detailField = ucfirst($this->options->get('allReferences')[$fieldName]['detail']);
$rowCode .= '$' . $this->options->get('singular') . '->get' .
- $this->options->get('allReferences')[$fieldName]['tableName'] . '()->get' . $detailField . '()';
+ $this->options->get('allReferences')[$fieldName]['tableName'] . '()->get' . $detailField . '();';
}
- $rowCode .= ' ?>' . PHP_EOL;
+ $rowCode .= '; ?>' . PHP_EOL;
}
$idField = $this->options->get('attributes')[0];
diff --git a/src/Generator/Snippet.php b/src/Generator/Snippet.php
index 2cc872248..89946e4d7 100644
--- a/src/Generator/Snippet.php
+++ b/src/Generator/Snippet.php
@@ -265,9 +265,9 @@ public function getModelFindFirst($className)
* Allows to query the first record that match the specified conditions
*
* @param mixed \$parameters
- * @return %s|\Phalcon\Mvc\Model\ResultInterface
+ * @return %s|\Phalcon\Mvc\Model\ResultInterface|\Phalcon\Mvc\ModelInterface|null
*/
- public static function findFirst(\$parameters = null)
+ public static function findFirst(\$parameters = null): ?\Phalcon\Mvc\ModelInterface
{
return parent::findFirst(\$parameters);
}
diff --git a/tests/_data/console/app/models/files/TestModel.php b/tests/_data/console/app/models/files/TestModel.php
index 69b95efad..f304a9b41 100644
--- a/tests/_data/console/app/models/files/TestModel.php
+++ b/tests/_data/console/app/models/files/TestModel.php
@@ -57,9 +57,9 @@ public static function find($parameters = null): \Phalcon\Mvc\Model\ResultsetInt
* Allows to query the first record that match the specified conditions
*
* @param mixed $parameters
- * @return TestModel|\Phalcon\Mvc\Model\ResultInterface
+ * @return TestModel|\Phalcon\Mvc\Model\ResultInterface|\Phalcon\Mvc\ModelInterface|null
*/
- public static function findFirst($parameters = null)
+ public static function findFirst($parameters = null): ?\Phalcon\Mvc\ModelInterface
{
return parent::findFirst($parameters);
}
diff --git a/tests/_data/console/app/models/files/TestModel2.php b/tests/_data/console/app/models/files/TestModel2.php
index 4455b90e6..0dd97ff8c 100644
--- a/tests/_data/console/app/models/files/TestModel2.php
+++ b/tests/_data/console/app/models/files/TestModel2.php
@@ -43,9 +43,9 @@ public static function find($parameters = null): \Phalcon\Mvc\Model\ResultsetInt
* Allows to query the first record that match the specified conditions
*
* @param mixed $parameters
- * @return TestModel2|\Phalcon\Mvc\Model\ResultInterface
+ * @return TestModel2|\Phalcon\Mvc\Model\ResultInterface|\Phalcon\Mvc\ModelInterface|null
*/
- public static function findFirst($parameters = null)
+ public static function findFirst($parameters = null): ?\Phalcon\Mvc\ModelInterface
{
return parent::findFirst($parameters);
}
diff --git a/tests/_data/console/app/models/files/TestModel3.php b/tests/_data/console/app/models/files/TestModel3.php
index 1cda62983..6d92c31d1 100644
--- a/tests/_data/console/app/models/files/TestModel3.php
+++ b/tests/_data/console/app/models/files/TestModel3.php
@@ -43,9 +43,9 @@ public static function find($parameters = null): \Phalcon\Mvc\Model\ResultsetInt
* Allows to query the first record that match the specified conditions
*
* @param mixed $parameters
- * @return TestModel3|\Phalcon\Mvc\Model\ResultInterface
+ * @return TestModel3|\Phalcon\Mvc\Model\ResultInterface|\Phalcon\Mvc\ModelInterface|null
*/
- public static function findFirst($parameters = null)
+ public static function findFirst($parameters = null): ?\Phalcon\Mvc\ModelInterface
{
return parent::findFirst($parameters);
}
diff --git a/tests/_data/console/app/models/files/TestModel5.php b/tests/_data/console/app/models/files/TestModel5.php
index 73c623879..c279eaec0 100644
--- a/tests/_data/console/app/models/files/TestModel5.php
+++ b/tests/_data/console/app/models/files/TestModel5.php
@@ -27,23 +27,13 @@ public function initialize()
$this->setSource("TestModel5");
}
- /**
- * Returns table name mapped in the model.
- *
- * @return string
- */
- public function getSource()
- {
- return 'TestModel5';
- }
-
/**
* Allows to query a set of records that match the specified conditions
*
* @param mixed $parameters
* @return TestModel5[]|TestModel5|\Phalcon\Mvc\Model\ResultSetInterface
*/
- public static function find($parameters = null)
+ public static function find($parameters = null): \Phalcon\Mvc\Model\ResultsetInterface
{
return parent::find($parameters);
}
@@ -52,9 +42,9 @@ public static function find($parameters = null)
* Allows to query the first record that match the specified conditions
*
* @param mixed $parameters
- * @return TestModel5|\Phalcon\Mvc\Model\ResultInterface
+ * @return TestModel5|\Phalcon\Mvc\Model\ResultInterface|\Phalcon\Mvc\ModelInterface|null
*/
- public static function findFirst($parameters = null)
+ public static function findFirst($parameters = null): ?\Phalcon\Mvc\ModelInterface
{
return parent::findFirst($parameters);
}
diff --git a/tests/_data/console/app/models/files/Testmodel4.php b/tests/_data/console/app/models/files/Testmodel4.php
index 2f8de1a67..358b7834f 100644
--- a/tests/_data/console/app/models/files/Testmodel4.php
+++ b/tests/_data/console/app/models/files/Testmodel4.php
@@ -43,9 +43,9 @@ public static function find($parameters = null): \Phalcon\Mvc\Model\ResultsetInt
* Allows to query the first record that match the specified conditions
*
* @param mixed $parameters
- * @return Testmodel4|\Phalcon\Mvc\Model\ResultInterface
+ * @return Testmodel4|\Phalcon\Mvc\Model\ResultInterface|\Phalcon\Mvc\ModelInterface|null
*/
- public static function findFirst($parameters = null)
+ public static function findFirst($parameters = null): ?\Phalcon\Mvc\ModelInterface
{
return parent::findFirst($parameters);
}