[{"data":1,"prerenderedAt":2018},["ShallowReactive",2],{"post-cards":3,"categories":546,"post-solid-principles-modern-php":584},[4,26,49,60,76,90,99,108,118,131,141,151,162,177,189,202,213,224,235,246,257,268,281,294,309,324,338,352,364,375,386,396,406,416,426,436,446,456,466,476,486,496,506,516,526,536],{"path":5,"title":6,"slug":7,"summary":8,"date":9,"readTime":10,"hasImage":11,"category":12,"tags":17,"tagSlugs":25},"\u002Fposts\u002Fsolid-principles-modern-php","SOLID Principles in Modern PHP","solid-principles-modern-php","SOLID has not changed in years, but PHP has. Here are the five object-oriented design principles rewritten for PHP 8.5, using typed properties, readonly, enums, constructor promotion, and property hooks to express the same ideas with far less boilerplate.","2026-06-14T12:00:00",9,true,{"id":13,"name":14,"slug":15,"hue":16},1,"PHP","php",264,[18,19,22],{"name":14,"slug":15},{"name":20,"slug":21},"OOP","oop",{"name":23,"slug":24},"Architecture","architecture",[15,21,24],{"path":27,"title":28,"slug":29,"summary":30,"date":31,"readTime":32,"hasImage":33,"category":34,"tags":39,"tagSlugs":48},"\u002Fposts\u002Fgit-flow-vs-github-flow-choosing-a-branching-strategy","Git Flow vs GitHub Flow: Choosing a Branching Strategy for Your Team","git-flow-vs-github-flow-choosing-a-branching-strategy","Git Flow and GitHub Flow take very different approaches to team branching and releases. Let's compare them, see where trunk-based development fits, and sort out how to handle versioned releases, hotfixes, and everything in between.","2026-06-14",7,false,{"id":35,"name":36,"slug":37,"hue":38},4,"Git","git",158,[40,42,45],{"name":41,"slug":37},"GIT",{"name":43,"slug":44},"Workflow","workflow",{"name":46,"slug":47},"GitHub","github",[37,44,47],{"path":50,"title":51,"slug":52,"summary":53,"date":31,"readTime":32,"hasImage":33,"category":54,"tags":55,"tagSlugs":59},"\u002Fposts\u002Fgithub-flow-keep-your-main-branch-deployable","GitHub Flow: Keep Your Main Branch Deployable","github-flow-keep-your-main-branch-deployable","GitHub Flow is the lightweight branching workflow built on a single rule: anything in main is deployable. Here is the whole loop, branch, pull request, review, merge and deploy, with the git and gh commands and an honest look at where it fits.",{"id":35,"name":36,"slug":37,"hue":38},[56,57,58],{"name":41,"slug":37},{"name":43,"slug":44},{"name":46,"slug":47},[37,44,47],{"path":61,"title":62,"slug":63,"summary":64,"date":65,"readTime":66,"hasImage":33,"category":67,"tags":72,"tagSlugs":75},"\u002Fposts\u002Fstarting-with-rust-installation-first-program","Starting with Rust: From Installation to Your First Program","starting-with-rust-installation-first-program","Learn how to install Rust and write your first \"Hello, world!\" program.","2024-03-23",2,{"id":68,"name":69,"slug":70,"hue":71},6,"Rust","rust-programming",38,[73],{"name":74,"slug":74},"rust",[74],{"path":77,"title":78,"slug":79,"summary":80,"date":81,"readTime":66,"hasImage":33,"category":82,"tags":87,"tagSlugs":89},"\u002Fposts\u002Fflutter-version-management-fvm","Flutter Version Management","flutter-version-management-fvm","Managing multiple Flutter versions does not need not be a headache. Let's jump into FVM and see how it can simplify your Flutter journey.","2023-10-07",{"id":83,"name":84,"slug":85,"hue":86},5,"Flutter","flutter",230,[88],{"name":85,"slug":85},[85],{"path":91,"title":92,"slug":93,"summary":94,"date":81,"readTime":13,"hasImage":33,"category":95,"tags":96,"tagSlugs":98},"\u002Fposts\u002Fsetting-up-cocoapods-fvm","Setting Up CocoaPods for FVM-managed Flutter Projects","setting-up-cocoapods-fvm","A guide to installing CocoaPods for a Flutter project while using FVM to manage Flutter versions, ensuring a smooth setup for iOS development.",{"id":83,"name":84,"slug":85,"hue":86},[97],{"name":85,"slug":85},[85],{"path":100,"title":101,"slug":102,"summary":103,"date":81,"readTime":13,"hasImage":33,"category":104,"tags":105,"tagSlugs":107},"\u002Fposts\u002Ftroubleshooting-xcode-15-build-issues-flutter","Troubleshooting Xcode 15 Build Issues in Flutter Projects","troubleshooting-xcode-15-build-issues-flutter","Uncovering solutions to common issues faced when updating to Xcode 15 in a Flutter project using an older version of CocoaPods.",{"id":83,"name":84,"slug":85,"hue":86},[106],{"name":85,"slug":85},[85],{"path":109,"title":110,"slug":111,"summary":112,"date":113,"readTime":35,"hasImage":33,"category":114,"tags":115,"tagSlugs":117},"\u002Fposts\u002Fgit-tracking-a-remote-branch-upstream-for-changes","Git: Tracking a Remote Branch for Changes","git-tracking-a-remote-branch-upstream-for-changes","When you fork a project, you need a way to pull in changes from the original repository, usually called upstream. Here is how to wire up an upstream remote, actually sync your fork, and set up branch tracking so plain git pull and git push just work.","2018-11-04",{"id":35,"name":36,"slug":37,"hue":38},[116],{"name":41,"slug":37},[37],{"path":119,"title":120,"slug":121,"summary":122,"date":113,"readTime":123,"hasImage":11,"category":124,"tags":128,"tagSlugs":130},"\u002Fposts\u002Fjavascript-array-map-filter-reduce-functions","JavaScript's map, filter, and reduce methods","javascript-array-map-filter-reduce-functions","JavaScript provides some amazing functions that can be called against your arrays to help filter them, manipulate them, or even reduce them down to a single value or grouped values.",3,{"id":66,"name":125,"slug":126,"hue":127},"JavaScript","javascript",92,[129],{"name":125,"slug":126},[126],{"path":132,"title":133,"slug":134,"summary":135,"date":136,"readTime":13,"hasImage":11,"category":137,"tags":138,"tagSlugs":140},"\u002Fposts\u002Fphp-fizzbuzz-example","FizzBuzz in PHP: A Fresh Approach","php-fizzbuzz-example","FizzBuzz is a very popular programming question that tests your logic to see if you can build a simple program.","2018-11-02",{"id":13,"name":14,"slug":15,"hue":16},[139],{"name":14,"slug":15},[15],{"path":142,"title":143,"slug":144,"summary":145,"date":146,"readTime":66,"hasImage":11,"category":147,"tags":148,"tagSlugs":150},"\u002Fposts\u002Fphp-array-reduce","PHP's array_reduce is not only for outputting single values","php-array-reduce","PHP's array_reduce is a simple way to partition a set of data or return a single value. It is super powerful and worth spending time learning.","2018-11-01",{"id":13,"name":14,"slug":15,"hue":16},[149],{"name":14,"slug":15},[15],{"path":152,"title":153,"slug":154,"summary":155,"date":156,"readTime":68,"hasImage":33,"category":157,"tags":158,"tagSlugs":161},"\u002Fposts\u002Fimprove-your-git-workflow-with-git-flow","Improve Your Git Workflow with Git Flow","improve-your-git-workflow-with-git-flow","Git Flow is a structured branching model built around versioned, scheduled releases. Here is how its branches fit together, a hands-on walkthrough of features, releases and hotfixes, and an honest take on when it is still the right call.","2016-12-06",{"id":35,"name":36,"slug":37,"hue":38},[159,160],{"name":41,"slug":37},{"name":43,"slug":44},[37,44],{"path":163,"title":164,"slug":165,"summary":166,"date":167,"readTime":68,"hasImage":33,"category":168,"tags":172,"tagSlugs":176},"\u002Fposts\u002Fusing-css-transitions","Using CSS Transitions","using-css-transitions","CSS transitions are the standard way to apply transitions to your elements, and have been for years, replacing the old approach of using JavaScript. In this article, I'll go through each of the transition properties available, and provide examples of how to use them.","2016-12-05",{"id":123,"name":169,"slug":170,"hue":171},"HTML & CSS","html-css",55,[173],{"name":174,"slug":175},"CSS","css",[175],{"path":178,"title":179,"slug":180,"summary":181,"date":182,"readTime":35,"hasImage":33,"category":183,"tags":184,"tagSlugs":188},"\u002Fposts\u002Fstructuring-your-website-with-html-5-semantics","Structuring Your Website With HTML 5 Semantics","structuring-your-website-with-html-5-semantics","Prior to HTML 5, there was no real markup to help explain the intent behind your HTML code. The goal of HTML 5 was to offer a more readable way of writing your code, so that any author that comes after you can have an easier time going through what you've created.","2016-12-04",{"id":123,"name":169,"slug":170,"hue":171},[185],{"name":186,"slug":187},"HTML","html",[187],{"path":190,"title":191,"slug":192,"summary":193,"date":194,"readTime":66,"hasImage":33,"category":195,"tags":196,"tagSlugs":201},"\u002Fposts\u002Finterpolation-in-stylus-css-pre-processor","Interpolation in Stylus","interpolation-in-stylus-css-pre-processor","You can also use interpolation to improve your functions for reuse, as well as your other code within your stylesheet. The way it works is that you can wrap your expression within {}, which will then be outputted as the identifier.","2016-12-03",{"id":123,"name":169,"slug":170,"hue":171},[197,200],{"name":198,"slug":199},"Stylus","stylus",{"name":174,"slug":175},[199,175],{"path":203,"title":204,"slug":205,"summary":206,"date":207,"readTime":13,"hasImage":33,"category":208,"tags":209,"tagSlugs":212},"\u002Fposts\u002Fcreating-configuration-files-in-stylus-css-pre-processor","Creating Configuration Files In Stylus","creating-configuration-files-in-stylus-css-pre-processor","It's super simple to create a configuration file for instance that would manage your media query break points. You could also use a configuration file for managing colors, font sizes, and other variables such as gutter spacing and more.","2016-12-02",{"id":123,"name":169,"slug":170,"hue":171},[210,211],{"name":174,"slug":175},{"name":198,"slug":199},[175,199],{"path":214,"title":215,"slug":216,"summary":217,"date":218,"readTime":35,"hasImage":33,"category":219,"tags":220,"tagSlugs":223},"\u002Fposts\u002Fusing-functions-and-mixins-with-stylus-css-pre-processor","Using Functions and Mixins with Stylus","using-functions-and-mixins-with-stylus-css-pre-processor","Stylus allows you to create functions and mixins of reusable code for your stylesheets. You can also handle mathematical operations, unary operations, and more allowing you complete control over your stylesheets with ease.","2016-12-01",{"id":123,"name":169,"slug":170,"hue":171},[221,222],{"name":174,"slug":175},{"name":198,"slug":199},[175,199],{"path":225,"title":226,"slug":227,"summary":228,"date":229,"readTime":66,"hasImage":33,"category":230,"tags":231,"tagSlugs":234},"\u002Fposts\u002Fsetting-variables-in-stylus-css-pre-processor","Setting Variables in Stylus","setting-variables-in-stylus-css-pre-processor","Unlike CSS, in Stylus you can assign expressions to variables that can be reusable throughout your stylesheets.","2016-11-29",{"id":123,"name":169,"slug":170,"hue":171},[232,233],{"name":174,"slug":175},{"name":198,"slug":199},[175,199],{"path":236,"title":237,"slug":238,"summary":239,"date":240,"readTime":83,"hasImage":33,"category":241,"tags":242,"tagSlugs":245},"\u002Fposts\u002Fusing-selectors-in-stylus-css-pre-processor","Using Selectors in Stylus","using-selectors-in-stylus-css-pre-processor","Selectors are a way to pick the elements that you want styled. In Stylus, similar to CSS, you can apply a set of styles to any element by separating them by a comma delimited list. Stylus though, also allows you to select multiple elements by separating each on their own line.","2016-11-28",{"id":123,"name":169,"slug":170,"hue":171},[243,244],{"name":174,"slug":175},{"name":198,"slug":199},[175,199],{"path":247,"title":248,"slug":249,"summary":250,"date":251,"readTime":13,"hasImage":33,"category":252,"tags":253,"tagSlugs":256},"\u002Fposts\u002Flearning-stylus-a-css-pre-processor","Learning Stylus: A CSS Pre-Processor","learning-stylus-a-css-pre-processor","This mini-series will be a little different to how you may see other articles on my site. Really this article is more geared as notes for me as I go through the documentation for Stylus, and learn the ins and outs of this beautiful language.","2016-11-27",{"id":123,"name":169,"slug":170,"hue":171},[254,255],{"name":174,"slug":175},{"name":198,"slug":199},[175,199],{"path":258,"title":259,"slug":260,"summary":261,"date":262,"readTime":35,"hasImage":33,"category":263,"tags":264,"tagSlugs":267},"\u002Fposts\u002Fbem-methodology-overview-and-naming-conventions","BEM Methodology Overview and Naming Conventions","bem-methodology-overview-and-naming-conventions","BEM or Block Element Modifier is a naming convention used to help organize your code base. In this article, I discuss its uses within your CSS projects.","2016-11-26",{"id":123,"name":169,"slug":170,"hue":171},[265,266],{"name":174,"slug":175},{"name":186,"slug":187},[175,187],{"path":269,"title":270,"slug":271,"summary":272,"date":273,"readTime":13,"hasImage":33,"category":274,"tags":275,"tagSlugs":280},"\u002Fposts\u002Fintroduction-to-ecmascript-6","Introduction to ECMAScript 6","introduction-to-ecmascript-6","The latest in ECMAScript 6 introduces new features to JavaScript which makes it so much more fun to use, while solving problems that have been around for years. The intent of this article is to provide you with resources you can use to start learning ES6 today.","2016-11-25",{"id":66,"name":125,"slug":126,"hue":127},[276,277],{"name":125,"slug":126},{"name":278,"slug":279},"ECMAScript","ecmascript",[126,279],{"path":282,"title":283,"slug":284,"summary":285,"date":286,"readTime":123,"hasImage":33,"category":287,"tags":288,"tagSlugs":293},"\u002Fposts\u002Fbabel-installation-and-configuration","Babel Installation and Configuration","babel-installation-and-configuration","Babel offers a convenient way to transform your ES6 code to JavaScript that all browsers can understand. In this article we'll go over a basic configuration that will enable you to start using it with any project right away.","2016-11-24",{"id":66,"name":125,"slug":126,"hue":127},[289,290],{"name":125,"slug":126},{"name":291,"slug":292},"Babel","babel",[126,292],{"path":295,"title":296,"slug":297,"summary":298,"date":299,"readTime":13,"hasImage":33,"category":300,"tags":301,"tagSlugs":308},"\u002Fposts\u002Fconfiguring-stylus-css-pre-processor-with-gulp-and-sourcemaps","Configuring Stylus CSS Pre-Processor with Gulp and Sourcemaps","configuring-stylus-css-pre-processor-with-gulp-and-sourcemaps","In this article we'll go over how to configure your project to process Stylus files using Gulp. We'll also create source map file which your browser will use to help point you in the right direction of your files when developing","2016-11-23",{"id":66,"name":125,"slug":126,"hue":127},[302,303,304,305],{"name":125,"slug":126},{"name":198,"slug":199},{"name":174,"slug":175},{"name":306,"slug":307},"Gulp","gulp",[126,199,175,307],{"path":310,"title":311,"slug":312,"summary":313,"date":314,"readTime":66,"hasImage":33,"category":315,"tags":316,"tagSlugs":323},"\u002Fposts\u002Fconfiguring-gulp-with-less-css-pre-processor","Configuring Gulp With Less CSS Pre-Processor","configuring-gulp-with-less-css-pre-processor","Less is a CSS pre-processor allowing you to create variables, mixins, and functions in an effort to make your CSS more maintainable.","2016-11-22",{"id":66,"name":125,"slug":126,"hue":127},[317,318,319,322],{"name":306,"slug":307},{"name":125,"slug":126},{"name":320,"slug":321},"Less","less",{"name":174,"slug":175},[307,126,321,175],{"path":325,"title":326,"slug":327,"summary":328,"date":329,"readTime":66,"hasImage":11,"category":330,"tags":331,"tagSlugs":337},"\u002Fposts\u002Fusing-browser-sync-with-gulp-for-live-reloading","Using Browser Sync with Gulp for Live Reloading","using-browser-sync-with-gulp-for-live-reloading","Browser Sync is a nice tool to use while developing. It allows your browser to reload live when changes are made to your files. For instance, assuming we're watching our CSS file for changes we can have the browser auto refresh\u002Fsync when it sees those changes made.","2016-11-21",{"id":66,"name":125,"slug":126,"hue":127},[332,333,336],{"name":125,"slug":126},{"name":334,"slug":335},"Browser Sync","browser-sync",{"name":306,"slug":307},[126,335,307],{"path":339,"title":340,"slug":341,"summary":342,"date":343,"readTime":66,"hasImage":33,"category":344,"tags":345,"tagSlugs":351},"\u002Fposts\u002Fgulp-watch-automate-your-gulp-tasks","Gulp Watch: Automate Your Gulp Tasks","gulp-watch-automate-your-gulp-tasks","Gulp watch is perfect for when you're editing project files since it allows you to not have to run the gulp command manually each time.","2016-11-20",{"id":66,"name":125,"slug":126,"hue":127},[346,347,350],{"name":125,"slug":126},{"name":348,"slug":349},"Yarn","yarn",{"name":306,"slug":307},[126,349,307],{"path":353,"title":354,"slug":355,"summary":356,"date":357,"readTime":68,"hasImage":33,"category":358,"tags":359,"tagSlugs":363},"\u002Fposts\u002Fconfiguring-gulp-on-a-new-project","Configuring Gulp On A New Project","configuring-gulp-on-a-new-project","Gulp may seem like a scary thing to wrap your head around at first, but it's actually quite easy to start using once you understand the basics.","2016-11-19",{"id":66,"name":125,"slug":126,"hue":127},[360,361,362],{"name":125,"slug":126},{"name":306,"slug":307},{"name":348,"slug":349},[126,307,349],{"path":365,"title":366,"slug":367,"summary":368,"date":369,"readTime":123,"hasImage":33,"category":370,"tags":371,"tagSlugs":374},"\u002Fposts\u002Fyarn-publishing-a-package","Yarn: Publishing a Package","yarn-publishing-a-package","Publishing a package to the npm repository has never been simpler. With a few steps, you can create a package that is redistributable to all of your projects.","2016-11-18",{"id":66,"name":125,"slug":126,"hue":127},[372,373],{"name":125,"slug":126},{"name":348,"slug":349},[126,349],{"path":376,"title":377,"slug":378,"summary":379,"date":380,"readTime":123,"hasImage":33,"category":381,"tags":382,"tagSlugs":385},"\u002Fposts\u002Fyarn-fast-and-secure-dependency-management","Yarn: Fast and Secure Dependency Management","yarn-fast-and-secure-dependency-management","Yarn is a super simple dependency management tool which is way faster to use instead of traditional npm. It acts as a drop-in replacement, so you can get started using yarn right away. The best way to install yarn is by using npm.","2016-11-17",{"id":66,"name":125,"slug":126,"hue":127},[383,384],{"name":125,"slug":126},{"name":348,"slug":349},[126,349],{"path":387,"title":388,"slug":389,"summary":390,"date":391,"readTime":13,"hasImage":11,"category":392,"tags":393,"tagSlugs":395},"\u002Fposts\u002Fsupport-for-keys-in-list-or-its-new-shorthand-syntax-in-php","Support for keys in list(), or its new shorthand syntax [] in PHP","support-for-keys-in-list-or-its-new-shorthand-syntax-in-php","Now as of PHP 7.1, you can define the keys of your array that will be parsed when destructuring your arrays. Prior to PHP 7.1, you could only use arrays with numeric indexes. Now with this new addition, our lives just got easier.","2016-11-16",{"id":13,"name":14,"slug":15,"hue":16},[394],{"name":14,"slug":15},[15],{"path":397,"title":398,"slug":399,"summary":400,"date":401,"readTime":13,"hasImage":11,"category":402,"tags":403,"tagSlugs":405},"\u002Fposts\u002Ftype-hinting-with-the-iterable-pseudo-type-in-php","Type Hinting With The Iterable pseudo-type In PHP","type-hinting-with-the-iterable-pseudo-type-in-php","As of PHP 7.1, you can now type hint your method\u002Ffunction arguments with the keyword iterable for handling arrays or even objects that implement the Traversable interface.","2016-11-15",{"id":13,"name":14,"slug":15,"hue":16},[404],{"name":14,"slug":15},[15],{"path":407,"title":408,"slug":409,"summary":410,"date":411,"readTime":13,"hasImage":11,"category":412,"tags":413,"tagSlugs":415},"\u002Fposts\u002Ftype-hinting-callable-functions-in-php","Type Hinting Callable Functions in PHP","type-hinting-callable-functions-in-php","As of PHP 5.4, you can type hint your method arguments with the callable keyword allowing you to enforce the type of data that is passed via your arguments.","2016-11-14",{"id":13,"name":14,"slug":15,"hue":16},[414],{"name":14,"slug":15},[15],{"path":417,"title":418,"slug":419,"summary":420,"date":421,"readTime":13,"hasImage":11,"category":422,"tags":423,"tagSlugs":425},"\u002Fposts\u002Fsetting-visibility-for-your-class-constants-in-php","Setting Visibility for Your Class Constants in PHP","setting-visibility-for-your-class-constants-in-php","Now in PHP 7.1+, you can set different visibility modifiers for each of your class constants. The available visibility modifiers consist of public, protected, and private.","2016-11-13",{"id":13,"name":14,"slug":15,"hue":16},[424],{"name":14,"slug":15},[15],{"path":427,"title":428,"slug":429,"summary":430,"date":431,"readTime":13,"hasImage":11,"category":432,"tags":433,"tagSlugs":435},"\u002Fposts\u002Fanonymous-classes-php","Using Anonymous Classes in PHP","anonymous-classes-php","As of PHP 7, you can now create quick throwaway objects for use within your projects. This can be especially useful for your automated tests, for instance, with allowing you to create quick implementations of your interfaces.","2016-11-12",{"id":13,"name":14,"slug":15,"hue":16},[434],{"name":14,"slug":15},[15],{"path":437,"title":438,"slug":439,"summary":440,"date":441,"readTime":13,"hasImage":11,"category":442,"tags":443,"tagSlugs":445},"\u002Fposts\u002Fsymmetric-array-destructuring-in-php","Symmetric Array Destructuring in PHP","symmetric-array-destructuring-in-php","As of PHP 7.1, you can now use the shorthand array syntax to destructure your arrays for assignment. Previously you would have had to use a function like list, but now you can use the simple new array shorthand syntax.","2016-11-11",{"id":13,"name":14,"slug":15,"hue":16},[444],{"name":14,"slug":15},[15],{"path":447,"title":448,"slug":449,"summary":450,"date":451,"readTime":66,"hasImage":11,"category":452,"tags":453,"tagSlugs":455},"\u002Fposts\u002Fphp-array-map-to-format-your-arrays-without-loops","Using PHP's array_map to format your arrays without loops","php-array-map-to-format-your-arrays-without-loops","So let's face it, loops are a bit boring. So how can we mix it up? Let's assume we have a case where we have a CSV file that we want to quickly parse.","2016-11-10",{"id":13,"name":14,"slug":15,"hue":16},[454],{"name":14,"slug":15},[15],{"path":457,"title":458,"slug":459,"summary":460,"date":461,"readTime":32,"hasImage":11,"category":462,"tags":463,"tagSlugs":465},"\u002Fposts\u002Fsolid-principles-in-php","SOLID Principles in PHP","solid-principles-in-php","The 5 basic principles for Object-Oriented Design, SOLID, were first created in an effort to improve maintainability in our code bases. SOLID is a mnemonic acronym that stands for each of the following principles: Single Responsibility, Open-Closed, Liskov Substitution, Interface Segregation, and Dependency Inversion.","2016-11-09",{"id":13,"name":14,"slug":15,"hue":16},[464],{"name":14,"slug":15},[15],{"path":467,"title":468,"slug":469,"summary":470,"date":471,"readTime":13,"hasImage":11,"category":472,"tags":473,"tagSlugs":475},"\u002Fposts\u002Ffiltering-arrays-without-using-loops-in-php","Filtering Arrays Without Using Loops in PHP","filtering-arrays-without-using-loops-in-php","PHP has a built-in function called array_filter that allows you to filter through your arrays without the need for a loop. Personally, this approach feels much cleaner to me and simpler to comprehend.","2016-11-08",{"id":13,"name":14,"slug":15,"hue":16},[474],{"name":14,"slug":15},[15],{"path":477,"title":478,"slug":479,"summary":480,"date":481,"readTime":13,"hasImage":11,"category":482,"tags":483,"tagSlugs":485},"\u002Fposts\u002Fvoid-return-types-in-php","Void Return Types in PHP","void-return-types-in-php","As of PHP 7.1, we can now use void return types within our methods. This is useful for cases where you have methods that are just setting or processing data without the need of returning any values.","2016-11-07",{"id":13,"name":14,"slug":15,"hue":16},[484],{"name":14,"slug":15},[15],{"path":487,"title":488,"slug":489,"summary":490,"date":491,"readTime":13,"hasImage":11,"category":492,"tags":493,"tagSlugs":495},"\u002Fposts\u002Ftype-hinting-with-nullable-types-in-php","Type Hinting with Nullable Types in PHP","type-hinting-with-nullable-types-in-php","As of PHP 7.1, you can now set your type declarations as nullable by simply prefixing them with a question mark ?. In doing so a null value can be passed in as a parameter or returned as a value for your methods.","2016-11-06",{"id":13,"name":14,"slug":15,"hue":16},[494],{"name":14,"slug":15},[15],{"path":497,"title":498,"slug":499,"summary":500,"date":501,"readTime":13,"hasImage":11,"category":502,"tags":503,"tagSlugs":505},"\u002Fposts\u002Fphp-group-multiple-use-declarations","PHP Group Multiple use Declarations","php-group-multiple-use-declarations","As of PHP 7, you can now group your imported classes, functions, and constants from under the same namespace.","2016-11-05",{"id":13,"name":14,"slug":15,"hue":16},[504],{"name":14,"slug":15},[15],{"path":507,"title":508,"slug":509,"summary":510,"date":511,"readTime":13,"hasImage":11,"category":512,"tags":513,"tagSlugs":515},"\u002Fposts\u002Fphp-null-coalescing-operator","PHP Null Coalescing Operator","php-null-coalescing-operator","One of my new favorite additions to PHP 7, is the Null Coalescing Operator. It cleans up your code by removing a tedious step of checking if some value is isset() and not NULL and returning it or if not setting a default.","2016-11-04",{"id":13,"name":14,"slug":15,"hue":16},[514],{"name":14,"slug":15},[15],{"path":517,"title":518,"slug":519,"summary":520,"date":521,"readTime":66,"hasImage":11,"category":522,"tags":523,"tagSlugs":525},"\u002Fposts\u002Fphp-spaceship-operator","PHP Spaceship Operator","php-spaceship-operator","One of the new features to hit PHP 7 is the Spaceship Operator. This new trick helps improve the way you'd compare 2 expressions. In short, the comparison returns 1 of 3 values (-1, 0, or 1) depending on the result of the comparison.","2016-11-03",{"id":13,"name":14,"slug":15,"hue":16},[524],{"name":14,"slug":15},[15],{"path":527,"title":528,"slug":529,"summary":530,"date":531,"readTime":123,"hasImage":11,"category":532,"tags":533,"tagSlugs":535},"\u002Fposts\u002Freturn-type-declarations-in-php","Return Type Declarations in PHP","return-type-declarations-in-php","PHP 7 now makes it possible to declare return types for your methods. This allows you better control over the data that will be returned from each method in your application.","2016-11-02",{"id":13,"name":14,"slug":15,"hue":16},[534],{"name":14,"slug":15},[15],{"path":537,"title":538,"slug":539,"summary":540,"date":541,"readTime":13,"hasImage":11,"category":542,"tags":543,"tagSlugs":545},"\u002Fposts\u002Fscalar-type-hints-php","Scalar Type Hints in PHP","scalar-type-hints-php","Starting with PHP 7.0, it's now possible to declare scalar type hints for your method arguments. Previously, we were able to use array and callable, but now with PHP 7+, we have much more control.","2016-11-01",{"id":13,"name":14,"slug":15,"hue":16},[544],{"name":14,"slug":15},[15],[547,554,560,566,572,578],{"id":548,"description":549,"extension":550,"hue":16,"meta":551,"name":14,"slug":15,"stem":552,"weight":13,"__hash__":553},"categories\u002Fcategories\u002Fphp.json","PHP articles and tutorials ranging from new language features to using interesting packages.","json",{},"categories\u002Fphp","h_EmN4YMO4b2mBt3MPLs7RvscJx0NBmwDIZPxqPqKLE",{"id":555,"description":556,"extension":550,"hue":127,"meta":557,"name":125,"slug":126,"stem":558,"weight":66,"__hash__":559},"categories\u002Fcategories\u002Fjavascript.json","JavaScript articles and tutorials ranging from new language features to using interesting packages.",{},"categories\u002Fjavascript","7gmVgkw5BRo26i1bFoSv96bwDJ4nTtZcJ9Ud6u5p0yk",{"id":561,"description":562,"extension":550,"hue":171,"meta":563,"name":169,"slug":170,"stem":564,"weight":123,"__hash__":565},"categories\u002Fcategories\u002Fhtml-css.json","HTML & CSS articles and tutorials ranging from new language features to using interesting packages.",{},"categories\u002Fhtml-css","vXvPlRA-iaeCJ64Wi3sLyUR0kqL48zYcZWORRqt8N70",{"id":567,"description":568,"extension":550,"hue":38,"meta":569,"name":36,"slug":37,"stem":570,"weight":35,"__hash__":571},"categories\u002Fcategories\u002Fgit.json","Git articles and tutorials ranging from new language features to different workflows.",{},"categories\u002Fgit","qOqFsFTKI9XB444UodUKW_3AakFadHzW-ss8V-maUmE",{"id":573,"description":574,"extension":550,"hue":86,"meta":575,"name":84,"slug":85,"stem":576,"weight":83,"__hash__":577},"categories\u002Fcategories\u002Fflutter.json","Dive into Flutter, the open-source UI software development toolkit, as we explore its capabilities in creating natively compiled applications for mobile, web, and desktop from a single codebase.",{},"categories\u002Fflutter","aD1moU8CgoYt4FRnSeA4Iy9xxnnopdEKBEYP2arAzdI",{"id":579,"description":580,"extension":550,"hue":71,"meta":581,"name":69,"slug":70,"stem":582,"weight":68,"__hash__":583},"categories\u002Fcategories\u002Frust-programming.json","From setting up your environment to advanced concepts, this is your go-to resource for all things Rust.",{},"categories\u002Frust-programming","LscnqSsk-htWc9yZg9eXaIUJwNfTK5oaZOClYKagNC4",{"id":585,"title":6,"body":586,"category":2007,"date":9,"description":592,"extension":2008,"hasImage":11,"meta":2009,"navigation":11,"path":5,"readTime":10,"seo":2010,"slug":7,"stem":2011,"summary":8,"tagSlugs":2012,"tags":2013,"__hash__":2017},"posts\u002Fposts\u002Fsolid-principles-modern-php.md",{"type":587,"value":588,"toc":1999},"minimark",[589,593,606,611,619,698,701,874,884,888,891,1022,1033,1193,1203,1207,1218,1353,1356,1360,1363,1625,1635,1750,1757,1761,1774,1867,1874,1975,1981,1985,1988,1995],[590,591,592],"p",{},"SOLID is a set of five object-oriented design principles, popularized by Robert C. Martin, that help you write code that is easier to extend, test, and maintain. The ideas have not changed in years. PHP, on the other hand, has changed enormously. When I first wrote about SOLID in 2016, expressing these principles took a lot of ceremony: manual property assignment, no real enums, getters and setters everywhere. PHP 8.5 strips most of that away, so the principles shine through with far less code. Let's walk through all five with modern PHP.",[594,595,597],"note",{"label":596},"PHP 8.5",[590,598,599,600,605],{},"These examples target PHP 8.5, the current release as of 2026. They lean on features added across the 8.x line: constructor property promotion, enums, readonly properties, first-class callables, and property hooks with asymmetric visibility. If you want to see how much has changed, the ",[601,602,604],"a",{"href":603},"\u002Farticles\u002Fsolid-principles-in-php","original 2016 version"," of this article is still up.",[607,608,610],"h2",{"id":609},"single-responsibility-principle","Single Responsibility Principle",[590,612,613,614,618],{},"A class should have one reason to change, which really just means it should do one job. The classic mistake is a class that both holds data and knows how to deliver it. Here the ",[615,616,617],"code",{},"Notification"," holds the message, and nothing else.",[620,621,625],"pre",{"className":622,"code":623,"language":15,"meta":624,"style":624},"language-php shiki shiki-themes github-dark github-dark","final class Notification\n{\n    public function __construct(\n        public readonly string $subject,\n        public readonly string $body,\n    ) {}\n}\n","",[615,626,627,642,648,663,677,688,693],{"__ignoreMap":624},[628,629,631,635,638],"span",{"class":630,"line":13},"line",[628,632,634],{"class":633},"sOPea","final",[628,636,637],{"class":633}," class",[628,639,641],{"class":640},"sFR8T"," Notification\n",[628,643,644],{"class":630,"line":66},[628,645,647],{"class":646},"suv1-","{\n",[628,649,650,653,656,660],{"class":630,"line":123},[628,651,652],{"class":633},"    public",[628,654,655],{"class":633}," function",[628,657,659],{"class":658},"s8ozJ"," __construct",[628,661,662],{"class":646},"(\n",[628,664,665,668,671,674],{"class":630,"line":35},[628,666,667],{"class":633},"        public",[628,669,670],{"class":633}," readonly",[628,672,673],{"class":633}," string",[628,675,676],{"class":646}," $subject,\n",[628,678,679,681,683,685],{"class":630,"line":83},[628,680,667],{"class":633},[628,682,670],{"class":633},[628,684,673],{"class":633},[628,686,687],{"class":646}," $body,\n",[628,689,690],{"class":630,"line":68},[628,691,692],{"class":646},"    ) {}\n",[628,694,695],{"class":630,"line":32},[628,696,697],{"class":646},"}\n",[590,699,700],{},"Because it is a readonly value object, once constructed it cannot be mutated, so there is exactly one reason it would ever change: the shape of a notification. Delivery is a separate concern, so it lives behind its own interface.",[620,702,704],{"className":622,"code":703,"language":15,"meta":624,"style":624},"interface Channel\n{\n    public function send(Notification $notification, string $to): void;\n}\n\nfinal class EmailChannel implements Channel\n{\n    public function __construct(private readonly Mailer $mailer) {}\n\n    public function send(Notification $notification, string $to): void\n    {\n        $this->mailer->deliver($to, $notification->subject, $notification->body);\n    }\n}\n",[615,705,706,714,718,750,754,759,773,777,799,803,827,833,863,869],{"__ignoreMap":624},[628,707,708,711],{"class":630,"line":13},[628,709,710],{"class":633},"interface",[628,712,713],{"class":640}," Channel\n",[628,715,716],{"class":630,"line":66},[628,717,647],{"class":646},[628,719,720,722,724,727,730,732,735,738,741,744,747],{"class":630,"line":123},[628,721,652],{"class":633},[628,723,655],{"class":633},[628,725,726],{"class":640}," send",[628,728,729],{"class":646},"(",[628,731,617],{"class":658},[628,733,734],{"class":646}," $notification, ",[628,736,737],{"class":633},"string",[628,739,740],{"class":646}," $to)",[628,742,743],{"class":633},":",[628,745,746],{"class":633}," void",[628,748,749],{"class":646},";\n",[628,751,752],{"class":630,"line":35},[628,753,697],{"class":646},[628,755,756],{"class":630,"line":83},[628,757,758],{"emptyLinePlaceholder":11},"\n",[628,760,761,763,765,768,771],{"class":630,"line":68},[628,762,634],{"class":633},[628,764,637],{"class":633},[628,766,767],{"class":640}," EmailChannel",[628,769,770],{"class":633}," implements",[628,772,713],{"class":640},[628,774,775],{"class":630,"line":32},[628,776,647],{"class":646},[628,778,780,782,784,786,788,791,793,796],{"class":630,"line":779},8,[628,781,652],{"class":633},[628,783,655],{"class":633},[628,785,659],{"class":658},[628,787,729],{"class":646},[628,789,790],{"class":633},"private",[628,792,670],{"class":633},[628,794,795],{"class":658}," Mailer",[628,797,798],{"class":646}," $mailer) {}\n",[628,800,801],{"class":630,"line":10},[628,802,758],{"emptyLinePlaceholder":11},[628,804,806,808,810,812,814,816,818,820,822,824],{"class":630,"line":805},10,[628,807,652],{"class":633},[628,809,655],{"class":633},[628,811,726],{"class":640},[628,813,729],{"class":646},[628,815,617],{"class":658},[628,817,734],{"class":646},[628,819,737],{"class":633},[628,821,740],{"class":646},[628,823,743],{"class":633},[628,825,826],{"class":633}," void\n",[628,828,830],{"class":630,"line":829},11,[628,831,832],{"class":646},"    {\n",[628,834,836,839,842,845,847,850,853,855,858,860],{"class":630,"line":835},12,[628,837,838],{"class":658},"        $this",[628,840,841],{"class":633},"->",[628,843,844],{"class":646},"mailer",[628,846,841],{"class":633},[628,848,849],{"class":640},"deliver",[628,851,852],{"class":646},"($to, $notification",[628,854,841],{"class":633},[628,856,857],{"class":646},"subject, $notification",[628,859,841],{"class":633},[628,861,862],{"class":646},"body);\n",[628,864,866],{"class":630,"line":865},13,[628,867,868],{"class":646},"    }\n",[628,870,872],{"class":630,"line":871},14,[628,873,697],{"class":646},[590,875,876,877,879,880,883],{},"Now if the way we model a message changes, we touch ",[615,878,617],{},". If the way we talk to an email provider changes, we touch ",[615,881,882],{},"EmailChannel",". The two never bleed into each other.",[607,885,887],{"id":886},"open-closed-principle","Open-Closed Principle",[590,889,890],{},"Code should be open for extension but closed for modification. In practice that means you should be able to add behavior without editing the classes that are already written, working, and tested. Channels make this easy: adding Slack support is a new class, not a change to an old one.",[620,892,894],{"className":622,"code":893,"language":15,"meta":624,"style":624},"final class SlackChannel implements Channel\n{\n    public function __construct(private readonly SlackClient $slack) {}\n\n    public function send(Notification $notification, string $to): void\n    {\n        $this->slack->post($to, \"*{$notification->subject}*\\n{$notification->body}\");\n    }\n}\n",[615,895,896,909,913,933,937,959,963,1014,1018],{"__ignoreMap":624},[628,897,898,900,902,905,907],{"class":630,"line":13},[628,899,634],{"class":633},[628,901,637],{"class":633},[628,903,904],{"class":640}," SlackChannel",[628,906,770],{"class":633},[628,908,713],{"class":640},[628,910,911],{"class":630,"line":66},[628,912,647],{"class":646},[628,914,915,917,919,921,923,925,927,930],{"class":630,"line":123},[628,916,652],{"class":633},[628,918,655],{"class":633},[628,920,659],{"class":658},[628,922,729],{"class":646},[628,924,790],{"class":633},[628,926,670],{"class":633},[628,928,929],{"class":658}," SlackClient",[628,931,932],{"class":646}," $slack) {}\n",[628,934,935],{"class":630,"line":35},[628,936,758],{"emptyLinePlaceholder":11},[628,938,939,941,943,945,947,949,951,953,955,957],{"class":630,"line":83},[628,940,652],{"class":633},[628,942,655],{"class":633},[628,944,726],{"class":640},[628,946,729],{"class":646},[628,948,617],{"class":658},[628,950,734],{"class":646},[628,952,737],{"class":633},[628,954,740],{"class":646},[628,956,743],{"class":633},[628,958,826],{"class":633},[628,960,961],{"class":630,"line":68},[628,962,832],{"class":646},[628,964,965,967,969,972,974,977,980,984,987,989,992,995,998,1001,1003,1005,1008,1011],{"class":630,"line":32},[628,966,838],{"class":658},[628,968,841],{"class":633},[628,970,971],{"class":646},"slack",[628,973,841],{"class":633},[628,975,976],{"class":640},"post",[628,978,979],{"class":646},"($to, ",[628,981,983],{"class":982},"s4wv1","\"*{",[628,985,986],{"class":646},"$notification",[628,988,841],{"class":633},[628,990,991],{"class":646},"subject",[628,993,994],{"class":982},"}*",[628,996,997],{"class":658},"\\n",[628,999,1000],{"class":982},"{",[628,1002,986],{"class":646},[628,1004,841],{"class":633},[628,1006,1007],{"class":646},"body",[628,1009,1010],{"class":982},"}\"",[628,1012,1013],{"class":646},");\n",[628,1015,1016],{"class":630,"line":779},[628,1017,868],{"class":646},[628,1019,1020],{"class":630,"line":10},[628,1021,697],{"class":646},[590,1023,1024,1025,1028,1029,1032],{},"Nothing that already exists has to change. The same idea applies inside a class when you would otherwise reach for a sprawling conditional. An ",[615,1026,1027],{},"enum"," paired with ",[615,1030,1031],{},"match"," keeps the branches in one well-typed place, and adding a case is an additive change the compiler helps you complete.",[620,1034,1036],{"className":622,"code":1035,"language":15,"meta":624,"style":624},"enum Priority: string\n{\n    case Low = 'low';\n    case Normal = 'normal';\n    case Urgent = 'urgent';\n\n    public function maxRetries(): int\n    {\n        return match ($this) {\n            self::Low, self::Normal => 1,\n            self::Urgent => 5,\n        };\n    }\n}\n",[615,1037,1038,1050,1054,1070,1084,1098,1102,1119,1123,1140,1166,1180,1185,1189],{"__ignoreMap":624},[628,1039,1040,1042,1045,1047],{"class":630,"line":13},[628,1041,1027],{"class":633},[628,1043,1044],{"class":640}," Priority",[628,1046,743],{"class":633},[628,1048,1049],{"class":633}," string\n",[628,1051,1052],{"class":630,"line":66},[628,1053,647],{"class":646},[628,1055,1056,1059,1062,1065,1068],{"class":630,"line":123},[628,1057,1058],{"class":633},"    case",[628,1060,1061],{"class":658}," Low",[628,1063,1064],{"class":633}," =",[628,1066,1067],{"class":982}," 'low'",[628,1069,749],{"class":646},[628,1071,1072,1074,1077,1079,1082],{"class":630,"line":35},[628,1073,1058],{"class":633},[628,1075,1076],{"class":658}," Normal",[628,1078,1064],{"class":633},[628,1080,1081],{"class":982}," 'normal'",[628,1083,749],{"class":646},[628,1085,1086,1088,1091,1093,1096],{"class":630,"line":83},[628,1087,1058],{"class":633},[628,1089,1090],{"class":658}," Urgent",[628,1092,1064],{"class":633},[628,1094,1095],{"class":982}," 'urgent'",[628,1097,749],{"class":646},[628,1099,1100],{"class":630,"line":68},[628,1101,758],{"emptyLinePlaceholder":11},[628,1103,1104,1106,1108,1111,1114,1116],{"class":630,"line":32},[628,1105,652],{"class":633},[628,1107,655],{"class":633},[628,1109,1110],{"class":640}," maxRetries",[628,1112,1113],{"class":646},"()",[628,1115,743],{"class":633},[628,1117,1118],{"class":633}," int\n",[628,1120,1121],{"class":630,"line":779},[628,1122,832],{"class":646},[628,1124,1125,1128,1131,1134,1137],{"class":630,"line":10},[628,1126,1127],{"class":633},"        return",[628,1129,1130],{"class":633}," match",[628,1132,1133],{"class":646}," (",[628,1135,1136],{"class":658},"$this",[628,1138,1139],{"class":646},") {\n",[628,1141,1142,1145,1148,1151,1154,1157,1160,1163],{"class":630,"line":805},[628,1143,1144],{"class":633},"            self::",[628,1146,1147],{"class":658},"Low",[628,1149,1150],{"class":646},", ",[628,1152,1153],{"class":633},"self::",[628,1155,1156],{"class":658},"Normal",[628,1158,1159],{"class":633}," =>",[628,1161,1162],{"class":658}," 1",[628,1164,1165],{"class":646},",\n",[628,1167,1168,1170,1173,1175,1178],{"class":630,"line":829},[628,1169,1144],{"class":633},[628,1171,1172],{"class":658},"Urgent",[628,1174,1159],{"class":633},[628,1176,1177],{"class":658}," 5",[628,1179,1165],{"class":646},[628,1181,1182],{"class":630,"line":835},[628,1183,1184],{"class":646},"        };\n",[628,1186,1187],{"class":630,"line":865},[628,1188,868],{"class":646},[628,1190,1191],{"class":630,"line":871},[628,1192,697],{"class":646},[590,1194,1195,1196,1199,1200,1202],{},"If you add a ",[615,1197,1198],{},"Priority::Critical"," case later, ",[615,1201,1031],{}," will throw on the unhandled value instead of silently falling through, so the gap is impossible to miss.",[607,1204,1206],{"id":1205},"liskov-substitution-principle","Liskov Substitution Principle",[590,1208,1209,1210,1213,1214,1217],{},"Anywhere you use a type, you should be able to swap in any of its subtypes without surprises. This is about behavior, not just matching signatures. Every ",[615,1211,1212],{},"Channel"," must genuinely honor the contract of ",[615,1215,1216],{},"send()",": deliver the message, or fail loudly, but never silently pretend. A dispatcher can then treat them all the same.",[620,1219,1221],{"className":622,"code":1220,"language":15,"meta":624,"style":624},"final class Dispatcher\n{\n    \u002F** @param list\u003CChannel> $channels *\u002F\n    public function __construct(private readonly array $channels) {}\n\n    public function dispatch(Notification $notification, string $to): void\n    {\n        foreach ($this->channels as $channel) {\n            $channel->send($notification, $to);\n        }\n    }\n}\n",[615,1222,1223,1232,1236,1256,1276,1280,1303,1307,1327,1340,1345,1349],{"__ignoreMap":624},[628,1224,1225,1227,1229],{"class":630,"line":13},[628,1226,634],{"class":633},[628,1228,637],{"class":633},[628,1230,1231],{"class":640}," Dispatcher\n",[628,1233,1234],{"class":630,"line":66},[628,1235,647],{"class":646},[628,1237,1238,1242,1245,1248,1251,1253],{"class":630,"line":123},[628,1239,1241],{"class":1240},"sJ8bj","    \u002F** ",[628,1243,1244],{"class":633},"@param",[628,1246,1247],{"class":658}," list",[628,1249,1250],{"class":1240},"\u003C",[628,1252,1212],{"class":658},[628,1254,1255],{"class":1240},"> $channels *\u002F\n",[628,1257,1258,1260,1262,1264,1266,1268,1270,1273],{"class":630,"line":35},[628,1259,652],{"class":633},[628,1261,655],{"class":633},[628,1263,659],{"class":658},[628,1265,729],{"class":646},[628,1267,790],{"class":633},[628,1269,670],{"class":633},[628,1271,1272],{"class":633}," array",[628,1274,1275],{"class":646}," $channels) {}\n",[628,1277,1278],{"class":630,"line":83},[628,1279,758],{"emptyLinePlaceholder":11},[628,1281,1282,1284,1286,1289,1291,1293,1295,1297,1299,1301],{"class":630,"line":68},[628,1283,652],{"class":633},[628,1285,655],{"class":633},[628,1287,1288],{"class":640}," dispatch",[628,1290,729],{"class":646},[628,1292,617],{"class":658},[628,1294,734],{"class":646},[628,1296,737],{"class":633},[628,1298,740],{"class":646},[628,1300,743],{"class":633},[628,1302,826],{"class":633},[628,1304,1305],{"class":630,"line":32},[628,1306,832],{"class":646},[628,1308,1309,1312,1314,1316,1318,1321,1324],{"class":630,"line":779},[628,1310,1311],{"class":633},"        foreach",[628,1313,1133],{"class":646},[628,1315,1136],{"class":658},[628,1317,841],{"class":633},[628,1319,1320],{"class":646},"channels ",[628,1322,1323],{"class":633},"as",[628,1325,1326],{"class":646}," $channel) {\n",[628,1328,1329,1332,1334,1337],{"class":630,"line":10},[628,1330,1331],{"class":646},"            $channel",[628,1333,841],{"class":633},[628,1335,1336],{"class":640},"send",[628,1338,1339],{"class":646},"($notification, $to);\n",[628,1341,1342],{"class":630,"line":805},[628,1343,1344],{"class":646},"        }\n",[628,1346,1347],{"class":630,"line":829},[628,1348,868],{"class":646},[628,1350,1351],{"class":630,"line":835},[628,1352,697],{"class":646},[590,1354,1355],{},"Because each channel upholds the same contract, the dispatcher does not need to know or care which ones it was handed. A channel that swallowed errors and returned as though it had delivered would technically satisfy the interface, but it would violate Liskov, and any caller relying on delivery would quietly break.",[607,1357,1359],{"id":1358},"interface-segregation-principle","Interface Segregation Principle",[590,1361,1362],{},"No class should be forced to depend on methods it does not use. The fix is small, focused interfaces instead of one large one. A paper book and an e-reader can both turn pages, but only the e-reader can bookmark, so those are two different capabilities.",[620,1364,1366],{"className":622,"code":1365,"language":15,"meta":624,"style":624},"interface Pageable\n{\n    public function nextPage(): void;\n    public function previousPage(): void;\n}\n\ninterface Bookmarkable\n{\n    public function bookmark(): void;\n}\n\nfinal class PaperBook implements Pageable\n{\n    public function nextPage(): void { \u002F* turn the physical page *\u002F }\n    public function previousPage(): void { \u002F* turn it back *\u002F }\n}\n\nfinal class Ebook implements Pageable, Bookmarkable\n{\n    public function nextPage(): void { \u002F* render the next screen *\u002F }\n    public function previousPage(): void { \u002F* render the previous screen *\u002F }\n    public function bookmark(): void { \u002F* persist the reader's position *\u002F }\n}\n",[615,1367,1368,1375,1379,1396,1413,1417,1421,1428,1432,1449,1453,1457,1470,1474,1497,1519,1524,1529,1549,1554,1576,1598,1620],{"__ignoreMap":624},[628,1369,1370,1372],{"class":630,"line":13},[628,1371,710],{"class":633},[628,1373,1374],{"class":640}," Pageable\n",[628,1376,1377],{"class":630,"line":66},[628,1378,647],{"class":646},[628,1380,1381,1383,1385,1388,1390,1392,1394],{"class":630,"line":123},[628,1382,652],{"class":633},[628,1384,655],{"class":633},[628,1386,1387],{"class":640}," nextPage",[628,1389,1113],{"class":646},[628,1391,743],{"class":633},[628,1393,746],{"class":633},[628,1395,749],{"class":646},[628,1397,1398,1400,1402,1405,1407,1409,1411],{"class":630,"line":35},[628,1399,652],{"class":633},[628,1401,655],{"class":633},[628,1403,1404],{"class":640}," previousPage",[628,1406,1113],{"class":646},[628,1408,743],{"class":633},[628,1410,746],{"class":633},[628,1412,749],{"class":646},[628,1414,1415],{"class":630,"line":83},[628,1416,697],{"class":646},[628,1418,1419],{"class":630,"line":68},[628,1420,758],{"emptyLinePlaceholder":11},[628,1422,1423,1425],{"class":630,"line":32},[628,1424,710],{"class":633},[628,1426,1427],{"class":640}," Bookmarkable\n",[628,1429,1430],{"class":630,"line":779},[628,1431,647],{"class":646},[628,1433,1434,1436,1438,1441,1443,1445,1447],{"class":630,"line":10},[628,1435,652],{"class":633},[628,1437,655],{"class":633},[628,1439,1440],{"class":640}," bookmark",[628,1442,1113],{"class":646},[628,1444,743],{"class":633},[628,1446,746],{"class":633},[628,1448,749],{"class":646},[628,1450,1451],{"class":630,"line":805},[628,1452,697],{"class":646},[628,1454,1455],{"class":630,"line":829},[628,1456,758],{"emptyLinePlaceholder":11},[628,1458,1459,1461,1463,1466,1468],{"class":630,"line":835},[628,1460,634],{"class":633},[628,1462,637],{"class":633},[628,1464,1465],{"class":640}," PaperBook",[628,1467,770],{"class":633},[628,1469,1374],{"class":640},[628,1471,1472],{"class":630,"line":865},[628,1473,647],{"class":646},[628,1475,1476,1478,1480,1482,1484,1486,1488,1491,1494],{"class":630,"line":871},[628,1477,652],{"class":633},[628,1479,655],{"class":633},[628,1481,1387],{"class":640},[628,1483,1113],{"class":646},[628,1485,743],{"class":633},[628,1487,746],{"class":633},[628,1489,1490],{"class":646}," { ",[628,1492,1493],{"class":1240},"\u002F* turn the physical page *\u002F",[628,1495,1496],{"class":646}," }\n",[628,1498,1500,1502,1504,1506,1508,1510,1512,1514,1517],{"class":630,"line":1499},15,[628,1501,652],{"class":633},[628,1503,655],{"class":633},[628,1505,1404],{"class":640},[628,1507,1113],{"class":646},[628,1509,743],{"class":633},[628,1511,746],{"class":633},[628,1513,1490],{"class":646},[628,1515,1516],{"class":1240},"\u002F* turn it back *\u002F",[628,1518,1496],{"class":646},[628,1520,1522],{"class":630,"line":1521},16,[628,1523,697],{"class":646},[628,1525,1527],{"class":630,"line":1526},17,[628,1528,758],{"emptyLinePlaceholder":11},[628,1530,1532,1534,1536,1539,1541,1544,1546],{"class":630,"line":1531},18,[628,1533,634],{"class":633},[628,1535,637],{"class":633},[628,1537,1538],{"class":640}," Ebook",[628,1540,770],{"class":633},[628,1542,1543],{"class":640}," Pageable",[628,1545,1150],{"class":646},[628,1547,1548],{"class":640},"Bookmarkable\n",[628,1550,1552],{"class":630,"line":1551},19,[628,1553,647],{"class":646},[628,1555,1557,1559,1561,1563,1565,1567,1569,1571,1574],{"class":630,"line":1556},20,[628,1558,652],{"class":633},[628,1560,655],{"class":633},[628,1562,1387],{"class":640},[628,1564,1113],{"class":646},[628,1566,743],{"class":633},[628,1568,746],{"class":633},[628,1570,1490],{"class":646},[628,1572,1573],{"class":1240},"\u002F* render the next screen *\u002F",[628,1575,1496],{"class":646},[628,1577,1579,1581,1583,1585,1587,1589,1591,1593,1596],{"class":630,"line":1578},21,[628,1580,652],{"class":633},[628,1582,655],{"class":633},[628,1584,1404],{"class":640},[628,1586,1113],{"class":646},[628,1588,743],{"class":633},[628,1590,746],{"class":633},[628,1592,1490],{"class":646},[628,1594,1595],{"class":1240},"\u002F* render the previous screen *\u002F",[628,1597,1496],{"class":646},[628,1599,1601,1603,1605,1607,1609,1611,1613,1615,1618],{"class":630,"line":1600},22,[628,1602,652],{"class":633},[628,1604,655],{"class":633},[628,1606,1440],{"class":640},[628,1608,1113],{"class":646},[628,1610,743],{"class":633},[628,1612,746],{"class":633},[628,1614,1490],{"class":646},[628,1616,1617],{"class":1240},"\u002F* persist the reader's position *\u002F",[628,1619,1496],{"class":646},[628,1621,1623],{"class":630,"line":1622},23,[628,1624,697],{"class":646},[590,1626,1627,1630,1631,1634],{},[615,1628,1629],{},"PaperBook"," implements only what it can actually do, with no empty ",[615,1632,1633],{},"bookmark()"," method left lying around. Since PHP 8.4, interfaces can even declare properties, including the hooks used to read them, so an interface can require a small slice of state without dragging in behavior a client does not need.",[620,1636,1638],{"className":622,"code":1637,"language":15,"meta":624,"style":624},"interface HasTitle\n{\n    public string $title { get; }\n}\n\nfinal class Post implements HasTitle\n{\n    public function __construct(private readonly string $headline) {}\n\n    public string $title {\n        get => trim($this->headline);\n    }\n}\n",[615,1639,1640,1647,1651,1666,1670,1674,1687,1691,1710,1714,1723,1742,1746],{"__ignoreMap":624},[628,1641,1642,1644],{"class":630,"line":13},[628,1643,710],{"class":633},[628,1645,1646],{"class":640}," HasTitle\n",[628,1648,1649],{"class":630,"line":66},[628,1650,647],{"class":646},[628,1652,1653,1655,1657,1660,1663],{"class":630,"line":123},[628,1654,652],{"class":633},[628,1656,673],{"class":633},[628,1658,1659],{"class":646}," $title { ",[628,1661,1662],{"class":658},"get",[628,1664,1665],{"class":646},"; }\n",[628,1667,1668],{"class":630,"line":35},[628,1669,697],{"class":646},[628,1671,1672],{"class":630,"line":83},[628,1673,758],{"emptyLinePlaceholder":11},[628,1675,1676,1678,1680,1683,1685],{"class":630,"line":68},[628,1677,634],{"class":633},[628,1679,637],{"class":633},[628,1681,1682],{"class":640}," Post",[628,1684,770],{"class":633},[628,1686,1646],{"class":640},[628,1688,1689],{"class":630,"line":32},[628,1690,647],{"class":646},[628,1692,1693,1695,1697,1699,1701,1703,1705,1707],{"class":630,"line":779},[628,1694,652],{"class":633},[628,1696,655],{"class":633},[628,1698,659],{"class":658},[628,1700,729],{"class":646},[628,1702,790],{"class":633},[628,1704,670],{"class":633},[628,1706,673],{"class":633},[628,1708,1709],{"class":646}," $headline) {}\n",[628,1711,1712],{"class":630,"line":10},[628,1713,758],{"emptyLinePlaceholder":11},[628,1715,1716,1718,1720],{"class":630,"line":805},[628,1717,652],{"class":633},[628,1719,673],{"class":633},[628,1721,1722],{"class":646}," $title {\n",[628,1724,1725,1728,1730,1733,1735,1737,1739],{"class":630,"line":829},[628,1726,1727],{"class":658},"        get",[628,1729,1159],{"class":633},[628,1731,1732],{"class":658}," trim",[628,1734,729],{"class":646},[628,1736,1136],{"class":658},[628,1738,841],{"class":633},[628,1740,1741],{"class":646},"headline);\n",[628,1743,1744],{"class":630,"line":835},[628,1745,868],{"class":646},[628,1747,1748],{"class":630,"line":865},[628,1749,697],{"class":646},[590,1751,1752,1753,1756],{},"A collaborator that only needs a title can depend on ",[615,1754,1755],{},"HasTitle"," and nothing more.",[607,1758,1760],{"id":1759},"dependency-inversion-principle","Dependency Inversion Principle",[590,1762,1763,1764,1767,1768,1770,1771,1773],{},"High-level code should depend on abstractions, not on concrete implementations. Notice that ",[615,1765,1766],{},"Dispatcher"," already does this: it accepts ",[615,1769,1212],{}," instances, never a specific ",[615,1772,882],{},". You wire the concrete pieces together at the edge of your application and inject them in.",[620,1775,1777],{"className":622,"code":1776,"language":15,"meta":624,"style":624},"$dispatcher = new Dispatcher([\n    new EmailChannel($mailer),\n    new SlackChannel($slack),\n]);\n\n$dispatcher->dispatch(\n    new Notification('Welcome aboard', 'Thanks for signing up.'),\n    'frank@fjp.io',\n);\n",[615,1778,1779,1796,1806,1815,1820,1824,1836,1856,1863],{"__ignoreMap":624},[628,1780,1781,1784,1787,1790,1793],{"class":630,"line":13},[628,1782,1783],{"class":646},"$dispatcher ",[628,1785,1786],{"class":633},"=",[628,1788,1789],{"class":633}," new",[628,1791,1792],{"class":658}," Dispatcher",[628,1794,1795],{"class":646},"([\n",[628,1797,1798,1801,1803],{"class":630,"line":66},[628,1799,1800],{"class":633},"    new",[628,1802,767],{"class":658},[628,1804,1805],{"class":646},"($mailer),\n",[628,1807,1808,1810,1812],{"class":630,"line":123},[628,1809,1800],{"class":633},[628,1811,904],{"class":658},[628,1813,1814],{"class":646},"($slack),\n",[628,1816,1817],{"class":630,"line":35},[628,1818,1819],{"class":646},"]);\n",[628,1821,1822],{"class":630,"line":83},[628,1823,758],{"emptyLinePlaceholder":11},[628,1825,1826,1829,1831,1834],{"class":630,"line":68},[628,1827,1828],{"class":646},"$dispatcher",[628,1830,841],{"class":633},[628,1832,1833],{"class":640},"dispatch",[628,1835,662],{"class":646},[628,1837,1838,1840,1843,1845,1848,1850,1853],{"class":630,"line":32},[628,1839,1800],{"class":633},[628,1841,1842],{"class":658}," Notification",[628,1844,729],{"class":646},[628,1846,1847],{"class":982},"'Welcome aboard'",[628,1849,1150],{"class":646},[628,1851,1852],{"class":982},"'Thanks for signing up.'",[628,1854,1855],{"class":646},"),\n",[628,1857,1858,1861],{"class":630,"line":779},[628,1859,1860],{"class":982},"    'frank@fjp.io'",[628,1862,1165],{"class":646},[628,1864,1865],{"class":630,"line":10},[628,1866,1013],{"class":646},[590,1868,1869,1870,1873],{},"Constructor property promotion makes the injection a single line, and marking the dependency ",[615,1871,1872],{},"readonly"," guarantees nothing swaps it out after construction. When you want a property the outside world can read but only the class can change, asymmetric visibility says exactly that.",[620,1875,1877],{"className":622,"code":1876,"language":15,"meta":624,"style":624},"final class ChannelRegistry\n{\n    \u002F** @var list\u003CChannel> *\u002F\n    public private(set) array $channels = [];\n\n    public function register(Channel $channel): void\n    {\n        $this->channels[] = $channel;\n    }\n}\n",[615,1878,1879,1888,1892,1908,1925,1929,1949,1953,1967,1971],{"__ignoreMap":624},[628,1880,1881,1883,1885],{"class":630,"line":13},[628,1882,634],{"class":633},[628,1884,637],{"class":633},[628,1886,1887],{"class":640}," ChannelRegistry\n",[628,1889,1890],{"class":630,"line":66},[628,1891,647],{"class":646},[628,1893,1894,1896,1899,1901,1903,1905],{"class":630,"line":123},[628,1895,1241],{"class":1240},[628,1897,1898],{"class":633},"@var",[628,1900,1247],{"class":658},[628,1902,1250],{"class":1240},[628,1904,1212],{"class":658},[628,1906,1907],{"class":1240},"> *\u002F\n",[628,1909,1910,1912,1915,1917,1920,1922],{"class":630,"line":35},[628,1911,652],{"class":633},[628,1913,1914],{"class":633}," private(set)",[628,1916,1272],{"class":633},[628,1918,1919],{"class":646}," $channels ",[628,1921,1786],{"class":633},[628,1923,1924],{"class":646}," [];\n",[628,1926,1927],{"class":630,"line":83},[628,1928,758],{"emptyLinePlaceholder":11},[628,1930,1931,1933,1935,1938,1940,1942,1945,1947],{"class":630,"line":68},[628,1932,652],{"class":633},[628,1934,655],{"class":633},[628,1936,1937],{"class":640}," register",[628,1939,729],{"class":646},[628,1941,1212],{"class":658},[628,1943,1944],{"class":646}," $channel)",[628,1946,743],{"class":633},[628,1948,826],{"class":633},[628,1950,1951],{"class":630,"line":32},[628,1952,832],{"class":646},[628,1954,1955,1957,1959,1962,1964],{"class":630,"line":779},[628,1956,838],{"class":658},[628,1958,841],{"class":633},[628,1960,1961],{"class":646},"channels[] ",[628,1963,1786],{"class":633},[628,1965,1966],{"class":646}," $channel;\n",[628,1968,1969],{"class":630,"line":10},[628,1970,868],{"class":646},[628,1972,1973],{"class":630,"line":805},[628,1974,697],{"class":646},[590,1976,1977,1978,1980],{},"The registry exposes its channels for inspection while keeping the only path to mutate them inside the class. High-level code depends on the ",[615,1979,1212],{}," interface throughout, so you can swap email for Slack, or drop in a fake channel during a test, without touching the parts of the system that actually matter.",[607,1982,1984],{"id":1983},"wrapping-up","Wrapping Up",[590,1986,1987],{},"None of these principles are new, and none are specific to PHP. What modern PHP changes is how little code it now takes to follow them. Typed and readonly properties make intent explicit, promotion and enums cut the boilerplate, and property hooks with asymmetric visibility let small interfaces describe exactly what a collaborator needs. Even newer conveniences, like the pipe operator added in PHP 8.5, reward the same habit of building small, single-purpose units that compose cleanly.",[590,1989,1990,1991,1994],{},"Treat SOLID as a set of guidelines, not laws. You will not always follow every one to the letter, and that is fine. But knowing them gives you a vocabulary for why one design feels easier to change than another. If you are curious how all of this looked a decade ago, the ",[601,1992,1993],{"href":603},"2016 version"," of this article works through the same ideas in the PHP of its day, and the contrast is its own little lesson.",[1996,1997,1998],"style",{},"html pre.shiki code .sOPea, html code.shiki .sOPea{--shiki-default:#F97583;--shiki-dark:#F97583}html pre.shiki code .sFR8T, html code.shiki .sFR8T{--shiki-default:#B392F0;--shiki-dark:#B392F0}html pre.shiki code .suv1-, html code.shiki .suv1-{--shiki-default:#E1E4E8;--shiki-dark:#E1E4E8}html pre.shiki code .s8ozJ, html code.shiki .s8ozJ{--shiki-default:#79B8FF;--shiki-dark:#79B8FF}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .s4wv1, html code.shiki .s4wv1{--shiki-default:#9ECBFF;--shiki-dark:#9ECBFF}html pre.shiki code .sJ8bj, html code.shiki .sJ8bj{--shiki-default:#6A737D;--shiki-dark:#6A737D}",{"title":624,"searchDepth":66,"depth":66,"links":2000},[2001,2002,2003,2004,2005,2006],{"id":609,"depth":66,"text":610},{"id":886,"depth":66,"text":887},{"id":1205,"depth":66,"text":1206},{"id":1358,"depth":66,"text":1359},{"id":1759,"depth":66,"text":1760},{"id":1983,"depth":66,"text":1984},{"id":13,"name":14,"slug":15,"hue":16},"md",{},{"title":6,"description":592},"posts\u002Fsolid-principles-modern-php",[15,21,24],[2014,2015,2016],{"name":14,"slug":15},{"name":20,"slug":21},{"name":23,"slug":24},"SvCljkM6euR0fCK6viaY_df80lZ4UoT0wRhTRjlLkY8",1781467527834]