0

One of my wordpress plugins is not working fine , i get this error

Parse error: syntax error, unexpected ':', expecting ';' or.... line 159

private static function getRepositories(): array    /*line 159*/
{
    return [
        new WP_AccessTokenRepository(),
        new WP_RefreshTokenRepository(),
        new WP_ImportPropertyRepository(),
    ];
}
c63Coupe
  • 17
  • 8

1 Answers1

2

Your server's php version in lower than 7.2, therefore the abovementioned syntax is invalid. To fix it, simply update your php in the server.

EDIT: If you are the author of this plugin, as @Ken Y-N said in the comments, you should make the code compatible with php5, as that is the officially supported minimum php version for wordpress

Simas Joneliunas
  • 2,890
  • 20
  • 28
  • 35
  • Or remove the `:array` bit, especially if it is a plugin the OP plans to distribute, as WordPress only requires 5.x or more, IIRC. – Ken Y-N Jul 10 '18 at 01:50
  • I have update it to 7.1 version , but then i am getting this error "Fatal error: Uncaught PDOException: SQLSTATE[HY000] [2002]" line 359 --- and this is line 359 : 'db' => new PDO('mysql:host=' . $wpdb->dbhost . ';dbname=' . $wpdb->dbname, $wpdb->dbuser, $wpdb->dbpassword), – c63Coupe Jul 10 '18 at 01:51
  • 1
    i assumed that its a third party plugin here. will update the answer accordingly @KenY-N – Simas Joneliunas Jul 10 '18 at 01:52
  • @c63Coupe the wordpress plugin cannot connect to your mysql server. Check if the server is properly configured, accessible and that all the connection params are valid – Simas Joneliunas Jul 10 '18 at 01:55
  • Everything works fine , just the plugin make problems if i activate it. – c63Coupe Jul 10 '18 at 01:57
  • without knowing the plugin, its really hard to say more. Maybe plugin cannot reach the db connection parameters or uses a different connector than the remaining plugins? – Simas Joneliunas Jul 10 '18 at 02:08