Skip to content

Add support to generate proxies for interfaces #11

Closed
@nicojust

Description

@nicojust

The following message will be shown by phpstan while analyzing.

Class Magento\Catalog\Api\ProductRepositoryInterface\Magento\Catalog\Api\ProductRepositoryInterface not found and could not be autoloaded.

The file that was analyzed by phpstan had this a constructor.

/**
 * @param ProductRepositoryInterface\Proxy $productRepository
*/
public function __construct(
    \Magento\Catalog\Api\ProductRepositoryInterface\Proxy $productRepository
) {}

This can be fixed by prefixing the extended Classname with a backslash.

$template .= "class {PROXY_CLASSNAME} extends {CLASSNAME} implements {MARKER_INTERFACE}\n";
in ProxyAutoloader.php:34 becomes
$template .= "class {PROXY_CLASSNAME} extends \{CLASSNAME} implements {MARKER_INTERFACE}\n";

After that a fatal error gets thrown because it will try to extend an Interface.
PHP Fatal error: Class Magento\Catalog\Api\ProductRepositoryInterface\Proxy cannot extend from interface Magento\Catalog\Api\ProductRepositoryInterface in /tmp/PSMPnSgzZV on line 6

<?php
namespace Magento\Catalog\Api\ProductRepositoryInterface;
/**
 * Proxy class for @see Magento\Catalog\Api\ProductRepositoryInterface
 */
class Proxy extends \Magento\Catalog\Api\ProductRepositoryInterface implements \Magento\Framework\ObjectManager\NoninterceptableInterface
{
    /**
     * @return array
     */
    public function __sleep() {}
    /**
     * Retrieve ObjectManager from global scope
     */
    public function __wakeup() {}
    /**
     * Clone proxied instance
     */
    public function __clone() {}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions