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

Correction comments and fix same bugs #106

Merged
merged 7 commits into from
Aug 28, 2013
Merged

Correction comments and fix same bugs #106

merged 7 commits into from
Aug 28, 2013

Conversation

Rathil
Copy link
Contributor

@Rathil Rathil commented Aug 26, 2013

Correction comments
Fix bug:
EMongoCriteria.php:231 -> EMongoCriteria.php:245 - is_numeric -> is_array

if($criteria->limit!=0)
$this->cursor->limit($criteria->limit);
}else{
$this->cursor = $this->model->getCollection()->find($criteria->getCondition(), $criteria->getProject())->sort($criteria->getSort());
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though this line uses the explicit functions ->project does actually route to getProject()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I know, but if you have given getter, a good programming practice will cause exactly that!

  • If you are using PhpStorm, it is very well send you what method return to you.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However, this code was coded by others than me and the consensus is that the preferred method is to use magics to ascertain properties in Yii.

I personally would prefer the use of magics here currently, it is the preferred Yii way and this is a Yii extension.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, then why are described getters when using magic methods?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you use magic methods, why should define get/set methods for property?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because those magics route to those getters and setters, if you check the __get/__set of CComponent you will see they do this. Here is a good example of __get:

    public function __get($name)
    {
        $getter='get'.$name;
        if(method_exists($this,$getter))
            return $this->$getter();
        elseif(strncasecmp($name,'on',2)===0 && method_exists($this,$name))
        {
            // duplicating getEventHandlers() here for performance
            $name=strtolower($name);
            if(!isset($this->_e[$name]))
                $this->_e[$name]=new CList;
            return $this->_e[$name];
        }
        elseif(isset($this->_m[$name]))
            return $this->_m[$name];
        elseif(is_array($this->_m))
        {
            foreach($this->_m as $object)
            {
                if($object->getEnabled() && (property_exists($object,$name) || $object->canGetProperty($name)))
                    return $object->$name;
            }
        }
        throw new CException(Yii::t('yii','Property "{class}.{property}" is not defined.',
            array('{class}'=>get_class($this), '{property}'=>$name)));
    }

You can see in the first 3 lines where it routes to the getter

@Sammaye
Copy link
Owner

Sammaye commented Aug 26, 2013

Added some audit notes to the code

@Sammaye
Copy link
Owner

Sammaye commented Aug 28, 2013

Hows this coming along?

@Rathil
Copy link
Contributor Author

Rathil commented Aug 28, 2013

Tonight fix and push, yesterday celebrated the anniversary with my wife.

@Sammaye
Copy link
Owner

Sammaye commented Aug 28, 2013

Hope you had a good one :) I'll wait for it

@Rathil
Copy link
Contributor Author

Rathil commented Aug 28, 2013

Yes, it was not bad. Do you have Skype?

@Sammaye
Copy link
Owner

Sammaye commented Aug 28, 2013

Nah, never needed it, I am a very textual kinda communicator :)

@Rathil
Copy link
Contributor Author

Rathil commented Aug 28, 2013

Ok, I have a friend just claimed that you know Russian language, if so - chat on Skype would be faster.

@Sammaye
Copy link
Owner

Sammaye commented Aug 28, 2013

Ah hell no, any suggestion I have been able to make of it is pure luck; hell I know more Arabic than Russian (I have actually been learning some Arabic). I play eve with quite a few Russians and was even in a Russian alliance on it but my understanding of it is just to understand the sort of notion of what's going on, at the end of the day they all spoke okish English when needed so we were able to play together.

@Rathil
Copy link
Contributor Author

Rathil commented Aug 28, 2013

I understand :)

@Rathil
Copy link
Contributor Author

Rathil commented Aug 28, 2013

Back

}

return $this; // Maintain chainability
// TODO I think this is should to investigate and remove
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will run the unit tests with this removed when I merge and see if it can be removed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good, since this line is really misleading

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome sauce cheers :)

Sammaye added a commit that referenced this pull request Aug 28, 2013
Correction comments and fix same bugs
@Sammaye Sammaye merged commit f9e4907 into Sammaye:master Aug 28, 2013
@Sammaye
Copy link
Owner

Sammaye commented Aug 28, 2013

Ok lets take a look at this

@Sammaye
Copy link
Owner

Sammaye commented Aug 28, 2013

All unit tests passing after merge, continuing with changes

@Sammaye
Copy link
Owner

Sammaye commented Aug 28, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants