stscoundrel/struct: Structs for PHP
planted on in: Nifty Show and Tell and PHP.
https://github.com/stscoundrel/struct
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;
}
—