title: Compile Error: Cannot declare class because the name is already in use
body: <p>I'm migrating the website from symfony 2.6 to 3.4 and I have some trouble with registration forms and FOSUserBundle. I have this error popping-up. I checked his code and see that under his src\Pix\UserBundle\Form\RegistrationFormType.php but there is another folder &quot;Type&quot; with a file with the same name: &quot;RegistrationFormType.php&quot;</p>
  <p>I tried modified the form with the newest style taking from there: <a href="https://github.com/symfony/symfony/blob/2.8/UPGRADE-2.8.md#form" rel="nofollow noreferrer">https://github.com/symfony/symfony/blob/2.8/UPGRADE-2.8.md#form</a></p>
  <p>app/config/config.yml:</p>
  <pre><code>fos_user:
      db_driver: orm
      firewall_name: main
      user_class: Pix\UserBundle\Entity\User
      registration:
          form:
              type: Pix\UserBundle\Form\RegistrationFormType
              validation_groups: [ pix_registration, Default ]
  </code></pre>
  <p>The service file under Pix/UserBundle/Resources/config/services.yml</p>
  <pre><code>services:
      pix_userbundle_registrationformtype:
          class: Pix\UserBundle\Form\Type\RegistrationFormType
          arguments: [&quot;%fos_user.model.user.class%&quot;]
          tags:
              - { name: form.type }
  </code></pre>
  <p>The Pix/UserBundle/Form/RegistrationFormType.php:</p>
  <pre class="lang-php prettyprint-override"><code>namespace Pix\UserBundle\Form;
  
  use FOS\UserBundle\Form\Type\RegistrationFormType as BaseRegistrationFormType;
  use Symfony\Component\Form\AbstractType;
  use Symfony\Component\Form\FormBuilderInterface;
  use Symfony\Component\OptionsResolver\OptionsResolverInterface;
  
  
  class RegistrationFormType extends AbstractType
  {
  
      public function __construct($class = &quot;User&quot;)
      {
          parent::__construct($class);
      }
  
      public function buildForm(FormBuilderInterface $builder, array $options)
      {
          parent::buildForm($builder, $options);
  
          $builder
              -&gt;add('username', 'text', array(
                  'label' =&gt; 'Pseudonyme',
              ))
              -&gt;add('email', 'text', array(
                  'label' =&gt; 'Adresse mail',
              ))
              -&gt;add('plainPassword', 'repeated', array(
                  'type' =&gt; 'password',
                  'first_options' =&gt; array('label' =&gt; 'Mot de passe'),
                  'second_options' =&gt; array('label' =&gt; 'Confirmation'),
                  'invalid_message' =&gt; 'Mot de passe incorrect',
              ))
              -&gt;add('enabled', 'checkbox', array(
                  'label' =&gt; &quot;Activé&quot;,
                  'required' =&gt; false
              ))
  
              -&gt;add('firstname', 'text', array(
                  'label' =&gt; 'Prénom',
              ))
              -&gt;add('lastname', 'text', array(
                  'label' =&gt; 'Nom',
              ))
              -&gt;add('phone', 'text', array(
                  'label' =&gt; 'Téléphone',
              ))
              -&gt;add('street', 'text', array(
                  'label' =&gt; &quot;Adresse postale&quot;,
                  'required' =&gt; true
              ))
              -&gt;add('number', 'text', array(
                  'label' =&gt; &quot;Numéro d'adresse&quot;,
                  'required' =&gt; true
              ))
              -&gt;add('npa', 'text', array(
                  'label' =&gt; &quot;Code postal&quot;,
                  'required' =&gt; true
              ))
              -&gt;add('city', 'text', array(
                  'label' =&gt; &quot;Ville&quot;,
                  'required' =&gt; true
              ))
              -&gt;add('state', 'text', array(
                  'label' =&gt; &quot;Canton&quot;,
                  'required' =&gt; true
              ))
              -&gt;add('country', 'text', array(
                  'label' =&gt; &quot;Pays&quot;,
                  'required' =&gt; true
              ))
              -&gt;add('latitude', 'text', array(
                  'label' =&gt; &quot;Latitude&quot;,
                  'required' =&gt; true
              ))
              -&gt;add('longitude', 'text', array(
                  'label' =&gt; &quot;Longitude&quot;,
                  'required' =&gt; true
              ))
              -&gt;add('code', 'text', array(
                  'label' =&gt; 'Code de parrainage',
                  'required' =&gt; false
              ))
              -&gt;add('pro', 'choice', array(
                  'label' =&gt; &quot;Professionel&quot;,
                  'choices'  =&gt; array(
                      true =&gt; 'Oui',
                      false =&gt; 'Non',
                  ),
                  'expanded' =&gt; false,
                  'multiple' =&gt; false,
                  'required' =&gt; true
              ))
  
              -&gt;add('iban', 'text', array(
                  'label' =&gt; 'IBAN',
                  'required' =&gt; false
              ))
              -&gt;add('distance', 'text', array(
                  'label' =&gt; &quot;Rayon d'intervention&quot;,
                  'required' =&gt; false
              ))
              -&gt;add('picture', new DocumentType(), array('required' =&gt; false))
              -&gt;add('curriculum', new DocumentType(), array('required' =&gt; false))
              -&gt;add('motivation', new DocumentType(), array('required' =&gt; false))
              -&gt;add('document', new DocumentType(), array('required' =&gt; false))
          ;
      }
  
      public function setDefaultOptions(OptionsResolverInterface $resolver)
      {
          $resolver-&gt;setDefaults(array(
              'data_class' =&gt; 'Pix\UserBundle\Entity\User'
          ));
      }
      public function getParent()
      {
          return BaseRegistrationFormType::class;
      }
      public function getBlockPrefix()
      {
          return 'pix_userbundle_registrationformtype';
      }
  }
  
  </code></pre>
  <p>And finally the Pix/UserBundle/Form/Type/RegistrationFormType.php:</p>
  <pre class="lang-php prettyprint-override"><code>namespace Pix\UserBundle\Form\Type;
  
  use Symfony\Component\Form\FormBuilderInterface;
  use Symfony\Component\OptionsResolver\OptionsResolverInterface;
  use FOS\UserBundle\Form\Type\RegistrationFormType;
  use Symfony\Component\Form\AbstractType;
  use Pix\UserBundle\Form\DocumentType;
  use Pix\UserBundle\Entity\AbilityRepository;
  use Symfony\Component\Form\Extension\Core\Type\TextType; 
  
  class RegistrationFormType extends AbstractType
  {
  
      public function __construct($class = &quot;User&quot;)
      {
          parent::__construct($class);
      }
  
      public function buildForm(FormBuilderInterface $builder, array $options)
      {
          parent::buildForm($builder, $options);
          $builder-&gt;remove('username');
          $builder
              -&gt;add('firstname', TexType::class, array(
                  'label' =&gt; 'Prénom',
              ))
              -&gt;add('lastname', TexType::class, array(
                  'label' =&gt; 'Nom',
              ))
              -&gt;add('phone', TexType::class, array(
                  'label' =&gt; 'Téléphone',
              ))
              -&gt;add('street', 'hidden')
              -&gt;add('number', 'hidden')
              -&gt;add('npa', 'hidden')
              -&gt;add('city', 'hidden')
              -&gt;add('state', 'hidden')
              -&gt;add('country', 'hidden')
              -&gt;add('latitude', 'hidden')
              -&gt;add('longitude', 'hidden')
              -&gt;add('code', TexType::class, array(
                  'label' =&gt; 'Code de parrainage',
                  'required' =&gt; false
              ))
              /*
              -&gt;add('contact', 'choice', array(
                  'label' =&gt; 'Moyen de contact favorisé',
                  'choices'  =&gt; array(
                      true =&gt; 'Par téléphone',
                      false =&gt; 'Par e-mail',
                  ),
                  'expanded' =&gt; true,
                  'multiple' =&gt; false,
                  'required' =&gt; true
              ))
              */
              -&gt;add('pro', 'choice', array(
                  'label' =&gt; false,
                  'choices'  =&gt; array(
                      true =&gt; 'Oui',
                      false =&gt; 'Non',
                  ),
                  'expanded' =&gt; false,
                  'multiple' =&gt; false,
                  'required' =&gt; true
              ))
  
              -&gt;add('iban', TexType::class, array(
                  'label' =&gt; 'IBAN',
                  'required' =&gt; false
              ))
              -&gt;add('distance', TexType::class, array(
                  'label' =&gt; &quot;Rayon d'intervention&quot;,
                  'required' =&gt; false
              ))
              -&gt;add('picture', new DocumentType(), array('required' =&gt; false))
              -&gt;add('curriculum', new DocumentType(), array('required' =&gt; false))
              -&gt;add('motivation', new DocumentType(), array('required' =&gt; false))
              -&gt;add('document', new DocumentType(), array('required' =&gt; false))
  
              -&gt;add('abilities', 'entity', array(
                  'label' =&gt; 'Domaines de compétence',
                  'attr' =&gt; array(
                      'class'=&gt;'form-control multiselect'
                  ),
                  'class' =&gt; 'PixUserBundle:Ability',
                  'property' =&gt; 'title',
                  'multiple' =&gt; true,
                  'expanded' =&gt; true,
                  'required' =&gt; false,
                  'query_builder' =&gt; function(AbilityRepository $er) {
                      return $er-&gt;getAbilities();
                  },
              ))
              -&gt;add('condition', 'checkbox', array('label' =&gt; &quot;J'ai lu et j'accepte les conditions générales.&quot;))
          ;
      }
  
      public function setDefaultOptions(OptionsResolverInterface $resolver)
      {
          $resolver-&gt;setDefaults(array(
              'data_class' =&gt; 'Pix\UserBundle\Entity\User',
              'intention'  =&gt; 'registration'
          ));
      }
      public function getBlockPrefix()
      {
          return 'pix_userbundle_registrationformtype';
      }
      public function getParent()
      {
      return RegistrationFormType::class;
      }
  }
  
  </code></pre>