zephir icon indicating copy to clipboard operation
zephir copied to clipboard

[BUG]: zephir generate not detecting required php extensions

Open noone-silent opened this issue 1 month ago • 0 comments

How to reproduce:

  • Checkout https://github.com/phalcon/cphalcon with branch v5.0.x
  • Move all interfaces, except ResultsetInterface from ext/phalcon/mvc/model/Resultset.zep to ext/phalcon/mvc/model/ResultsetInterface.zep (see code below)
  • Add missing use statements
  • try zephir fullclean && zephir build

The build fails with an error message:

cphalcon/ext/phalcon/mvc/model/resultsetinterface.zep.c:37:75: error: 'php_json_serializable_ce' undeclared (first use in this function)
37 |         zend_class_implements(phalcon_mvc_model_resultsetinterface_ce, 1, php_json_serializable_ce);

Findings:

After digging into the problem, following things I found out:

In ext/mvc/model/Resultset.zep.c two header files are removed:

#include "ext/spl/spl_iterators.h"
#include "ext/json/php_json.h"

but not added in ext/mvc/model/ResultsetInterface.zep.c

Running all steps manually and adding the missing header files to ext/mvc/model/ResultsetInterface.zep.c will compile the extension without error

zephir fullclean
zephir generate
// Adding the missing header files to resultsetinterface.zep.c
zephir compile
zephir install

Info: Zephir Version: 1.6.0 PHP Version: 8.0, 8.1, 8.2, 8.3

Code:

// ext/mvc/model/Resultset.zep
abstract class Resultset implements ResultsetInterface
// ext/mvc/model/ResultsetInterface.zep
use ArrayAccess;
use Closure;
use Countable;
use Iterator;
use JsonSerializable;
use SeekableIterator;
use Serializable;
use Phalcon\Messages\MessageInterface;
use Phalcon\Mvc\ModelInterface;

interface ResultsetInterface extends Iterator, SeekableIterator, Countable, ArrayAccess, Serializable, JsonSerializable

noone-silent avatar May 10 '24 00:05 noone-silent