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

[Contradiction] Liskov Substitution Principle (LSP) #37

Closed
peter-gribanov opened this issue Aug 30, 2017 · 2 comments
Closed

[Contradiction] Liskov Substitution Principle (LSP) #37

peter-gribanov opened this issue Aug 30, 2017 · 2 comments

Comments

@peter-gribanov
Copy link
Contributor

See Liskov Substitution Principle (LSP)

function renderLargeRectangles($rectangles) {
    foreach($rectangle in $rectangles) {
        if ($rectangle instanceof Square) {
            $rectangle->setLength(5);
        } else if ($rectangle instanceof Rectangle) {
            $rectangle->setWidth(4);
            $rectangle->setHeight(5);
        }
        
        $area = $rectangle->getArea(); 
        $rectangle->render($area);
    });
}

contradicts Avoid type-checking (part 1).

@peter-gribanov peter-gribanov changed the title Liskov Substitution Principle (LSP) [Contradiction] Liskov Substitution Principle (LSP) Aug 30, 2017
@TomasVotruba
Copy link
Contributor

Could you send PR for that, please?

mcustiel added a commit to mcustiel/clean-code-php that referenced this issue Sep 12, 2017
TomasVotruba pushed a commit that referenced this issue Dec 29, 2017
@peter-gribanov
Copy link
Contributor Author

fixed in #101

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