Skip to content

[Form] Shortcut debug:form for partial type name #29452

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 10, 2018
Merged

[Form] Shortcut debug:form for partial type name #29452

merged 1 commit into from
Dec 10, 2018

Conversation

ro0NL
Copy link
Contributor

@ro0NL ro0NL commented Dec 4, 2018

Q A
Branch? master
Bug fix? yes-ish
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #...
License MIT
Doc PR symfony/symfony-docs#...

When running debug:form we must specify the short type class case-sensitive. As the current autoloader doesnt check for insensitive names.

I propose this shortcut to quickly enable

debug:form url
debug:form urltype

instead of forcing

debug:form UrlType

@yceruto
Copy link
Member

yceruto commented Dec 4, 2018

👍 for the shortcut.

I'd like also type mydatetype instead of MyDateType.

@ro0NL
Copy link
Contributor Author

ro0NL commented Dec 4, 2018

i dont think we can conventionally change mydate to MyDate

@yceruto
Copy link
Member

yceruto commented Dec 4, 2018

right, but we can change MyDate to mydate :)

@nicolas-grekas nicolas-grekas added this to the next milestone Dec 6, 2018
@nicolas-grekas nicolas-grekas removed the Bug label Dec 6, 2018
@stof
Copy link
Member

stof commented Dec 7, 2018

@yceruto but that replacement is not the one you were asking for, as the input you asked for is mydate

@msvrtan
Copy link

msvrtan commented Dec 8, 2018

In order to test your branch out, I rebased it locally with current master (and there were around 3k commits difference) and I have a bug to report:

On symfony 4.2 based skeleton project, when I run php bin/console debug:form urltype I get

2018-12-08T11:32:46+00:00 [error] Error thrown while running command "debug:form urltype -vvv". Message: "Case mismatch between loaded and declared class names: "Symfony\Component\Form\Extension\Core\Type\urltype" vs "Symfony\Component\Form\Extension\Core\Type\UrlType"."
2018-12-08T11:32:46+00:00 [debug] Command "debug:form urltype -vvv" exited with code "1"

In DebugClassLoader.php line 185:

  [RuntimeException]
  Case mismatch between loaded and declared class names: "Symfony\Component\Form\Extension\Core\Type\urltype" vs "Symfony\Component\Form\Extension\Core\Type\UrlType".


Exception trace:
 () at /work/noob/learning/symfonyconhackday/symfony/src/Symfony/Component/Debug/DebugClassLoader.php:185
 Symfony\Component\Debug\DebugClassLoader->checkClass() at /work/noob/learning/symfonyconhackday/symfony/src/Symfony/Component/Debug/DebugClassLoader.php:161
 Symfony\Component\Debug\DebugClassLoader->loadClass() at n/a:n/a
 spl_autoload_call() at n/a:n/a
 class_exists() at /work/noob/learning/symfonyconhackday/symfony/src/Symfony/Component/Form/Command/DebugCommand.php:159
 Symfony\Component\Form\Command\DebugCommand->getFqcnTypeClass() at /work/noob/learning/symfonyconhackday/symfony/src/Symfony/Component/Form/Command/DebugCommand.php:119
 Symfony\Component\Form\Command\DebugCommand->execute() at /work/noob/learning/symfonyconhackday/symfony/src/Symfony/Component/Console/Command/Command.php:255
 Symfony\Component\Console\Command\Command->run() at /work/noob/learning/symfonyconhackday/symfony/src/Symfony/Component/Console/Application.php:919
 Symfony\Component\Console\Application->doRunCommand() at /work/noob/learning/symfonyconhackday/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:89
 Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand() at /work/noob/learning/symfonyconhackday/symfony/src/Symfony/Component/Console/Application.php:262
 Symfony\Component\Console\Application->doRun() at /work/noob/learning/symfonyconhackday/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:75
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /work/noob/learning/symfonyconhackday/symfony/src/Symfony/Component/Console/Application.php:145
 Symfony\Component\Console\Application->run() at /work/noob/learning/symfonyconhackday/pr29452/bin/console:40

Same thing happens with php bin/console debug:form urlType -vvv

2018-12-08T11:33:35+00:00 [error] Error thrown while running command "debug:form urlType -vvv". Message: "Case mismatch between loaded and declared class names: "Symfony\Component\Form\Extension\Core\Type\urlType" vs "Symfony\Component\Form\Extension\Core\Type\UrlType"."
2018-12-08T11:33:35+00:00 [debug] Command "debug:form urlType -vvv" exited with code "1"

In DebugClassLoader.php line 185:

  [RuntimeException]
  Case mismatch between loaded and declared class names: "Symfony\Component\Form\Extension\Core\Type\urlType" vs "Symfony\Component\Form\Extension\Core\Type\UrlType".


Exception trace:
 () at /work/noob/learning/symfonyconhackday/symfony/src/Symfony/Component/Debug/DebugClassLoader.php:185
 Symfony\Component\Debug\DebugClassLoader->checkClass() at /work/noob/learning/symfonyconhackday/symfony/src/Symfony/Component/Debug/DebugClassLoader.php:161
 Symfony\Component\Debug\DebugClassLoader->loadClass() at n/a:n/a
 spl_autoload_call() at n/a:n/a
 class_exists() at /work/noob/learning/symfonyconhackday/symfony/src/Symfony/Component/Form/Command/DebugCommand.php:159
 Symfony\Component\Form\Command\DebugCommand->getFqcnTypeClass() at /work/noob/learning/symfonyconhackday/symfony/src/Symfony/Component/Form/Command/DebugCommand.php:119
 Symfony\Component\Form\Command\DebugCommand->execute() at /work/noob/learning/symfonyconhackday/symfony/src/Symfony/Component/Console/Command/Command.php:255
 Symfony\Component\Console\Command\Command->run() at /work/noob/learning/symfonyconhackday/symfony/src/Symfony/Component/Console/Application.php:919
 Symfony\Component\Console\Application->doRunCommand() at /work/noob/learning/symfonyconhackday/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:89
 Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand() at /work/noob/learning/symfonyconhackday/symfony/src/Symfony/Component/Console/Application.php:262
 Symfony\Component\Console\Application->doRun() at /work/noob/learning/symfonyconhackday/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:75
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /work/noob/learning/symfonyconhackday/symfony/src/Symfony/Component/Console/Application.php:145
 Symfony\Component\Console\Application->run() at /work/noob/learning/symfonyconhackday/pr29452/bin/console:40


while the php bin/console debug:form url does work as expected.

IMO issue is not in your changes in the code but as you have based it on an older master or tag, there are additional changes needed.

@ro0NL
Copy link
Contributor Author

ro0NL commented Dec 8, 2018

Hi @msvrtan ive rebased on latest master. On my machine everything is working as expected;

debug:form urltype

Symfony\Component\Form\Extension\Core\Type\UrlType (Block prefix: "url")
========================================================================


debug:form urltype --no-debug

Symfony\Component\Form\Extension\Core\Type\UrlType (Block prefix: "url")
========================================================================

@fabpot
Copy link
Member

fabpot commented Dec 10, 2018

Thank you @ro0NL.

@fabpot fabpot merged commit a28e3b6 into symfony:master Dec 10, 2018
fabpot added a commit that referenced this pull request Dec 10, 2018
This PR was merged into the 4.3-dev branch.

Discussion
----------

[Form] Shortcut debug:form for partial type name

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yes-ish
| New feature?  | yes
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | #...   <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | symfony/symfony-docs#... <!-- required for new features -->

When running `debug:form` we must specify the short type class case-sensitive. As the current autoloader doesnt check for insensitive names.

I propose this shortcut to quickly enable

```
debug:form url
debug:form urltype
```

instead of forcing

```
debug:form UrlType
```

Commits
-------

a28e3b6 [Form] Shortcut debug:form for partial type name
@ro0NL ro0NL deleted the form-debug branch December 10, 2018 08:12
nicolas-grekas added a commit that referenced this pull request Mar 13, 2019
This PR was merged into the 4.3-dev branch.

Discussion
----------

[Form] Fix debug form when using partial type name

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT

Since #29452 (4.3) we have the possibility of passing a partial type name. This fixes the case where `debug:form dateTime` doesn't work as expected:
```bash
In FormRegistry.php line 89:

  [Symfony\Component\Form\Exception\InvalidArgumentException]
  Could not load type "dateTime": class does not implement "Symfony\Component\Form\FormTypeInterface".
```

Commits
-------

22b20ca Fix debug:form dateTime
@nicolas-grekas nicolas-grekas modified the milestones: next, 4.3 Apr 30, 2019
@fabpot fabpot mentioned this pull request May 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants