Project

General

Profile

Actions

Bug #61193

closed

DependencyInjection with @var uses everything as classname

Added by Guido Wehner over 9 years ago. Updated about 8 years ago.

Status:
Rejected
Priority:
Won't have this time
Assignee:
-
Category:
Extbase
Target version:
-
Start date:
2014-08-26
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
6.2
PHP Version:
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

Description

Hello,

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
[[http://phpdoc.org/docs/latest/references/phpdoc/tags/var.html]]

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.

Actions #1

Updated by Alexander Opitz over 9 years ago

  • Category set to Extbase
Actions #2

Updated by Frank Nägler over 9 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.

Actions #3

Updated by Frank Nägler over 9 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.

Actions #4

Updated by Helmut Hummel over 9 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.

Actions #5

Updated by Frank Nägler over 9 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.

Actions #6

Updated by Nils Blattner about 9 years ago

http://www.phpdoc.org/docs/latest/references/phpdoc/tags/var.html

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

Kind regards
Nils

Actions #7

Updated by Christian Kuhn about 9 years ago

  • Status changed from Rejected to New
Actions #8

Updated by Mathias Schreiber about 8 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 :)

Actions

Also available in: Atom PDF