src/PHPStubs/Generator.php
private function getConstantValue(\CG\Generator\PhpConstant $constant)
    {
        if (null !== $value = $constant->getValue()) {
            return $value;
        }

        if ($constant->hasAttribute('type')) {
            switch ($constant->getAttribute('type')) {
                case 'int':
                case 'integer':
                    return 0;

                case 'double':
                case 'float':
                    return 0.1;

                case 'bool':
                case 'boolean':
                    return true;

                case 'string':
                    return 'dummy';

                case 'int/float/bool/enum':
                case '':
                    return null;

                default:
                    throw new \RuntimeException(sprintf('Unknown constant type "%s".', $constant->getAttribute('type')));
            }
        }

        return null;
    }
private function getConstantValue(\CG\Generator\PhpConstant $constant)
    {
        if (null !== $value = $constant->getValue()) {
            return $value;
        }

        if ($constant->hasAttribute('type')) {
            switch ($constant->getAttribute('type')) {
                case 'int':
                case 'integer':
                    return 0;

                case 'double':
                case 'float':
                    return 0.1;

                case 'bool':
                case 'boolean':
                    return true;

                case 'string':
                    return 'dummy';

                case 'int/float/bool/enum':
                case '':
                    return null;

                default:
                    throw new \RuntimeException(sprintf('Unknown constant type "%s".', $constant->getAttribute('type')));
            }
        }

        return null;
    }
private function getConstantValue ( \ CG \ Generator \ PhpConstant $ constant ) { if ( null !== $ value = $ constant -> getValue ( ) ) { return $ value ; } if ( $ constant -> hasAttribute ( 'type' ) ) { switch ( $ constant -> getAttribute ( 'type' ) ) { case 'int' : case 'integer' : return 0 ; case 'double' : case 'float' : return 0.1 ; case 'bool' : case 'boolean' : return true ; case 'string' : return 'dummy' ; case 'int/float/bool/enum' : case '' : return null ; default : throw new \ RuntimeException ( sprintf ( 'Unknown constant type "%s".' , $ constant -> getAttribute ( 'type' ) ) ) ; } } return null ; }
Returns the value of a constant, or makes up an arbitrary value that
matches the type of the constant.

The reasoning behind generating an arbitrary value is that for type
inference, the actual value is not important as long as we can infer the
correct type. For other types of data flow analysis it might be interesting
though; we can re-visit it then.

@param \CG\Generator\PhpConstant $constant

@return int|real|boolean|string|null
Returns the value of a constant or makes up an arbitrary value that matches the type of the constant .