Follow along with the video below to see how to install our site as a web app on your home screen.
Бележка: This feature may not be available in some browsers.
//Interface Reflection --------------------------------------------------------------------
if ($reflector -> isInterface()) {
$name = $reflector -> getName();
$folderName = 'controllers';
$folderPath = realpath('..' . DIRECTORY_SEPARATOR . $folderName);
if ($folderPath != FALSE && is_dir($folderPath) && is_readable($folderPath)) {
$files = scandir($folderPath);
$diff = array_diff($files, array('.', '..'));
foreach ($diff as $iClass) {
$ex = explode('.php', $iClass);
$ex = array_diff($ex, array(''));
foreach ($ex as $e) {
$iClass = $folderName . DIRECTORY_SEPARATOR . $e;
if (in_array($name, class_implements($iClass))) {
$interface = $iClass;
break;
}
}
}
}
$iReflector = new \ReflectionClass($interface);
$iStaticProperties = $iReflector -> getStaticProperties();
if ($iStaticProperties) {
foreach ($iStaticProperties as $k => $v) {
if ($k == '_instance' && $v === NULL) {
return $interface::getInstance();
}
}
}
if (!$iReflector -> isInstantiable()) {
throw new \Exception('This Class ' . $interface . ' Is Not Instantiable In: ' . __METHOD__, 500);
}
$iConstructor = $iReflector -> getConstructor();
if (is_null($iConstructor)) {
return new $interface;
}
$iParameters = $iConstructor -> getParameters();
$iDependencies = $this -> getDependencies($iParameters);
return $iReflector -> newInstanceArgs($iDependencies);
}
//End Of Interface Reflection --------------------------------------------------------------------
Нещо са се разместили думите...teroristd каза:дали един клас се имплементира от повече от един интерфейс?
anonimen каза:Нещо са се разместили думите...teroristd каза:дали един клас се имплементира от повече от един интерфейс?
Дали един клас имплеметира 2+ интерфейса? (http://php.net/manual/en/function.class-implements.php)
или
Дали един интерфейс е имплементиран от 2+ класа? (това май-го имаше по-горе - http://stackoverflow.com/questions/3993759/php-how-to-get-a-list-of-classes-that-implement-certain-interface)
$iClass = $folderName . DIRECTORY_SEPARATOR . $e;
if (in_array($name, class_implements($iClass), TRUE)) {
$repeatingInterfaceArr[] = $name;
$count = array_count_values($repeatingInterfaceArr);
if ($count[$name] > 1) {
$iClass =
}
}
Това изглежда доста странно... едва ли е бъг в рhр...По горния начин не става, защото навсякъде ползват функцията get_declared_classes(), която не връща всички класове, и в частност не връща точно тези които ми трябват.
anonimen каза:Това изглежда доста странно... едва ли е бъг в рhр...По горния начин не става, защото навсякъде ползват функцията get_declared_classes(), която не връща всички класове, и в частност не връща точно тези които ми трябват.
Сложи някви echo-та около класовете, които не се зареждат; а там, където ти трябват, принтни get_classes и после в outputа виж дали класовете са заредени преди или след извикването на get_classes.
namespace controllers;
use application\interfaces\TestInterface;
class Test {
public $_testInterface;
public function __construct(TestInterface $testInterface) {
$this -> _testInterface = $testInterface;
}
public function run() {
$this -> _testInterface -> callSomeMethod();
}
$iClass = $folderName . DIRECTORY_SEPARATOR . $e;
if (in_array($name, class_implements($iClass), TRUE)) {
$repeatingInterfaceArr[] = $name;
$count = array_count_values($repeatingInterfaceArr);
$this -> _settings[] = $iClass;
if ($count[$name] > 1) {
$iClass =
}
}