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.
This commit is contained in:
Rafal Kupiec 2018-07-13 17:58:50 +02:00
parent e53cfb8ba0
commit d0357787db
Signed by: belliash
GPG Key ID: 4E829243E0CFE6B4

15
vm.c
View File

@ -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);