While PHP namespaces allow you to refer to a function in file without using the fully qualified name, there is a catch when adding a WordPress hook or filter. The PHP __NAMESPACE__ magic constant can be helpful in this situation.
Shampoo Bottle Protocol
One day I realized that the last 10% of the shampoo bottle lasted at least as long as the first 90%. I suspected this was because most of the time I was using too much shampoo but as I neared the end of the bottle I used a more appropriate amount. How could I trick my brain to always use the appropriate amount?
Brady Bunch Achievement
The “Brady Bunch Achievement” is when you have exactly nine people on a video call. When this happens, viewing all participants in a grid looks like the intro to the Brady Bunch.
Remove newline at end of text file
Sometimes when I’m working with files in Git, I find myself with a change in a file that says “No newline at end of file”. This occurs when my editor adds the missing newline at the end of the file. While you should have a newline at the end of the file, you may have a reason for not wanting to add this change. In that case, you can remove the newline from the end of the file.
phpunit.xml vs phpunit.xml.dist
As a PHP programmer I’ve seen projects with a phpunit.xml file or a phpunit.xml.dist file (or even both, which is a mistake). These are configuration files for PHPUnit but why the two different file names? PHPUnit first tries to use phpunit.xml and if that file does not exist, then it tries to use phpunit.xml.dist instead. PHPUnit only uses one of these files, never both.
The “or” (||) operator and the “nullish coalescing operator” (??) can often be used in similar ways when reading a property from an object that may or may not exist. When dealing with strings you’re typically better off using “or” (||) and for numbers you’re typically better off using the “nullish coalescing operator” (??).
Semantic versioning (SemVer) is a standard for defining the version numbers. A version number consists of three numbers separated by periods (X.Y.Z). The type of change being introduced (e.g. a new feature or a change that breaks backwards compatibility) determines which numbers are incremented.
Git Alias Open Pull Request on GitHub
I want to be able to type “git open-github-pr” and have my browser open to the GitHub URL to create a Pull Request (PR) for my current branch on the current project I’m working on. Here is how I built this.
Your edited hunk does not apply
When using git add -p and faced with a hunk that can not be split sufficiently for your purposes, you can use the e option (manually edit the current hunk). Unfortunately, after manually editing the current hunk it is common to get the message “Your edited hunk does not apply.” I’ve found there are some things I can do to avoid this failure.
Writing Posts with CLI Commands
A lot of the posts I write include command-line interface (CLI) commands to type in. I’ve found over time there are things I can do to improve how these commands are communicated.