Repository navigation
Closed
Closed
Copy link
Labels
Description
Problem
Zephir does not enforce a callable parameter type or a return type. For a var parameter, cphalcon has no type. At these sites phalcon throws TypeError at once. cphalcon accepts the value, and then fails later (Error or warning) or works.
zep callable parameter, phalcon callable parameter
| Method | cphalcon (value 'nope') |
phalcon |
|---|---|---|
Support\Collection::each(), filter(), map(), reduce() |
Error: Call to undefined function nope() (an empty collection: no error) |
TypeError at the parameter |
Container\Definition\ServiceDefinition::setFactory(), addExtender(), Container\Container::extend() |
Error: Call to undefined function nope() when the service is built |
TypeError at the parameter |
Container\Resolver\Resolver::resolveCall() |
TypeError: Failed to create closure from callable: ... |
TypeError at the parameter |
Container\Resolver\Lazy\LazyFactory::call() |
Error: Call to undefined function nope() at resolve |
TypeError at the parameter |
DataMapper\Pdo\ConnectionLocator constructor, setRead(), setWrite() |
warning function "nope" not found or invalid function name, getRead() returns null |
TypeError at the parameter |
Db\Dialect::registerCustomFunction() |
Error: Call to undefined function nope() when the SQL is made |
TypeError at the parameter |
Queue subscribe() (SubscriptionConsumerTrait) |
TypeError from call_user_func() in consume(); the message is already removed from the queue |
TypeError at the parameter |
zep var (no type), phalcon typed
| Method | phalcon type | cphalcon | phalcon |
|---|---|---|---|
Forms\FormsLocator::set(), setElement() |
callable $factory |
accepts; get() gives Error: Call to undefined function nope() |
TypeError |
Forms\FormsLocator::getElement() |
return callable |
setElement('bad', 5), getElement('bad') returns 5 |
TypeError |
Forms\FormsLocator::get() |
?object $entity |
get('f', 5) returns a Form |
TypeError |
Container\Resolver\Lazy\GetCall, NewCall, StaticCall constructors |
Lazy|string |
new GetCall(5, 'm', []) works |
TypeError |
Support\Helper\Arr\Group::__invoke() |
callable|string $method |
$method = 0 groups the rows |
TypeError (strict caller) |
Return types that cphalcon does not enforce
| Method | phalcon type | cphalcon | phalcon |
|---|---|---|---|
Mvc\Model\Manager::load() (used by the eager loader and getRelationRecords()) |
ModelInterface |
a relation to a class that is not a model: warning class X does not have a method "find", null |
TypeError: Manager::load(): Return value must be of type ModelInterface |
Html\TagFactory::newInstance() |
object |
a factory that returns 5: warning first array member is not a valid class name or object, null |
TypeError: Return value must be of type object, int returned |
Decision needed
- zep
var: usemixedin phalcon (copy the cphalcon signature; "cphalcon loose types win"). - zep
callableand return types: keep the phalcon type (it fails earlier, with a clear message, and the signature is the same as cphalcon), or relax it tomixedand copy the later failure.
Tests (they must run on phalcon and cphalcon with no change)
- For each changed method: the value that is accepted by cphalcon is accepted by phalcon, and the later result is the same.
Note
Manager::load() of a class with no constructor crashes cphalcon (phalcon/cphalcon issue 1 above). Test it with a class that has a constructor.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsReleased
Activity
[#818] - fixing duplication
niden commentedon Nov 17, 2026
Resolved in #827
[phalcon#818] - aligning with cphalcon for type errors and parameter …
[phalcon#818] - updating changelog