« first day (3602 days earlier)      last day (1353 days later) » 

12:37 AM
@LeviMorrison That's funny. This person was an account manager so I doubt it was related to the application. I would have loved to have a job working on open source projects but I ended up landing a job I think I'm really going to enjoy so I'm pretty happy how things turned out
 
 
2 hours later…
2:48 AM
tfw second interview :D
 
3:00 AM
:D
 
Working on code at 4am again? @MarkR
 
3:34 AM
I had my first coffee in almost a week just now.
 
Once i've finished waking up I'm sure I will do a couple of hours before going back to bed
 
it's like that scene where Neo wakes up from the matrix.
 
 
2 hours later…
5:08 AM
Good morning.

\o
 
o/
 
5:33 AM
Man, have you slept any?
 
me?
 
Yes. Seeing your post from 2 hours something ago.
 
I think I slept from about 11pm until 3am. Sleep patterns are wrecked from several days of hunting phantom bugs last week
 
Oh?
How they say? Today will be the day.
 
several consecutive 18 hour workdays is enough to kill off any sleep pattern in a hurry
 
5:39 AM
Definitely. x x
 
 
1 hour later…
cmb
7:01 AM
@LeviMorrison account request approved :)
 
7:25 AM
@Girgias That one seems okay, as it's only used in named constructors. Those can return null.
 
7:47 AM
@LeviMorrison Yes, but usually not after midnight :-)
 
8:09 AM
note to self: next time, ask for no corn on the Hawaiian ANY pizza.
 
 
2 hours later…
10:17 AM
\o
 
get_object_vars() does not return uninitialized properties ・ Documentation problem ・ #80019
 
10:40 AM
Morning
 
Morning
 
11:00 AM
Gurning
 
@salathe thought that was Gaelic for a moment :P
 
Morning
 
11:50 AM
Can closures be bad from a memory leak standpoint? Specifically closures passed by references, so I can call the closure itself from within the closure, or call a closure that's defined later.
I have an example where a simple change in such closure leads to -100 MB in memory consumption.
 
@OndřejMirtes Yes
Anything that introduces cycles means it will only be destroyed by GC, so it may delay memory reclamation
 
@NikiC So what exactly is bad about them and what should I do instead? Pass around an object?
Also, are closures with more lines of code more bad?
 
@OndřejMirtes There's nothing wrong with closures themselves. From your description it sound like you have a cycle of closures
 
Or more used variables...
Alright, I'm gonna look into it :)
 
Though generally it just means that memory is freed later than usual, it won't leak. Whether that matters or not depends on the case :)
 
11:53 AM
Well in my case I have gc_disable :) But it doesn't help at all when I enable it.
 
hey how i can retrieve record on the basis of date from firebase?
 
@OndřejMirtes You don't need gc_disable on PHP >= 7.4
Or 7.3? I forgot
 
@NikiC Oh, that's why it doesn't help.
 
Wes
12:07 PM
\o
 
12:21 PM
o/
 
12:33 PM
@NikiC Such a simple change and it takes 100 megs less :) github.com/phpstan/phpstan-src/commit/…
 
@Wes \o
 
Wes
hey folks, how you doin?
does static function(){}; still have effect, or did i dream about it being automatic now?
ie if there's no $this in the function body, then it become static automagically
 
@Wes I've thought about it but it's not possible. The context is important not only for $this but for other stuff too.
For example calling a private method etc.
So static function cannot be automated.
 
Wes
context is different, that's just a string and it's separated from $thisval, i was thinking about closures preventing $this from being garbage collected
i mean i suppose people could call non-static methods without $this
for example MyParentClass::method() will carry $this as well as parent::method()
so that's probably not a thing
php is strange
class A{
    public function foo(){
        var_dump($this);
    }
}

class B extends A{
    public function x(){
        return function(){
            A::foo();
        };
    }
}
you probably meant this @OndřejMirtes
that looks static but it is not, $this is carried to A::foo even if A::foo is called with the "static" syntax
 
Wes
1:02 PM
i mean it probably could make closures static sometimes. when no static method calls appear and when there's no $this around. for example fn($x, $y) => $x + $y; is certainly static
 
@Wes I wanted to do this, but there was a complication
It was related to scope or LSB
 
Wes
ugh i can't even begin to realize how LSB is related to that :D
 
php_value ・ *Configuration Issues ・ #80020
 
1:19 PM
Incident on 2020-08-26 13:18 UTC
 
1:50 PM
All issues have been resolved!
 
2:33 PM
@Derick Oh, it wasn't urgent; was just making sure I did that task that I had been putting off :)
@cmb Thanks!
 
@LeviMorrison Seems somebody had already taken care of it
 
3:18 PM
@bwoebi Hey! Question for you. I added SPEC(OBSERVER) to return handlers and it seems to work well: github.com/php/php-src/pull/5857/commits/… But when I add the spec to DO_FCALL which already has a RETVAL spec, it becomes: SPEC(RETVAL,OBSERVER) and zend_vm_gen.php does not generate the following handlers: ZEND_DO_FCALL_SPEC_RETVAL_UNUSED_OBSERVER_HANDLER and ZEND_DO_FCALL_SPEC_RETVAL_USED_OBSERVER_HANDLER. What am I missing?
@bwoebi Wait - nevermind. I think it's user error. :facepalm:
 
3:30 PM
So what would be a good tool for finding memory leaks? Ideally I'd like to see how much memory is taken by various arrays in classes etc. For example Blackfire has only a timeline view where I can see the memory rises the whole time but it's not that useful.
 
@SammyK @LeviMorrison Datadog still doesn't have a developer advocate I can 'give honest feedback to' does it? I am mildly disappointed at being billed months after trying to get my account deleted.
 
@Danack Just to clarify, you mean deleted, as it gone, GDPR style?
 
@OndřejMirtes do you mean leaks, or do you just mean, "where stuff is being used, and continued references to mean it's still held in memory"?
 
I'd like to see why a program takes twice as much memory to run than it did a few months ago :)
 
I'm not so familiar with Doctrine but watching a tutorial and then reading code is making me wonder if the code is doing things correctly. The goal of the code is to get a list of entities from an API and sync it in it's database. Sometimes no changes would be needed because the list is the same, but if one is deleted or removed then it would make those changes.
 
3:34 PM
@LeviMorrison your support pretty much refused to delete my account, and just 'disabled' it instead. I'm pretty tired of emailing them so I said 'fine'. And today I got another 'we tried to bill you' but it failed as I deliberately have no money in that account to prevent the datadog billing from occuring.
 
@OndřejMirtes you want to use the php-meminfo extension: github.com/BitOne/php-meminfo
 
The code is here. Am I right to think that if they were to only flush once at the end of the code that it would remove only the ones that are necessary and add only the ones that are necessary in a single (or in two) SQL calls?
 
the way blackfire (and also tideways for the record) do memory profiling is not optimal with how php's memory model works
 
@beberlei Nice! No PHP 7.4 support?
 
@Danack Can you email me at one of my public email addresses? I'll send you to Priyanshi, who isn't the right person but has agreed to help me get you to the right person.
 
3:35 PM
@OndřejMirtes probably just outdated readme
 
Alright, I'll give it a try, thank you!
 
Hello guys
 
Priyanshi is better integrated into the rest of Datadog, so she'll be a much better help than I am.
 
does anybody have any idea how to analize code by sonarqube for php application
 
@LeviMorrison thanks. will do.
 
3:38 PM
I can scan code through sonarqube scanner but it's not showing any results into the sonarqube server
 
@beberlei Not sure if this is PHP 7.4 not being supported or something else, I'll probably open an issue: gist.github.com/ondrejmirtes/78567d3c26c5da67a7060ce6725087a3
Looks like PHP 7.4 is really not supported yet, I'm gonna check out the PR github.com/BitOne/php-meminfo/pull/97
 
@OndřejMirtes hm right, looks like it requires some changes for 7.4, is this a 7.4 only issue though? you could just reproduce this with 7.3 i assume
 
Yeah but it'd mean to destroy my dev environment :)
 
@OndřejMirtes that PR looks fine though, you should just compile with that one
 
Still getting an error, the list is shorter though gist.github.com/ondrejmirtes/5347683e1c6b78edf1adc3ff8e181813
 
3:47 PM
@OndřejMirtes are you on mac?
 
yes
There's another PR linked in that PR, gonna try that one
 
cmb
@OndřejMirtes just change ulong to unsigned long (this would affect Windows users as well)
 
4:04 PM
so the two kittens we rescued
turn out to be amazing at killing little house geckos
scale wise, it's like using a lion to hunt.. I dunno. squirrels.
 
@Stephen :D
 
its brutal to watch.
but if you're a gecko and try to cross a floor in a house with two young cats. well stupid is as stupid does.
can't wait for my - I dunno what to call it. tool shed I guess - to be finished and have some shelves up on the walls, so we can let them in there. I can't even begin to imagine the acrobatics we're gonna see with two cats chasing tiny geckos in 4m of vertical space.
 
4:20 PM
@Stephen aren't they accidently destroying stuff in the house when chasing the geckos?
 
@beberlei they dont even need geckos as an excuse to destroy stuff
one of them ripped into a cling-film sealed pack of BANANA MUFFINS
what kind of cat eats banana muffins
to re-use the lion analogy
having these two cats is kind of like if you had a problem with squirrels in your... attic
and your solution was... lions. in your attic.
 
...indent issue in yaml kept me from bringing up a box...
~20 minutes of googling and wondering wtf was going on...lost
@Stephen used to have a cat growing up that ate bread
my mom had a loaf of bread in plastic on the kitchen table, little cat jumped up during the night and teared into it
 
@Tiffany why so many people think yaml makes any sense for a human edited format, when even the various parsers and serialisers for it can't agree, is beyond me.
to be clear, I'm not suggesting it makes any sense as a computer generated format either.
 
4:48 PM
I love yaml
 
hey. do you know some resources to improve in array manipulation and anonymous functions?
Sometimes I see this kind of magic and I'd like to understand it faster lol
https://github.com/Roave/BetterReflection/blob/master/src/Reflection/ReflectionClass.php#L950
 
@FlorianMargaine I love lamp.
 
5:10 PM
@FlorianMargaine You also write Python, so that's to be expected. :-)
@Sara @GabrielCaruso Are either of y'all around?
 
morns
 
Wes
\o
 
5:31 PM
@Crell What up?
 
On the subject of cleaning up array function argument names before they become part of the API, care to weigh in to avoid bikeshedding? :-)
I'd like clear guidelines before I proceed with more patches.
 
:facepalm:
 
I did not sign up for this shit
 
You're a release manager, these questions come with the territory. :-)
 
Sara probably
 
5:33 PM
I think, first off, which ones do you find particularly bad?
We're post FF for 8.0 which means those names *are* set.
 
Particularly bad: array_diff($array1, $array2, ...$rest). array_intersect($array1, $array2, ...$arrays).
(I think intersect uses $arrays; I know the use of $rest isn't consistent.)
I had proposed $source, $exclude and $source, $include. Others suggested $input. Others said just $array. I don't feel that strongly about the first one as long as it's more self-documenting than $array1/$array2, which is useless.
(As for timing, erm, I'd been told we still had a bit of time to clean those up.)
 
Yeah, we do, but my default needs to be "No". :)
 
Dur.
 
IMO just define a standard and send the PR. It's the responsibility of those who object to have better ideas
 
Hm. I was hoping to minimize the bikeshedding by getting you to define a standard before I start working. Saves time for everyone, since you get more veto than anyone else. :-)
 
5:46 PM
set_error_handler documentation ・ Documentation problem ・ #80021
 
@LeviMorrison Did you have a look? I'm still ready to pick the RFC back up. I'm also open to suggestions if you have a better idea on how to handle use.
 
@IluTov I looked but don't have any specific comments at the moment.
 
arrays reads really weird, though
 
@LeviMorrison Ok, let me know when you do. We could also announce it just to get some feeling on if this has any chance of being accepted.
 
i'd pick $arrayN
 
5:51 PM
And other people might have better ideas.
 
@Derick The most common right now is $rest, for when it's variadic. And in practice I highly doubt the named param approach and variadic approach would be used in the same call.
 
They can't be used in the same call, but I would plan as if they can someday, somehow.
 
Unless we changed it to make $exclude accept a single array or array of arrays, but that's definitely an API change and out of my pay grade.
$exclude/$excludes?
@Sara So what's he guideline for "that's too much change" for now?
I guess I'll probably just redo a new PR for all changes at once, to make it faster...
 
@Crell at least with array_diff we can have $minuend, ...$substrahends
 
I have no idea what you just said.
 
6:01 PM
@Crell array_diff($minuend, ...$substrahends) - $minuend being the initial set and substrahends what's to be substracted from the initial minuend
 
those are stupid names
ffing worse than T_PAMAYAIM_NEKUDOTAYIM
 
yeah, I'm not too fond of them either, but array_diff($array, ...$rest) is just telling nothing
maybe something like $initial and $excludes, whatever
 
array_diff($array, $exclude, ...$excludes) should be pretty self-documenting, though.
The name for the first parameter is what people were bikeshedding and I wanted to short circuit. I'm mostly comfortable with whatever gets past the RMs.
 
whats up with this $exclude, ...$excludes? Can't it just be ...$excludes, single variadic?
 
no, because one is required
 
6:05 PM
@Derick why? substracting nothing from an initial set returns that initial set
 
var_dump() is the same
 
Because array_diff($array, ... $excludes) would be an API change and a code change, rather than just a stub change.
I'm not looking to change anything but the stub file.
 
ah well, it currently requires one arg -.-
stupid
I've been writing code like $set = array_diff($set, [], ...$excludes) in the past because of such things
 
If you have multiple arrays to exclude, that works I suppose. But in most cases there's just one to exclude.
But... I'll go through later today (I hope) and take another swing at the whole array file at once, and hope that @Sara doesn't hate me for it.
 
@Crell btw. I agree on generally calling such first parameters of array_* functions to be called just array as long as the others are sensibly named
 
6:11 PM
If that causes the least fuss I'm OK with that.
 
but I don't want to see ($array1, $array2, ...$arrayN)
 
That's exactly what I'm trying to get rid of. :-)
 
And I'd like to see the API simplified to coalesce the last required arg into the variadics when it makes sense
 
I'm not opposed, but it's out of scope/my skillset.
 
I mean, this can be done now … doing it in 8.1 would be a clearer BC break
 
6:14 PM
@bwoebi We can change that stuff if it makes sense. We already did some similar changes...
 
@Crell It's mostly arbitrary checks directly in the function: heap.space/xref/php-src/ext/standard/array.c?r=1e9a5c67#5383
 
Anyone has a clue as to why Appveyor stopped building on my PRs?
 
you made too many
 
It's still building some PRs tho
Just not a specific one
 
7:18 PM
Is there any way to get Composer to ignore some dependencies? Specifically PHP extensions
I need PHP extensions I can't get to work on Windows, but I need to look through some vendor code. I can't get the packages installed though because of the extension
Oh wait I am stupid I found it. --ignore-platform-reqs
 
7:31 PM
I'm in favor of changing array_diff all the way to variadics, no required parameters at all, though would also support just one parameter.
The reason for 0-arg is simple; the values in the empty set that do not exist in any other set is just the empty set again. Accepting 0-arg is sometimes useful for highly generic code.
 
user12640521
7:44 PM
@IluTov You're authoring the Better string interpolation? I just discovered this is a valid assignment ${0x0} = 1; How come?
 
@JellyLegend Not really related to string interpolations, but any number is a valid variable variable. 3v4l.org/Wp1ve
 
user12640521
@IluTov I know, it's not but since your currently dealing with strings I thought you'd be the best person to ask
 
@JellyLegend I see. Why that is? No clue, maybe by accident. Has been this way since at least PHP 4, you'd have to go ask someone a bit older than me to get a more accurate answer ^^
 
I need to borrow an Australian (or person who lives there), if you are one then please get in touch to collect your prize.
2
 
user12640521
@IluTov Thank you. This is also interesting: 3v4l.org/53iIE
 
7:53 PM
@DaveRandom Switzerland is close to Austria, does that count? :P
 
@DaveRandom G'day, mate!
 
It does not, but I do have a T shirt from when I went on holiday to Zell when I was about 9 that has a pic of a kangaroo holding an edelweiss on it
@StatikStasis I thought your were 'murican?
 
Zell am Ziller?
 
I thought this was America
@Derick zell am see
 
@DaveRandom I am... just a boring American.
 
7:56 PM
ah, the wrong one then
 
I went once on a school ski trip and once in the summer
It was nice, though I was 10 so most places are nice when you're 10
@StatikStasis I srsly need to find an Australian, I cannot believe how much difficulty I have had finding one, I swear they accounted for about 90% of the English speaking world about 6 months ago
Maybe they were really badly hit by corona or something
 
I went for skiing
 
Need someone who lives there now? Didn't @Danack live there for a while?
 
I need someone to take delivery of something and forward it on to me, after (not even joking) ~10 years of search for this thing I have finally found it, but the site only ships to Aus
 
ask your twitter followers?
 
8:00 PM
Oh that's not a bad idea
Good call
I forget Twitter is a thing sometimes (basically unless I'm drunk)
 
twitter is a bad idea when you're drunk. Before you know it you call people amateurs ;-)
 
@DaveRandom What did you find?
 
I'm not so bad for that kind of thing (although I am now having a sudden attack of beer fear), I'm more prone to ranting about stuff with no one even reading it
 
I had some friends that went to college there- but they moved. I don't know any one of their friends well enough to trust having something shipped to them. Sorry. =/
 
8:03 PM
That's .au, not .at
australia vs austria ?
 
I said Australia, @IluTov started with the Austria thing :-P
 
if I'm using RedirectMatch in apache, is it advisable to use the FQDN?
 
Have you tried calling them to see if you can get them to ship it Internationally?
 
(oh and I have some contract work \o/)
 
Yeh, no dice, they won't do it, mostly because they can't accept a payment in a way that conforms with any kind of tax law
The guy was super helpful tbf but he just couldn't do it legally, whereas ironically this thing of finding a stranger to do it for me is fine
 
8:07 PM
@Tiffany \o/
@DaveRandom Now that I know what it is- it is sorta funny. The two individuals I know went to Hillsong college down there (Christian college.) I can just imagine them asking one of the music directors for help with buying a bong and shipping it to the UK.
=D
 
Heh yeh maybe not :-P
Ftr it's literally just little bits of brass though, perfectly legal and easy to get through customs just labelled as "brass fixings" or sth
 
 
1 hour later…
9:40 PM
Inconsistency DateTimeInterface::ISO8601 ・ Documentation problem ・ #80022
 
Every time someone reports a bug with DATE_ISO8601... that time could be confusingly represented by DATE_ISO8601
 
9:57 PM
@Stephen also, kittens are basically like small children... except they're fuzzy and cute and have daggers for nails in which they don't know how to use them correctly. After about two or three years, they're less destructive but still playful
I would say a year, but I can't remember cause my cats are old, mellow and don't destroy my stuff
 
10:21 PM
@NikiC I know you did a lot of memory work and asan work for PHP 7.4; are fatal errors still expected to leak at all?
 
Pop quiz: For array functions that take a variadic number of arrays, sometimes the parameter is called $arrays, sometimes $rest. We should pick one. Which should we pick?
Currently it's about 14 $arrays, 22 $rest, according to my ctrl-F command...
 
10:34 PM
Can I be really controversial and suggest $_ or $args? I don't like $rest because it doesn't always make sense if there wasnt sonething before it (e.g. array_push()) and we should be consistent across everything, not just array related things
That message took sooooo long to write on a mobile keyboard :-P
It is at least coherent though, which makes a change
 
It's the closest we have to "doesn't have a name", which some args don't have in docs today (for example, array_push).
array_push ( array &$array [, mixed $... ] ) : int
 
The docs are quite a bit out of sync with the stubs already. That's something I'm going to try and clean up after we're settled on the code changes.
I'm trying to remove $args; there was a previous PR that mass-removed most of $args.
 
@Crell Is it too much to ask for 2 examples from each camp?
 
Here's an easy sample:

function array_intersect_ukey(array $array1, array $array2, ...$rest): array {}

function array_intersect(array $array1, array $array2, array ...$arrays): array {}
 
I tend to use $args in userland and I think $_ is a borderline-acceptable general placeholder for unnamed things which seems to be fairly common parlance
 
10:38 PM
$array1/$array2 I'm changing anyway. It's the variadic that is especially inconsistent right now.
@DaveRandom But a pretty lousy name when used as a named parameter.
 
Yes, I'm no longer sure I think what I said before
 
:-)
Another obvious example:

function array_diff_ukey(array $array1, array $array2, ...$rest): array {}
function array_diff(array $array1, array $array2, array ...$arrays): array {}
Although in that case $rest is complicated by being possibly a callable, just to make life harder.
Oh, this is interesting. In all but one case, $rest is used when the type is array|callable.
 
wait, possibly being a callable??
there are a lot of array_* functions I don't even know exist I think, some of them are so utterly insane
 
Well, the type signature doesn't enforce it, but it looks like a case of "one or more arrays, followed by a callable", which we can't really capture in the current type system.
 
Should have been the first arg...
 
10:43 PM
and you can't even change it because arrays can be valid callables \o/
 
What a lovely overlap...
array_diff is going to change to 0 or 1 required args, right?
 
Can't without touching the C code. I'm sticking to just stubs for now.
And it's actually minimum 2 args to make any sense.
 
I know we must have had this conversation like a billion times before, but remind me again why we can't automagically box callable args into closures?
 
@Crell 0 and 1 have a basis in mathematics, yes?
 
lies.
 
10:45 PM
0 would be the empty set (empty array); 1 would be the first arg?
The 0 case may not really be useful, but the 1 case definitely is.
 
I have no earthly idea what you're talking about. :-)
 
I don't think array_diff with 0 args makes sense, surely? Or is it just to allow for graceful handling of array_diff(...[]) ?
 
Besides, that requires work outside of the stub file and is even more of an API change. Please don't distract me. :-)
 
@DaveRandom Yes, graceful handling in fully generic cases is the goal of supporting 0, as long as there is some behavior for 0 args.
It's the same logic for the 1 arg situation, except would be more common I expect.
 
i.e. as long as it's idempotent(?)
 
10:49 PM
Out of scope.
 
yeh not all that relevant to stubs :-P
As a direct answer to your original question @Crell, I will go with $arrays, at least in the examples you gave
 
What about the cases where there's a callable at the end?
 
It's more descriptive than $rest, rest of what? $arrays tells me what it actually contains
@Crell they can't be meaningfully represented fully anyway so I dunno
the fact that they are hard to document betrays the fact that they are badly designed, the only real work around to that is a load of comments
 
But if named params and variadics ever played nice, you'd end up with

array_udiff(array=$foo, exclude=$bar, arrays=[$baz, $beep, fn($x) => ...);

Which is just all sorts of weird.
Yeah, no one is arguing the API design isn't crappy. :-)
 
maybe functions with incompatible signature need to be special-case excluded and just fatal
and a replacement compatible signature function be introduced
 
10:56 PM
Also out of scope.
 
I don't like the idea of this API which everyone acknowledges is crappy dictating the design of something new and shiny
 
@Crell The cases like array_udiff will never work with named parameters.
They are too special.
 
"special"
 
@Crell yeh I get that, but at the same time you have a related, fundamentally unsolvable problem which is firmly inside your scope... maybe the scope is a little leaky :-P
@Crell in the least politically correct sense of the word.
 
Examples like this are partly why I think there is room for another stdlib that has been designed with all of PHP's features in mind. Stuff like this would be represented differently.
But also, that's a huge undertaking and the chance for errors and such is very high. Would have to be seriously dedicated...
 
10:59 PM
@LeviMorrison Issue is that array_diff* is the complement of the intersection of array1 and the union of all the remaining arrays, so I'm not even sure array_diff with 1 arg makes any sense
 
@LeviMorrison while (true) +1
 
@Girgias The intersection of only 1 array makes sense too...
 
@LeviMorrison I mean, you can't really take an intersection of one set tho
 
We should really just use $arr1 - $arr2 and be done with it. :-)
 
It's all about definition.
 
11:01 PM
And I'm not even sure I'm totally correct about the set semantics of array_diff
 
@Crell omg yes also this :-P
 
Plenty of things are defined multiple ways, and people tend to choose the version that suits them :)
 
So is it the intersection of itself or the intersection of it with the empty set
 
@Sara @NikiC @bwoebi @beberlei @Gordon For visibility (pun intended): github.com/php/php-src/pull/5857#issuecomment-681154728
 
@SammyK This seems to brake a lot of stuff going from the output of Travis
Also there is a compile failure/assertion failure in debug builds
php: /home/vsts/work/1/s/Zend/zend_observer.c:140: zend_observer_fcall_call_end_helper: Assertion `observer_handlers' failed.
 
11:21 PM
function array_intersect(array $array, array $include, array ...$arrays): array {}

or

function array_intersect(array $array, array $include, array ...$includes): array {}
 
Hello. I am trying to understand why FLOAT values are ignored in my PHP snippet. May I paste a pastebin link?
 
Sure
 
First of all, the indexes that you assign will all be integers and not strings
 
@Girgias I am trying to get a random Key from the array on-top, based on weight of each key. The last two weights (values) are float. These are getting ignored for some reason..
Yes, I need the keys to be like that. This is the returned numbers. The weight is in the value position of the array.
 
11:29 PM
Again, you're keys will not be strings
PHP will convert them to integers
 
No problem.
The problem is with the last two :)
I convert the returned keys to Integers later on.
 
The keys are already integers
You cannot have an array string index such as '30' in PHP
 
My problem is the values tho
 
I know, that's why I don't get why when I give you a technical correction about one bit before I got to the next one you're debating it >_>
 
I'm correcting it as we speak :) I don't debate you!
$coinMultipliers = array(1 => 12, 2 => 12, 3 => 12, 4 => 10, 5 => 10, 6 => 8, 7 => 8, 8 => 6, 10 => 6, 14 => 5, 16 => 4, 18 => 3, 20 => 2, 25 => 1, 30 => 0.7, 150 => 0.3);
See? :P
 
11:34 PM
Tbh, you're way of doing it makes no sense to me
 
Why is that
 
Oh god, array_multisort() is an absolute disaster.
 
make 0.7 7, 0.3 3 and multiply the rest of your values by 10
mt_rand is questionable at best
 
Isn't any "random" function questionable? :/
 
mt_random is pure shait
 
11:36 PM
haha
 
@CDoc random_int(), random_bytes(), or give up and go home.
 
^
 
All other random mechanisms should be viewed as actively trying to hurt you.
 
Also you could just add the corresponding number of array entries and just random_int and index
Now in your case seems quite meh because of the number of entries you would need
 
@Girgias yup, I would end up with a screen-sized page full of array data..
 
11:39 PM
@CDoc That's kinda irrelevant, it's more the memory cost
 
I refuse to clean up array_multisort(). It's beyond saving.
 
It's an exotic function for sure
 
Every single parameter's meaning depends on whether or not other parameters are defined.
 
And you can't get rid of it apparently because it has use cases
I know
 
There is no hope of giving it meaningful names.
 
11:41 PM
Changed the values to x10 and used random_int() as @Crell suggested. Seems to be what I need! :)
 
cmb
@CDoc if $rand is an int, subtracting some double <1 doesn't modify $rand.
 
array_walk() already uses $input as its main parameter... because it takes both an array or an object, despite its name.

... How?
 
Welcome to legacy shit PHP does :D
 
I don't know if changing it is bad, because then $array could be an object, or leaving it as is would be worse, because then they're the only array functions that use $input instead of $array.
 
@cmb you suggest me to convert $rand to float, if I understand correctly?
I've already chagned values to x10 :)
 
cmb
11:52 PM
@CDoc yes; I've seen that you've did x10, but I think not enforcing float calculations throughout was the original problem. Having no floats at all is even better, though. :)
 
Thank you!!!
 
Getting rid of floats, especially for something like what it looks to be is just better, no risk in getting into weird float behaviour territory
 

« first day (3602 days earlier)      last day (1353 days later) »