![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magento/framework/Setup/SchemaListenerDefinition/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\Framework\Setup\SchemaListenerDefinition; /** * Convert definition for all real types: decimal, float, double. */ class RealDefinition implements DefinitionConverterInterface { /** * Decimal, double and float have different default values. * * @var array */ private static $shapeByType = [ 'float' => [ 'precision' => '0', 'scale' => '0' ], 'decimal' => [ 'precision' => '0', 'scale' => '10' ], 'double' => [ 'precision' => '0', 'scale' => '0' ] ]; /** * @inheritdoc */ public function convertToDefinition(array $definition) { if (isset($definition['length'])) { list($definition['precision'], $definition['scale']) = explode(",", $definition['length']); } return [ 'xsi:type' => $definition['type'], 'name' => $definition['name'], //In previous adapter this 2 fields were switched, so we need to switch again 'scale' => $definition['scale'] ?? self::$shapeByType[$definition['type']]['scale'], 'precision' => $definition['precision'] ?? self::$shapeByType[$definition['type']]['precision'], 'unsigned' => $definition['unsigned'] ?? false, 'nullable' => $definition['nullable'] ?? true, 'default' => isset($definition['default']) && $definition['default'] !== false ? (int) $definition['default'] : null, 'primary' => $definition['primary'] ?? false ]; } }