Categories
Coding

How WooCommerce handles object data

Previously on “Stop using arrays for everything“, I exposed that an array wasn’t always the best way to accomplish a task and I gave an example in which an object was a better solution for that case.

Today, I’d like to illustrate how powerful the OOP can be and the benefits of using objects. To do so, I’ll use as an example one of the most popular WordPress plugins and the biggest e-commerce platform at this moment. I’m talking about WooCommerce and how this one handles the data of its different kinds of objects like products, orders, coupons, etc.

Categories
Coding

Stop using arrays for everything

Arrays are a very important element in PHP. We can use them as functions’ arguments, to store and sort a collection of data, etc. They are always there for making our lives easier, but sometimes we tend to use arrays more than we should be.

Categories
Coding

How to deprecate code in WordPress

The codebase of a project is in continuous evolution. We add new features, fix issues, and at some point in the development, we found that some code we wrote in the past is no longer necessary. Under this situation, we may have the temptation of removing this piece of code, but is it right?

Categories
Coding

How to enable PHP_CodeSniffer in PhpStorm

In a previous post, we learned how to use the tool PHP_CodeSniffer to accomplish with the WordPress and WooCommerce standards and make our code more readable, robust, and secure.

But executing a command in our terminal every time we want to check if the code we have written is correct can be quite tedious. Fortunately, we can integrate this tool with our favorite IDE and get assistance for the coding standards while we write our code.

Categories
Coding

Coding standards with PHP_CodeSniffer

Every programming language, framework, or library has (or should have) its own coding standards. The benefits of using a standard are well known in our industry.