We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Zephir: What value does a class variable get if it is not assigned a value at declaration?

In this case:

class Blah {

    protected static something;

}

Is the default value of something null?



85.5k

probably, die(var_dump(self::something)); ?



8.7k

I'm seeing lots of if something === null on undefined class variables in Phalcon code.

Trying to debug something. Just wondering



85.5k

can you give me a link to check it and see if i can explain it ( eeventually )



8.7k
edited Apr '17

Sure.

There is some issue with MongoCollection in the Incubator with PHP 7.1. One of the issues is with the reserved words when saving. ref: here and here

In Phalcon\Mvc\Collection, the base class of MongoCollection, _reserved is declared on line 59: protected static _reserved; then tested later:

var reserved;

let reserved = self::_reserved;
if reserved === null {...

Been reading that Zephir tries to do type inference, so maybe _reserved gets [] instead of null.

That said, I am just now looking at Zephir.

Null i think.