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

Sniff to prevent conditionals in constructors #82

Open
bmitch opened this issue May 30, 2017 · 1 comment
Open

Sniff to prevent conditionals in constructors #82

bmitch opened this issue May 30, 2017 · 1 comment

Comments

@bmitch
Copy link
Owner

bmitch commented May 30, 2017

Extracted from #71

@Exadra37
Copy link

Exadra37 commented Aug 5, 2017

With the exception for Immutable Values Objects constructors should only accept objects and their body we should only see them assigned to private properties.

So calls to collaborators methods, self methods or any other kind of logic MUST NOT be presented in the body of a constructor.

<?php

class UserHandler
{
    private $userRepo;

    public function __construct(UserRepositoryContract $userRepo)
    {
        $this->userRepo = $userRepo;
    }
}

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

No branches or pull requests

2 participants