-
Notifications
You must be signed in to change notification settings - Fork 7.9k
typeof #1932
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
typeof #1932
Conversation
I will try to reproduce the build failure on my setup and fix it. PS: Please do not tell me where the problem is, I would prefer to find it on my own. I already prepared a Linux VM to run the tests similarly to Travis CI. |
Previously not enough memory was allocated and it was just pure luck that it worked in my initial tests.
The problem is actually extremely obvious to the experienced C developer. The allocated memory for the type variable must be freed after it was copied for returning to userland.
@@ -2563,6 +2564,11 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_is_callable, 0, 0, 1) | |||
ZEND_ARG_INFO(0, syntax_only) | |||
ZEND_ARG_INFO(1, callable_name) | |||
ZEND_END_ARG_INFO() | |||
|
|||
ZEND_BEGIN_ARG_INFO_EX(arginfo_typeof, 0, 0, 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit; Use ZEND_RETURN_VALUE instead of 0 in the third arg. It's better for BC and more readable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think anybody does this in core.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed it now, the readability argument directly convinced me.
@@ -434,6 +450,135 @@ PHP_FUNCTION(is_callable) | |||
} | |||
/* }}} */ | |||
|
|||
#define RETURN_TYPE_NAME(t) { RETURN_STRINGL(t, sizeof(t) - 1) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor; Create interned strings for these return values so that you're not creating a new string on every invocation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would only apply to the extended mode, right? The constants are already constant and the sizeof
will be replaced with the actual number anyways during compilation. Just asking to gain a better understanding of C.
Reading up on interned strings now.
More readable and better for BC; according to @sgolemons feedback.
Closing in favor of #1935. |
Proposal for a
gettype()
successor.