This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Component
Fabien Potencier e7077605bb feature #18869 [Routing] Throw exception when PHP start tag is missing (WouterJ)
This PR was merged into the 3.2-dev branch.

Discussion
----------

[Routing] Throw exception when PHP start tag is missing

| Q             | A
| ------------- | ---
| Branch?       | master (?)
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | yes
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | https://github.com/symfony/symfony-docs/issues/6116 (and many more)
| License       | MIT
| Doc PR        | -

The Problem
---

In the documentation, we never use the PHP start tag. However, in the first tutorials, people simply copy/past the code examples, save the file and expect things to work. They seem to often forget to add the PHP start tag.

Without start tag, the annotation file loader simply skips the file without providing any reason why. As a big framework is quite overwhelming, simple things like this are completely forgotten.

The Fix
---

If a `*.php` file only consists of `T_INLINE_HTML`, it means there is no `<?php` start tag. In this case, instead of skipping the file, an exception is throwed with a possible fix.

BC Break?
---

As the file loader is only executed for `*.php` files, I think the BC break is minimal, but it is possible that people have applications with `*.php` files *without* a start tag. If this file lives in a routing loaded directory (e.g. when doing `@AppBundle/Controller`), it would now result in an exception.

I think this BC break is minimal and can be ignored. If you don't agree, we can add a little str match to check if `class ... {` exists. If that's the case, I think it's safe to say that it was meant to be a PHP file.

Bug or Feature?
---

I don't know if this is considered a bug or a feature, so I submitted it as a feature.

Commits
-------

1e765c8 Throw exception when PHP start tag is missing
2016-06-12 09:33:47 +02:00
..
Asset updated version to 3.2 2016-05-13 13:13:23 -05:00
BrowserKit Merge branch '2.7' into 2.8 2016-06-06 17:06:25 +02:00
Cache [Cache] AbstractAdapter: avoid an extra call to ApcuAdapter::isSupported 2016-06-08 12:08:03 +02:00
ClassLoader updated version to 3.2 2016-05-13 13:13:23 -05:00
Config Merge branch '2.7' into 2.8 2016-06-06 13:11:27 +02:00
Console feature #18781 [Console] Display errors in quiet mode (multi-io) 2016-06-10 08:29:21 +02:00
CssSelector Merge branch '3.1' 2016-06-06 13:53:30 +02:00
Debug Merge branch '3.1' 2016-06-06 17:09:02 +02:00
DependencyInjection feature #18728 deprecate get() for uncompiled container builders (xabbuh) 2016-06-08 13:34:19 +02:00
DomCrawler updated version to 3.2 2016-05-13 13:13:23 -05:00
EventDispatcher Merge branch '3.1' 2016-06-06 13:53:30 +02:00
ExpressionLanguage updated version to 3.2 2016-05-13 13:13:23 -05:00
Filesystem updated version to 3.2 2016-05-13 13:13:23 -05:00
Finder Merge branch '2.7' into 2.8 2016-06-06 13:11:27 +02:00
Form Merge branch '3.1' 2016-06-06 13:53:30 +02:00
HttpFoundation Merge branch '3.1' 2016-06-06 13:53:30 +02:00
HttpKernel feature #19011 [HttpKernel] Add convenient method ArgumentResolver:: getDefaultArgumentValueResolvers (romainneutron) 2016-06-10 07:28:15 +02:00
Inflector Added people - person inflection 2016-05-23 11:06:27 +02:00
Intl updated version to 3.2 2016-05-13 13:13:23 -05:00
Ldap updated version to 3.2 2016-05-13 13:13:23 -05:00
OptionsResolver Merge branch '2.7' into 2.8 2016-05-24 12:00:02 +02:00
Process Merge branch '3.1' 2016-06-06 13:53:30 +02:00
PropertyAccess [PropertyAccess] add missing argument PHPdoc 2016-06-11 12:21:16 +02:00
PropertyInfo feature #18337 [PropertyInfo] Support singular adder and remover (dunglas) 2016-06-07 21:56:47 +02:00
Routing Throw exception when PHP start tag is missing 2016-06-07 09:44:36 +02:00
Security @throws annotations should go after @return 2016-06-06 13:03:51 +02:00
Serializer feature #18483 [Serializer] Deprecate SerializerAwareEncoder (JhonnyL) 2016-06-08 13:18:45 +02:00
Stopwatch Merge branch '3.1' 2016-06-06 13:53:30 +02:00
Templating updated version to 3.2 2016-05-13 13:13:23 -05:00
Translation Merge branch '3.1' 2016-06-06 13:53:30 +02:00
Validator Merge branch '3.1' 2016-05-24 12:07:02 +02:00
VarDumper feature #18675 [VarDumper] Add Redis caster (nicolas-grekas) 2016-05-25 10:18:05 +02:00
Yaml Merge branch '3.1' 2016-06-06 13:53:30 +02:00