Skip to content

Support new array syntax #18

@olafgrabienski

Description

@olafgrabienski

After running the Tocbot module through Coder upgrade, I couldn't enable Tocbot on a test site due to the following errors:

ParseError: syntax error, unexpected ''textfield'' (T_CONSTANT_ENCAPSED_STRING), expecting ']' in backdrop_load() (line 87 of /.../modules/tocbot/tocbot.module).

syntax error, unexpected ''textfield'' (T_CONSTANT_ENCAPSED_STRING), expecting ']'

Line 87 is the type textfield related one in this code part:

$form['moduleSettings']['tocbot_extrabodyclass'] =[
  '#type' 'textfield'

Related code from the D7 module:

$form['moduleSettings']['tocbot_extrabodyclass'] = [
  '#type' => 'textfield',

Coder upgrade strips the => between typeand textfield and the comma at the end of the line.

Also, according to @docwilmot in Gitter, Coder upgrade doesnt handle the square brackets syntax yet. At the moment a line like

$form['moduleSettings']['tocbot_extrabodyclass'] = [

has to be converted manually to:

$form['moduleSettings']['tocbot_extrabodyclass'] = array(

Note: The bracket syntax shouldn't be used because it's not available in PHP 5.3 (Backdrop supports 5.3).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions