2017-08-01 4 views
5

J'ai téléchargé et installé Symfony 2.8 à partir de mon propre PC. J'ai copié mon projet et je l'ai collé dans le pc de nos sociétés. Je n'ai pas encore créé et connecté à la base de données. J'ai essayé de faire php app/console server:run sur c:\xampp\htdocs\ninjaz\ mais après que j'obtiens ce message d'erreur.Symfony 2.8 Erreur d'analyse: erreur de syntaxe, inattendue ':', attente de ';' ou '{' dans c: xampp htdocs monprojet chemin vers AnnotationRegistry.php sur la ligne 50

Parse error: syntax error, unexpected ':', expecting ';' or '{' in C:\xampp\htdo cs\Ninjaz\vendor\doctrine\annotations\lib\Doctrine\Common\Annotations\Annotation Registry.php on line 50

Edit: Mon PC a XAMPP avec PHP 7.1. Notre PC de l'entreprise a XAMPP PHP 5.5.19

Ceci est le contenu de AnnotationRegistry.php:

<?php 

namespace Doctrine\Common\Annotations; 

final class AnnotationRegistry 
{ 
/** 
* A map of namespaces to use for autoloading purposes based on a PSR-0 convention. 
* 
* Contains the namespace as key and an array of directories as value. If the value is NULL 
* the include path is used for checking for the corresponding file. 
* 
* This autoloading mechanism does not utilize the PHP autoloading but implements autoloading on its own. 
* 
* @var string[][]|string[]|null[] 
*/ 
static private $autoloadNamespaces = []; 

/** 
* A map of autoloader callables. 
* 
* @var callable[] 
*/ 
static private $loaders = []; 

/** 
* An array of classes which cannot be found 
* 
* @var null[] indexed by class name 
*/ 
static private $failedToAutoload = []; 

public static function reset() : void 
{ 
    self::$autoloadNamespaces = []; 
    self::$loaders   = []; 
    self::$failedToAutoload = []; 
} 

/** 
* Registers file. 
* 
* @deprecated this method is deprecated and will be removed in doctrine/annotations 2.0 
*    autoloading should be deferred to the globally registered autoloader by then. For now, 
*    use @example AnnotationRegistry::registerLoader('class_exists') 
*/ 
public static function registerFile(string $file) : void 
{ 
    require_once $file; 
} 

/** 
* Adds a namespace with one or many directories to look for files or null for the include path. 
* 
* Loading of this namespaces will be done with a PSR-0 namespace loading algorithm. 
* 
* @param string   $namespace 
* @param string|array|null $dirs 
* 
* @deprecated this method is deprecated and will be removed in doctrine/annotations 2.0 
*    autoloading should be deferred to the globally registered autoloader by then. For now, 
*    use @example AnnotationRegistry::registerLoader('class_exists') 
*/ 
public static function registerAutoloadNamespace(string $namespace, $dirs = null) : void 
{ 
    self::$autoloadNamespaces[$namespace] = $dirs; 
} 

/** 
* Registers multiple namespaces. 
* 
* Loading of this namespaces will be done with a PSR-0 namespace loading algorithm. 
* 
* @param string[][]|string[]|null[] $namespaces indexed by namespace name 
* 
* @deprecated this method is deprecated and will be removed in doctrine/annotations 2.0 
*    autoloading should be deferred to the globally registered autoloader by then. For now, 
*    use @example AnnotationRegistry::registerLoader('class_exists') 
*/ 
public static function registerAutoloadNamespaces(array $namespaces) : void 
{ 
    self::$autoloadNamespaces = \array_merge(self::$autoloadNamespaces, $namespaces); 
} 

/** 
* Registers an autoloading callable for annotations, much like spl_autoload_register(). 
* 
* NOTE: These class loaders HAVE to be silent when a class was not found! 
* IMPORTANT: Loaders have to return true if they loaded a class that could contain the searched annotation class. 
* 
* @deprecated this method is deprecated and will be removed in doctrine/annotations 2.0 
*    autoloading should be deferred to the globally registered autoloader by then. For now, 
*    use @example AnnotationRegistry::registerLoader('class_exists') 
*/ 
public static function registerLoader(callable $callable) : void 
{ 
    // Reset our static cache now that we have a new loader to work with 
    self::$failedToAutoload = []; 
    self::$loaders[]   = $callable; 
} 

/** 
* Autoloads an annotation class silently. 
*/ 
public static function loadAnnotationClass(string $class) : bool 
{ 
    if (\class_exists($class, false)) { 
     return true; 
    } 

    if (\array_key_exists($class, self::$failedToAutoload)) { 
     return false; 
    } 

    foreach (self::$autoloadNamespaces AS $namespace => $dirs) { 
     if (\strpos($class, $namespace) === 0) { 
      $file = \str_replace('\\', \DIRECTORY_SEPARATOR, $class) . '.php'; 

      if ($dirs === null) { 
       if ($path = stream_resolve_include_path($file)) { 
        require $path; 
        return true; 
       } 
      } else { 
       foreach((array) $dirs AS $dir) { 
        if (is_file($dir . \DIRECTORY_SEPARATOR . $file)) { 
         require $dir . \DIRECTORY_SEPARATOR . $file; 
         return true; 
        } 
       } 
      } 
     } 
    } 

    foreach (self::$loaders AS $loader) { 
     if ($loader($class) === true) { 
      return true; 
     } 
    } 

    self::$failedToAutoload[$class] = null; 

    return false; 
    } 
} 

J'ai réussi à obtenir le serveur en cours d'exécution en supprimant les : void et : bool mais quand je passe en revue mon projet, il renvoie une autre erreur et c'est la même chose avec le premier mais quand j'essaye de l'enlever encore, cela crée une autre erreur sur d'autres bibliothèques. C'est comme une erreur sans fin après un scénario d'erreur. Je ne sais pas quoi faire maintenant. Je ne suis nouveau qu'à Symfony. L'aide est grandement nécessaire.

Répondre

5

Ceci est dû à une mauvaise version de PHP. J'ai eu le même problème. Vous avez besoin de PHP 7+. PHP dans la version inférieure à 7 ne supporte pas la "déclaration des types de retour".

Vous pouvez aussi ajouter du code ci-dessous à votre composer.json:

{ 
    "config": { 
     "platform": {"php": "5.6"} 
    } 
} 
+0

Ouais. Je pense que c'est la raison. J'ai copié mon projet depuis mon pc qui a PHP 7 alors que dans notre entreprise, nous n'avons que PHP 5.6. – WashichawbachaW