Skip to content

Instantly share code, notes, and snippets.

@DaveLiddament
DaveLiddament / NamespaceVisibilityExample.php
Last active May 11, 2023 17:46
Example of usage of NamespaceVisbility
<?php
namespace Foo {
class Telephone
{
#[NamespaceVisibility]
public function ring(): void
{
}
@DaveLiddament
DaveLiddament / PHP generics notation for static analysis.md
Created October 30, 2022 14:13
PHP generics notation for static analysis

Notation for generics to PHP: #<>

Disclaimer: I assume someone has already suggested this and there are good reasons it hasn't happened!

Inspired by a conversation with @pronskiy after my talk "PHP Generics Today (Almost)" at IPC Munich

Examples:

class Queue #
@DaveLiddament
DaveLiddament / Friend attribute example.php
Created May 27, 2022 10:49
Example of using the #[Friend] attribute from the PHP Language extensions library
// Example of the #[Friend] attribute available from https://github.com/DaveLiddament/php-language-extensions
class Person {
#[Friend(PersonBuilder::class)]
public function __construct() {}
}
class PersonBuilder {
public function build(): Person {
@DaveLiddament
DaveLiddament / StubbingAndMocking.md
Created February 20, 2019 18:31
Stubbing and Mocking notes
@DaveLiddament
DaveLiddament / TDD katas.md
Last active January 16, 2019 14:10
TFF katas

TDD katas

Roman numerals

Write a function that converts an integer into a roman numeral.

Extended exercises:

  • Throw an exception if input is invalid (e.g. 0 or negative)

String calculator

@DaveLiddament
DaveLiddament / RomanNumeralKataNotes.md
Last active January 16, 2019 14:00
Roman Numeral Kata setup

Roman Numeral Kata

Requirements:

  • php >= 7.1
  • composer

Setup

Create a new directory and cd into it: