Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yii framework activerecord object __get() can't work #870

Closed
fightingbamboo opened this issue Jul 20, 2013 · 5 comments
Closed

yii framework activerecord object __get() can't work #870

fightingbamboo opened this issue Jul 20, 2013 · 5 comments

Comments

@fightingbamboo
Copy link

class Ad extends CActiveRecord

abstract class CActiveRecord extends CModel

abstract class CModel extends CComponent implements IteratorAggregate, ArrayAccess

public function __get($name)  is in the CComponent

a property in Ad can't call CComponent's __get($name)

@scannell
Copy link
Contributor

Hi @fightingbamboo, can you provide more information? (The source and what the error is exactly?)

This might be the same issue as #657 but I'm not sure from this.

@fightingbamboo
Copy link
Author

<?php

class CComponent
{
    private $_m;

    public function __get($name)
    {
        $getter='get'.$name;
        if(method_exists($this,$getter))
            return $this->$getter();
        else if(isset($this->_m[$name]))
            return $this->_m[$name];
        echo "can't get $name <br />";
    }

    public function __set($name,$value)
    {
        $setter='set'.$name;
        if(method_exists($this,$setter))
            return $this->$setter($value);
        echo "can't set '$name = $value' <br />";
    }

    public function __isset($name)
    {
        $getter='get'.$name;
        if(method_exists($this,$getter))
            return $this->$getter()!==null;
        else if(is_array($this->_m))
        {
            if(isset($this->_m[$name]))
                return true;
            foreach($this->_m as $object)
            {
                if($object->getEnabled() && (property_exists($object,$name) || $object->canGetProperty($name)))
                    return true;
            }
        }
        return false;
    }

    public function __call($name,$parameters)
    {
        if($this->_m!==null)
        {
            foreach($this->_m as $object)
            {
                if($object->getEnabled() && method_exists($object,$name))
                    return call_user_func_array(array($object,$name),$parameters);
            }
        }
    }

    public function hasProperty($name)
    {
        return method_exists($this,'get'.$name) || method_exists($this,'set'.$name);
    }

    public function canGetProperty($name)
    {
        return method_exists($this,'get'.$name);
    }
    public function canSetProperty($name)
    {
        return method_exists($this,'set'.$name);
    }
}

class Ad extends CComponent
{
    public function testfunc()
    {
        $this->testvar = "is's me";
        echo "property testvar:", $this->testvar, "<br />";
    }
}

$test = new Ad();
echo "call testfunc function:","<br />";
$test->testfunc();

echo "<br />";

echo "call testfunc property:","<br />";
$test->testfunc;

?>

@scannell
Copy link
Contributor

Why do you think this is an HHVM bug? Do you see different behavior using Zend PHP? I tried your code sample in three different versions of Zend and I get the same results:

HHVM:
call testfunc function:
can't set 'testvar = is's me'
property testvar:can't get testvar

call testfunc property:

Zend 5.3:
call testfunc function:
can't set 'testvar = is's me'
property testvar:can't get testvar

call testfunc property:

Zend 5.4:
call testfunc function:
can't set 'testvar = is's me'
property testvar:can't get testvar

call testfunc property:

Zend 5.5:
call testfunc function:
can't set 'testvar = is's me'
property testvar:can't get testvar

call testfunc property:

@fightingbamboo
Copy link
Author

I am so sorry,the code sample is wrong.I run the full app which written with yii. it run in zend 5.3 is ok,but in the hhvm is wrong. i only run the code samlple in hhvm. sorry very much.I give the right code sample later.

@scannell
Copy link
Contributor

Closing due to lack of activity and repro. This may be a dupe of #384 and #657 or it may have been fixed by #951 or might be something else entirely.

facebook-github-bot pushed a commit that referenced this issue Oct 16, 2024
Summary:
# Motivation

And if there is one is one design mistake Rust ecosystem made, it is making [`group_by` weird](rust-itertools/itertools#374) and possible for users to, quote:

> I spent several hours debugging my code written using the group_by function.

Luckily for internal users, the build tooling responds accordingly and fails build for all usages of deprecated API. Thus, there is a need to adjust all of them manually.

# [Release notes](https://github.com/rust-itertools/itertools/blob/master/CHANGELOG.md#0130)

### Breaking
- Removed implementation of `DoubleEndedIterator` for `ConsTuples` (#853)
- Made `MultiProduct` fused and fixed on an empty iterator (#835, #834)
- Changed `iproduct!` to return tuples for maxi one iterator too (#870)
- Changed `PutBack::put_back` to return the old value (#880)
- Removed deprecated `repeat_call, Itertools::{foreach, step, map_results, fold_results}` (#878)
- Removed `TakeWhileInclusive::new` (#912)

NOTE: Quick search didn't tell me anything related to breaking changes above, CI will tell. And, of course, scream to me if it breaks your personal build.

Reviewed By: anps77

Differential Revision: D64306014

fbshipit-source-id: 881ac716e1dc23968d4a28000fdaccdbf9097ec2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants