When running this code:
class MyClass {
public int $one;
public int $two;
public int $three;
}
$rc = new ReflectionClass(MyClass::class);
foreach ($rc->getProperties() as $property) {
echo $property->getName() . "\n";
}
, the properties in the output are ordered like in the class declaration:
one
two
three
Can I rely on this ordering, concerning ReflectionClass::getProperties()
?
Context: I want to use a class to represent a specific file format, each class property being a field in the file (using Php attributes to characterize each of them). The ordering of the fields in the file is of course a necessity.
Aucun commentaire:
Enregistrer un commentaire