2014-04-21 4 views
2

엄격한 기준 "만 변수는 참조에 의해 전달되어야한다"변수 만이 C에서 참조에 의해 전달되어야한다 : \ XAMPP \ htdoc 의 \ EliteFifa2 \ SRC \ EliteFifa \ 번들 \ DataFixtures \ ORM \ MatchFixtures.php 라인 (70)Symfony2 DataFixtures 오류가 발생 했습니까?

에 선 (70)는이 라인을 참조한다 :

$lastHomeTeam = array_shift(array_splice($homeTeams, 1, 1)); 

나는 다음과 같은 알고리즘이 정상 PHP 페이지에서 작동하기 때문에 잘못 무슨 일이 일어나고 있는지 이해가 안 돼요.

class MatchFixtures extends AbstractFixture implements OrderedFixtureInterface, ContainerAwareInterface 
{ 
    private $container; 

    public function setContainer(ContainerInterface $container = null) 
    { 
     $this->container = $container; 
    } 

    public function load(ObjectManager $manager) 
    { 
     $teams = array(0, 1, 2, 3); 
     $worldSeason1 = $this->getReference("WorldSeason1"); 
     $league1 = $this->getReference("League 1"); 

     $fixtures = $this->createFixtures($teams, $worldSeason1, $league1); 
    } 

    private function createFixtures($teams, $season, $competition) 
    { 
     $teamsCount = count($teams); 
     $rounds = $teamsCount - 1; 
     $matchesPerRound = $teamsCount/2; 

     $awayTeams = array_splice($teams, $matchesPerRound); 
     $homeTeams = $teams; 

     $fixtures = array(); 
     for ($r = 0; $r < $rounds; $r++) { 
      for ($m = 0; $m < $matchesPerRound; $m++) { 
       $homeTeam = $homeTeams[$m]; 
       $awayTeam = $awayTeams[$m]; 

       $fixtures[$r][$m]["home"] = $homeTeam; 
       $fixtures[$r][$m]["away"] = $awayTeam; 
      } 
      $lastHomeTeam = array_shift(array_splice($homeTeams, 1, 1)); 
      array_unshift($awayTeams, $lastHomeTeam); 

      $lastAwayTeam = array_pop($awayTeams); 
      array_push($homeTeams, $lastAwayTeam); 
     } 

     return $fixtures; 
    } 
} 
+0

가능한 복제본 [Strict 표준 : 변수 만 참조로 전달해야 함] (http://stackoverflow.com/questions/2354609/strict-standards-only-variables-should-be-passed-by-reference) –

답변

2

이 문제가 해결됩니다 :

$spliced = array_splice($homeTeams, 1, 1); 
$lastHomeTeam = array_shift($spliced); 

편집을

주에서 함수가 배열을 수정하기 때문에 $array 인수 (&로 표시) 참조로 전달하는 array_shift() docs 직접.

혼합 array_shift (배열 & $ 배열)

당신은 E_STRICT 메시지를 받고있다. 나는 당신이 여기서 어떤 버전의 PHP를 사용하고 있는지 모르지만, 내 컴퓨터에서 같은 작업을하면 치명적인 오류가 발생합니다 (5.5 사용).

+0

고마워! – Jonathan

+0

사용하고 있습니다. 5.4.19 – Jonathan

+0

문제 없습니다! 또한, devmode Symfony2는 가능한 최대로 오류보고를 설정합니다 (E_ALL | E_STRICT와 같은 것). PHP 설치가 다른 기본값을 가지고 있다고 가정합니다. 따라서 다른 스크립트에 오류가 나타나지 않는 이유는 무엇입니까? –