Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eloquent\Model: match @property annotation type #8

Closed
16 tasks done
rentalhost opened this issue May 30, 2017 · 1 comment
Closed
16 tasks done

Eloquent\Model: match @property annotation type #8

rentalhost opened this issue May 30, 2017 · 1 comment

Comments

@rentalhost
Copy link
Owner

rentalhost commented May 30, 2017

Eg.

class User extends Eloquent\Model 
{
    protected $casts = [
        "some_property" => "int"
    ];
}

Requires: @property int $some_property
Should accept: @property int|null $some_property
Should accept: @property int|anything $some_property


To consider:

  • For id (or other $primaryKey) consider $keyType property (or "int");
  • For _id suffix consider int (eg. user_id);
  • For _at suffix consider Carbon\Carbon (eg. created_at);
    • Should consider any $dates properties as Carbon\Carbon too;
  • For accessors consider the returned type;
    • From mutator, consider the accessor return type too;
  • Should consider $casts value;
    • For int or integer consider int;
    • For real, float or double consider float;
    • For string consider string;
    • For bool or boolean consider bool;
    • For object consider object;
    • For array or json consider array;
    • For collection consider Collection;
    • For date, datetime or timestamp consider Carbon;
  • For any other case consider mixed;
@rentalhost rentalhost added this to the 0.2.0+ milestone May 30, 2017
@rentalhost rentalhost changed the title Eloquent\Model: check if @property type matches with the reference Eloquent\Model: match @property annotation type Jun 1, 2017
@rentalhost rentalhost removed the fixed label Jun 1, 2017
@rentalhost rentalhost reopened this Jun 1, 2017
@rentalhost
Copy link
Owner Author

rentalhost commented Jun 1, 2017

Forgotten item: should consider any $dates properties as Carbon\Carbon too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant