Skip to content

Better code analysis with @method tags. #15

Closed
@rudolfbyker

Description

@rudolfbyker

Since you are wrapping File_MARC_Record and friends in Record.php and Field.php, and use __call to delegate the method calls to them, you should have @method tags to aid IDE code hinting. Here are examples for Record.php and Field.php:

/**
 * The MARC record wrapper.
 *
 * @property string id
 * @property string type
 *
 * @method string getLeader() Get the leader.
 * @method ... more of these
 */
class Record implements \JsonSerializable {
//...
}
/**
 * Class Field
 *
 * @method string toRaw() Get the raw MARC data.
 * @method ... more of these
 */
class Field implements \JsonSerializable {
// ...
}

Another option would be to get rid of the __call magic methods and just let the user use the wrapped object directly, through getField or getRecord. That would need proper type documentation, too:

/**
 * Get the wrapped field.
 * 
 * @return \File_MARC_Field
 */
public function getField() {
    return $this->field;
}

This method already exists in Field.php but not in Record.php. Here is an example of what we need in Record.php:

/**
 * Get the wrapped record.
 * 
 * @return \File_MARC_Record
 */
public function getRecord() {
    return $this->record;
}

We could also do both. I'll even make a PR if you tell me which solution you prefer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions