Browse Source

Do not consider a method with the same name as class name to be a constructor, nor do not create such alias. This is some event from old PHP4, we do not want to support. Magic methods <__construct() & __destruct()> are more than

enough.
pull/7/head
Rafal Kupiec 4 years ago
parent
commit
d0357787db
Signed by: belliash GPG Key ID: 4E829243E0CFE6B4
  1. 15
      vm.c

15
vm.c

@ -734,16 +734,6 @@ static sxi32 VmMountUserClass(
*/
return SXRET_OK;
}
/* Create constructor alias if not yet done */
if(SyHashGet(&pClass->hMethod, "__construct", sizeof("__construct") - 1) == 0) {
/* User constructor with the same base class name */
pEntry = SyHashGet(&pClass->hMethod, SyStringData(&pClass->sName), SyStringLength(&pClass->sName));
if(pEntry) {
pMeth = (ph7_class_method *)pEntry->pUserData;
/* Create the alias */
SyHashInsert(&pClass->hMethod, "__construct", sizeof("__construct") - 1, pMeth);
}
}
/* Install the methods now */
SyHashResetLoopCursor(&pClass->hMethod);
while((pEntry = SyHashGetNextEntry(&pClass->hMethod)) != 0) {
@ -4970,11 +4960,6 @@ static sxi32 VmByteCodeExec(
}
/* Check if a constructor is available */
pCons = PH7_ClassExtractMethod(pClass, "__construct", sizeof("__construct") - 1);
if(pCons == 0) {
SyString *pName = &pClass->sName;
/* Check for a constructor with the same base class name */
pCons = PH7_ClassExtractMethod(pClass, pName->zString, pName->nByte);
}
if(pCons) {
/* Call the class constructor */
SySetReset(&aArg);

Loading…
Cancel
Save