Bad patterns

Here you will find some of the bad patterns I have found while reviewing code.

Particular value which triggers a specific process

if (in_array($product->stock_amount, [8888, 9999])) {
    $ignoreStockCheck = true;
}

Explaination :

Here, stock_amount normally stores the stock amount of this product. Typically, if the stock amount reaches zero, the product should appear unavailable in front pages.

This piece of code implements a typical bad pattern : the values 8888 and 9999 carry a specific business logic. The developer thought he can do this because in the current state of the business (i.e. actual size of the warehouse), a stock amount of 8888 is not realistic, and this value could be safely used as a flag.

Better approach

Reading this code, we can see that the business logic has two specific not-combinable cases where the product stock is ignored. It looks like a kind of enumerable "states" of the product :

class Product {
    const STATE8888 = 8888;
    const STATE9999 = 9999;

    public $state;
}
...
if (in_array($product->state, [Product::STATE8888, Product::STATE9999])) {
    $ignoreStockCheck = true;
}

Of course, the "8888", "9999" and "state" names here should be replaced by something more descriptive about the business feature implemented by these fields and constants.