Skip to content
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

Factories created by generate-factory-for-class have fully-qualified namespace for classes pulled from the container #20

Closed
weierophinney opened this issue Dec 31, 2019 · 2 comments

Comments

@weierophinney
Copy link
Member

@weierophinney, here is the issue, as requested.

As I was researching generate-factory-for-class today to create a tutorial on it, I noticed that while most classes referenced in the factory classes it generates were relative, with their fully qualified namespaces included via use statements, classes which were pulled from the container were not.

Here's an example of what I mean:

<?php

namespace App\ServiceManager\TableGateway;

use Interop\Container\ContainerInterface;
use Zend\ServiceManager\Factory\FactoryInterface;
use App\ServiceManager\TableGateway\JournalTable;

class JournalTableFactory implements FactoryInterface
{
    /**
     * @param ContainerInterface $container
     * @param string $requestedName
     * @param null|array $options
     * @return JournalTable
     */
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
    {
        // Note that \Zend\Db\TableGateway\TableGateway is fully qualified
        return new JournalTable(
            $container->get(\Zend\Db\TableGateway\TableGateway::class)
        );
    }
}

I'm not sure if there's something that I've missed; but to me, for consistency's sake if nothing else, it makes sense to have classes retrieved from the container be relative as well.


Originally posted by @settermjd at zendframework/zend-servicemanager#172

@weierophinney
Copy link
Member Author

fwiw, great job on the class. The generated classes are excellently formatted, with proper docblock comments, etc. Thanks for making this happen.


Originally posted by @settermjd at zendframework/zend-servicemanager#172 (comment)

@GeeH
Copy link
Contributor

GeeH commented Jun 8, 2020

I'm closing this; it's a 3 year old formatting tweak that hasn't been commented on in ages. @settermjd please reopen if you want to work on this further.

@GeeH GeeH closed this as completed Jun 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants