matura icon indicating copy to clipboard operation
matura copied to clipboard

Consider to use $this instead of $ctx argument

Open fesor opened this issue 11 years ago • 1 comments

I know that it will break compability wth php5.3 but hey... php5.3 is no longer supported.

Example:

describe('User Database', function () {
    foreach(range(1,5) as $repetition) {
        it('should insert a user', function (){
            $user = $this->db->findOne([
                'username' => $this->username;
            ]);
            expect($user)->to->have->length(1);
        });

        it('should not accumulate users', function (){
            $users = $this->db->find();
            expect($users)->to->have->length(1);
        });
    }
    // ...
}

This will allow to add mock injection into closures based on typehint (see phpspec implementation for example).

    before_all(function (Database $databaseMock) {
        $this->db = $databaseMock;
    });

fesor avatar Nov 07 '14 15:11 fesor

Just made a comment about this on /r/php. I agree and I'm considering it.

jacobstr avatar Nov 07 '14 18:11 jacobstr