Repository navigation
Expand file tree
/
Copy pathReflection.d.ts
More file actions
190 lines (190 loc) · 9.32 KB
/
Copy pathReflection.d.ts
File metadata and controls
190 lines (190 loc) · 9.32 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
import type { PHPContext } from "../PHPContext.js";
import type { PHPEngine } from "../PHPEngine.js";
import { PHPReference } from "./PHPVariable.js";
export declare const SYMBOL_PHP_META: unique symbol;
export declare const SYMBOL_PHP_NAME: unique symbol;
export declare const SYMBOL_PHP_CONSTANTS: unique symbol;
export declare const SYMBOL_PHP_PROPERTIES: unique symbol;
export declare const SYMBOL_PHP_METHODS: unique symbol;
export declare const SYMBOL_PHP_CLASS: unique symbol;
export declare const SYMBOL_PHP_PARENT: unique symbol;
export declare const SYMBOL_PHP_NEW: unique symbol;
export declare const SYMBOL_PHP_INIT: unique symbol;
export declare const SYMBOL_PHP_CLASS_HAS_MAGIC_METHODS: unique symbol;
export declare const SYMBOL_PHP_CLASS_INTERFACES: unique symbol;
export declare const SYMBOL_PHP_METHOD_THEN: unique symbol;
export declare const SYMBOL_PHP_STATIC_METHOD_PROTOTYPE: unique symbol;
export declare function normalizePhpRegistryName(name: string): string;
export declare function encodePhpIdentifier(name: string): string;
export declare function encodePhpMethodName(name: string, isStatic?: boolean): string | symbol;
export declare function encodePhpPropertyName(name: string): string;
export declare function decodePhpIdentifier(name: string): string;
export declare function decodePhpPropertyName(name: string): string;
export declare function decodePhpMethodName(name: string | symbol): string;
export declare function isEncodedPhpMethodKey(name: string): boolean;
export interface PHPParameterMetadata {
name: string;
position: number;
isOptional: boolean;
hasDefault: boolean;
defaultValue?: any;
type?: string;
byref?: boolean;
}
export interface PHPPropertyMetadata {
name: string;
visibility: "public" | "protected" | "private";
isStatic: boolean;
isReadOnly: boolean;
defaultValue?: any;
encodedName?: string;
}
export type PHPPropertyMetadataRecord = Record<string, PHPPropertyMetadata>;
export interface PHPMethodMetadata {
name: string;
visibility: "public" | "protected" | "private";
isStatic: boolean;
isAbstract: boolean;
isFinal: boolean;
numberOfParameters: number;
numberOfRequiredParameters: number;
parameters: PHPParameterMetadata[];
fn?: Function;
}
export interface FunctionMetaOptions {
name: string;
visibility?: "public" | "protected" | "private";
parameters?: {
name: string;
byref?: boolean;
isOptional?: boolean;
hasDefault?: boolean;
defaultValue?: any;
type?: string;
}[];
}
export declare function defineFunction<T extends Function>(fn: T, meta: FunctionMetaOptions): T;
export declare function parseJSFunctionMetadata(fn?: Function, name?: string): any;
export declare class Reflection {
static getModifierNames(ctx: PHPContext, modifiersArg?: PHPReference): Promise<string[]>;
}
export declare class ReflectionType {
typeName: string;
allowsNullFlag: boolean;
static [SYMBOL_PHP_NEW](ctx: PHPContext, typeNameArg?: PHPReference, allowsNullFlagArg?: PHPReference): Promise<ReflectionType>;
static __construct(this: ReflectionType, ctx: PHPContext, typeNameArg?: PHPReference, allowsNullFlagArg?: PHPReference): Promise<void>;
allowsNull(ctx: PHPContext): boolean;
getName(ctx: PHPContext): string;
__toString(ctx: PHPContext): string;
}
export declare class ReflectionParameter {
paramName: string;
paramPosition: number;
defaultValue: any;
hasDefault: boolean;
static [SYMBOL_PHP_NEW](ctx: PHPContext, nameArg?: PHPReference, positionArg?: PHPReference, defaultValueArg?: PHPReference, hasDefaultArg?: PHPReference): Promise<ReflectionParameter>;
static __construct(this: ReflectionParameter, ctx: PHPContext, nameArg?: PHPReference, positionArg?: PHPReference, defaultValueArg?: PHPReference, hasDefaultArg?: PHPReference): Promise<void>;
getName(ctx: PHPContext): string;
getPosition(ctx: PHPContext): number;
isOptional(ctx: PHPContext): boolean;
isDefaultValueAvailable(ctx: PHPContext): boolean;
getDefaultValue(ctx: PHPContext): any;
isPassedByReference(ctx: PHPContext): boolean;
getType(ctx: PHPContext): Promise<ReflectionType>;
}
export declare class ReflectionProperty {
name: string;
declaringClassName: string;
meta?: PHPPropertyMetadata;
isAccessible: boolean;
static [SYMBOL_PHP_NEW](ctx: PHPContext, classArg?: PHPReference, nameArg?: PHPReference, metaArg?: PHPReference): Promise<ReflectionProperty>;
static __construct(this: ReflectionProperty, ctx: PHPContext, classArg?: PHPReference, nameArg?: PHPReference, metaArg?: PHPReference): Promise<void>;
getName(ctx: PHPContext): string;
getDeclaringClass(ctx: PHPContext): Promise<ReflectionClass>;
isPublic(ctx: PHPContext): boolean;
isProtected(ctx: PHPContext): boolean;
isPrivate(ctx: PHPContext): boolean;
isStatic(ctx: PHPContext): boolean;
isReadOnly(ctx: PHPContext): boolean;
setAccessible(ctx: PHPContext, accessibleArg?: PHPReference): Promise<void>;
getValue(ctx: PHPContext, objArg?: PHPReference): Promise<any>;
setValue(ctx: PHPContext, objArg?: PHPReference, valArg?: PHPReference): Promise<void>;
}
export declare class ReflectionMethod {
className: string;
methodName: string;
meta: PHPMethodMetadata;
static [SYMBOL_PHP_NEW](ctx: PHPContext, classArg?: PHPReference, methodArg?: PHPReference, metaArg?: PHPReference, fnArg?: PHPReference): Promise<ReflectionMethod>;
static __construct(this: ReflectionMethod, ctx: PHPContext, classArg?: PHPReference, methodArg?: PHPReference, metaArg?: PHPReference, fnArg?: PHPReference): Promise<void>;
getName(ctx: PHPContext): string;
getDeclaringClass(ctx: PHPContext): Promise<ReflectionClass>;
isPublic(ctx: PHPContext): boolean;
isProtected(ctx: PHPContext): boolean;
isPrivate(ctx: PHPContext): boolean;
isStatic(ctx: PHPContext): boolean;
isAbstract(ctx: PHPContext): boolean;
isFinal(ctx: PHPContext): boolean;
isConstructor(ctx: PHPContext): boolean;
isDestructor(ctx: PHPContext): boolean;
getNumberOfParameters(ctx: PHPContext): number;
getNumberOfRequiredParameters(ctx: PHPContext): number;
getParameters(ctx: PHPContext): Promise<ReflectionParameter[]>;
setAccessible(ctx: PHPContext, accessibleArg?: PHPReference): void;
invoke(ctx: PHPContext, objectArg?: PHPReference, ...args: PHPReference[]): Promise<any>;
invokeArgs(ctx: PHPContext, objectArg?: PHPReference, argsArg?: PHPReference): Promise<any>;
}
export declare class ReflectionFunction {
name: string;
meta: any;
static [SYMBOL_PHP_NEW](ctx: PHPContext, nameArg?: PHPReference, fnOrCtxArg?: PHPReference): Promise<ReflectionFunction>;
static __construct(this: ReflectionFunction, ctx: PHPContext, nameArg?: PHPReference, fnOrCtxArg?: PHPReference): Promise<void>;
getName(ctx: PHPContext): string;
getNamespaceName(ctx: PHPContext): string;
inNamespace(ctx: PHPContext): boolean;
getNumberOfParameters(ctx: PHPContext): number;
getNumberOfRequiredParameters(ctx: PHPContext): number;
getParameters(ctx: PHPContext): Promise<ReflectionParameter[]>;
invoke(ctx: PHPContext, ...args: PHPReference[]): Promise<any>;
invokeArgs(ctx: PHPContext, argsArg?: PHPReference): Promise<any>;
}
export declare class ReflectionClass {
name: string;
private phpClass?;
private classConstructor?;
private interfaceFlag;
static [SYMBOL_PHP_NEW](ctx: PHPContext, nameOrInstanceArg?: PHPReference): Promise<ReflectionClass>;
static __construct(this: ReflectionClass, ctx: PHPContext, nameOrInstanceArg?: PHPReference): Promise<void>;
getName(ctx: PHPContext): string;
getShortName(ctx: PHPContext): string;
getNamespaceName(ctx: PHPContext): string;
inNamespace(ctx: PHPContext): boolean;
getParentClass(ctx: PHPContext): Promise<ReflectionClass | false>;
isInterface(ctx: PHPContext): boolean;
isAbstract(ctx: PHPContext): boolean;
isFinal(ctx: PHPContext): boolean;
isInstantiable(ctx: PHPContext): boolean;
isSubclassOf(ctx: PHPContext, classNameArg?: PHPReference): Promise<boolean>;
hasMethod(ctx: PHPContext, nameArg?: PHPReference): Promise<boolean>;
getMethod(ctx: PHPContext, nameArg?: PHPReference): Promise<ReflectionMethod>;
getMethods(ctx: PHPContext): Promise<ReflectionMethod[]>;
hasProperty(ctx: PHPContext, nameArg?: PHPReference): Promise<boolean>;
getProperty(ctx: PHPContext, nameArg?: PHPReference): Promise<ReflectionProperty>;
getProperties(ctx: PHPContext): Promise<ReflectionProperty[]>;
hasConstant(ctx: PHPContext, nameArg?: PHPReference): Promise<boolean>;
getConstant(ctx: PHPContext, nameArg?: PHPReference): Promise<any>;
getConstants(ctx: PHPContext): Promise<Record<string, any>>;
newInstance(ctx: PHPContext, ...args: PHPReference[]): Promise<any>;
newInstanceArgs(ctx: PHPContext, argsArg?: PHPReference): Promise<any>;
newInstanceWithoutConstructor(ctx: PHPContext): Promise<any>;
}
export declare class ReflectionRuntime {
static classes: {
reflectionclass: typeof ReflectionClass;
reflectionmethod: typeof ReflectionMethod;
reflectionproperty: typeof ReflectionProperty;
reflectionfunction: typeof ReflectionFunction;
reflectionparameter: typeof ReflectionParameter;
reflectiontype: typeof ReflectionType;
};
static register(engine: PHPEngine): void;
}