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

[BUG]: Incorrect return type hint for Phalcon\Db\Column::getSize() #15019

Closed
sergeyklay opened this issue May 6, 2020 · 1 comment · Fixed by #15020
Closed

[BUG]: Incorrect return type hint for Phalcon\Db\Column::getSize() #15019

sergeyklay opened this issue May 6, 2020 · 1 comment · Fixed by #15020
Assignees
Labels
bug A bug report status: low Low

Comments

@sergeyklay
Copy link
Contributor

Current return type hint of the Phalcon\Db\Column::getSize implies that method must return a integer value:

/**
* Integer column size
*
* @var int
*/
protected size = 0 { get };

But this method MAY return a string for enum columns:

use Phalcon\Db\Column;

$column = new Column('field_enum', [
    'type'          => Column::TYPE_ENUM,
    'isNumeric'     => false,
    'size'          => "'xs','s','m','l','xl','internal'",
    'default'       => null,
    'unsigned'      => false,
    'notNull'       => false,
    'autoIncrement' => false,
    'primary'       => false,
    'first'         => false,
    'after'         => 'field_decimal_default',
    'bindType'      => Column::BIND_PARAM_STR,
    'typeValues'    => 'c',
    'typeReference' => Column::TYPE_ENUM,
]);

var_dump($column->getSize()); // string

This leads to a fatal error:

PHP Fatal error:
Return value of Phalcon\Db\Column::getSize()
must be of the type int, string returned in Unknown on line 0
@sergeyklay sergeyklay self-assigned this May 6, 2020
sergeyklay added a commit that referenced this issue May 6, 2020
@sergeyklay sergeyklay linked a pull request May 6, 2020 that will close this issue
5 tasks
@sergeyklay
Copy link
Contributor Author

Fixed in 4.0.x

niden pushed a commit that referenced this issue May 16, 2020
@niden niden moved this to Released in Phalcon v5 Aug 25, 2022
@niden niden added this to Phalcon v5 Aug 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug report status: low Low
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant