« first day (3320 days earlier)      last day (1619 days later) » 

4:35 AM
@Wes that's silly
o/
 
Wes
yeah :B
\o
 
5:30 AM
good morning guys
 
Wes
@JoeWatkins around?
 
@Wes like a fox
 
Wes
:D
wanted to ask you how hard it would be to have a generalized syntax for "alternative" primitive types
or simply an alternative function call syntax
for example
$val = d278 + d832723.23872387;
plus use function my\d;
d278; would call d(278) or new Decimal(278)
similarly, u"string" would call u("string") or new UnicodeString("string")
so sort of make parentheses optional
$this->setEmail(email "info@example.org");
which calls the 1-arity function email
function email($email): EmailAddress{
    return new EmailAddress($email);
}
 
> plus use function my\d;
I'm not sure about that
I mean it's all possible, but you have to convince people it's a good idea
 
Wes
imagine it like a function call with 1 argument only and with optional parentheses
i can see people abusing that
but even if they do, i don't think it's a big problem
however the limited use cases make it not very abusable
that syntax can only be used with arity 1 function calls and only if the argument is a primitive literal
you cannot nest them
well apart
$val = map[
  22 => "foo",
  33 => u"unicode string",
];
but i am not even sure it's necessary for arrays
integers and strings would suffice more than enough
 
6:04 AM
I'm not sure we want to hand over this sort of thing to userland, it means we can never use the ustring prefix, we can never have native specialized integer types ... I'm not sure we want to give those up
also, I'm not sure why you wouldn't just define the functions and call them normally, there are no optimizations the engine can do to make it faster with a different syntax
I can see the utility in the operator interaction, but overloading operators is generally a bad idea
even restricting to the top of a file, nobody wants to have to read headers to find out how code works in the most basic ways
 
_T() all the things! (god no)
My guess would be that all strings would be basic binary unless .toUtf8 was called on them using scalar objects, and that'd return a cast one. But there'd probably need to be a utf8 string type added at scalar level with implicit conversion
 
Wes
6:25 AM
@JoeWatkins what if the syntax can only be used to call internal functions?
that is, this stuff can only be used by extensions
 
7:01 AM
there's still an element of "how is this code going to work", and putting all that effort into engine support for prefixes, or specializations, and then not implementing those specializations as a core feature doesn't make much sense to me either ...
 
7:16 AM
morning all
what are your thoughts on arrayable pseudo type which came back on internals ML?
I think we discuss the same topic again without discussing why its not good idea
I read general array object would be nice but we forget about that in other languages with generics there are specified object initializers as a core feature which easies a lot a use of general array object
The thing is when you use array_filter, map etc. you get a new instance of that object so it needs to be initialized by those functions in the same way as in input, right?
 
good mornings
 
so then without initializer like new Array<int,string>{ 1 => 'foo } which is a specialized generic array initializator core functions like array_filter won't be able to handle that, right?
o/
cause if I get generat array object which is initialized through array passed into constructor I can extend it and change constructor definition, the object FooArray would still behave like Array but none of core functions like array_filter would not know how to initialize the outputting FooObject, unless you would only get Array instance at the end, but then I see bo benefit and it only complicates a lot
 
7:55 AM
IMO if you're looking at generics, the normal array functions shouldn't touch them.
 
cmb
\o
 
If you have array manipulations on them, they should be member functions.
o/ cmb
 
@MarkR I share the opinion but then those member functions would be able to produce only the same type cause of implemented in the Array object
if someone wan't to change array_* functions they could IMO only work by calling a member function inside but then there is no sense for them to exist
 
If Array<int,string> effectively became a class instance, creating a new copy of itself would probably be done internally a new static
 
8:11 AM
@MarkR and what about constructor?
 
Would be up to it as well.

class ABC extends Array<int, string> {
public function __construct($could, $be, $anything) { }
}

Unless the Array generic exposed an interface for the constructor.
 
cmb
@Girgias, @JoeWatkins, yesterday I committed svn.php.net/viewvc?view=revision&revision=348311, and that change is already on php.net/strip_tags. Lets see when svn.php.net/viewvc?view=revision&revision=348313 is shown there.
 
with generics you can doo class FooArray<TKey, TValue> extends Array<TKey, TValue> { public function __construct(DateTime $date)}
@MarkR I guess it's not a common and you should not put constructor into interface, right?
That's why I mentioned initializers
Lemme google an example for you
use of initializer and constructor argument here makes sense for me
 
ah, i was only commenting on the use of array_xxx functions.
 
@MarkR IMO this all is connected, cause in a future if PHP gets general Array object and there will be generics which I really am looking forward to hear about and like know on ML there is a thinking of creating an general Array object then when you extend it to your FooArray or the new Cat("Fluffy"){ Age = 10 } from above example then array_xxx functions which always return a new array instance would always be able to produce only common array type, cause that would be hard for them...
 
8:22 AM
You and me both wanting to hear about them :P but they're the second coming of christ feature
 
to create a new instance initializing collection|array object|iterable|traversable|arrayable like given in the input
what I think when speaking of general Array object is making a solid OO api on it and leave all the array_xxx functions as they're now and deprecate or change them to call only a proper Array method and raise a deprecation warning
 
8:37 AM
Can somebody explain 3v4l.org/limeL please?
 
== === evil
If memory serves, numeric comparison will treat the RHS as a number, it doesn't have any digits at the front so will evaluate to 0. I think.
 
8:58 AM
Morning!
 
9:12 AM
\o
 
9:23 AM
o/
 
@JoeWatkins I'm searching the way to read and modify the return value of user-defined function. Any ideas? )
I've checked the implementation of this feature in uopz, but it completely hides an original return value, whereas I want to preserve it somehow...
 
9:58 AM
 
@Kalle <marquee>Depressingly, so do I</marquee>
moin
 
it's too monday morning to think about ... anything ...
 
10:23 AM
@JoeWatkins consider this... humans have an innate understanding that north is "up" and south is "down". The galaxy is broadly on a plane, so there is a more or less universal "up" and "down" no matter where you are. Assuming there is other intelligent life in the galaxy (a statistical near-certainty), what if the whole rest of the galaxy has it the other way up, and we are the weird ones?
 
I'll stop you at the first sentence ... you've been outside with me, right ?
 
Objection. Galaxy is on a plane. Universe isn't.
 
granted, the word "universal" was ill-chosen there
@JoeWatkins no, I've been outside near you, but only briefly as you wandered off in the opposite direction with an oddly misplaced aura of someone who knows where they are going
 
okay, I dispute that we all have an innate sense of anything about our location or orientation in relation to anything else including the earth ...
 
Fairly sure your ears tell you which way is down.
 
10:28 AM
true, but if I asked you to map the tuples "north/south" and "up/down" surely even you would do it that way round? :-P
 
only above water
 
Fair point
 
also, I'm not sure what we mean by down now
 
The direction in which we accelerate due to the curvature of spacetime
 
what do you mean by accelerate ?
 
10:30 AM
even that's not entirely true
@JoeWatkins it's slang for pooping
 
lol
 
A change in a velocity component
 
cmb
@SebastianBergmann, like Mark said, see also 3v4l.org/GjofV
 
If we ever get versions, I hope that gets typeerror'd
 
10:52 AM
@MarkR is that what you kids are calling it these days
 
?
 
@MarkR we used to call it penis enlargement
 
Now I'm just lost.
 
11:35 AM
Hi, I'm looking for CSRF (Middleware) example, I want to load it in my project. I don't understand how to do it in book.cakephp.org/3/en/controllers/…. Could someone give me an example/ link?
 
11:47 AM
hello
has anyone used db diagram dbdiagram.io
i have an issue, with importing sql files
it doesn't seem to understand
ALTER TABLE `users`
ADD UNIQUE KEY `users_email_unique` (`email`);
the issue is with the UNIQUE keyword in the sql code
 
12:00 PM
Got a maybe weird question: both unset and echo are language constructs, both accept multiple arguments, both doesn't return anything, then why the heck unset($var1, $var2); uses parentheses and requires them and echo $var1, $var2; don't? That is inconsistent for sure, but is it worth of correcting it?
 
12:15 PM
This got me thinking, there are few language constructs in PHP which works like a function or not, but why they can't all look like a language constructs?
<?php
class Foo { public function __toString() { return "Foo\n"; } }
$foo = new Foo;
function foo() {

    global $foo;
    if (@isset($foo) && !@empty($foo) && $foo instanceof Foo) {
        if (print($foo)) echo 'Foo printed: ', $foo, PHP_EOL;
    }
    unset($foo);

}
foo();
This is valid PHP, a mix of language constructs function-like and non-function-like ones
 
@brzuchal they can, but they would all need their own opcodes, which is clearly not practical
a few are already done, iirc count() in_array() and array_key_exists() will all skip DO_FCALL if they are literal
 
@DaveRandom and they aren't specialized opcodes anyway?
 
however a big key difference between lang constructs and fcalls is that you can't do dynamic calls to language constructs
e.g. $f = 'isset'; var_dump($f($a)); doesn't work
and you definitely can't break BC on that
 
@DaveRandom which is not clear when you look at isset($something)
I don't wanna break BC here
 
indeed, but it is nevertheless true
 
12:19 PM
global $foo;
if (isset $foo && !(empty $foo) && $foo instanceof Foo) {
    if (print $foo) echo 'Foo printed: ', $foo, PHP_EOL;
}
unset $foo;
@DaveRandom the part from previous examples without parentheses - you can see from faaar away that they're language constructs cause they don't look like functions, right?
 
does that work with isset and empty?
 
Not now, it's only showing how could it look like
 
dunno how that would interplay with multiple args
we don't have comma exprs though so probably doable
 
the only one maybe print - I'm not sure is that lang construct of func
 
print is a language construct
 
12:22 PM
@DaveRandom there is one difference, I removed silence operators cause in case of isset and empty it is possible to add them now
 
it returns 1 where echo is void, echo takes multiple args, not sure if the same is true of print
 
@DaveRandom ur mom is a language construct
 
@MadaraUchiha I did your mum bitwise
she's definitely not logical
 
Thinking more there is much more weirdness in all of that, you cand call isset(foo()) but can empty(foo())
the same goes for unset() which requires parentheses but doesn't allow expressions like isset()
empty() returns bool the same like isset() but empty can accept expressions
print() has parentheses works with one arg, echo works with multiple args forbids parentheses, both works with expressions, one returns other not and cannot be used to get a value
@DaveRandom would it hurt that much to have opcodes for all of them?
 
12:35 PM
@brzuchal isset(foo()) makes no sense though
you do foo() === null instead, that's what you are actually testing
 
@DaveRandom yes it has no sense, that's why IMO it would be non-confusing to have isset $var
and have language constructs which accepts vars only or expressions+vars but all of them without parentheses - so you can see from faar away that this is not a function
@DaveRandom it makes no sense but syntactically a valid syntax someone could say cause it may be hard to see that this is not function
Maybe I'm bullshitting, just thought PHP could have less inconsistencies and be more intuitive
 
tbh I prefer parens in that sort of scenario anyway
e.g. in JS I always do typeof(whatever)
and I always do sizeof(whatever) in C
parens aren't necessary in either of those but I think it reads nicer
I know where you are coming from but it's just not a thing for me :-P
@brzuchal yeh that doesn't matter, I thought you were getting at something else when I said that
echo, print etc already have their own opcodes afaik
 
@DaveRandom I can agree typeof() and sizeof() reads better and even more they evaluate into a value, but unset() is not and isset() with unset() don't accept expressions
I would see here a place to improve readability/consistence
at leas in unset($var1, $var2) -> unset $var1, $var2;
 
require_once and friends are keywords not functions, but frequently written with parentheses; I remove these wherever possible because they once caused an extremely hard-to-spot bug
if you write if ( require_once($someFile) && $someCondition ) it looks like the parentheses are doing the right thing
 
@IMSoP maybe it should be cleaned up and start throwing deprecation notice, error whatever?
 
12:47 PM
but it actually parses as if ( require_once($someFile && $someCondition) )
 
why is that?
 
precedence
the parentheses are actually meaningless, so you have require_once $a && $b
the && happens to bind tighter
 
ohh yeah, and it accepts expressions
but shouldn't accept those evaluating to bool
 
then replace && with .
 
back to the typeof() and sizeof() they don't exist in PHP, not with the same meaning, so maybe going with remove parens everywhere could work
 
12:51 PM
the point is, you shouldn't make keywords look like a function call that aren't, or you end up obfuscating your own code
in this case, what was actually intended was if ( (require_once $someFile) && $someCondition ) )
 
and it reads nicer
 
I'd argue the opposite: it would be better if require_once did use function syntax, and then the above wouldn't have been a problem
 
if ((isset $var) && !(empty $var) && (print $var)) would all require parens to be wrapped in
 
I don't think there's a way to fix require and friends now, but I'd hesitate to add more keywords with the same problem
but what happens if you don't add the parens? what precedence would each of them have?
 
wait, but if require_once would forbid parens and be an opcode which allows only string operations and expression with higher precedense then problem dissapears, right?
 
12:56 PM
pretty sure it's already an opcode; even some actual functions are optimised to their own opcodes now
 
for some this is easy, like isset and unset cause they require variable not an expression
 
forbidding parens is a lot harder
because right now, the parser just says "must be followed by an expression", and the implementation says "expression should evaluate to a string"
I've no idea how you'd forbid require_once ( $foo . $bar . $baz ) but allow require_once $foo . ( $bar . $baz )
 
what is the difference?
 
there isn't one, that's the point
so you'd have to say that $require_once always took a single variable name or a single string
 
whell you remove all parens cause both expressions evaluates to string
 
12:59 PM
it was a simplified example; the point is that expressions have parentheses in all the time
 
that would require to introduce statement probably evaluating to string
 
require_once $condition ? ($foo . $suffix) : ($foo . $otherSuffix);
 
with expression + concatenation + variable
you can verify if both evaluates to string
on parser level
 
require_once someFunction()
it's not the parser's job to do type checking
 
as said before this hits runtime so hipotetically should evaluate to string to work
 
1:01 PM
and it's not type mismatches that are the problem, it's that the code looks like it does one thing but actually does another
 
require_once $condition ? ($foo . $suffix) : null; this will be an error if condition evaluates to false
 
the if happened to be a case that type checking would have spotted earlier, but it could just as easily have been something like $someString = require_once($someConfigFile) . $suffix
 
and can be forbidden on parsing
@IMSoP yes, but if you forbid parens the developer can see straight that it's suspicious expression
 
but how do you forbid the parens?
we've gone round in a circle
if you can write require_once ($condition ? $someConfigFile : $someOtherConfigFile) . $suffix then you can write require_once ($someConfigFile) . $suffix
 
$someString = require_once .... ok, here is the catch ($someConfigFile) is the same without parens
 
1:05 PM
precisely
parentheses can be added anywhere
 
excluding global and return and static
 
anywhere in an expression, I meant
anywhere you can write 1, you can also write (1), or ((1)), or (((1)))
 
yes, fair, some language construct can be used in expressions some not
 
so to come back to the point: keywords that don't take their argument in parentheses are easy to make mistakes with, so should be introduced with extreme caution
 
ok so going to conclusion at leas unset if forbids parens would be more clear to me - doesn't return anything, cannot be used in expression, and cannot be used with expression following the same rules as global
is that right?
 
1:09 PM
yes, I think it's safe when it's always a statement not an expression, like with echo
 
global $var1, $var2;
echo $var1, $var2;
unset $var1, $var2;
that would be consistent
but is it worth?
 
it limits idioms that some people like, like $condition && unset($foo) or $condition ? print($foo) : unset($bar)
 
at least allowing it without parentheses makes sense, yes?
 
I guess allowing no parentheses if it is used as a statement?
 
unset can be used only as a statement, and only with $variable multiple times with comma separated list of $variables
 
1:13 PM
yeah, since it's already statement-only, optional parens seem safe, I think
 
ok, I think I got my next small weird RFC then :D
@IMSoP going further declare could forbid parens as well, right?
if the tick won't exists
 
declare has horrible syntax anyway
 
ok, maybe next time in few years, when tick could be removed
@IMSoP yes, agree, but PHP versions changes all the time and the language syntax even if is horrible doesn't improve
I believe allowing declare strict_types = 1; could make sense
 
meh; saves one byte, still looks nothing like PHP code; but wouldn't hurt I guess
 
as a way to improve a language in a future and say we allow no parentheses here and we prefer removing them cause in a future we might wanna forbid them and improve language consistency
 
1:21 PM
I don't think declare is consistent with anything either way
 
I'll add both to my todo list one micro RFC for unset
and other for syntax of declare with no parens
 
the only way I can think to make declare not feel like a unique snowflake is if we had annotation support (which we really should have by now!) and then it could be a file-scoped annotation
<<StrictTypes(true)>>
it also really bugs me that it takes an integer instead of a boolean
that or move the whole mechanism to a package/module config file, using whatever syntax makes sense there
 
I was thinking of reviving annotations: simple and featured
but not yet ready for it, got to finish my idea of structs and their usage in annotations but am not sure if structs is something could get into PHP :/
 
If you do annotations, just clone doctrine :-)
 
heh, so many ideas, so little time, eh :)
 
1:36 PM
no
not like doctrine
it's not possible
 
well, it needs to be enough like Doctrine that people will migrate
 
Why is it not? That it's the most widely used annotation system for PHP
@classname defaultvalue, key1=>val, key2={some, other, array}
 
annottions need a syntax with an initializer and the only way I can see is introducing structs with initializer syntax like $var = SomeStruct {true}; or $var = SomeStruct { foo = 1 }; and then wrap them in square brackets as a featured annotation, like [SomeAnnotation{true}] class Foo {}
 
Just do the doctrine method, dump them into the constructor via an array
 
no methods, no logic, no magic, no new, value-type
@MarkR Doctrine doesn't just do that, cause it allows to pass field = value syntax and only values
 
1:40 PM
are you just saying you don't like the complexity?
 
which could be done with structs and the plus is annotations done that way actually doesn't need nothing more than just built in initializer
 
Unnecessary complexity is bad, 'mmkay?
 
well, that's the million-dollar question: is it unnecessary?
 
@IMSoP annotation parser can handle the logic, annotations should just IMO be a container for some values with some structure and that's it
 
And the answer to that, is subjective ;)
 
1:41 PM
anyway got to go for my kids from school+kindergarden now, will be online lata
 
I don't have a particularly strong opinion on the matter, but you're going to have an uphill struggle if you propose native annotations which don't have a) equivalent power to Doctrine annotations; and b) a clean migration path from Doctrine annotations
if you can manage both of those, and nail the implementation, I'm all for it
 
2:16 PM
In my opinion, annotations should never be part of a language.
They are extras to the code, shortcuts if you will.
 
2:35 PM
/me shares that opinion
 
https://stackoverflow.com/questions/58891800/while-loop-to-output-a-list-from-sql-on-a-per-user-permission-basis-returns-dupl

Can anyone tell me what am I missing here? I am losing my mind trying to think of how to solve this...
 
2:59 PM
What I was trying to do is pull rows from a "products_list" table , each row should be checked vs the current user group (also pulled from sql) (tl;dr if the user has permissions, the row will be displayed) but instead I get many duplicates of my rows

help will be appreciated.. thanks!
 
someone can help me to finding closest sum of numbers on array to a given number?
for example , i have array [10000,5000,1000,1000]
and I would like to find the closest sum of numbers to a given number. Sorry for the crappy explanation but here's an example:

Say I have a list [10000,5000,1000,1000] I want to find the closest numbers to, say, 6000

Then the method should return 5000 and 1000

and if i put number 14000, it return 10000 and 5000

anyone have solutions about this ?
 
cmb
3:26 PM
@RobyFirnandoYusuf, calculate the difference between the search number and every number in the array, and then find the largest negative value and the smallest positive value in the array of differences.
 
3:53 PM
eeeeeeew arrayable
Also morning
 
@MarkR Eh, it's a difficult problem but the hardest part is politics.
 
4:05 PM
@JoeWatkins Do you have any extensions which add a "hook" or maybe a better word would be "event" or "notification" whenever a function is compiled?
I'm still learning the details, but this seems to be how .NET's stuff works.
 
I can't remember, you are looking for op array callbacks that are part of zend ext api
yeah, tombs
 
I'll take a look, thanks!
 
4:20 PM
@JoeWatkins This one, right? php-lxr.adamharvey.name/source/xref/PHP-7.0/Zend/…? When is this called beyond a function def? Is there also one for an entire file? Any other situations?
 
4:46 PM
How does it interact with opcache?
 
5:21 PM
Looks like there's one op_array per file, and one per function, and I still haven't figured out what's allowed on the inside and how it works with opcache. It looks like it's fired in pass two, so I can't do anything that would change pointers?
I'm interested in adding a const or flag or something like that so I can quickly know at runtime if it's a function of interest.
Is there a spot in op_array->reserved for each zend_extension or something?
 
5:49 PM
@cmb Saw that you needed to revert the change
 
6:13 PM
@cmb Still thinking about getting rid of it for 8 :P
 
cmb
@Girgias, yes, but wrt. the roll-out to php.net that doesn't really matter. It's already on docs.php.net.
@PeeHaa, I'm not against having strip_tags, but nobody should use it for sec purposes.
 
I probably will just write a small dom based implementation so we can kill strip_tags
Once that is a thing there is no need for the broken strip_tags
Even outside sec (which indeed is my first (but not only) motivation for killing it) it's just a terrible thing implementation wise
It's a string function that tried to get away with being a dom function imho
On top if that it has the somewhat wtf "string as allowed tags" param
 
6:42 PM
> EventManagerAwareInterface
le sigh intensifies.
Also, I just got this:
> A new security advisory was published
We found a vulnerable dependency in repositories you have security alert access to.
Security advisory GHSA-pgwj-prpq-jpc2 (critical severity) affects 5 repositories:
symfony/dependency-injection (Composer) used in 5 repositories
from github. But clicking through gives no details ...is it bugged?
 
7:01 PM
@cmb Thanks, @MarkR and @cmb.
 
cmb
@PeeHaa, fully agree that the implementation of strip_tags is … ambitious.
 
@cmb true, now how is that going to go down for deprecating it :')
 
cmb
@Danack, it seems to me only the links are buggy. After clicking a link, click on the "Alerts" button (have to be logged in).
IIRC, Nikita suggested to deprecate only the $allowed_tags param, and even that met resistance (and so far that resistance wasn't futile).
 
@cmb thanks.
 
@cmb "ambitious" you would make a great manager :D
 
cmb
7:13 PM
nope, because if I had to say that, I certainly couldn't suppress my laughter.
 
:P
 
What a day... good morning, all.
 
7:47 PM
That's partly why Hack is so far ahead of PHP in terms of modernisation... much less politics.
that and the hundreds of millions they can throw at it
 
Wes
@PeeHaa new season of high castle tho
 
@PeeHaa if you manage to pass the test-suite for backwards compat...
 
@cmb btw shouldn't the strip-tag warning be applied to fgetss too?
I know it's deprecated but still a while before it gets removed
 
Wes
8:21 PM
are strings always interned in php or does it intern them on a best effort basis?
 
 
2 hours later…
cmb
10:07 PM
@MarkR, I think more important is that there's much less legacy code.
@Girgias, in principle, yes (and there's also the string.strip_tags filter), but likely way less important there (and to avoid duplicate info, it might make sense simply to refer to the strip_tags warnings).
 
Fair point
 
cmb
@Wes, more the latter. Since interned strings persist requests, it wouldn't make sense to intern all (intermediate) strings.
 
Wes
what is considered an "intermediate" string?
i mean how do you decide what should be interned?
 
Is there are reason the engines uses massive if-elseif-else chains when comparing the exact same value instead of a switch statement?
 
11:02 PM
if something is known to be a string at compile time, it'd be definitely interned, is that right?
 
Wes
11:30 PM
that is not surprising, but what about strings that are not known at compile time?
 
@Wes I think this is about whether a string is read-only and/or it needs to be reused again
it a string is not going to be used ever again or, if it's going to be altered, it doesn't make sense for it to be interned
at least to my understanding
on that note, /me switches to windoze
 

« first day (3320 days earlier)      last day (1619 days later) »