Skip to content

Latest commit

 

History

History
19 lines (17 loc) · 568 Bytes

2023-09-24-stscoundrelstruct-structs-for-php.md

File metadata and controls

19 lines (17 loc) · 568 Bytes
title tags cite
stscoundrel/struct: Structs for PHP
Nifty Show and Tell
name href
Sampo Silvennoinen

While we wait for [[PHP: rfc:structs]] to make some traction there are other solutions that attempt to bring Structs to #PHP. This one by Sampo Silvennoinen provides an AbstractStruct class which can be extended to produce struct like behaviour. For example:

class Employee extends AbstractStruct
{    
    public string $name;    
    public string $department;
    public int $salary;
}