TypeRocket / core

TypeRocket core source files where all the magic lives.
https://typerocket.com
36 stars 21 forks source link

Invalid PHPDoc blocks #51

Closed szepeviktor closed 5 years ago

szepeviktor commented 5 years ago

Hello!

core may have 311 lines of invalid PHPDoc values. Would you welcome a PR?

kevindees commented 5 years ago

@szepeviktor

If you wanted to do a PR for a sample group first I'm open to it. Then we can go from there.

szepeviktor commented 5 years ago

@kevindees While working (grep -rFl '@param $'|xargs -L1 sed -e 's#@param $#@param string $#' -i) on this I've noticed

Do you have plans to go more object oriented?

kevindees commented 5 years ago

@szepeviktor

I do not have plans to go full-on OOP with the logic. I like a mix of functional and OOP personally but I'm always open to refactors as long as it doesn't negatively impact performance.

szepeviktor commented 5 years ago
$ find src/ -type f | wc -l
136 files

$ grep -r 'if \?(' src/ | wc -l
903 if-s

So 6.6 branchings per class. That we may call an If Jungle.

kevindees commented 5 years ago

@szepeviktor

If there is a class you want to refactor and add a PR for I'm open to seeing your ideas to help clean things up.

szepeviktor commented 5 years ago

You can get rid of almost all else-s by early exiting:

// Current code
if($found) {
    $this->success('Seeded config/app.php with: ' . $seed );
} else {
    $this->error('Manually Seed config/app.php with: ' . $seed);
}

// Errors go into `if`-s
if (!$found) {
    $this->error('Manually Seed config/app.php with: ' . $seed);
    return;
}

// Normal execution is not indented -> much cleaner 😸
$this->success('Seeded config/app.php with: ' . $seed );
szepeviktor commented 5 years ago

PHPDoc blocks are almost 💯% okay.

kevindees commented 5 years ago

@szepeviktor

If you wanted to do a PR for these kinds of issues I'm all for it. Would love to have help getting the code cleaned up and optimized.

szepeviktor commented 5 years ago

You can start using ObjectCalisthenics.ControlStructures.NoElse from https://github.com/object-calisthenics/phpcs-calisthenics-rules today! See my living docs.