This documentation describes unreleased changes on the main branch.

#[TableFields]

Attribute on classes.

use Saij\WpAppFramework\Table\TableFields;

Marks a class whose public static methods return the columns of a row class for queries:

#[TableFields(LogEntry::class)]
final class LogEntryFields
{
    public static function message(): StringField
    {
        return new StringField(LogEntry::class, 'message');
    }
}

Write it by hand or generate it with wp-app-framework table-fields <row class>. The build calls every public static method that returns a field and checks the field against the row class. The class is no service.

Arguments

#[TableFields(string $rowClass)]
ParameterTypeDefaultDescription
rowClassclass-string<AbstractRow>requiredThe row class (#[Table]).