diff options
Diffstat (limited to 'src/Components/IntoKeyword.php')
-rw-r--r-- | src/Components/IntoKeyword.php | 58 |
1 files changed, 26 insertions, 32 deletions
diff --git a/src/Components/IntoKeyword.php b/src/Components/IntoKeyword.php index dea5d9d..c3f8a43 100644 --- a/src/Components/IntoKeyword.php +++ b/src/Components/IntoKeyword.php @@ -1,8 +1,8 @@ <?php - /** * `INTO` keyword parser. */ +declare(strict_types=1); namespace PhpMyAdmin\SqlParser\Components; @@ -13,10 +13,6 @@ use PhpMyAdmin\SqlParser\TokensList; /** * `INTO` keyword parser. - * - * @category Keywords - * - * @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+ */ class IntoKeyword extends Component { @@ -25,37 +21,37 @@ class IntoKeyword extends Component * * @var array */ - public static $FIELDS_OPTIONS = array( - 'TERMINATED BY' => array( + public static $FIELDS_OPTIONS = [ + 'TERMINATED BY' => [ 1, 'expr', - ), + ], 'OPTIONALLY' => 2, - 'ENCLOSED BY' => array( + 'ENCLOSED BY' => [ 3, 'expr', - ), - 'ESCAPED BY' => array( + ], + 'ESCAPED BY' => [ 4, 'expr', - ) - ); + ], + ]; /** * LINES Options for `SELECT...INTO` statements. * * @var array */ - public static $LINES_OPTIONS = array( - 'STARTING BY' => array( + public static $LINES_OPTIONS = [ + 'STARTING BY' => [ 1, 'expr', - ), - 'TERMINATED BY' => array( + ], + 'TERMINATED BY' => [ 2, 'expr', - ) - ); + ], + ]; /** * Type of target (OUTFILE or SYMBOL). @@ -88,9 +84,9 @@ class IntoKeyword extends Component /** * Options for FIELDS/COLUMNS keyword. * - * @var OptionsArray - * * @see static::$FIELDS_OPTIONS + * + * @var OptionsArray */ public $fields_options; @@ -104,15 +100,13 @@ class IntoKeyword extends Component /** * Options for OPTIONS keyword. * - * @var OptionsArray - * * @see static::$LINES_OPTIONS + * + * @var OptionsArray */ public $lines_options; /** - * Constructor. - * * @param string $type type of destination (may be OUTFILE) * @param string|Expression $dest actual destination * @param array $columns column list of destination @@ -143,9 +137,9 @@ class IntoKeyword extends Component * * @return IntoKeyword */ - public static function parse(Parser $parser, TokensList $list, array $options = array()) + public static function parse(Parser $parser, TokensList $list, array $options = []) { - $ret = new self(); + $ret = new static(); /** * The state of the parser. @@ -203,10 +197,10 @@ class IntoKeyword extends Component $ret->dest = Expression::parse( $parser, $list, - array( + [ 'parseField' => 'table', - 'breakOnAlias' => true - ) + 'breakOnAlias' => true, + ] ); } else { $ret->values = ExpressionArray::parse($parser, $list); @@ -269,7 +263,7 @@ class IntoKeyword extends Component * * @return string */ - public static function build($component, array $options = array()) + public static function build($component, array $options = []) { if ($component->dest instanceof Expression) { $columns = ! empty($component->columns) ? '(`' . implode('`, `', $component->columns) . '`)' : ''; @@ -287,7 +281,7 @@ class IntoKeyword extends Component $ret .= ' ' . $fields_options_str; } - $lines_options_str = OptionsArray::build($component->lines_options, array('expr' => true)); + $lines_options_str = OptionsArray::build($component->lines_options, ['expr' => true]); if (trim($lines_options_str) !== '') { $ret .= ' LINES ' . $lines_options_str; } |