A Field Guide to PHProperties

* Intro * PHP has new features: hooks, interface props, aviz * Very brief example of each * Easy approach: don't use hooks, write less code, it's an escape hatch * This is OK! If you stop here, you are not doing it wrong. * ... But we can go further. * What is a property? * What is an object? (Philosoraptor) * No one-true OOP * Product types: internals exposed * Compound types: internals hidden (eg, DateTime) * Logical representation (classic OOP academia) * Closures with funny syntax (services, internals hidden) * Historically: All properties private always. Couldn't do better. * "Language teaches you to not want what it doesn't offer." (find source) * Property vs Field * Wikipedia * https://en.wikipedia.org/wiki/Property_(programming) * https://en.wikipedia.org/wiki/Field_(computer_science) * C# * Kotlin * Swift * Others... * What is a property? Depends on the type of object * "Make one thing do many things" (find source) * My def: "A visible aspect of a value." * Method: "An action taken on a value." * Must manipulating an aspect be a method? Depends who you ask... * Things you CAN do with hooks * BC shim * Cached value * Upcasting inside a value object upcast from an array record (eg, DB hydration) *
A Field Guide to PHProperties