This repository was archived by the owner on Feb 19, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 71
This repository was archived by the owner on Feb 19, 2025. It is now read-only.
Invalid Proxy Generation #47
Copy link
Copy link
Open
Description
I have been investigating an issue which is causing invalid proxies to be generated, and it appears to be associated with classes in namespaces starting with a "v" prefix, e.g. v1.
Example code:
<?php
require_once __DIR__ . '/vendor/autoload.php';
use GeneratedHydrator\Configuration;
$object = new \AcmeBank\Services\BankingService\Core\Contracts\v1\Broken('code');
$config = new Configuration(get_class($object));
$hydratorClass = $config->createFactory()->getHydratorClass();
$hydrator = new $hydratorClass();
$extracted = $hydrator->extract($object);
var_dump($extracted);
During the $hydrator->extract($object) call, the following error occurs:
PHP Notice: Undefined index: in /private/var/folders/fv/r2fq3kk54rb6g1ycxwpcyf4svg09tw/T/GeneratedHydratorGeneratedClass__PM__AcmeBankServicesBankingServiceCoreContractsv1BrokenYToxOntzOjc6ImZhY3RvcnkiO3M6NDE6IkdlbmVyYXRlZEh5ZHJhdG9yXEZhY3RvcnlcSHlkcmF0b3JGYWN0b3J5Ijt9.php on line 27
Here's a look at the generated proxy:
<?php
namespace GeneratedHydratorGeneratedClass\__PM__\AcmeBank\Services\BankingService\Core\Contracts\v1\Broken;
class YToxOntzOjc6ImZhY3RvcnkiO3M6NDE6IkdlbmVyYXRlZEh5ZHJhdG9yXEZhY3RvcnlcSHlkcmF0b3JGYWN0b3J5Ijt9 extends \AcmeBank\Services\BankingService\Core\Contracts\v1\Broke$
{
private $institutionCode = null;
private $name = null;
function __construct()
{
$this->institutionCodeWriter56e1c00865d30311291394 = \Closure::bind(function ($object, $value) {
$object->institutionCode = $value;
}, null, 'AcmeBank\\Services\\BankingService\\Core\\Contracts\\v1\\Broken');
$this->nameWriter56e1c00865d7b109427712 = \Closure::bind(function ($object, $value) {
$object->name = $value;
}, null, 'AcmeBank\\Services\\BankingService\\Core\\Contracts\\v1\\Broken');
}
function hydrate(array $data, $object)
{
$this->institutionCodeWriter56e1c00865d30311291394->__invoke($object, $data['institutionCode']);
$this->nameWriter56e1c00865d7b109427712->__invoke($object, $data['name']);
return $object;
}
function extract($object)
{
$data = (array) $object;
return array('institutionCode' => $data['^@AcmeBank\\Services\\BankingService\\Core\\Contracts^K1\\Broken^@institutionCode'], 'name' => $data['^@AcmeBank\\S$
}
}
If you take a look at the extract method in the proxy, you'll notice that instead of the v1 namespace, the string ^K1 is being included. It's not clear if this is an issue in PhpParser or GeneratedHydrator, but I've begun examining the source to determine where the problem is occurring.
I would be happy to provide a sample project to ease reproduction of the issue if needed.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels