« first day (3932 days earlier)      last day (1002 days later) » 

12:57 AM
@OlleHärstedt @IluTov Apropos of earlier discussion: twitter.com/Crell/status/1417984589453271048
 
 
1 hour later…
user4717133
2:16 AM
@hakre ok, but I have a problem with this ... hum I don't know if the variable or any node of an array or object ... contains the instance of a class with properties ... can it also be detected with reflection? I'm sorry I'm bad with the subject of reflection, I've seen tutorials but nothing similar.
 
@FranciscoNúñez-TodoPoderoso technically yes, you just would need to check for anything if it is an object, and if so, check (via reflection) for private properties of it and (as this is about private properties) every of it's parent classes recursively.
that is the part in var_dump where it has the parent's class name of the private property "FooBar"in your example.
what I just wrote may sound pretty abstract, perhaps if you share what you're after in concrete, it might be easier to talk about.
so for the part to detect the "object" you have to go through yourself (e.g. is_object).
array_walk might be handy for a poc.
or better array_walk_recursive
then on each leaf node, check for the private property you're after.
 
user4717133
2:32 AM
I am working on a refactory, in my library to expose data from any other variable.
 
user4717133
i going to powe on my pc let me a minute...
 
@FranciscoNúñez-TodoPoderoso you might want to put conscious effort into getting better at using search engines. putting in "php check variable is object type" gets lots of useful results.
php has pretty good search results for most questions you could ask, if you break them down to the just the key words.
 
user4717133
@Danack I come here because I already tried and what I found is not associated with what I am trying to do.
 
user4717133
I am working on it currently I have something a little more advanced, but I have not updated the branch.
 
user4717133
 
user4717133
this is my current output ...
 
user4717133
but this node: FooBarpriv_array_long_name not have the spected key....
 
user4717133
@hakre I was thinking of creating a mechanism that detects that it is an object with a class instance and that it has properties ... and extract or simulate or reproduce this key: "priv_array_long_name": "FooBar": private
 
user4717133
2:52 AM
well I'm going little by little ... XD ... I want to do it myself ... thanks for the hints ... if you can help me with something else you will be welcome.
 
little by little is normally the way to go. IMHO this is especially true for refactorings.
it's easy to compress (little) steps later on then.
but as we need the code (and changes to it) to confirm our understanding, little steps reveal the most very often.
 
user4717133
@hakre it is correct, I just updated the branch.
 
3:14 AM
@FranciscoNúñez-TodoPoderoso sounds good!
I chocked a bit on refactoring and reflection as the first is normally static code and the second is meta programming, and everything meta or dynamic may introduce some obstacles.
as it is easy to be "too clever" when writing / generating the code.
 
user4717133
@hakre ok, I already looked at the documentation but there is something that is not clear to me ... how to implement it if I have an object of the following structure ...
 
user4717133
class FooBar
{
    private array $priv_array_long_name = ['a' => 1, 'b' => 2];
}

$varclass = new FooBar;

$examplearray = ['class' => $varclass];

echo '<pre>';
echo var_dump($examplearray);
echo '</pre>';
 
var_dump should show the private property, doesn't it?
 
user4717133
the implement of reflection need this:
 
user4717133
$oReflectionClass = new ReflectionClass('Core\Singleton');
 
user4717133
3:25 AM
i do not have: Core\Singleton'
 
user4717133
i only have a objet to work around XD
 
you don't need to if you use ReflectionObject instead.
 
user4717133
$examplearray
 
new ReflectionObject($examplearray['class'])
 
user4717133
ok let me try
 
3:27 AM
ReflectionClass and ReflectionObject are pretty similar, it should be relatively straight forward.
 
user4717133
something else, how do I know that I can use reflection ... I mean this: I have an object in all of them, I can apply reflection but I don't want to use it in all, only in those that contain the instance of a class ...
 
user4717133
and that is not a stdClass class
 
that is a check for object, e.g. is_object($x).
 
user4717133
ok
 
or is_object($x) && get_class($x) !== \stdClass::class if you want to exclude stdClass.
What Danack wrote, easy to search for.
so you can do the combinations you need.
 
user4717133
3:32 AM
ok
 
user4717133
class FooBar
{
    private array $priv_array_long_name = ['a' => 1, 'b' => 2];
}

$varclass = new FooBar;

$examplearray = ['class' => $varclass, (object) ['object' => [1, 2, 3, 4, 5]]];

echo '<pre>';
echo var_dump($examplearray);
echo '</pre>';
 
3:45 AM
Random off-topic @hakre are you looking for work by chance?
Not sure if what my employer may be looking at hiring would interest you, and there's nothing official yet, but it lines up with the libraries you've written. Also not sure if we can offer an appropriate salary for Europe or if we can hire in Europe x_x but was curious if you are
 
4:04 AM
@Tiffany I have certain options, esp. if there is some free-form need. at least you made me curious.
 
Do you mainly freelance? I'll find out more tomorrow. Do you have a private communication medium like email/twitter? (yes, I know, not secure, but private at least)
Contracting may be an option, I know we used to contract a third-party for awhile, but I'll try to find out more.
 
4:22 AM
@Trowski thx, I was unable to find it in the docs
 
5:14 AM
o/
@ramsey @PatrickAllaert anything you need from me today ?
 
 
3 hours later…
7:53 AM
$a = fn1() || fn2() || fn3();
fn1, fn2, fn3 returns true or a string value. I want to set $a as the value of fn1() is it's string, otherwise fn2(), and so on. But the current code set $a as true. What should I do to fix it?
 
@JoeWatkins I don't get your patch. You're returning persistent objects to userland, no?
 
@NikiC no, we don't create any objects until object store is initialized
there is no such thing as a persistent zend_object in this version, we just store information to do real construction just in time for request
 
@JoeWatkins Okay, but I still don't see how this can be thread safe
Aren't you going to overwrite zend_test_persistent_object in each thread?
 
zend_objects_store_persist is only meant to be called in MINIT stage
zend_test_persistent_object should be TLS
fixed that ...
 
@JoeWatkins That doesn't work, because you're still taking the address of the TLS of the thread that ran MINIT, it will always be the same
You'd have to do something like only returning an ID for the persistent object during MINIT and then fetching the corresponding object from TSRM at runtime
 
8:10 AM
ah ok, fixed that ...
"constructors" get the request local, normal object ...
that "constructor" in test just sets the global for returnsPersistent test method ...
the idea behind being able to pass a pointer (without duplication) to zend_object_persistent_construct was that you may pass a hashtable, or some other internal (to your ext) structure which doesn't need to be duplicated ... I used it wrong for zend_test_persistent_object was/is confusing you, I think ?
 
Okay, so this is not so much "persistent objects" as it is "automatically create objects on rinit"
But, how would this work for the enum use case?
 
yeah it just looks simpler to me, I don't think we really need to invent actually persistent zend_object* ...
I'm not sure yet
 
You need the object to be stored in the class_table for that. And the class_table for internal classes is not per-request
(And if we make it per-request, then we technically don't need persistent objects at all)
 
hmmm
where are enum objects inserted into class_table ?
 
@JoeWatkins sorry, constant_table
class constants
 
8:46 AM
@NikiC Dumb quiestion of the day... how would I separate this?
 
Yeah @Joe the main restriction we need to dance around is that internal class consts are immutable. So there are basically four possibilities: a) true malloc()'ed persistent objects in userland, b) special casing class const fetching from enums, c) have some sort of dynamic lookup (function pointers on the zce, a secondary non-persistent mapping on the class … somehow) or d) somehow converting some dummy value to an actual emalloc()'ed userland object. My approach was the latter.
approaches b), c) and d) all need some runtime allocation of the objects - at a tracked location so that the same object can be returned multiple times
 
@Derick SEPARATE_ARRAY?
 
I did see that, but it's almost nowhere used. I don't quite understand why I need to seaprate it though, because I've just created it.
 
yeah I didn't see this, I do more thinking
 
@Derick If you just created it, then it should not have a refcount larger than 1
 
8:54 AM
Sorry, I lied. I created the thing I am add_assoc_zval adding, not what I'm adding it to.
 
Right, you need to separate the thing you're adding it to
 
How did pre PHP-7 handle that?
 
@Derick Using some SEPARATE_* macro... don't ask me which
 
I did just ask ;-) I'll go look i tup.
 
 
1 hour later…
10:03 AM
@CodePanda use null coalesce assignment: php.net/??=
 
10:17 AM
@CodePanda $a = fn1() ?: fn2() ?: fn3(); should work
but note: if fn1() returns an empty string, $a will be set to fn2() .. etc
 
@hakre Thanks a lot. The idea is to log only fatal errors, because we have an overview in the portal and all developers have access to and from there we can create tickets to solve it quickly
 
10:52 AM
@Crell Implying other FP languages are "new weird ones"? :D How dare you, sir. They're older than PHP.
 
11:03 AM
I'm on php cli 5.5.9. How can I see the openssl certificate locations? Looks like openssl_get_cert_locations() is only working >= 5.6.0
1
Q: PHP OpenSSL openssl_get_cert_locations

BengaliMy phpinfo is showing this: OpenSSL support enabled OpenSSL Library Version OpenSSL 1.0.1f 6 Jan 2014 OpenSSL Header Version OpenSSL 1.0.1f 6 Jan 2014 I am still getting this error: Call to undefined function openssl_get_cert_locations What am I missing? Even openssl_get_privatekey ...

 
@OlleHärstedt I think he's talking about people trying to make esoteric languages that are functional by default but "replace" PHP. I'm terrible at detecting sarcasm, so if you were sarcastic, ignore this.
 
@Tiffany Is anyone doing that, tho?
What's harder - turn PHP into Lisp, or create a PHP ecosystem for Lisp...? Including people you can hire.
 
Well, it's why it's a quoted tweet. I don't think anyone is, but instead of Larry making his own, he's trying to improve PHP.
 
Hmmmmmmm.
 
Wouldn't touch that even with a 10 feet pole
 
11:06 AM
Wouldn't touch Lisp? lol what a 1xer /s
 
11:34 AM
@OlleHärstedt yes: phel-lang.org
 
Oh yeah, I remember that one. Pretty cool project.
No type-system tho. Bah. Edit, sorry, no static types.
 
 
1 hour later…
@Tiffany Right. The question was asked "why FP-ify PHP instead of using Haskell/OCamel/whatever?" To which the answer is "because there's about 400x as many PHP developers and PHP jobs in the world as all of those combined."
Also, because IMO multi-paradigm languages are the way to go for most situations. FP is great... most of the time. But sometimes shifting your brain to a procedural model does make more sense for a given problem. Or an OOP mindset. Etc. Mix and match, best tool for the job, yadda yadda.
 
cmb
@salathe that voting already ended a year ago
 
o.O
RFC author needs to buy a new calendar. But you're right the vote should have ended (yesterday).
No RFCs are in voting. \o/
 
cmb
\o/
 
@Crell Sooo yeah, OCaml has objects, hint hint, notch notch. :D
But I'm the devils advocate, I agree with both PFA and pipe operator.
 
1:05 PM
I've heard good things about F# as a hybrid language, too. :-) Haven't worked in it, though.
 
F# is copy-pasted OCaml, but for .NET
Same way C# is Java for .NET
 
Par for the course, MS. :-)
 
The object system in OCaml is a special beast, however. Worth reading about, but maybe not use...
 
1:26 PM
Isn't it OCaml which doesn't restrict variance of params/return types?
 
Doesn't follow LSP?
 
1:49 PM
Howdy folks. Has anyone ever seen PHP Windows failing to cast float to int?
// Linux
$n = (float) 11984531456; // float(11984531456)
$n = (int) $n; // int(11984531456)

// Windows
$n = (float) 11984531456; // float(11984531456)
$n = (int) $n; // int(-901419008)
 
Is it 32bit perhaps?
 
Let me check. It's a client's server
Yup, 32. Nice catch, I'll research about this
 
@Girgias Not sure what that means? Variance?
 
Yeah, that's definetly the reason. Thanks @PeeHaa.

Max. Int: 2147483647
Exp. Val: 11984531456
expected value*
 
2:06 PM
Unless you mean parametric polymorphism, in which case yes, it infers the most general type (sometimes you have to poke on it a little).
But that's let-polymorphism, a system designed before. I think.
 
I looked it up again, but yeah it does Structural Subtyping instead of Behavioural subtyping
 
2:24 PM
class MissingClassException extends ParamsException
{
    public static function fromClassname(string $classname): self
    {
        $message = sprintf(
            Messages::CLASS_NOT_FOUND,
            $classname
        );

        return new self($message);
    }
}
 
cmb
@LucasBustamante see php.net/manual/en/…; need bigint
 
If I have code like that, is there an actually useful test that can be written for it? It seems it's either going to be just duplication, or a useless test.
 
@Danack FWIW I have a somewhat similar way of dealing with exceptions and exception messages and I don't see any value in testing the exception itself. Normally I'll write a test for something that throws it and ensure the message is what I expect.
YMMV on whether that's useful I suppose
 
I'm writing tests for it, just so I can get them covered by tests, so I can have 100% coverage for the library.....but yeah....it doesn't seem to be providing much value other than making a note of "tests for this wasn't missed".
 
Yea. Admittedly I have written some simple tests just for getting that code coverage number. I'm still not sold on how valuable those tests actually are
 
2:30 PM
if $classname type is not enforced by static analysis, then empty string or/and a non valid class name ( "foo-bar" )?

personally i would cover it for the sake of code coverage %, leaving stuff like that untested, i end up with 90~% code coverage, and i have to wonder if i missed some logic, or it's just cases that are not worth it.
 
@SaifEddinGmati That's a fair point
 
@Girgias It's worse than that: records, sum types are nominally typed; objects and modules are structurally typed.
 
coroutine(fn(Promise $promise) => (yield $promise)->onStop($server)) Should I be proud or ashamed?
 
Yes.

What does that do?
 
2:45 PM
Probably installs a virus in your brain when you read it ;)
 
@Crell coroutine returns a callable which in turn returns a promise. When invoking the returned callable, the callable passed to coroutine is invoked, which should return a Generator, which is run as a coroutine.
Using that in conjunction with array_map.
 
So, what Olle said...
 
mind
blown
 
but_why.gif
 
return Promise\all(array_map(
    coroutine(fn(Promise $promise) => (yield $promise)->onStop($server)),
    $this->routes
));
 
2:48 PM
"Fewer lines of code makes it more readable"
 
@Crell You're the functional guy, I figured you'd love it. :P
 
Yes, that doesn't mean my brain works with promises. :-)
 
[delete]
Promises are like gotos, change my mind
 
So... each route is a promise, and you async iterate over them and call their onStop method?
 
@Crell Exactly.
Unfortunately type information is lost because no generics.
 
2:52 PM
What's the benefit of them being promises?
 
(This will sometimes still be a problem with fibers)
@Crell Avoiding race condition using the promise as a placeholder.
 
In case one of their onStop methods does IO?
 
The promise exists once the op starts, so another request for the same route sees the existing promise and attaches to that instead of trying to create the route again.
 
Ah.
Then I return to my original answer: Yes. :-)
 
@Crell What onStop does isn't relevant, it's that $this->routes is an array of promises.
Though onStop does return a promise too :)
 
2:54 PM
Because of course it does.
 
Fibers will help with some of that at least.
 
Is this Amphp?
 
Yes. In particular, implementing the onStop method of ServerObserver from amphp/http-server on an object that has a collection of other observers.
 
Amphp is kewl
Although I'm not sure I'd code such functionality in PHP
 
@ramsey 8.1.0beta1 is not yest announced ?
 
3:39 PM
nein.
not yest! we yest later.
 
/me looks forward to yesting.
 
4:05 PM
In one single utility class, I have use cases for:
Pipes
PFA
Generics
 
Can I see?
 
3v4l.org/jEpac#v8.0.8 - Still very much in progress, but...
Oh, and some of the methods here are single-expressions could easily have been short-functions.
 
4:21 PM
You use match() for boolean cases?
Also, it's not possible to use match() with instanceof?
Ah, wait, that's an expression, not a statement.
 
Not most of the time, but in this case it felt cleaner and more modern-y. A ternary would have worked there as well.
And match() only does === at the moment. Hopefully we can expand it to pattern matching, including instanceof, in 8.2.
 
I just mentally go "a union type, where the type matters, go for a match".
 
Well, you can still do your own pipe(), I guess. Or use one of the existing ones.
I wonder how Psalm likes that...
 
I'll probably just build my own damned fp library at this point out of spite... :-) On my list for this project.
I would have done so had pipes passed, as the RFC noted.
 
4:28 PM
There's no already?
 
@JoeWatkins Regarding your blog post: while I don't agree with the "chicken shit" you mentioned, I do feel that not having documentation for the core is one of the biggest hurdles for new people to contribute. I know it was (and is) for me.
 
Not of the type I was describing.
 
The effort on the internals book was laudable and despite being outdated, it does still help understanding the larger concepts. But there are plenty of parts in the php-src where even you internal folks don't know what they do (fpm anyone?). For these cases people > docs doesn't work. Also, people > docs doesn't scale. Of course, we all wish we had a scaling problem, but that's a chicken egg problem if we want to stay with the chicken analogies.
 
@Crell Now right the code in a FP language and compare. :)
 
Is there a cleaner way to get the base class name of a class string than this? return substr($className, strrpos($className, '\\') + 1);
I feel like there is, but it's escaping me.
 
4:40 PM
getShortName according to - stackoverflow ;)
 
Ah! And I do have a reflection object available in this case, so that works out. Thanks.
 
@Crell strrchr ... but it includes the separator
 
ObjectAnalyzer is a command object, btw. CommandInterface + run() or such?
 
No it's not?
 
Gah
Wrong again!
 
4:43 PM
:-)
It will probably turn into a generic attribute handling utility by the time I'm done. I'm extracting it from another experimental project that will likely spawn a few more.
 
@Crell end(explode("\\", $className)) or substr(strrchr($className, "\\"), 1)
the former one also being able to handle top-level class names without separators
 
Hm, I like the first one for cases where I don't have a reflection object. Thanks.
 
cmb
Do we need to be concerned that our pear/install-pear-nozlib.phar still has Archive_Tar 1.4.9, and that this might be vulnerable?
@Crell basename($className)
 
@cmb … basename works with backslashes?
 
cmb
on Windows ;)
 
4:46 PM
yes
 
/me doesn't do Windows. :-)
 
whee!
Does that include readonly?
 
@Crell Yes. That made it into the build
@Crell As far as I know, beta1 includes all RFCs that had been accepted for 8.1
 
Spiffy. Now to wait for the docker image to update, and for Derrick to tag an xdebug beta. :)
 
4:53 PM
@Crell Yes! That's what I wrote in my tweet
 
@Crell Maybe I'll convert your code to OCaml just for the heck of it.
 
@OlleHärstedt Not unless you find someone to pay me more to do that than to work on a GPLed PHP project. :-)
 
I said I
Would show if PFA, pipe etc would really make a diff
Might be too much reflection magic going on, tho
 
@Crell Is this related to your recent question about an alternative to an Apache-licensed library?
 
@ramsey Um. No, I don't think so?
 
5:03 PM
Just curious. Weren't you recently asking about an alternative to an Apache-licensed library, since you couldn't use the Apache-licensed library with a GPL project?
 
Ah, yes, I was looking at error handling libraries, and whoops (I think it was?) had a licensing issue. They apparently removed the offending JS library, or so they said.
This is a different thing.
 
ah
 
@Gordon it seems to scale as much as we need it too, there's not 100 volunteers coming forward to do serious work, there are a few a year ...
like I said, it's not good, but it's how it is ... and silver linings, I think we do an okay job of helping people, for a bunch of people that aren't being paid ...
 
@Crell $basename = (new \ReflectionClass($nsName))->getShortName();
 
5:20 PM
Is there a specific reason why there's no money to the core devs...? Seems strange for such an established language.
 
It's a very long story.
 
(And I should probably not be the one to tell it, since I've only been contributing to core for a year and a half; before that I was just talkative on the list a lot.)
 
5:35 PM
That's not entirely accurate. Several of us have patron/github-sponsor/etc... enabled in various places and see a little mad-money cash come it.

It's also worth noting that a number of us are far enough into our careers that such contributions are unnecessary. If you want to contribute, find someone early in their career who's nonetheless contributing to PHP. I like to point at @GabrielCaruso (no idea what his actual financial situation is) as a younger person who's putting in real time and isn't directly sponsored by a company (as, for example, Nikita is).
 
@Sara @Danack did a thing phpopendocs.com/sponsoring/internals
2
 
@Crell Not all contributions are based on lines of code. You've been a contributing member of this project for much more than a year and a half, m'boy.
@Tiffany Nice!
 
Depends on the definition of contributing that is in play, which depends who you ask. See also: The perennial thread on the list about who should have voting rights. :-)
@Tiffany Ooo! <3
 
Voting rights is a stupidly hot-button topic and I loathe having to have that conversation for realsies
 
Andreas has a tremendous amount of patience
 
5:39 PM
@Sara Cool!
 
@ramsey how do you prefer to be called on internals, ramsey, Ben, Jedi Master Ben Ramsey, something else entirely?
 
5:54 PM
oh... I did the wrong thing
I R bad at email
 
6:07 PM
Didn't realise that GitHub now allow one time payments, which avoids the awkward sponsor for 1 month thing (can't find the "enable custom amounts" tickbox though).
 
@Tiffany How can we teach Dan that it's called Fibers and not Fibres? He seems quite stubborn there.
 
6:24 PM
@bwoebi something something overriding British-ness
 
@Tiffany His name is "Wild Garlic"
 
cmb
but Fibers is not spelt correctly :p
 
Specifically, THIS is Wild Garlic: flickr.com/photos/sebastian_bergmann/286847543
 
Someone submit a PR changing all the API from Fiber to Fibre and just leave the comment "Typo fix"
2
 
6:41 PM
@Sara bahaha
 
6:52 PM
@JoeWatkins Sure many things in php-src move around, but some things are pretty static like zend_string and HashTable, but there is fuck all documentation around HashTables that I still have a hard time dealing with them.
And then there is black magic like FPM
 
7:08 PM
it's WEEKEND time
 
@MarkR Pluralized Fabri.
 
7:54 PM
@FélixAdriyelGagnon-Grenier No it's not Felix
not yet
 
If you put your mind to it it sure is @ln-s
 
haha
 
ln -s weekend now
5
I expected better from you :P
 
8:10 PM
are we not friday tho?
@ln-s that's basically weekend ;-)
 
8:42 PM
@FélixAdriyelGagnon-Grenier it's Thursday though... unless you're like UTC+12
 
8:52 PM
@Tiffany yeah I just realized and started laughing incontrollably
@FélixAdriyelGagnon-Grenier narrator : it wasn't friday
 
@bwoebi are you suggesting I need learnt, how it's spelt?
 
9:30 PM
lol
 
Hello, everybody!
 
10:11 PM
GOOD NEWS, EVERYBODY!
 
@PeeHaa Do we want to know your idea of a good news?
 
Honestly? Probably not :P
 
10:32 PM
Does web-php follow the same workflow as doc-en for pulling from github, building the site on docs.php.net, then building on www every six hours?
Or eight hours or twelve hours, I don't remember
 
11:23 PM
wiki.php.net/rfc/open_release_manifest not a PHP feature, but opening it for discussion anyway
 
@Tiffany It pulls every ...mumble... and ...mumble... the docs
 
11:47 PM
@Sara He was so young then.
FWIW, I also spell it Fibres, because it's just muscle memory to use re instead of er
 
@MarkR how is this manifest supposed to be generated? Is this something affecting the workflow of contributors?
 

« first day (3932 days earlier)      last day (1002 days later) »