Closed gossi closed 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
):
setMethods(PhpMethod[] $methods): $this
setMethod(PhpParameter $method): $this
removeMethod(string|PhpMethod[] $nameOrMethod): $this
hasMethod(string|PhpMethod[] $nameOrMethod): boolean
getMethod(string|PhpMethod $nameOrMethod): PhpMethod
getMethods(): PhpMethod[]
getMethodNames(): string[]
clearMethods(): $this
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.
The API for most php structs works like this (method as example, but also for properties, constants, etc... you name it):
setMethod($method)
getMethod($nameOrMethod)
removeMethod($nameOrMethod)
getMethods()
setMethods()
while
setMethod()
is technically the correct name, adding is the action we have in mind. Although, sometimesgetMethods()
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.