1818#include " generated/ScopeContext.h"
1919
2020namespace slots = ptdecl::ScopeContext::slot;
21+ namespace sigs = ptdecl::ScopeContext::sig;
2122#include " zv.h"
2223#include " TypeTraits.h"
2324
@@ -211,23 +212,18 @@ using phpstanturbo::ScopeContext;
211212
212213#include " reg.h"
213214
214- #define SCOPE_CONTEXT_CLASS " PHPStanTurbo\\ ScopeContext"
215215
216216void pt_register_scope_context ();
217217
218218void pt_register_scope_context ()
219219{
220220 reg::Class cls (" PHPStan\\ Analyser\\ ScopeContext" );
221221 ptdecl::ScopeContext::declareClass (cls);
222- /* file/classReflection/traitReflection must stay in this order
223- * (OBJ_PROP_NUM slots) */
224- cls.privateNullProperty (" file" );
225- cls.privateNullProperty (" classReflection" );
226- cls.privateNullProperty (" traitReflection" );
222+ ptdecl::ScopeContext::declareProperties (cls);
227223
228224 /* private like the twin's: `new ScopeContext(...)` from userland fails
229225 * the same way; the native factories fill the slots without it */
230- cls.method (" __construct " , reg::Private, 3 , { reg::stringArg ( " file " ), reg::objectArg ( " classReflection " , true ), reg::objectArg ( " traitReflection " , true ) } , [](INTERNAL_FUNCTION_PARAMETERS ) {
226+ cls.method (sigs::__construct , [](INTERNAL_FUNCTION_PARAMETERS ) {
231227 zend_string *file;
232228 zval *classReflection, *traitReflection;
233229 if (!zp::parse<zp::Str, zp::ObjOrNull, zp::ObjOrNull>(execute_data, file, classReflection, traitReflection)) RETURN_THROWS ();
@@ -237,7 +233,7 @@ void pt_register_scope_context()
237233 ScopeContext (ZEND_THIS ).construct (zv::Ref (&fileZv), zv::Ref (classReflection != NULL ? classReflection : &null), zv::Ref (traitReflection != NULL ? traitReflection : &null));
238234 });
239235
240- cls.method (" create " , reg::PublicStatic, 1 , { reg::stringArg ( " file " ) } , [](INTERNAL_FUNCTION_PARAMETERS ) {
236+ cls.method (sigs::create , [](INTERNAL_FUNCTION_PARAMETERS ) {
241237 zend_string *file;
242238 if (!zp::parse<zp::Str>(execute_data, file)) RETURN_THROWS ();
243239 zval fileZv;
@@ -247,30 +243,30 @@ void pt_register_scope_context()
247243 result.intoReturnValue (return_value);
248244 });
249245
250- cls.method (" beginFile " , reg::Public, 0 , {} , [](INTERNAL_FUNCTION_PARAMETERS ) {
246+ cls.method (sigs::beginFile , [](INTERNAL_FUNCTION_PARAMETERS ) {
251247 ZEND_PARSE_PARAMETERS_NONE ();
252248 zv::Val result = ScopeContext (ZEND_THIS ).beginFile ();
253249 if (UNEXPECTED (result.isUndef ())) RETURN_THROWS ();
254250 result.intoReturnValue (return_value);
255251 });
256252
257- cls.method (" enterClass " , reg::Public, 1 , { reg::objectArg ( " classReflection " ) } , [](INTERNAL_FUNCTION_PARAMETERS ) {
253+ cls.method (sigs::enterClass , [](INTERNAL_FUNCTION_PARAMETERS ) {
258254 zval *classReflection;
259255 if (!zp::parse<zp::Obj>(execute_data, classReflection)) RETURN_THROWS ();
260256 zv::Val result = ScopeContext (ZEND_THIS ).enterClass (zv::Ref (classReflection));
261257 if (UNEXPECTED (result.isUndef ())) RETURN_THROWS ();
262258 result.intoReturnValue (return_value);
263259 });
264260
265- cls.method (" enterTrait " , reg::Public, 1 , { reg::objectArg ( " traitReflection " ) } , [](INTERNAL_FUNCTION_PARAMETERS ) {
261+ cls.method (sigs::enterTrait , [](INTERNAL_FUNCTION_PARAMETERS ) {
266262 zval *traitReflection;
267263 if (!zp::parse<zp::Obj>(execute_data, traitReflection)) RETURN_THROWS ();
268264 zv::Val result = ScopeContext (ZEND_THIS ).enterTrait (zv::Ref (traitReflection));
269265 if (UNEXPECTED (result.isUndef ())) RETURN_THROWS ();
270266 result.intoReturnValue (return_value);
271267 });
272268
273- cls.method (" equals " , reg::Public, 1 , { reg::obj ( " otherContext " , SCOPE_CONTEXT_CLASS ) } , [](INTERNAL_FUNCTION_PARAMETERS ) {
269+ cls.method (sigs::equals , [](INTERNAL_FUNCTION_PARAMETERS ) {
274270 zval *otherContext;
275271 bool out;
276272 ZEND_PARSE_PARAMETERS_START (1 , 1 )
@@ -280,17 +276,17 @@ void pt_register_scope_context()
280276 RETURN_BOOL (out);
281277 });
282278
283- cls.method (" getFile " , reg::Public, 0 , {} , [](INTERNAL_FUNCTION_PARAMETERS ) {
279+ cls.method (sigs::getFile , [](INTERNAL_FUNCTION_PARAMETERS ) {
284280 ZEND_PARSE_PARAMETERS_NONE ();
285281 ScopeContext (ZEND_THIS ).getFile ().intoReturnValue (return_value);
286282 });
287283
288- cls.method (" getClassReflection " , reg::Public, 0 , {} , [](INTERNAL_FUNCTION_PARAMETERS ) {
284+ cls.method (sigs::getClassReflection , [](INTERNAL_FUNCTION_PARAMETERS ) {
289285 ZEND_PARSE_PARAMETERS_NONE ();
290286 ScopeContext (ZEND_THIS ).getClassReflection ().intoReturnValue (return_value);
291287 });
292288
293- cls.method (" getTraitReflection " , reg::Public, 0 , {} , [](INTERNAL_FUNCTION_PARAMETERS ) {
289+ cls.method (sigs::getTraitReflection , [](INTERNAL_FUNCTION_PARAMETERS ) {
294290 ZEND_PARSE_PARAMETERS_NONE ();
295291 ScopeContext (ZEND_THIS ).getTraitReflection ().intoReturnValue (return_value);
296292 });
0 commit comments