views:

37

answers:

1

is have 2 class

first

<?php

  require_once( 'error/DisconnectedHandler.php' );
  require_once( 'error/NoSuchRequestHandler.php' );


  class NetworkManager {

  public static final $RESPONSE_JUMP = 1000;
  ....

second

<?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 ?

thank in advanced

+4  A: 

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.

Stefan Gehrig
thank you good to know
shay