Skip to content

Generate property annotations for Model #167

@DenTray

Description

@DenTray

Need to extend model generation logic by generating @property annotations for each model's field

Description

What needs to be done?

Enhance the existing model generation script to automatically create @property annotations for each field of the model. For each field declared in the generation command, the script should determine the corresponding PHP type and generate a @property annotation indicating the type and field name in the model's PHPDoc block. The annotations should be added to the top of the generated model file. For example, fields like -e User should generate @property int user_id, and timestamps like -t first_booked_at should generate @property Carbon first_booked_at.

Expected Outcome

What is the expected result?

The generated model file will contain accurate @property annotations reflecting each field’s type and name. For the example command:

php artisan make:entity Property -S name -e User -F price -b is_free -t first_booked_at -j meta

The model will include the following PHPDoc annotations:

/**
 * @property int user_id
 * @property float price
 * @property string name
 * @property bool is_free
 * @property Carbon first_booked_at
 * @property array meta
 */

Verification Scenarios

How can this be tested?

  1. Run the model generation command with various combinations of fields and flags (like -e, -F, -S, etc.).
  2. Check that the generated model file contains @property annotations correctly mapping field names to their expected types and names (including type hints like int, float, string, bool, Carbon, array).
  3. Verify that all fields passed in the command are included as annotations in the model PHPDoc block without duplicates or typos.
  4. Confirm the annotations are syntactically correct and do not cause PHPDoc or IDE parsing errors.
  5. Ensure no debug information or errors occur during generation.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions