woocart / cartfront

Full-featured child theme for Storefront.
GNU General Public License v3.0
1 stars 0 forks source link

Prevent "wrong theme name" bugs in the future #34

Open zupo opened 6 years ago

zupo commented 6 years ago

The Story

Handbook documents: User story & Work process

As a Victor, I never want to see wrong theme name bug again, because it is completely preventable.

Problem

Theme names are hardcoded in CartFront theme and not checked against the valid values defined in openapi.yaml schema.

Proposal

Before you start: It's Bookstore, not Books Store or Book Store. Use search & replace to fix all codebase.

Option A:

Option B:

Pitfalls

Best practices (DoD)

Expectations (AC)

dz0ny commented 6 years ago

Enums in PHP


<?php

trait EnumHelpers {
    public static function getValues(){
      return (new ReflectionClass(get_called_class()))->getConstants(); 
    }
}

class Themes {
  use EnumHelpers;

  const BookStore = "bookstore";
  const ToyStore = "toystore";

}

var_dump(Themes::BookStore);
var_dump(Themes::getValues());

?>

See https://repl.it/repls/ForestgreenSaneWamp

ikolar commented 5 years ago

@zupo tried option B; would be nice if you could take a look.

zupo commented 5 years ago

What's the next step here?