blob: e198e6995a9f207ed52b09b8b24e5cfdf0fe5c32 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
/**
* fastcall.cpp
*
* This file holds some PHP functions implementation in C directly.
*
*/
#include "includes.h"
namespace Php {
bool class_exists(const std::string &classname, bool autoload) {
// we need the tsrm_ls variable
TSRMLS_FETCH();
zend_class_entry **ce;
int found;
const char * str = classname.c_str();
int32_t len = (int32_t)classname.length();
if (autoload) {
char lc_name[len + 1];
zend_str_tolower_copy(lc_name, str, len);
char *name = lc_name;
if (lc_name[0] == '\\') {
name = &lc_name[1];
--len;
}
found = zend_hash_find(EG(class_table), name, len + 1, (void **) &ce);
return (found == SUCCESS && !(((*ce)->ce_flags & (ZEND_ACC_INTERFACE | ZEND_ACC_TRAIT)) > ZEND_ACC_EXPLICIT_ABSTRACT_CLASS));
}
if (zend_lookup_class(str, len, &ce TSRMLS_CC) == SUCCESS) {
return (((*ce)->ce_flags & (ZEND_ACC_INTERFACE | (ZEND_ACC_TRAIT - ZEND_ACC_EXPLICIT_ABSTRACT_CLASS))) == 0);
}
return false;
}
}
|