PhpStorm allows you to pre-define how you want to document your functions. Using templates, you layout the DocBlock format and structure for things like the revision number, parameters, return value, etc. Why? Why would you want to do this? It saves you time and promotes a standard approach for documentation. Let’s define the template together in this episode.
Labs
Labs are hands-on coding projects that you build along with Tonya as she explains the code, concepts, and thought processes behind it. You can use the labs to further your code knowledge or to use right in your projects. Each lab ties into the Docx to ensure you have the information you need.
Each lab is designed to further your understanding and mastery of code. You learn more about how to think about its construction, quality, maintainability, programmatic and logical thought, and problem-solving. While you may be building a specific thing, Tonya presents the why of it to make it adaptable far beyond that specific implementation, thereby giving you the means to make it your own, in any context.
Autocompletions. Inline and Online Documentation.
Intelligence is built into PhpStorm in order to help you as you are working on your project. In this episode, I’ll show you how PhpStorm helps you discover different functions and then the arguments that each needs in order to be used. It provides a list plus autocompletion plus inline documentation, not only for PHP functions, but also for WordPress Core, any theme or plugin you have in your project, Sass, LESS, JavaScript, and more. Plus, I’ll show you how you can quickly find online documentation and help for a particular function, i.e. an option that is built into PhpStorm.
Active Code Inspection to WPCS
Wouldn’t it be nice if your editor would tell you that you are not being compliant to the coding standard? Imagine the editor highlighting a piece of code, as you are developing it, and giving you the reason why it broke a rule. Wouldn’t that save you time and frustration later? Sure it would. We can configure PhpStorm to use our project’s PHPCS XML file to do active code inspection. Here, let me show you. Here are the composer.json and phpcs.xml.dist files from Beans.
Enable WordPress & Jump to Hook
To take full advantage of what PhpStorm has to offer, we need to enable WordPress integration. Once we do, then we get features like: Jump to where a hook (event) is being fired. Autocompletes for hook names. Filtering lookup for hooks.
Refactoring Tools
The refactoring tools in PhpStorm are awesome! I use them all the time to automate my workflow and get rid of some of the steps/tasks. Let me show you.
Jump to the Function
In one keystroke, you can quickly jump right to the source function (or class, trait, or interface). This feature is one of my favorites. Here, let me show you.
Selecting Multiple Instances (Multi-Cursor)
File Header Template
In this episode, let’s continue configuring our coding standard template by doing the file header for PHP and JavaScript.
Configuring Other Coding Standards
Many times, you need a different coding standard than the one specified by WordPress. Maybe your team and you use a modified version of the WPCS. Or maybe you are developing a project that uses PSR. PhpStorm lets you configure and save different coding standards, giving you the ability to set it up once and then select the one you need on each project.
WordPress Coding Standard
PhpStorm allows you to configure a coding standard. Using that standard, you can reformat an entire file to compile the standard…with just one keystroke. It saves you so much time, allowing you to do your work, trigger the reformatter, and bam, you’re done. Let’s configure and test that together.