• Resolved gringostarr

    (@gringostarr)


    I’m working on a plugin running on wamp64 and PHP 7.4.0. When I tried changing the PHP version to 7.3.12 I got this error:
    Parse error: syntax error, unexpected ‘string’ (T_STRING), expecting function (T_FUNCTION) or const (T_CONST) on the line indicated by >>>> in the code below.

    
    defined( 'ABSPATH' ) || exit;
    if ( ! class_exists( 'WC_Test_Integration' ) ) :
        class WC_Test_Integration extends WC_Integration {
    
    >>>>     public function __construct() { 
             }
    

    The plugin works fine when I use PHP 7.4.0. The problem is that the plugin is going to be used on sites running PHP 7.3.12. Does anyone know why I’m getting this error?

    Thanks

    • This topic was modified 4 years, 8 months ago by gringostarr.
    • This topic was modified 4 years, 8 months ago by gringostarr.
    • This topic was modified 4 years, 8 months ago by gringostarr.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support con

    (@conschneider)

    Engineer

    Hi there,

    Your code looks correct. Maybe:

    * rewrite the ternary operator to a standard if() { ... }.
    * eliminate trailing white space in front of public function __construct.

    Kind regards,

    Thread Starter gringostarr

    (@gringostarr)

    Hi Con,

    Thanks for your help. I just found out what the problem is. I
    recently started using typed properties which PHP 7.3.12 doesn’t
    support. The parse error occurred on a different line so I didn’t
    suspect the typed properties was causing the problem.

    Thread Starter gringostarr

    (@gringostarr)

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘syntax error, unexpected ‘string’ (T_STRING),’ is closed to new replies.