Payton.Codes

Musings on life, games, and code

Blog

  • wires

    How do we deal with dependencies in PHP

    Generally what we want to do when we’re coding something is to call a function. While some of the functions we call could stand alone and some could be methods on an object, they’re all just function calls. So why does most PHP code have so many classes? I don’t think code organization is a…

  • Legend of the Whale

    As has become tradition, every year I design and run a one-shot Dungeons & Dragons game for my co-workers at our annual gathering. This year I was heavily inspired by my experiences playing Breath of the Wild and I wanted to try to re-create that particular “Zelda” feeling in D&D. I’d love to have done…

  • Safely coding with constants

    In PHP there is a tendency to assume that the code we are working on is the only code that is running. The global and transactional nature of the language’s past has made this easy to do. This tendency naturally leads us to use global state, and while there does seem to be a resistance…

  • Giving more time to each thing

    Lately a lot of my dharma practice has been revealing restlessness. Even when I think I’m being calm and slow and contemplative, I still am giving more thought to my Instagram-mind, or my what-do-I-need-to-do-next mind. Most of all I’ve noticed that my inclination toward efficiency in all things leads me to always be doing more…

  • Creating Sniffs for a PHPCS Standard

    As a follow-up to my summary of using phpcs to lint your PHP code, this post will explain how to create, modify, and test a phpcs standard. As a quick refresher, phpcs organizes its linting messages (warnings and errors) into “sniffs”, then into “categories”, then into a “standard”. The official tutorial for creating a standard…

  • Linting PHP with phpcs sniffs

    Linting is the process of using an automated tool to scan your code for problems before you commit and deploy. It is a practice widely used in the development workflow of many languages, but hasn’t much been used in the PHP of WordPress developers. The most commonly used linter in PHP right now is called…

  • Maybe returning errors in PHP

    A common pattern I see in WordPress PHP code (and probably other PHP code) is a function which does some operation on data and returns a value. For example, a function which makes a database query and then returns the resulting row. In order to make more robust code and prevent bugs, I’ve been systematically…

  • Functional Dependency Injection in PHP

    Having become used to the convenience of passing first-class functions around in JavaScript to make other functions decoupled and easily testable, I was wondering if we could do the same thing in PHP. Of course, PHP technically has first-class functions as well, but the syntax is a little awkward, since the functions must be referenced…

  • Thoughts on Privilege

    Today in my Sangha we explored the concept of Engaged Buddhism, particularly as it applies to race, gender, and class. We explored the most insidious aspect of privilege in our society: that those with privilege do not see it; we are blind to it. White people do not consider race to be a primary factor…

  • Search for the Sage

    My fourth D&D adventure crafted for the Automattic Grand Meetup, Search for the Sage is a one-shot game perfect for new and experienced players alike. It runs in about 3-4 hours. I had a lot of fun creating and running this one! Huge thanks to the many friends who played through this adventure and extra…

  • Declarative vs. Imperative: asking for soup vs. making soup

    A little while ago I wrote a post about my concepts of declarative vs. imperative programming. I ended that article by saying, “I can’t wait to see what I’ll learn next.” Well, I’ve found another definition which has been very helpful to me lately. Also, I’m a little worried that it might actually be the…

  • Lightweight rendering of React to strings

    For a recent project I needed to be able to render React components (or really, just React-like components) into plain HTML strings. Of course, React provides a mechanism to do this: renderToStaticMarkup in its ReactDOM library. But wow, that library is a really big dependency to import if I don’t want any of the DOM reconciliation…