Reputation: 1357
My first class:
<?php
require_once( 'error/DisconnectedHandler.php' );
require_once( 'error/NoSuchRequestHandler.php' );
class NetworkManager {
public static final $RESPONSE_JUMP = 1000;
....
My second class:
<?php
require_once( '../NetworkManager.php' );
class DisconnectedHandler implements Handler{
public static $TYPE = 2000;
public static $RESPONSE_TYPE = self::$TYPE + NetworkManager::$RESPONSE_JUMP;
public static $VER = 0;
I get an error in this line:
public static $RESPONSE_TYPE = self::$TYPE + NetworkManager::$RESPONSE_JUMP;
Eclipse IDE paint $TYPE
in red and says:
Multiple annotations found at this line:
- syntax error, unexpected '$TYPE', expecting
'identifier'
- syntax error, unexpected '$TYPE', expecting
'identifier'
What is the correct syntax for that?
Upvotes: 0
Views: 1390
Reputation: 83622
Static variable declarations (as well as class constants) must be literally defined and cannot contain expression as they are evaluated prior to runtime.
You have to initialize your DisconnectedHandler::$RESPONE_TYPE
in a constructor or more likely in a static initializer method.
Upvotes: 7