Re: [PHP-DEV] [RFC] is_literal()

This is only part of a thread. view whole thread
  109191
March 21, 2020 21:58 craig@craigfrancis.co.uk (Craig Francis)
On Sat, 21 Mar 2020 at 21:23, Jakob Givoni <jakob@givoni.dk> wrote:

> On Sat, Mar 21, 2020 at 3:26 PM Craig Francis <craig@craigfrancis.co.uk> > wrote: > > > > As to the name, it's to work alongside functions such as > > is_int(), is_string(), etc - is that a good enough reason? > > I think it could cause confusion since int and string are value types, > - literal is not a type as such, it merely describes the way the value > was created. >
I'm happy to use a different name; but I should add that is_numeric() isn't really a type, there are other functions such as is_writable(), and the taint extension uses is_tainted().
> I'm under the impression that PHP already defines these as literals > > Does anyone know if that is correct? Does PHP remember how the string > variable / constant was created? >
I've talked to Paul Dragoonis and Derick Rethans recently (they both kindly did talks at PHP-SW); when I mentioned it to Paul, I was told that's where I should start looking, and that was the correct terminology; and Derick helped confirm some of these ideas (but we were walking to the pub at the time). And while I keep trying, I don't know enough about C, or the internals of PHP.
  109197
March 21, 2020 23:22 jakob@givoni.dk (Jakob Givoni)
On Sat, Mar 21, 2020 at 4:58 PM Craig Francis <craig@craigfrancis.co.uk> wrote:

> I'm happy to use a different name; but I should add that is_numeric() isn't really a type, there are other functions such as is_writable(), and the taint extension uses is_tainted().
Right, good points. However, to my logic, whether or not the value was created from a literal is not something you can infer from the value itself, it needs an accompanying flag or something. I'll suggest is_from_literal() as a more precise formulation.
> I've talked to Paul Dragoonis and Derick Rethans recently (they both kindly did talks at PHP-SW); when I mentioned it to Paul, I was told that's where I should start looking, and that was the correct terminology; and Derick helped confirm some of these ideas (but we were walking to the pub at the time).
Sounds like you were having fun though :-)
> And while I keep trying, I don't know enough about C, or the internals of PHP.
Appreciate the effort.
  109198
March 22, 2020 01:48 craig@craigfrancis.co.uk (Craig Francis)
On Sat, 21 Mar 2020 at 23:22, Jakob Givoni <jakob@givoni.dk> wrote:

> I'll suggest is_from_literal() as a more precise formulation.
Good suggestion, I've added it to the list of Open Issues (if we can determine the different ways this can be achieved, without affecting performance, then we can see what people prefer for the name). Sounds like you were having fun though :-) I was; although I must confess, I didn't recognise Derick until the talk began (then, suddenly, the voice from the PHP Internals podcast). On Sat, 21 Mar 2020 at 23:22, Jakob Givoni <jakob@givoni.dk> wrote:
> On Sat, Mar 21, 2020 at 4:58 PM Craig Francis <craig@craigfrancis.co.uk> > wrote: > > > I'm happy to use a different name; but I should add that is_numeric() > isn't really a type, there are other functions such as is_writable(), and > the taint extension uses is_tainted(). > > Right, good points. However, to my logic, whether or not the value was > created from a literal is not something you can infer from the value > itself, it needs an accompanying flag or something. > > I'll suggest is_from_literal() as a more precise formulation. > > > I've talked to Paul Dragoonis and Derick Rethans recently (they both > kindly did talks at PHP-SW); when I mentioned it to Paul, I was told that's > where I should start looking, and that was the correct terminology; and > Derick helped confirm some of these ideas (but we were walking to the pub > at the time). > > Sounds like you were having fun though :-) > > > And while I keep trying, I don't know enough about C, or the internals > of PHP. > > Appreciate the effort. >