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

TINYINT database column identified as bool by Automatic phpDocs for models #480

Closed
jclee100 opened this issue Apr 4, 2017 · 3 comments
Closed

Comments

@jclee100
Copy link
Contributor

jclee100 commented Apr 4, 2017

Using php artisan ide-helper:models, a TINYINT column is documented as bool.

While TINYINT is commonly used to represent bool, I am using it to map to a small amount of model states.

And while I do not know what's the best way to differentiate the two, the length of the column can be used to at least rule out bool if it's >1. i.e. TINYINT(2) can never be bool.

@barryvdh
Copy link
Owner

barryvdh commented Apr 4, 2017

Makes sense, can you make a Pr?

@jclee100
Copy link
Contributor Author

jclee100 commented Apr 4, 2017

@barryvdh I only just had a brief look at the source code. If you look here, it looks like there's no reference to tinyInt. So I am guessing this is a doctrine issue?

@jclee100
Copy link
Contributor Author

jclee100 commented Apr 4, 2017

Could be related: doctrine/dbal#1205

It may be best to classify dbal's boolean as int altogether and let the model's $casts property finally decide if it should be a boolean.

jclee100 added a commit to jclee100/laravel-ide-helper that referenced this issue Apr 4, 2017
`tinyint` is classified by bool as doctrine/dbal, but it should not be so in our use case. `tinyint` is better PHPDoc'ed as int. If the user wants bool, he should use Eloquent's `$casts` property to do that.
Belphemur pushed a commit to Belphemur/laravel-ide-helper that referenced this issue Apr 10, 2017
cgxxv pushed a commit to cgxxv/laravel-ide-helper that referenced this issue Mar 25, 2022
* Fix barryvdh#480 where tinyint is casts as bool

`tinyint` is classified by bool as doctrine/dbal, but it should not be so in our use case. `tinyint` is better PHPDoc'ed as int. If the user wants bool, he should use Eloquent's `$casts` property to do that.

* Pass PSR-2 check

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

No branches or pull requests

2 participants