<commit_before><?php

namespace Faker\ORM\Propel;

use \PropelColumnTypes;
use \ColumnMap;

class ColumnTypeGuesser
{
    protected $generator;

    public function __construct(\Faker\Generator $generator)
    {
        $this->generator = $generator;
    }

    public function guessFormat(ColumnMap $column)
    {
        $generator = $this->generator;
        if ($column->isTemporal()) {
            if ($column->isEpochTemporal()) {
                return function() use ($generator) { return $generator->dateTime; };
            } else {
                return function() use ($generator) { return $generator->dateTimeAD; };
            }
        }
        $type = $column->getType();
        switch ($type) {
            case PropelColumnTypes::BOOLEAN:
            case PropelColumnTypes::BOOLEAN_EMU:
                return function() use ($generator) { return $generator->boolean; };
            case PropelColumnTypes::NUMERIC:
            case PropelColumnTypes::DECIMAL:
                $size = $column->getSize();

                return function() use ($generator, $size) { return $generator->randomNumber($size + 2) / 100; };
            case PropelColumnTypes::TINYINT:
                return function() { return mt_rand(0,255); };
            case PropelColumnTypes::SMALLINT:
                return function() { return mt_rand(0,65535); };
            case PropelColumnTypes::INTEGER:
                return function() { return mt_rand(0,intval('4294967295')); };
            case PropelColumnTypes::BIGINT:
                return function() { return mt_rand(0,intval('18446744073709551615')); };
            case PropelColumnTypes::FLOAT:
                return function() { return mt_rand(0,intval('4294967295'))/mt_rand(1,intval('4294967295')); };
            case PropelColumnTypes::DOUBLE:
            case PropelColumnTypes::REAL:
                return function() { return mt_rand(0,intval('18446744073709551615'))/mt_rand(1,intval('18446744073709551615')); };
            case PropelColumnTypes::CHAR:
            case PropelColumnTypes::VARCHAR:
            case PropelColumnTypes::BINARY:
            case PropelColumnTypes::VARBINARY:
                $size = $column->getSize();

                return function() use ($generator, $size) { return $generator->text($size); };
            case PropelColumnTypes::LONGVARCHAR:
            case PropelColumnTypes::LONGVARBINARY:
            case PropelColumnTypes::CLOB:
            case PropelColumnTypes::CLOB_EMU:
            case PropelColumnTypes::BLOB:
                return function() use ($generator) { return $generator->text; };
            case PropelColumnTypes::ENUM:
                $valueSet = $column->getValueSet();

                return function() use ($generator, $valueSet) { return $generator->randomElement($valueSet); };
            case PropelColumnTypes::OBJECT:
            case PropelColumnTypes::PHP_ARRAY:
                // no smart way to guess what the user expects here
                return null;
        }
    }
}<commit_msg>Limit Propel numbers to signed range of values.<commit_after><?php

namespace Faker\ORM\Propel;

use \PropelColumnTypes;
use \ColumnMap;

class ColumnTypeGuesser
{
    protected $generator;

    public function __construct(\Faker\Generator $generator)
    {
        $this->generator = $generator;
    }

    public function guessFormat(ColumnMap $column)
    {
        $generator = $this->generator;
        if ($column->isTemporal()) {
            if ($column->isEpochTemporal()) {
                return function() use ($generator) { return $generator->dateTime; };
            } else {
                return function() use ($generator) { return $generator->dateTimeAD; };
            }
        }
        $type = $column->getType();
        switch ($type) {
            case PropelColumnTypes::BOOLEAN:
            case PropelColumnTypes::BOOLEAN_EMU:
                return function() use ($generator) { return $generator->boolean; };
            case PropelColumnTypes::NUMERIC:
            case PropelColumnTypes::DECIMAL:
                $size = $column->getSize();

                return function() use ($generator, $size) { return $generator->randomNumber($size + 2) / 100; };
            case PropelColumnTypes::TINYINT:
                return function() { return mt_rand(0,127); };
            case PropelColumnTypes::SMALLINT:
                return function() { return mt_rand(0,32767); };
            case PropelColumnTypes::INTEGER:
                return function() { return mt_rand(0,intval('2147483647')); };
            case PropelColumnTypes::BIGINT:
                return function() { return mt_rand(0,intval('9223372036854775807')); };
            case PropelColumnTypes::FLOAT:
                return function() { return mt_rand(0,intval('2147483647'))/mt_rand(1,intval('2147483647')); };
            case PropelColumnTypes::DOUBLE:
            case PropelColumnTypes::REAL:
                return function() { return mt_rand(0,intval('9223372036854775807'))/mt_rand(1,intval('9223372036854775807')); };
            case PropelColumnTypes::CHAR:
            case PropelColumnTypes::VARCHAR:
            case PropelColumnTypes::BINARY:
            case PropelColumnTypes::VARBINARY:
                $size = $column->getSize();

                return function() use ($generator, $size) { return $generator->text($size); };
            case PropelColumnTypes::LONGVARCHAR:
            case PropelColumnTypes::LONGVARBINARY:
            case PropelColumnTypes::CLOB:
            case PropelColumnTypes::CLOB_EMU:
            case PropelColumnTypes::BLOB:
                return function() use ($generator) { return $generator->text; };
            case PropelColumnTypes::ENUM:
                $valueSet = $column->getValueSet();

                return function() use ($generator, $valueSet) { return $generator->randomElement($valueSet); };
            case PropelColumnTypes::OBJECT:
            case PropelColumnTypes::PHP_ARRAY:
                // no smart way to guess what the user expects here
                return null;
        }
    }
}
{'fraction_non_alphanumeric': 0.11671304632509412, 'fraction_numerical': 0.035521361925028645, 'mean_word_length': 2.2586666666666666, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3214134', 'n_tokens_mistral': 1768, 'n_tokens_neox': 1613, 'n_words': 341}