zephir-lang / zephir

Zephir is a compiled high-level language aimed to ease the creation of C-extensions for PHP
https://zephir-lang.com
MIT License
3.29k stars 466 forks source link

[NFR] isProperty shortcut #1121

Open sergeyklay opened 9 years ago

sergeyklay commented 9 years ago

Without isProperty shortcut we usually have code like:

namespace App;

class MyClass
{
    protected fallback = true {
        set
    };

    protected cancelable = true;

    public function isCancelable()
    {
        return this->cancelable;

        // or something like this
        // return (boolean) this->cancelable;
    }

    public function setFallback(boolaen fallback)
    {
        let this->fallback = fallback;
    }

    public function isFallback()
    {
        return this->fallback;
    }
}

My proposal is to introduce is<property> shortcut. So we can write the same code using shortcuts as follows:

namespace App;

class MyClass
{
    protected fallback = true {
        set, is
    };

    protected cancelable = true {
        is
    };
}
steffengy commented 9 years ago

I personally think that this is not necessary, I won't implement it for now, which doesn't mean that this won't be merged.

mruz commented 8 years ago

What is the difference to get and getFallback()?

namespace App;

class MyClass
{
    protected fallback = true {
        set, get
    };

}
sergeyklay commented 8 years ago
if ($component->isFalback())

better than

if ($component->getFalback())