Skip to content

Squiz.Strings.ConcatenationSpacing fix creates syntax error when joining a number to a string #1252

@gseric

Description

@gseric

This fixer generates invalid PHP code in some cases. E.g.:

// Original PHP code:
echo 1 . 'test';

// After fix (syntax error!!!):
echo 1.'test';

// Should be:
echo (1).'test';

PHP reports the following error:

Parse error: syntax error, unexpected ''test'' (T_CONSTANT_ENCAPSED_STRING), expecting ',' or ';'

PHP treats dot as decimal separator instead of concat operator if used directly after number.

PHP_CodeSniffer 2.7.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions