how to add an static array in php class with php-cpp

128 views Asked by At

I want to add a static member like below

class BaseYii{
    public static $map = [1,2,3]//sutff
}

this is my c++ code ,

class BaseYii : public Php::Base {
public:
Php::Array  hehe;

BaseYii() = default;

/**
 *  c++ destructor
 */
virtual ~BaseYii() = default;

void __construct() {
    Php::Value self(this);
    Php::Array x{123, "adf"};
    self["fff"] = x;
}

void getServer() {
    Php::call("var_dump", Php::SERVER);
}
};

register extension, how to set a Php::Array or Php::value to this property

Php::Class<BaseYii> baseYii("BaseYii");

Php::Class<Yii> Yii("Yii");
static std::map<int, int> map;
map[1] = 1;
baseYii.property("classMap", "here ,i want to set a Array or Php::value", Php::Public | Php::Static);
1

There are 1 answers

0
Big Pig On

Zend API does not support this — default property values cannot be arrays, objects or resources.

http://lxr.php.net/source/xref/PHP-7.0/Zend/zend_API.c

https://github.com/CopernicaMarketingSoftware/PHP-CPP/issues/277