phpowermove / php-code-generator

PHP code generator library
https://php-code-generator.readthedocs.org
Apache License 2.0
147 stars 43 forks source link

More consistent API #22

Closed gossi closed 8 years ago

gossi commented 8 years ago

The API for most php structs works like this (method as example, but also for properties, constants, etc... you name it):

while setMethod() is technically the correct name, adding is the action we have in mind. Although, sometimes getMethods() returns different value types. Sometimes that is ok (depending on the type we want to fetch) but most times there should be better method names for such tasks, e.g. getMethodNames().

There is time to work through this API, identify similar patterns and make the API consistent.

gossi commented 8 years ago

Consolidated API:

There are 5 parts: methods, properties, constants, parameters and traits (a list of traits as used for use {trait} in structure bodies). There are 2 types: Map and List

Map (means, their names are keys):

List (they come in any order):

Methods for maps (at the example of methods):

Methods for lists (at the example of parameters):

They'll come with setParameters, addParameter, getParameter, removeParameter, getParameters, hasParameter yet their method parameters vary depending on the type they handle.