title: Impossible to access an attribute on a string variable
body: <p>In my controller i just pass some users on my twig view.
  Here is my function :</p>
  
  <pre><code>public function viewAction($id)
      {
          $em = $this-&gt;getDoctrine()-&gt;getManager();
          $planningRepo = $em-&gt;getRepository('SimonPediBundle:Planning');
          $userRepo = $em-&gt;getRepository('SimonUserBundle:User');
  
          $user = $this-&gt;getUser();
          $planningId = $user-&gt;getPlanning()-&gt;getId();
          $planning = $planningRepo-&gt;find($planningId);
  
  
          $users = $userRepo-&gt;findByPlanning($planningId);
  
          if (null === $planning) {
              throw new NotFoundHttpException("Le planning d'id ".$id. "n'existe pas.");
          }
  
          return $this-&gt;render('planningAction/planning.html.twig', array('planning' =&gt; $planning,
                                                                          'users' =&gt; $users,));
      }
  </code></pre>
  
  <p>And this is my twig view where i want to display some information on a html table :</p>
  
  <pre><code>&lt;tbody&gt;
                      &lt;tr&gt;
                      &lt;th scope="row"&gt;Responsable&lt;/th&gt;
                       {% for i in 1..5 %}
                          {% set assigned_user = ' ' %}
                          {% for user in users if user.planningday == i%}
                              {% set assigned_user = user %}
                          {% endfor %}
                          &lt;td&gt;{{assigned_user.name}} {{assigned_user.lastname}}&lt;/td&gt;
                          {% endfor %}
                      &lt;/tr&gt;
                      &lt;tr&gt;
                          &lt;th scope="row"&gt;Description&lt;/th&gt;
                          {% for i in 1..5 %}
                          {% set assigned_user = ' ' %}
                          {% for user in users if user.planningday == i%}
                              {% set assigned_user = user %}
                          {% endfor %}
                          &lt;td&gt;{{assigned_user.planningcontent}}&lt;/td&gt;
                          {% endfor %}
                      &lt;/tr&gt;
                  &lt;/tbody&gt;
  </code></pre>
  
  <p>And i got this error : 
  Impossible to access an attribute ("name") on a string variable (" ").
  for this line :</p>
  
  <pre><code>&lt;td&gt;{{assigned_user.name}} {{assigned_user.lastname}}&lt;/td&gt;
  </code></pre>
  
  <p>Thanks for help!</p>
  
  <p>And here is my User Entity</p>
  
  <pre><code>/**
   * User
   *
   * @ORM\Table(name="user")
   * @ORM\Entity(repositoryClass="Simon\UserBundle\Repository\UserRepository")
   */
  class User extends BaseUser
  {
      /**
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
     protected $id;
     /**
       * @var string
       *
       * @ORM\Column(name="name", type="string", length=255)
       * @Assert\NotBlank(message="Merci d'entrer votre prénom.", groups={"Registration", "Profile"})
       * @Assert\Length(
       *     min=3,
       *     max=50,
       *     minMessage="Prénom trop court",
       *     maxMessage="Prénom trop long",
       *     groups={"Registration", "Profile"}
       * )
       */
      protected $name;
  
      /**
       * @var string
       *
       * @ORM\Column(name="lastname", type="string", length=255)
       * @Assert\NotBlank(message="Merci d'entrer votre nom.", groups={"Registration", "Profile"})
       * @Assert\Length(
       *     min=3,
       *     max=50,
       *     minMessage="Nom trop court",
       *     maxMessage="Nom trop long",
       *     groups={"Registration", "Profile"}
       * )
       */
      protected $lastname;
       /**
       * @var string
       *
       * @ORM\Column(name="phone", type="string", length=12)
       * @Assert\NotBlank(message="Merci d'entrer un numéro de téléphone.", groups={"Registration", "Profile"}))
       * @Assert\Length(
       *      min=10,
       *      max=10,
       *      minMessage="Entrez un numéro de téléphone valide",
       *      maxMessage="Entrez un numéro de téléphone valide",
       *      groups={"Registration", "Profile"}
       * )
       */
      protected $phone;
      /**
       * @var boolean
       *
       *@ORM\Column(name="hasAdvert", type="boolean", nullable=true)
       */
      protected $hasAdvert;
      /**
       * @var boolean
       *
       * @ORM\Column(name="isAdmin", type="boolean", nullable=true)
       */
      protected $isAdmin;
      /**
       *
       * @ORM\ManyToOne(targetEntity="Simon\PediBundle\Entity\Planning", cascade={"persist"})
       *
       */
      protected $planning;
      /**
       * @var int
       *
       * @ORM\Column(name="planningday", type="smallint", nullable= true)
       */
      protected $planningday;
      /**
       * @var text
       *
       * @ORM\Column(name="planningcontent", type="text", nullable= true)
       */
      protected $planningcontent;
      /**
       *@ var string
       * @ORM\Column(name="address", type="string", length=255)
       */
      protected $address;
  
      /**
       * Get id
       *
       * @return integer
       */
      public function getId()
      {
          return $this-&gt;id;
      }
  
      /**
       * Set name
       *
       * @param string $name
       *
       * @return User
       */
      public function setName($name)
      {
          $this-&gt;name = $name;
  
          return $this;
      }
  
      /**
       * Get name
       *
       * @return string
       */
      public function getName()
      {
          return $this-&gt;name;
      }
  
      /**
       * Set lastname
       *
       * @param string $lastname
       *
       * @return User
       */
      public function setLastname($lastname)
      {
          $this-&gt;lastname = $lastname;
  
          return $this;
      }
  
      /**
       * Get lastname
       *
       * @return string
       */
      public function getLastname()
      {
          return $this-&gt;lastname;
      }
  
      /**
       * Set phone
       *
       * @param string $phone
       *
       * @return User
       */
      public function setPhone($phone)
      {
          $this-&gt;phone = $phone;
  
          return $this;
      }
  
      /**
       * Get phone
       *
       * @return string
       */
      public function getPhone()
      {
          return $this-&gt;phone;
      }
  
      /**
       * Set hasAdvert
       *
       * @param boolean $hasAdvert
       *
       * @return User
       */
      public function setHasAdvert($hasAdvert)
      {
          $this-&gt;hasAdvert = $hasAdvert;
  
          return $this;
      }
  
      /**
       * Get hasAdvert
       *
       * @return boolean
       */
      public function getHasAdvert()
      {
          return $this-&gt;hasAdvert;
      }
  
      /**
       * Set isAdmin
       *
       * @param boolean $isAdmin
       *
       * @return User
       */
      public function setIsAdmin($isAdmin)
      {
          $this-&gt;isAdmin = $isAdmin;
  
          return $this;
      }
  
      /**
       * Get isAdmin
       *
       * @return boolean
       */
      public function getIsAdmin()
      {
          return $this-&gt;isAdmin;
      }
  
      /**
       * Set planningday
       *
       * @param integer $planningday
       *
       * @return User
       */
      public function setPlanningday($planningday)
      {
          $this-&gt;planningday = $planningday;
  
          return $this;
      }
  
      /**
       * Get planningday
       *
       * @return integer
       */
      public function getPlanningday()
      {
          return $this-&gt;planningday;
      }
  
      /**
       * Set planningcontent
       *
       * @param string $planningcontent
       *
       * @return User
       */
      public function setPlanningcontent($planningcontent)
      {
          $this-&gt;planningcontent = $planningcontent;
  
          return $this;
      }
  
      /**
       * Get planningcontent
       *
       * @return string
       */
      public function getPlanningcontent()
      {
          return $this-&gt;planningcontent;
      }
  
      /**
       * Set address
       *
       * @param string $address
       *
       * @return User
       */
      public function setAddress($address)
      {
          $this-&gt;address = $address;
  
          return $this;
      }
  
      /**
       * Get address
       *
       * @return string
       */
      public function getAddress()
      {
          return $this-&gt;address;
      }
  
      /**
       * Set planning
       *
       * @param \Simon\PediBundle\Entity\Planning $planning
       *
       * @return User
       */
      public function setPlanning(\Simon\PediBundle\Entity\Planning $planning = null)
      {
          $this-&gt;planning = $planning;
  
          return $this;
      }
  
      /**
       * Get planning
       *
       * @return \Simon\PediBundle\Entity\Planning
       */
      public function getPlanning()
      {
          return $this-&gt;planning;
      }
  }
  </code></pre>