Skip to content

Instantly share code, notes, and snippets.

@Danack
Created December 25, 2013 14:20
Show Gist options
  • Save Danack/8123572 to your computer and use it in GitHub Desktop.
Save Danack/8123572 to your computer and use it in GitHub Desktop.
Example of object returned from factory not being return type hinted.
{
"methodCalls": [
{
"class": "Maker",
"method": "make",
"position": 0
}
],
"functionCalls": [
{
"function": "\\verify",
"position": 0
}
]
}
<?php
class Maker {
function make($className) {
return new $className;
}
}
<?php
class MakerFactory {
/**
* @return Maker
*/
function create() {
return new Maker();
}
}
<?php
function shamoan($className) {
return new $className();
}
class TestClass {
function foo() {
}
}
$maker = new \Intahwebz\Maker();
$makerFactory = new \Intahwebz\MakerFactory();
//Commenting out this line makes it work.
$maker = $makerFactory->create();
$object = $maker->make("TestClass");
$object->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment