Overview for 'stitcher-io'

Typed properties in PHP 7.4

Written by / Original link on Jun. 29, 2019

Typed class properties have been added in PHP 7.4 and provide a major improvement to PHP's type system. These changes are fully opt-in and non breaking to previous versions. In this post we'll look at the feature in-depth, but first let's start by summarising the most important points: They are ava…

Tests and types

Written by / Original link on Jun. 6, 2019

Imagine a simple function: rgbToHex. It takes three arguments, integers between 0 and 255; and converts it to a hexadecimal string. Here's what this function's definition might look like in a dynamic, weakly typed language: rgbToHex(red, green, blue) { // … } I think we all agree that "program corr…

Arrow functions in PHP 7.4

Written by / Original link on May. 1, 2019

Short closures, also called arrow functions, are a way of writing shorter functions in PHP. This notation is useful when passing closures to functions like array_map or array_filter. This is what they look like: // A collection of Post objects $posts = [/* … */]; $ids = array_map(fn($post) => $p…