« first day (3386 days earlier)      last day (1553 days later) » 

12:22 AM
Til that #humpday on twitter is a weird mix of interesting things, idiotic platitudes and straight-up porn
Kind of obvious in retrospect but never looked at it before
 
o/
It's gin o'clock in the morning
All is currently well, but 47.3% abv suggests it may not be in ~8hrs or so
 
1:05 AM
Hello Guy , I developed a php website main features are (paypal , textchat , zoom api )
I did not use a framework and i have some developer reviewing my code ,my main strategy is that i echo html inside php what should i do to make my code look better and to get a good review
 
Imagine you are not you. Imagine that 5 years have passed and you have forgotten everything about what you were thinking when you wrote your code. Write your code so that guy understands what it does without having to Google anything. That's the basic principle of what separates "good" from "bad" code.
"Write once, read 500 times" - everything you wrote needs to be read by a human in order to maintain it, if you write your code to be read that's 90% of the battle.
I realise that may not seem particularly helpful but honestly that's what really matters. Forget about "design", just write for readability
(And make it work properly, obviously)
In general, anything you can't read without comments needs to be rewritten. Sometimes things are complicated and you really can't do that, if so then add some comments.
"Design patterns" are things which emerge from that basic concept, not the other way round
 
2:15 AM
@AbdelazizWaheedLasheen The thing that distinguishes PHP apart from other languages is that it was specifically designed to allow for code to be embedded in data, rather than the other way around, which is what most languages today and languages that came before PHP, typically allow. So rather than having to do echo "<html>Some stuff</html>", which can cause some cognitive gymnastics, you can more intuitively write things like <html><?=$stuff></html>
@AbdelazizWaheedLasheen A big part of writing better code is about learning to think better. And if you're thinking is that you should be printing HTML from your php, you have yet to think about what makes php — php.
 
 
3 hours later…
5:32 AM
Which one is correct?
- As of version 4.3 and higher
- As in version 4.3 and more
- From version 4.3 and onward
 
Good morning
 
5:59 AM
Hey!
$fp = fopen("abc3.txt", "a+b");
flock($fp, LOCK_EX);
fwrite($fp, "test1");

unlink("abc3.txt");
var_dump(fwrite($fp, "test2")); //int(5)
In this code, abc3.txt isn't re-created, so where does fwrite() successfully write the bytes to?
 
6:58 AM
So I've just learnt that contrary to what the manual says, unlink() doesn't actually delete a file
...it unlinks it (as the name would imply to those familiar with how filesystems work - but the manual doesn't state), which is not the same thing as deleting a file.
 
7:38 AM
@NikiC For Java, Traversable<B> won't be subtype of Traversable<A>, but Iterator<A> will be subtype of Traversable<A>
 
8:19 AM
@lisachenko yeah, but subtype of Traversable<? extends A>
which does not invalidate Nikitas point here
 
@bwoebi what Java does is effectively reduce this to Traversable<A> for every implementation.
If you pass class B for this generic that extends A, then it's still valid, you will get Traversable<A> which can return covariant type B, because of dynamic nature of PHP.
 
8:50 AM
@lisachenko that's fine for traversables, which return, but not when the generic is an input parameters
@lisachenko and what java effectively does is type erasure...
 
@bwoebi maybe we can adopt something similar to PHP? But in compile-time...
 
@lisachenko that's ... not very PHP
 
I'm just reading the github issue, I'm inclined to think the current mechanism makes sense, but that decisions should be taken that leave the door open for a monomorphized implementation in certain circumstances at a later time, without external behaviour changes
 
Can I safely on ReflectionFunction::getStaticVariables() to return the use statements for closures, or it this just a 'funky' implementation detail?
 
9:00 AM
When I was debating union types I thought creating a class entry for every item made sense because it was a semi-simple permutation of heirarchy chains, but I can see how unions make it a lot more complex
 
@MarkR this is why it is better to restrict generics to simple type
otherwise runtime checks of union types for generic classes will be a nightmare...
 
I don't think that restriction would fly @lisachenko.
 
@MarkR yeah, I know..
 
cmb
@Jasny-ArnoldDaniels who knows, since "This function is currently not documented; only its argument list is available." ;)
 
@MarkR yes, selective monomorphization (e.g. when code may be strongly optimized) makes a lot of sense.
 
9:08 AM
@MarkR but if we can separate inheritance checks (like in Java), then implementation will be much more simpler. Traversable<A> will accept argument Iterator<A> as valid, but not Iterator<B>. And when we declare concrete entries, then check generic restrictions: Traversable<? extends A> allows to create Traversable<B>, but not Traversable<C>
 
WRT early binding and loading loops, what about looking into making pre-loading not so... pre?
 
The function simply returns `op_array.static_variables`. This is intended for variables bound with `static`, but closures also use this array for the `use` variables.
Is this intended, or just a 'quick hack' that will be changed in PHP 8? Like adding `op_array.use_variables`.
 
Perhaps something similar to databases' query caches. Store compiled versions in memory but throw the entire cache out if an included file has changed, which 99.9999[...] it won't have.
 
@Jasny-ArnoldDaniels no you can't
definitely a funky implementation detail ;)
@bwoebi Yes, selective monomorphization as an optimization is a different question :)
 
yeah, too early for that right now except that the impl shouldn't lock it out.
 
9:13 AM
Back when I think it was Levi was looking at a single method for compiling a file to opcodes, I was pondering about a method which took in an array of class maps, e.g. composers optimized class list.
 
@rahuldottech not sure I've seen unlink used with files and what the expected behavior was, but I have seen it used with arrays which does remove the key/value in that array. I don't know how it works from an internal perspective though.
 
@lisachenko I think that having type parameter variance is pretty important...
 
@NikiC Even if it's changed (for PHP 8), it will always be available through reflection, right? Like adding ReflectionFunction::getUseVariables().
 
@NikiC this can be added later as a feature )
 
If we added something extra to such a function, say, a combined hash of all the files, PHP could use that to clear its cache. Obvious downsides are classes which are declared conditionally
 
9:15 AM
@lisachenko As the point here was that a naive monomorphized implementation precludes that feature, it's important to consider upfront
@Jasny-ArnoldDaniels yeah ... to be honest I'm surprised something like that doesn't exist yet
 
Side note, what does unlink actually do with files? Does it delete the file? Does it remove reference to the file within memory?
And if that's a stupid question, I blame it on just waking up
 
cmb
@Tiffany on non Windows systems, the POSIX semantics apply: pubs.opengroup.org/onlinepubs/9699919799/functions/unlink.html
 
And on Windows, it performs a dark ritual involving the sacrifice of a goat
2
If you don't sacrifice the goat, you're not allowed to unlink a file other people are using...
 
Pouring goat blood over the drive in question works too. Always worth keeping a few pints in the fridge.
 
9:38 AM
hi
anyone know how to use image tag in fpdf
$message ='<img src="new_star.png" style="height:10px;width:10px">';
$pdf->writeHTML($message);
$pdf->Output();
this is my code\
 
Someone here with docker / devilbox knowledge?
@khairuddeen
// Insert a logo in the top-left corner at 300 dpi
$pdf->Image('logo.png',10,10,-300);
// Insert a dynamic image from a URL
$pdf->Image('http://chart.googleapis.com/chart?cht=p3&chd=t:60,40&chs=250x100&chl=Hello|World',60,30,90,0,'PNG');
As far a I know you can't use it just like HTML
 
ok thanks
 
cmb
@NikiC due to the sacrifice of the master goat, as of PHP 7.3 you are allowed to unlink a file in use by others. :)
 
10:01 AM
@NikiC just seeing: github.com/php/php-src/blob/… - how are we supposed to distinguish whether it is any instance of AbstractDefaulted? Will there be AbstractDefaulted<?>?
 
I was under the assumption that defaults are just for concretes
 
@bwoebi I'd first ask: Why would we want to know that, given that they have no subtyping relationship?
 
Just finished my Go conference talk where I insulted Laravel somewhere at the end :thumbs-up:
 
@NikiC because of the common methods they may have and not dependent on the generic
 
10:03 AM
@bwoebi You wouldn't be able to (backwards compatibly) implement Traversable with that
@bwoebi I think in that case the class design is probably inappropriate, but hard to say without examples
Such a check would have to be performed through a reflective channel
It's not meaningful on the typesystem level
 
@NikiC simple collection example: move X elements from start to end. It's independent on what the collection contains.
it would be essentially something like $collection->append(...$collection->splice(0, $elements))
 
@bwoebi Right, but I don't think doing a type check on it being a collection would not be useful in that context either
 
@NikiC why not? you want to ensure it actually is a collection
to operate on it
 
If it's an inherent method on the collection it will be parameterized over the collection type. If it's not an inherent method, you'd accept a Collection<T>
That's how you say that the type is irrelevant
 
you mean T as a dummy, unspecified T?
@NikiC I was talking about an independent function
not a method part of it
so, this would look like function move(Collection<T> $collection, int $elements): void { ... }?
without T ever being specified?
 
10:12 AM
Wouldn't that be more inclined towards Arrays<T>::move($collection, $elements) ?
 
@bwoebi It would be function move<T>(Collection<T> $collection, int $elements): void { ... }
 
okay
and if this were a property?
 
Hello, peoples. I'm using the online editor to try and edit the docs. I've made and saved a change, but... I'm not sure how to then turn it into a PR or whatever the equivalent is.
 
I.e. private <T> Collection<T> $wildcardCollection; ? @NikiC
 
@bwoebi Theoretically. More likely just <T> on the class.
I have a hard time seeing how you'd actually use that property without having <T> on the class
 
10:15 AM
@NikiC but then you are forced to specify T, if it's on the class and you want to instantiate the class
 
@Crell On the left side you need to find your work in progess and right click it
 
I mean, the property must come from somewhere, and in that place you'd have that T anyway
 
Something something submit patch
 
Ah ha. Merci. Filing patch now.
 
@Crell fyi you can also use github.com/php/doc-en
If you don't want to deal with online editor
 
10:17 AM
O'rly?
Ooo... Definitely better, thanks. I didn't realize the Git work was far enough ahead for that.
Are PRs there actually checked? :-) (I don't want things to get left hanging, so whichever vector is most likely to get accepted is what I want to use.)
 
@NikiC yes, you may have the T where you call the method setting this property. But then another caller may set it to some totally other T - the T is not fixed.
 
(Also, I love hearing about people talking about generics. Want.)
 
The online editor is where a lot of patches die unless somebody in specific get spinged most of the time
 
Fun. Who do I ping?
 
@Crell @PeeHaa
 
10:20 AM
:-)
 
@bwoebi Okay, I can see that in theory, but not really where it would turn up practically
 
@PeeHaa I'm working on some FFI docs improvements. How do you want 'em? I just filed one through the editor.
 
@bwoebi I don't think we really want higher-kinded existential type systems in PHP ;)
 
Ooh. Just noticed that the docs now use PHP syntax for return types, instead of Java style. When did that happen? I guess my ticket got closed : )
 
@Crell Depends whether I am qualified to review it :D
 
10:23 AM
@NikiC I can just say that we have multiple thousands of <?> in our java codebase at work (it's a really large codebase, yes ... but <?> is not rare.)
 
@PeeHaa I don't know where the one I just filed goes, so if you can find it, let me know if I Did it Wrong(tm) or if you are the wrong person. This one was just some Notes. The next one or two would be some see-alsos. Etc.
I've been futzing with FFI recently at work to demonstrate how to use it on Platform.sh, and want to make sure the road bumps are filed somewhere useful, not just in my blog posts.
 
@NikiC A lot of <?> is with Futures for example - where something shall happen in the error case, but success value does not interest us.
then the success type is just the ? wildcard
 
cmb
@Crell There's a typo in the first paragraph (#deifne). Also, please don't use CAPITALIZATION, but rather <emphasis>. (also think about Windows)
 
I know zero about FFI on Windows.
 
I just assume it doesn't work for shit :P
 
10:26 AM
Also... how do I get back to it now?
 
@NikiC Or Class<?> is also very common - to reflect on things, where the actual type is not known
 
I was using caped SHOULD and MUST in the IETF sense. What's the proper PHP-doc alternative?
 
cmb
@Crell <emphasis>should</emphasis> and <emphasis>must</emphasis>
 
OK. How do I go back and edit it now that it's submitted?
Or should I just redo it as a GitHub PR?
 
cmb
@Crell I'm not sure whether you're even allowed to edit the submitted patch. I can do the fixes, if nobody beats me to it. :)
 
10:33 AM
Whee!
 
@NikiC what would be great, would be internal type placeholders. E.g. a property private Promise<T> $foo; and function getFoo(): Promise<T> where T is not part of the class generics, but just internal. (i.e. as implicit sanity check)
 
cmb
@PeeHaa It's supposed to work on Windows, with the exception of preloading.
 
I guess I should do Git PRs for future ones, then.
 
@bwoebi How would T be determined in that case?
 
cmb
@Crell IMHO preferable.
 
10:36 AM
Roger. So what do I do with the current one?
 
cmb
@Crell I'll address that this evening. Also, if you have done some doc patches, consider to apply for a documentation php.net account.
 
These are my first. I figure I should do a few, then apply.
 
@NikiC all users of T must match at any given time T is checked - so if getFoo() returns a Promise<Foo>, T must be Foo. It sees $foo is using T. Hence it checks whether foo is a Promise<Foo> (or fails)
 
@cmb Let me know if you need me to do anything on the one I just submitted, then. I'll do anything else via GitHub. Should I poke you/someone here afterward for that, or will they get noticed?
 
cmb
@Crell GH doc-en PRs are usually addressed timely. :)
 
10:40 AM
thumbs-up.gif
 
@NikiC but that's really food for later :-) But my point still stands, we will pretty much need wildcards (and possibly bounded wildcards)
 
10:57 AM
I wrote dome some implementation notes at github.com/PHPGenerics/php-generics-rfc/issues/45 and gonna switch to something else for now. I think github.com/PHPGenerics/php-generics-rfc/issues/43 needs a resolution before it's possible to move forward.
 
wrt your Q about missing types, any scope for modifying union types to omit the type if it's not present o r cannot be loaded at use time? array<AmpPromise|@ReactPromise>
Then either remove it from the list of types, or substitute it in for a quasi type that never matches anything.
 
11:15 AM
WRT immutable opcodes, the instance scope is known at call type I assume. Could the value of T be pushed into the call as a hidden parameter and the opcodes use that instead?
 
Union types in generic declarations? I've... never seen that before. Is that even wise?
Or is it more of a "whelp, it just sorta falls out that way now that we have union types"?
 
 
1 hour later…
12:20 PM
@NikiC I'm interested to hear your opinion about explicit optional types (i.e. which aren't required to exist) like @MarkR proposes...
@Crell you must've never written any typescript
@Crell the most common occurrence of that is in arrays (string | number or string | symbol), but also in Promises (note that ?Type is already an union: Type | null - as the most primitive example).
common use case we have, a GenericError and some sort of specific error: callback: Function<Promise<E extends Error | GenericError>>
so yeah, it's definitely a nice feature - then you distinguish exactly two cases and have full type coverage. (or you just get the message, because both classes are instanceof Error - which is also easy then)
 
12:42 PM
Question, when nikic mentions that X instanceof T isn't performant, how much of a hit are we talking?
 
@MarkR quite small. - but it will be relatively significant compared to a normal instanceof call. I can easily imagine it being 2-3 times as expensive as a "regular" instanceof call.
 
@bwoebi I think it's a reasonable approach to satisfy the niche case while keeping the more intuitive behavior for the majority case
 
@NikiC That's pretty much a good résumé of what it is.
 
Could also extend that to an independent feature. Right now if class loading fails in a type check it's just ignored (hey, maybe the class is gonna be defined next time!), with this one could make it throw
 
@NikiC can you have a look at the mbstring warning conversions again? (see github.com/php/php-src/pull/4971)
Okay why on earth do I have an unrelated file test deletion in that PR, sight
 
12:54 PM
@NikiC yuuup :-)
 
@Girgias so much diff
 
@NikiC though not sure how much that would impact BC ...
 
@bwoebi yeah ... union types is php 8, but the same applies to ?Type already
And it's also kind of inconvenient to actually load the type if the value is null
So making it a hard requirement that it must throw if the class isn't defined is also problematic in that context
 
@NikiC we could do it ... except if the value is null :-D
 
How often is that done, vs a bug or typo?
 
1:00 PM
@NikiC it's mostly tests :( And one change on how to handle the OOB condition for mb_strpos and co
 
1:52 PM
Buenos dias mi compadres!
 
@StatikStasis Donde es mi cerveca?
 
2:06 PM
morning
 
o/ morning
 
\o
 
2:28 PM
@Gordon Pensé que toda la cerveza estaba en Alemania.
 
@StatikStasis Pero no está en mi escritorio
 
@Gordon No bebas y codifiques.
 
@pmmaga LOL!
 
@Tiffany Doesn't remove the file from disk
See comments and linked question here: stackoverflow.com/questions/59873228/…
I spent a lot of time figuring this stuff out
I've since decided that Sync SyncReaderWriter is best suited for my purposes. But that also appears to be like the least documented PHP "feature", so I had to get a friend to explain it to me
 
2:42 PM
@rahuldottech In that sense most delete actions won't delete anything from the disk :-)
 
@PeeHaa That does appear to be the case. Apparently it's up to the OS to "delete" (as in remove from disk) the file once there remain no open handles to it.
 
I want to join in the spanish but can't words ... so ... hola ...
 
@JoeWatkins Hola!
 
Buen día!
 
I just got back from Dominican Republic... so begins my futile attempt to dedicate myself to learn conversational Spanish before I return next year... which usually begins to wane around March.
 
2:55 PM
no puedo hablar en ingles ... a espanol tengo el idioma pero todovia no puedo hablar con gente
 
perra
am i doing it rite?
 
that's a female dog
 
that's an eloquent way to put it yeah :)
 
ah then ...
bon dia, perras
spanish is not good for cussing ...
 
2:59 PM
it's too pretty ...
 
@JoeWatkins Not sure about that. They have some gems
 
you don't really hear people swear though
 
In Spanish it's more about how you say it than it is about what you say
 
understanding what a spanish person is talking about is really half a matter of knowing the words, and half knowing how to read other verbal queues and body language
yeah, what he said ... I totally fail at reading people
because they are limited on words, they have about half as many as english or something ... so they have to communicate with hands and tones and other stuff I don't pick up on ...
 
@Tiffany I'll take a look, thanks!
 
3:02 PM
Less words seems better though. Less to learn
 
but everything else is much more subtle, the words of a question and a statement don't differ a single bit most of the time, it's hard to tell if you're being told something or asking something just going by the words being used
 
English is a lot of "This word can mean x, but it can also mean y. Sometimes even z, but very rarely q. Unless you use it with l, then it could mean g. It actually doesn't matter, it means whatever you want it to mean"
But Spanish is a lot more structured
 
@Alesana Pretty sure Dutch is even worse :P
 
and their voices and patterns aren't the same as english, so a rising inflection as the end of a sentence in english almost always means you're talking with an australian or being asked a question, but they don't do the same here, it's eye brows and other facial expressions and it differs from person to person ..
I really struggle, even with people with whom I'm familiar
 
@PeeHaa I don't know if I am ready to start learning Dutch in that case
@JoeWatkins Related video
 
3:07 PM
@Alesana Considering you already speak spanish and english you are pretty much set for most of the world
 
I really like languages, it would be nice to learn a third but I just don't have time. I tried studying Arabic for a little bit but it was pretty difficult.
 
I suck at all languages :(
 
You're pretty good with English :P
 
@NikiC
@NikiC are you based in Berlin?
 
@alcaeus yes
 
@Alesana Luckily my country doesn't do shitty dubbing of television :P
 
Nicolas and I would love to have a chat with you since we're both in town next week. Any chance you can make it?
 
@JoeWatkins It's the language of love.
 
meanwhile I have been in TR for 2 years now and it's still all gibberish
@StatikStasis I thought that was german?
 
@PeeHaa lol, definitely not going to serenade any senoritas in German.
 
3:21 PM
:D
 
hahahahaha I know that one
Always funny :D
 
@alcaeus uh... maybeish?
 
I wonder how different the world would be if we all spoke the same language.
 
@NikiC nice. If you can't make it, don't sweat it. Just thought we'd at least ask
 
3:33 PM
speaking of going to places, anyone planning to go to fosdem next weekend?
 
3:51 PM
What a wonderful type error message )) TypeError: Typed property My::$value must be int, unknown used
 
@lisachenko Assuming you're not messing with FFI, that's a bug ;)
 
@NikiC I'm messing with FFI, just forgot to return a value from write_property handler (null)
So, not a bug ))
Crafting immutable object by allowing to set values only in ctor or in static method-constructors...
 
@bwoebi That specific <T> would probably have to exist on the enclosing class, not on the class property.
 
4:08 PM
hi everybody
Can I ask something?
if the answer is correct but the question was downvoted why downvote the answer too?
 
@PeeHaa You learned English from watching tv?
 
Magic question: am I allowed to throw a PHP exception within write_property handler? Because this violates returning values from FFI first: FFI\Exception: Incompatible types when assigning to type 'struct _zval_struct*' from PHP 'unknown'
Maybe there is a way to emulate exception? Because it is Zend engine and it doesn't expect PHP exceptions during calls to write_property handler...
 
4:29 PM
@Alesana I guess so when I was young
 
Hi @Emiliano first of all: Welcome! Second: 'Don't ask to ask, just ask.' ;-) Third: Why was the question downvoted? Maybe the answer works™ but is not the right way (phptherightway.com)
 
5:01 PM
@PeeHaa That's impressive. I watch a bit of foreign TV with subtitles but I don't come close to actually learning any of the words, even the simplest ones
 
5:17 PM
7 hours ago, by bwoebi
@NikiC what would be great, would be internal type placeholders. E.g. a property private Promise<T> $foo; and function getFoo(): Promise<T> where T is not part of the class generics, but just internal. (i.e. as implicit sanity check)
 
5:44 PM
Lo all.
 
 
2 hours later…
7:29 PM
@Alesana I've learned bits and pieces of Japanese from watching anime. Though, I would confirm with my cousin that they were actual words and not something specific to a show. Most of the time they were actual words.
Mind you, I'm not fluent, not even close, but there are maybe two or three phrases I don't need subtitles for
 
7:53 PM
/me drums fingers waiting for 7.4.2 docker image to drop
 
8:06 PM
morns
 
8:35 PM
0
Q: CFS Firewall - Allow domain access to download

TiagoI'm trying to install Sitepad, but it asks for: If you have a firewall, then please allow access to download all packages from *.sitepad.com and *.softaculous.com Note : Please allow access to the following domains to your firewall as these are the servers through which your website will...

 
 
2 hours later…
cmb
10:52 PM
@Crell, I think your edit.php.net patch can be improved, but I'm not sure about the details, so I've submitted github.com/php/doc-en/pull/24.
 

« first day (3386 days earlier)      last day (1553 days later) »