Skip to content

Commit 3a1a94d

Browse files
ISSUE-1478: Fixed findFirst return type
1 parent 94d96c9 commit 3a1a94d

File tree

7 files changed

+17
-23
lines changed

7 files changed

+17
-23
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# [4.0.6](https://github.com/phalcon/cphalcon/releases/tag/v4.0.6)
2+
## Fixed
3+
- Fixed model findFirst return type error [#1478](https://github.com/phalcon/phalcon-devtools/issues/1478)
4+
15
# [4.0.5](https://github.com/phalcon/cphalcon/releases/tag/v4.0.5) (2021-03-14)
26
## Fixed
37
- Fixed model creation failure in webtools due to wrong variable mutation [#1415](https://github.com/phalcon/phalcon-devtools/issues/1415)

src/Generator/Snippet.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -265,9 +265,9 @@ public function getModelFindFirst($className)
265265
* Allows to query the first record that match the specified conditions
266266
*
267267
* @param mixed \$parameters
268-
* @return %s|\Phalcon\Mvc\Model\ResultInterface
268+
* @return %s|\Phalcon\Mvc\Model\ResultInterface|\Phalcon\Mvc\ModelInterface|null
269269
*/
270-
public static function findFirst(\$parameters = null)
270+
public static function findFirst(\$parameters = null): ?\Phalcon\Mvc\ModelInterface
271271
{
272272
return parent::findFirst(\$parameters);
273273
}

tests/_data/console/app/models/files/TestModel.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ public static function find($parameters = null): \Phalcon\Mvc\Model\ResultsetInt
5757
* Allows to query the first record that match the specified conditions
5858
*
5959
* @param mixed $parameters
60-
* @return TestModel|\Phalcon\Mvc\Model\ResultInterface
60+
* @return TestModel|\Phalcon\Mvc\Model\ResultInterface|\Phalcon\Mvc\ModelInterface|null
6161
*/
62-
public static function findFirst($parameters = null)
62+
public static function findFirst($parameters = null): ?\Phalcon\Mvc\ModelInterface
6363
{
6464
return parent::findFirst($parameters);
6565
}

tests/_data/console/app/models/files/TestModel2.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ public static function find($parameters = null): \Phalcon\Mvc\Model\ResultsetInt
4343
* Allows to query the first record that match the specified conditions
4444
*
4545
* @param mixed $parameters
46-
* @return TestModel2|\Phalcon\Mvc\Model\ResultInterface
46+
* @return TestModel2|\Phalcon\Mvc\Model\ResultInterface|\Phalcon\Mvc\ModelInterface|null
4747
*/
48-
public static function findFirst($parameters = null)
48+
public static function findFirst($parameters = null): ?\Phalcon\Mvc\ModelInterface
4949
{
5050
return parent::findFirst($parameters);
5151
}

tests/_data/console/app/models/files/TestModel3.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ public static function find($parameters = null): \Phalcon\Mvc\Model\ResultsetInt
4343
* Allows to query the first record that match the specified conditions
4444
*
4545
* @param mixed $parameters
46-
* @return TestModel3|\Phalcon\Mvc\Model\ResultInterface
46+
* @return TestModel3|\Phalcon\Mvc\Model\ResultInterface|\Phalcon\Mvc\ModelInterface|null
4747
*/
48-
public static function findFirst($parameters = null)
48+
public static function findFirst($parameters = null): ?\Phalcon\Mvc\ModelInterface
4949
{
5050
return parent::findFirst($parameters);
5151
}

tests/_data/console/app/models/files/TestModel5.php

+3-13
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,13 @@ public function initialize()
2727
$this->setSource("TestModel5");
2828
}
2929

30-
/**
31-
* Returns table name mapped in the model.
32-
*
33-
* @return string
34-
*/
35-
public function getSource()
36-
{
37-
return 'TestModel5';
38-
}
39-
4030
/**
4131
* Allows to query a set of records that match the specified conditions
4232
*
4333
* @param mixed $parameters
4434
* @return TestModel5[]|TestModel5|\Phalcon\Mvc\Model\ResultSetInterface
4535
*/
46-
public static function find($parameters = null)
36+
public static function find($parameters = null): \Phalcon\Mvc\Model\ResultsetInterface
4737
{
4838
return parent::find($parameters);
4939
}
@@ -52,9 +42,9 @@ public static function find($parameters = null)
5242
* Allows to query the first record that match the specified conditions
5343
*
5444
* @param mixed $parameters
55-
* @return TestModel5|\Phalcon\Mvc\Model\ResultInterface
45+
* @return TestModel5|\Phalcon\Mvc\Model\ResultInterface|\Phalcon\Mvc\ModelInterface|null
5646
*/
57-
public static function findFirst($parameters = null)
47+
public static function findFirst($parameters = null): ?\Phalcon\Mvc\ModelInterface
5848
{
5949
return parent::findFirst($parameters);
6050
}

tests/_data/console/app/models/files/Testmodel4.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ public static function find($parameters = null): \Phalcon\Mvc\Model\ResultsetInt
4343
* Allows to query the first record that match the specified conditions
4444
*
4545
* @param mixed $parameters
46-
* @return Testmodel4|\Phalcon\Mvc\Model\ResultInterface
46+
* @return Testmodel4|\Phalcon\Mvc\Model\ResultInterface|\Phalcon\Mvc\ModelInterface|null
4747
*/
48-
public static function findFirst($parameters = null)
48+
public static function findFirst($parameters = null): ?\Phalcon\Mvc\ModelInterface
4949
{
5050
return parent::findFirst($parameters);
5151
}

0 commit comments

Comments
 (0)