0

I have two classes:

public class B {
    public static $fields = [
        'name',
        'descripion'
    ];
}


public class A {
    public static $fields = [
        'name',
        'descripion',
        'subFields' => B::$fields
    ];
}

but when I try to get the $fields var from B that way I get the error: Constant expression contains invalid operations

Is there another way to do it or is just impossible?

Adrian
  • 75
  • 1
  • 11
  • 1
    Does this answer your question? [PHP Error : Fatal error: Constant expression contains invalid operations](https://stackoverflow.com/questions/40171546/php-error-fatal-error-constant-expression-contains-invalid-operations) – digijay Jun 15 '21 at 15:30
  • Maybe a `get_fields()` method in `B`? – AbraCadaver Jun 15 '21 at 15:34

0 Answers0