Zend FR

Consultez la FAQ sur le ZF avant de poster une question

Vous n'êtes pas identifié.

#1 29-11-2017 15:45:58

samziceliza
Membre
Date d'inscription: 29-03-2017
Messages: 12

Uncaught Error: Undefined class constant 'ARRAY_AS_PROPS'

Bonjour,

Mon site Web développé avec Zend 3 cesse de fonctionner de temps en temps en affichant ce massage d'erreur :

[Wed Nov 29 09:04:21.864514 2017] [php7:error] [pid 1856:tid 1572] [client 188.130.104.106:61315] PHP Fatal error:  Uncaught Error: Undefined class constant 'ARRAY_AS_PROPS' in D:\\xampp\\htdocs\\Xerfi\\vendor\\zendframework\\zend-view\\src\\Variables.php:41\nStack trace:\n#0 D:\\xampp\\htdocs\\Xerfi\\vendor\\zendframework\\zend-view\\src\\Model\\ViewModel.php(77): Zend\\View\\Variables->__construct()\n#1 D:\\xampp\\htdocs\\Xerfi\\vendor\\zendframework\\zend-mvc\\src\\MvcEvent.php(201): Zend\\View\\Model\\ViewModel->__construct()\n#2 D:\\xampp\\htdocs\\Xerfi\\vendor\\zendframework\\zend-mvc\\src\\View\\Http\\ViewManager.php(155): Zend\\Mvc\\MvcEvent->getViewModel()\n#3 D:\\xampp\\htdocs\\Xerfi\\vendor\\zendframework\\zend-mvc\\src\\View\\Http\\ViewManager.php(243): Zend\\Mvc\\View\\Http\\ViewManager->getViewModel()\n#4 D:\\xampp\\htdocs\\Xerfi\\vendor\\zendframework\\zend-mvc\\src\\View\\Http\\ViewManager.php(107): Zend\\Mvc\\View\\Http\\ViewManager->injectViewModelIntoPlugin()\n#5 D:\\xampp\\htdocs\\Xerfi\\vendor\\zendframework\\zend-eventmanager\\src\\EventManager.php(322): Zend\\Mvc\\View\\Http\\ViewManager->onBootstrap(Object(Zend\\Mvc\\MvcEvent))\n#6 D:\\xampp\\htdocs\\Xerfi\\vendor\\zendframework\\zend-eventmanag in D:\\xampp\\htdocs\\Xerfi\\vendor\\zendframework\\zend-view\\src\\Variables.php on line 41


Un fois que je redémarre Xampp le site fonctionne.

Je ne comprends pas d'ou vient le problème.

Merci par avance pour votre aide.

Hors ligne

 

#2 30-11-2017 10:41:05

tdutrion
Administrateur
Lieu: Dijon, Paris, Edinburgh
Date d'inscription: 23-12-2009
Messages: 614
Site web

Re: Uncaught Error: Undefined class constant 'ARRAY_AS_PROPS'

Bonjour,

Pourrait-on voir le fichier D:\\xampp\\htdocs\\Xerfi\\vendor\\zendframework\\zend-view\\src\\Variables.php ?

Hors ligne

 

#3 01-12-2017 11:30:13

samziceliza
Membre
Date d'inscription: 29-03-2017
Messages: 12

Re: Uncaught Error: Undefined class constant 'ARRAY_AS_PROPS'

Bonjour,

Merci pour votre retour.

Voici le contenu du fichier variable.php

Code:

<?php
/**
 * Zend Framework (http://framework.zend.com/)
 *
 * @link      http://github.com/zendframework/zf2 for the canonical source repository
 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
 * @license   http://framework.zend.com/license/new-bsd New BSD License
 */

namespace Zend\View;

use ArrayObject;

/**
 * Class for Zend\View\Renderer\PhpRenderer to help enforce private constructs.
 *
 * @todo       Allow specifying string names for manager, filter chain, variables
 * @todo       Move escaping into variables object
 * @todo       Move strict variables into variables object
 */
class Variables extends ArrayObject
{
    /**
     * Strict variables flag; when on, undefined variables accessed in the view
     * scripts will trigger notices
     *
     * @var bool
     */
    protected $strictVars = false;

    /**
     * Constructor
     *
     * @param  array $variables
     * @param  array $options
     */
    public function __construct(array $variables = [], array $options = [])
    {
        parent::__construct(
            $variables,
            ArrayObject::ARRAY_AS_PROPS,
            'ArrayIterator'
        );

        $this->setOptions($options);
    }

    /**
     * Configure object
     *
     * @param  array $options
     * @return Variables
     */
    public function setOptions(array $options)
    {
        foreach ($options as $key => $value) {
            switch (strtolower($key)) {
                case 'strict_vars':
                    $this->setStrictVars($value);
                    break;
                default:
                    // Unknown options are considered variables
                    $this[$key] = $value;
                    break;
            }
        }
        return $this;
    }

    /**
     * Set status of "strict vars" flag
     *
     * @param  bool $flag
     * @return Variables
     */
    public function setStrictVars($flag)
    {
        $this->strictVars = (bool) $flag;
        return $this;
    }

    /**
     * Are we operating with strict variables?
     *
     * @return bool
     */
    public function isStrict()
    {
        return $this->strictVars;
    }

    /**
     * Assign many values at once
     *
     * @param  array|object $spec
     * @return Variables
     * @throws Exception\InvalidArgumentException
     */
    public function assign($spec)
    {
        if (is_object($spec)) {
            if (method_exists($spec, 'toArray')) {
                $spec = $spec->toArray();
            } else {
                $spec = (array) $spec;
            }
        }
        if (!is_array($spec)) {
            throw new Exception\InvalidArgumentException(sprintf(
                'assign() expects either an array or an object as an argument; received "%s"',
                gettype($spec)
            ));
        }
        foreach ($spec as $key => $value) {
            $this[$key] = $value;
        }

        return $this;
    }

    /**
     * Get the variable value
     *
     * If the value has not been defined, a null value will be returned; if
     * strict vars on in place, a notice will also be raised.
     *
     * Otherwise, returns _escaped_ version of the value.
     *
     * @param  mixed $key
     * @return mixed
     */
    public function offsetGet($key)
    {
        if (!$this->offsetExists($key)) {
            if ($this->isStrict()) {
                trigger_error(sprintf(
                    'View variable "%s" does not exist',
                    $key
                ), E_USER_NOTICE);
            }
            return;
        }

        $return = parent::offsetGet($key);

        // If we have a closure/functor, invoke it, and return its return value
        if (is_object($return) && is_callable($return)) {
            $return = call_user_func($return);
        }

        return $return;
    }

    /**
     * Clear all variables
     *
     * @return void
     */
    public function clear()
    {
        $this->exchangeArray([]);
    }
}

Hors ligne

 

#4 01-12-2017 11:41:28

tdutrion
Administrateur
Lieu: Dijon, Paris, Edinburgh
Date d'inscription: 23-12-2009
Messages: 614
Site web

Re: Uncaught Error: Undefined class constant 'ARRAY_AS_PROPS'

As-tu plusieurs versions de PHP sur ton Wamp (même si toutes les versions de PHP sont compatibles avec ce truc normalement) ?

Je ne vois pas pourquoi ça peut ne pas marcher... Le caractère aléatoire fait penser à un problème au niveau de WAMP sur ta machine pour ma part, mais je peux me tromper complètement...

Hors ligne

 

#5 01-12-2017 11:54:37

samziceliza
Membre
Date d'inscription: 29-03-2017
Messages: 12

Re: Uncaught Error: Undefined class constant 'ARRAY_AS_PROPS'

j'ai eu ce problème sur deux serveurs différents.
Sur les deux serveurs on a la version wamp qu'on a installé en premier puis on a installé xampp(PHP7).
Je viens de renommer l'ancien répertoire wamp pour éviter les conflits.

On verra si ce problème persiste.

Merci

Hors ligne

 

Pied de page des forums

Propulsé par PunBB
© Copyright 2002–2005 Rickard Andersson
Traduction par punbb.fr

Graphisme réalisé par l'agence Rodolphe Eveilleau
Développement par Kitpages