Tharos / LeanMapper

Lean Mapper is a tiny ORM based on powerful Dibi database abstraction library for PHP.
MIT License
87 stars 35 forks source link

Allow to use all class constants in m:enum, not only prefixed ones. #100

Closed janfolwarczny closed 7 years ago

janfolwarczny commented 7 years ago

Hi!

here is a little change of LeanMapper. With this change m:enum(SomeClass::*) can be used instead of only m:enum(SomeClass::SOME_*).

It is very useful when you have Enum classes like this one:

class WhenEnum {
    const NEVER = 'never';
    const ONCE = 'once';
    const EACH_TIME = 'eachTime';
}

So the entity could look like this:

/**
 * @property int $id
 * @property string $when m:enum(WhenEnum::*)
 */
class MyEntity extends \LeanMapper\Entity {
}

What do you think about that? It'll be great for me if it could be merged.

I'm looking forward to your answer!

Thanks, Jan

Tharos commented 7 years ago

It seems like a good idea to me. :)

@castamir Merge?

Tharos commented 7 years ago

@JanFolwarczny Thx!

janfolwarczny commented 7 years ago

@Tharos @castamir Thanks! :)