Magento2: ClassGenerator generates class with empty namespace

Created on 20 Dec 2016  路  2Comments  路  Source: magento/magento2

When injecting a factory for a class without a namespace the generator creates a factory with an empty namespace.

Preconditions

  1. All Versions

Steps to reproduce

  1. Inject a factory for a class without a namespace in the constructor
<?php

namespace Vendor\ModuleName;

class MyClass {

protected $akismetFactory;

public function __construct(\Zend_Service_AkismetFactory $akismetFactory){
   $this->akismetFactory = $akismetFactory;
}

Expected result

  1. A class without a namespace should be generated
<?php
/**
 * Factory class for @see \Zend_Service_Akismet
 */
class Zend_Service_AkismetFactory
{ 

Actual result

  1. A class with an empty namespace gets generated
<?php
namespace ;

/**
 * Factory class for @see \Zend_Service_Akismet
 */
class Zend_Service_AkismetFactory
{
bug report

Most helpful comment

The class "Zend_Service_Akismet" (as an example) is part of the magento fork of zend-framework (https://github.com/magento/zf1/blob/master/library/Zend/Service/Akismet.php).

Does that mean that i should not create a factory for a zf1 components?

All 2 comments

Please, use namespaces as best practice.

The class "Zend_Service_Akismet" (as an example) is part of the magento fork of zend-framework (https://github.com/magento/zf1/blob/master/library/Zend/Service/Akismet.php).

Does that mean that i should not create a factory for a zf1 components?

Was this page helpful?
0 / 5 - 0 ratings