IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Langage PHP Discussion :

[POO] Comment corriger l'erreur E_STRICT afin de standardiser le code pour PHP5 ?


Sujet :

Langage PHP

  1. #1
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Février 2004
    Messages
    41
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2004
    Messages : 41
    Points : 30
    Points
    30
    Par défaut [POO] Comment corriger l'erreur E_STRICT afin de standardiser le code pour PHP5 ?
    Bonjour a tous,

    Je voudrais perreniser un code qui n'est pas Orienté PHP5.

    Je recupere cette erreur:

    Declaration of ServiceAuthenticator::authenticate() should be compatible with that of AuthenticatorBase::authenticate()


    issue ici:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
     
     
    [warning] 10:53:19 01/10/07 DEPRECATED ERROR: 
    Declaration of ServiceAuthenticator::authenticate() should be compatible with that of AuthenticatorBase::authenticate()
    Dans le fichier /var/www/php-/WEB-INF/classes/php/authenticator/ServiceAuthenticator.php à la ligne 180
     
    #0 /var/www/php-/WEB-INF/GlobalPrependEx.php(70): myErrorHandler(2048, 'Declaration of ...', '/var/www/php-...', 180, Array)
    #1 /var/www/php-/WEB-INF/GlobalPrependEx.php(70): include_once()
    #2 /var/www/php-/WEB-INF/globalPrepend.php(33): include_once('/var/www/php-...')
    #3 /var/www/site_at/WEB-INF/boot-php.inc(96): include_once('/var/www/php-...')
    #4 /var/www/site_at/Admin.php(8): include('/var/www/site...')
    #5 {main}
    Je n'arrive pas a comprendre cette erreur, même en traduisant ca ne me parle pas......

    L'erreur est lancée lorsqu'on include_once la classe ServiceAuthenticator.

    Voici la classe:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
     
     
    class ServiceAuthenticator extends AuthenticatorBase {
     
    	// ----- Instance Variables --------------------------------------------- //
     
    	/**
    	* Descriptive information about this implementation.
    	* @type string
    	*/
    	var $sInfo = 'php.authenticator.ServiceAuthenticator/1.0';
     
    	/**
    	* Character encoding to use to read the username and password parameters
    	* from the request. If not set, the encoding of the request body will be
    	* used.
    	* @type string
    	*/
    	var $sCharacterEncoding = '';
     
     
    	// ----- Public Properties ---------------------------------------------- //
     
    	/**
    	* Return descriptive information about this Valve implementation.
    	*/
    	function getInfo() {
    		return $this->sInfo;
    	}
     
    	/**
    	* Return the character encoding to use to read the username and password.
    	*/
    	function  getCharacterEncoding() {
    		return $this->sCharacterEncoding;
    	}
     
    	/**
    	* Set the character encoding to be used to read the username and password. 
    	*/
    	function  setCharacterEncoding($sCharacterEncoding) {
    		$this->sCharacterEncoding = $sCharacterEncoding;
    	}
     
     
    	// ----- Constructor ---------------------------------------------------- //
     
    	function ServiceAuthenticator() {
     
    		// Setup the parent object first
    		#parent::__construct();	// PHP5
    		parent::AuthenticatorBase();
     
    	}
     
     
    	// ----- Public Methods ------------------------------------------------- //
     
    	/**
    	* Authenticate the user (service) making this request, based on the 
    	* specified login configuration. Return <code>True</code> if any specified
    	* constraint has been satisfied, or <code>False</code> on failure to
    	* authenticate.
    	*
    	* @param Request		Request we are processing
    	* @param Response		Response we are creating
    	* @param LoginConfig	The LoginConfig configuration describing how 
    	*              			authentication should be performed.
    	* @returns boolean
    	*/
    	function authenticate(&$request, &$response, $oConfig) {
     
    		// References to objects we will need later
    		$oSession = Null;
     
    		// Have we already authenticated someone?
    		$oPrincipal = $request->getUserPrincipal();	// Principal
    		#String ssoId = (String) request.getNote(Constants.REQ_SSOID_NOTE);
    		if($oPrincipalNote(PhpMVC_Auth_Const::getKey('SESS_USERNAME_NOTE'), $sUsername);
    		#$session->setNote(PhpMVC_Auth_Const::getKey('SESS_PASSWORD_NOTE'), $sPassword);
     
    		// Redirect the user to the original request URI:
    		// There is no login page for a service authentication (non-interactive logon), 
    		// so we just return True (auth=success) and garnt permission to access the 
    		// resourses guarded by this authenticator.
    		return True;	// 
     
    	}
    }

    Je vous remercie d'avance pour l'aide!!!

    Ronio

  2. #2
    Expert éminent sénior

    Profil pro
    Inscrit en
    Juin 2002
    Messages
    6 152
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2002
    Messages : 6 152
    Points : 17 777
    Points
    17 777
    Par défaut
    Est-ce que vos méthodes sont strictement identiques au niveau de la déclaration de la méthode authentificate entre celle de la classe AuthenticatorBase et ServiceAuthenticator ?


    Julp.

  3. #3
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Février 2004
    Messages
    41
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2004
    Messages : 41
    Points : 30
    Points
    30
    Par défaut Merci Julp pour votre Réponse!
    Bonjour,

    MERCI beaucoup d'avoir répondu!

    Non, les méthodes authentificate de chacune des 2 classes ne sont pas pareil.

    la méthode authenticate de la classe AuthenticatorBase est vide.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    function authenticate($request, $response, $oConfig) {
    		// Create this method in a sub-class
    	}

    Si je comprend bien, il faut que je copie/colle la méthode non vide vers celle qui est vide pour corriger l'erreur ...?
    ( désolé d'avance si c'est une question bête... ).


    Ou plutôt juste mettre un ; dans la méthode vide.
    Normalement on redéfini la méthode donc c'est peut être ça.

    MERCI encore!

  4. #4
    Expert éminent Avatar de Mr N.
    Profil pro
    Inscrit en
    Septembre 2004
    Messages
    5 418
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2004
    Messages : 5 418
    Points : 6 449
    Points
    6 449
    Par défaut
    Il faut AMHA enlever les & de ServiceAuthenticator::authenticate()

  5. #5
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Février 2004
    Messages
    41
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2004
    Messages : 41
    Points : 30
    Points
    30
    Par défaut Exact Mr N. MERCI
    Exact, c'etait bien cela,
    Merci Mr N.
    Merci beaucoup pour l'aide.

    J'ai corrigé les classes de mon appli de cette maniere .

    J'ai d'autres Erreurs strictes Je reposterai dans un new topic si j arrive pas.... car jcrois qu'elles sont differentes.


    Merci encore!

  6. #6
    Expert éminent Avatar de Mr N.
    Profil pro
    Inscrit en
    Septembre 2004
    Messages
    5 418
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2004
    Messages : 5 418
    Points : 6 449
    Points
    6 449
    Par défaut
    Ben si tu as d'autres erreurs E_STRICT ce sujet de discussion est très bien. Pas la peine de multiplier...

  7. #7
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Février 2004
    Messages
    41
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2004
    Messages : 41
    Points : 30
    Points
    30
    Par défaut OK alors j'affiche un autre probleme:
    Je récupere une autre Erreur:


    Declaration of DB_common::raiseError() should be compatible with that of PEAR::raiseError()
    Dans le fichier /var/www/php-mvc/WEB-INF/lib/pear/DB/common.php à la ligne 48


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    [warning] 16:08:47 01/15/07 DEPRECATED ERROR: 
    Declaration of DB_common::raiseError() should be compatible with that of PEAR::raiseError()
    Dans le fichier /var/www/php-mvc/WEB-INF/lib/pear/DB/common.php &agrave; la ligne 48
     
    #0 /var/www/php/WEB-INF/lib/pear/DB/common.php(48): myErrorHandler(2048, 'Declaration of ...', '/var/www/php-mv...', 48, Array)
    #1 /var/www/php-mvc/WEB-INF/lib/pear/DB/mysql.php(30): require_once('/var/www/php...')
    #2 /var/www/php-mvc/WEB-INF/GlobalPrependEx.php(128): include_once('/var/www/php...')
    #3 /var/www/php-mvc/WEB-INF/globalPrepend.php(33): include_once('/var/www/php...')
    #4 /var/www/site_at/WEB-INF/boot-php.inc(91): include_once('/var/www/php...')
    #5 /var/www/site_at/Main.php(10): include('/var/www/siterh...')
    #6 {main}

    Il n'y a pas le même rapport avec les corrections precedentes.


    Dans le fichier Common.php

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
     
        /**
         * Communicates an error and invoke error callbacks, etc
         *
         * Basically a wrapper for PEAR::raiseError without the message string.
         *
         * @param mixed   integer error code, or a PEAR error object (all
         *                 other parameters are ignored if this parameter is
         *                 an object
         * @param int     error mode, see PEAR_Error docs
         * @param mixed   if error mode is PEAR_ERROR_TRIGGER, this is the
         *                 error level (E_USER_NOTICE etc).  If error mode is
         *                 PEAR_ERROR_CALLBACK, this is the callback function,
         *                 either as a function name, or as an array of an
         *                 object and method name.  For other error modes this
         *                 parameter is ignored.
         * @param string  extra debug information.  Defaults to the last
         *                 query and native error code.
         * @param mixed   native error code, integer or string depending the
         *                 backend
         *
         * @return object  the PEAR_Error object
         *
         * @see PEAR_Error
         */
        function raiseError($code = DB_ERROR, $mode = null, $options = null,
                             $userinfo = null, $nativecode = null)
        {
            // The error is yet a DB error object
            if (is_object($code)) {
                // because we the static PEAR::raiseError, our global
                // handler should be used if it is set
                if ($mode === null && !empty($this->_default_error_mode)) {
                    $mode    = $this->_default_error_mode;
                    $options = $this->_default_error_options;
                }
                $tmp = PEAR::raiseError($code, null, $mode, $options,
                                        null, null, true);
                return $tmp;
            }
     
            if ($userinfo === null) {
                $userinfo = $this->last_query;
            }
     
            if ($nativecode) {
                $userinfo .= ' [nativecode=' . trim($nativecode) . ']';
            } else {
                $userinfo .= ' [DB Error: ' . DB::errorMessage($code) . ']';
            }
     
            $tmp = PEAR::raiseError(null, $code, $mode, $options, $userinfo,
                                    'DB_Error', true);
            return $tmp;
        }


    Et voici celle de PEAR.php

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
     
    	/**
         * This method is a wrapper that returns an instance of the
         * configured error class with this object's default error
         * handling applied.  If the $mode and $options parameters are not
         * specified, the object's defaults are used.
         *
         * @param mixed $message a text error message or a PEAR error object
         *
         * @param int $code      a numeric error code (it is up to your class
         *                  to define these if you want to use codes)
         *
         * @param int $mode      One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT,
         *                  PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE,
         *                  PEAR_ERROR_CALLBACK, PEAR_ERROR_EXCEPTION.
         *
         * @param mixed $options If $mode is PEAR_ERROR_TRIGGER, this parameter
         *                  specifies the PHP-internal error level (one of
         *                  E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR).
         *                  If $mode is PEAR_ERROR_CALLBACK, this
         *                  parameter specifies the callback function or
         *                  method.  In other error modes this parameter
         *                  is ignored.
         *
         * @param string $userinfo If you need to pass along for example debug
         *                  information, this parameter is meant for that.
         *
         * @param string $error_class The returned error object will be
         *                  instantiated from this class, if specified.
         *
         * @param bool $skipmsg If true, raiseError will only pass error codes,
         *                  the error message parameter will be dropped.
         *
         * @access public
         * @return object   a PEAR error object
         * @see PEAR::setErrorHandling
         * @since PHP 4.0.5
         */
    	function raiseError($message = null,
    	$code = null,
    	$mode = null,
    	$options = null,
    	$userinfo = null,
    	$error_class = null,
    	$skipmsg = false)
    	{
    		// The error is yet a PEAR error object
    		if (is_object($message)) {
    			$code        = $message->getCode();
    			$userinfo    = $message->getUserInfo();
    			$error_class = $message->getType();
    			$message->error_message_prefix = '';
    			$message     = $message->getMessage();
    		}
     
    		if (isset($this) && isset($this->_expected_errors) && sizeof($this->_expected_errors) > 0 && sizeof($exp = end($this->_expected_errors))) {
    			if ($exp[0] == "*" ||
    			(is_int(reset($exp)) && in_array($code, $exp)) ||
    			(is_string(reset($exp)) && in_array($message, $exp))) {
    				$mode = PEAR_ERROR_RETURN;
    			}
    		}
    		// No mode given, try global ones
    		if ($mode === null) {
    			// Class error handler
    			if (isset($this) && isset($this->_default_error_mode)) {
    				$mode    = $this->_default_error_mode;
    				$options = $this->_default_error_options;
    				// Global error handler
    			} elseif (isset($GLOBALS['_PEAR_default_error_mode'])) {
    				$mode    = $GLOBALS['_PEAR_default_error_mode'];
    				$options = $GLOBALS['_PEAR_default_error_options'];
    			}
    		}
     
    		if ($error_class !== null) {
    			$ec = $error_class;
    		} elseif (isset($this) && isset($this->_error_class)) {
    			$ec = $this->_error_class;
    		} else {
    			$ec = 'PEAR_Error';
    		}
    		if ($skipmsg) {
    			$a = new $ec($code, $mode, $options, $userinfo);
    			return $a;
    		} else {
    			$a = new $ec($message, $code, $mode, $options, $userinfo);
    			return $a;
    		}
    	}
    J'ai beau chercher... je suis un peu dépassé.....


    Je vous remercie d'avance !!!

    Ronio

  8. #8
    Expert éminent Avatar de Mr N.
    Profil pro
    Inscrit en
    Septembre 2004
    Messages
    5 418
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2004
    Messages : 5 418
    Points : 6 449
    Points
    6 449
    Par défaut
    Euh normalement ce n'est pas vraiment à toi de porter le code de pear pour le rendre compatible php5... Essaie de voir si il n'existe pas des versions plus récentes strictement compatibles php5...

  9. #9
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Février 2004
    Messages
    41
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2004
    Messages : 41
    Points : 30
    Points
    30
    Par défaut
    Merci pour l'info j'ai mis a jour PEAR et je n'ai plus de problèmes

    J'espère que ce poste aidera la communauté!

    Merci

    Ronio

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 20
    Dernier message: 21/01/2008, 18h27
  2. Réponses: 4
    Dernier message: 11/01/2008, 21h37
  3. Comment corriger ces erreurs ?
    Par apt dans le forum Langage
    Réponses: 9
    Dernier message: 18/01/2007, 17h49
  4. [W3C] Comment corriger mon erreur d'affichage
    Par jeremy_chauvel dans le forum Balisage (X)HTML et validation W3C
    Réponses: 7
    Dernier message: 19/11/2006, 17h23
  5. Réponses: 3
    Dernier message: 21/07/2006, 15h50

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo