Bug #61193

DependencyInjection with @var uses everything as classname

Added by Guido Wehner almost 7 years ago. Updated over 5 years ago.

Won't have this time
Target version:
Start date:
Due date:
% Done:


Estimated time:
TYPO3 Version:
PHP Version:
Is Regression:
Sprint Focus:



this is my first issue.

If you use dependency injection in your controller und you use @var to describe the type of the variable the ClassInfoFactory uses everything after @var as class name

In function buildClassInfoFromClassname($className) the className isn't parsed or formatted.

I need to write the name of the property after the type

Reference for phpdoc @var

I need to write

 * @var \BM\Simpleblog\Domain\Repository\BlogRepository $blogRepository
 * @inject
protected $blogRepository;

but then "BM\Simpleblog\Domain\Repository\BlogRepository $blogRepository" is used as className.

$className = preg_replace("/(\s.*)/", "", $className);
would do the job, but I cannot say if it breaks tests or why there is no parsing the variable, maybe there are reasons I dont know.


Updated by Alexander Opitz almost 7 years ago

  • Category set to Extbase

Updated by Frank Naegler almost 7 years ago

within in the class properties you can declare it like this:

 * @var \BM\Simpleblog\Domain\Repository\BlogRepository
 * @inject
protected $blogRepository;

simply remove the $blogRepository after the class name.
I agree this is a bug, but for the most IDEs and for TYPO3 the variable after the class is not needed.


Updated by Frank Naegler almost 7 years ago

it looks like the problem is located in TYPO3\CMS\Extbase\Reflection\DocCommentParser::parseTag($line) the tag is split with a limit: $tagAndValue = preg_split('/\\s/', $line, 2);.
I am not sure why the limit is set, maybe someone from the extbase team can get an answer.


Updated by Helmut Hummel almost 7 years ago

  • Status changed from New to Rejected
  • Priority changed from Should have to Won't have this time
@var \BM\Simpleblog\Domain\Repository\BlogRepository $blogRepository

This is an invalid property annotation. I do not think we need to support invalid annotations.


Updated by Frank Naegler almost 7 years ago

Why it is an invalid annotation? The documentation for @var is

@var [“Type”] [$element_name] [<description>]

see the link above in the original issue message.


Updated by Nils Blattner over 6 years ago


Clearly shows that the above is a valid notation and should be interpreted correctly.
Can you please reopen the ticket?

Kind regards


Updated by Christian Kuhn over 6 years ago

  • Status changed from Rejected to New

Updated by Mathias Schreiber over 5 years ago

  • Status changed from New to Rejected

Taken from the mentioned docs:

class Foo
  /** @var string|null Should contain a description */
  protected $description = null;

We support this.

Your misconception ($varname goes in as well):

class Foo
   * @var string $name        Should contain a description
   * @var string $description Should contain a description
  protected $name, $description;

Used for compound syntax (which we do not support).
Helmut wins :)

Also available in: Atom PDF