« first day (3294 days earlier)      last day (1651 days later) » 
04:00 - 13:0013:00 - 00:00

4:21 AM
o/
 
@JoeWatkins I stumbled across an older SO comment of yours today. Regarding type hinting on "array of objects". It was pertaining to method parameters, and I was googling for return type hinting specifically at the time. Sorry the RFC was declined but I did see that was for PHP 5.6... any new news on that front?
 
it's likely that we won't get arrayof until we get generics, it's likely to be built on the same modifications to the type system, and nikita thinks doing arrayof without generics is not worthwhile ....
nobody has made a start on generics, and I doubt they will, actually ...
 
hmm sad to hear that. Well regardless I appreciate your insight on the matter
I wonder if the subject of generics (not educated on the subject of them, will have to do some reading) would also correlate then to specifying the return type for yielded objects of a \Generator method as well
 
4:32 AM
it would allow that
 
been making more use of them lately I like them a lot actually. reduces iterations
at least in my usage of them. less "method that iterates and prepares an array" followed by "now that we have the results, iterate those results and do something with each element of that resultset"
Anyhow... back to my late night coding here. take care
 
have fun :)
 
personal project so always do :)
 
4:53 AM
might help generics if we could begin by specifying the form,
i assume it'll be myclass<typename, typename>
 
that wouldn't be a generic ... that would be a ... specific ...
 
Just trying to imagine things the parser could trip up on.
 
the parser part isn't the problem, I've written that bit two or three times already
it's all of the rest
getting the parser to create useful structures is trivial, it's the resolution of types given the restrictions and flexibility of php that's the actual problem ...
or was perceived as a problem, but today, maybe less so - it's not so strange to hear that class Y has to be loaded before use because of variance changes ... if we can impose the same sort of rules on generics it makes it simpler, but it's still a big complicated thing to model ...
someone is going to have to sit down one day and do nothing else for maybe three or six months ... we have no such person available, and it's not a thing you can work on in your spare time, I don't think ... it's probably one of the most complex changes to the type system that could be devised, it's going to take massive effort ...
I mean making a thing that works, is but a few days work, but making a thing that always works .. not so easy here ... just defining the limitations of the system is going to be a lot of effort, and require the kind of knowledge that only exists (clearly) in about three heads right now ...
in case not clear, I don't think I can write this, even if I had the time, not on my own anyway ...
 
How were you minded to handle inheritance chains? If you had class A extends B and then had some Template<A> would you create concrete Template_A and Template_B at the same time?
 
you don't need a concrete b, you just need b to be available before concrete template<A>
it creates a very strange dependency graph, for at the time when you construct the template, you may not have constructed any A
 
5:08 AM
my thought was that if in the class entity, Template_A "extended" Template_B then you get the ability to do LSP
 
but template has it's own hierarchy
(ie. extends Collection/List/Whatever)
 
Same issue isn't it? When encountering Template<X> generate all permutations of that class hierarchy. The alternative would be changing the type system to do recursive instance checking of multiple type names.
 
I don't see the need
to generate anything ... except the type being constructed, of course ...
<?php
class Template<K, V> {
    public function add(K $k, V $v) {

    }
}

class KeyObject {}
class ValueObject {}

class Key extends KeyObject {}
class Value extends ValueObject {}

$generic = new Template<Key, Value>();

$generic->add(new Key(), new Value());
?>
why do you need Template<KeyObject, ValueObject> or any other type than the one constructed ?
I'm probably missing something ?
 
My thinking is, without needing to resort to recursive instance type checking, you would get:

function foo(Template<KeyObject, ValueObject> $x) { ... }
foo(new Template<Key, Value>);
So once mangled, somewhere you'd end up with a Template_Key_Value extends Template_KeyObject_KeyValue
 
this is precisely the hard stuff I'm talking about, this is not going to be solved with generated classes, these are the hard modifications to the type system that will require us to impose the kinds of rules we impose elsewhere ... I can't give you a description of those modifications or rules because I can't model them in 5 minutes and don't have several months to work on it ...
 
5:22 AM
That's why I originally asked if you'd generate or change the underlying type system :-)
 
oh yeah definitely change, sorry I missed that simple version of the question ... there will be a generated class, for the final type, but one ... I'm pretty sure ...
 
Fair dos. I appreciate the discussion.
 
people look to java and see no generics or mention of generics in one version (J2SE 1.4), and then full support for generics throughout the language in the very next version (J2SE 5.0), and forget that it took a team of sun engineers at least 30 months to achieve this
that's the kind of resources that we will just never have ...
 
I need to look into how that PHP pre-compiler does it.
 
even if we aim for some basic support (not throughout the language), that's still by my estimates about 6 months work to make a start from at least one dedicated engineer ... we don't even have that ...
 
5:30 AM
I've seen a couple of userland implementations but they all rely on intercepting and re-writing the code
while (!$generics) { $workers[] = clone $nikic; }
 
Wes
mornen
 
So it is... I should probably get up and make my first of what I'm sure will be an excessive number of cups of tea (also, morning Wes)
 
Wes
i just got myself some too. i am in the english phase again
english breakfast with milk
:B
 
My most sincere sympathies.
 
Wes
:D
 
5:40 AM
I dare not imagine what it must be like to live in a world where I can only assume you are being forced, at gunpoint, to drink English Breakfast rather than Yorkshire Gold.
 
Wes
i don't know what that is
but i can pretty much only accept english breakfast's flavor. earl gray is pretty bad with milk or lemon for me
or any other teas... i think i have prince of wales or something
 
My dear fellow, you must with all due haste find a box of yorkshire gold.
Embrace the light that is the best tea in the world.
 
Wes
is it strong? i like strong
 
Let's put it this way... the usual amount of time you need to stew a mug of yorkshire tea is about 10 seconnds. 5 if you're stirring.
 
Wes
i keep the water on the fire withe the teabag in so i get darker tea
do i get killed if i do that in britain?
i live in espressoland i like strong stuff :B
 
5:47 AM
Well we almost exclusively use electric kettles, so if you put the teabag in and left it on, you'd ruin your kettle
 
Wes
i know, but it's not ruined, it's just some residues from tea
you can remove them with some drops of bleech diluted in water, like clothes bleech :B
.........or wd40
 
Can't say Ive ever wanted to spray lubricating oil into my kitchen appliances xD
 
Wes
indeed lol, when i bleach the kettle i have to clean it thoroughly... i am not planning drinking bleach :B
 
I get really paranoid when I bleach my cat's water fountain :| I usually put it through at least a couple of extra washes just in case
 
Just use left hand side burner.
Good morning.
 
6:07 AM
o/
 
Wes
@MarkR yeah i would be extra careful too with that
 
t in spain is crap, like pissy water (looks like, haven't drunk it myself - piss or spanish t) ... I import PG tips ...
 
Wes
i think humans handle a bit of bleach since we put it in tap water... not sure about cats
 
what bleach do we put in tap water ?
 
Wes
chlorine? are there different bleaches? :B
yes^
 
6:10 AM
chlorine by itself is not a bleach
 
I thought bleech was based on its hydrogen ion content?
 
Wes
Chlorine bleach usually contains sodium hypochlorite.
Oxygen bleach contains hydrogen peroxide or a peroxide-releasing compound such as sodium perborate or sodium percarbonate.
Bleaching powder is calcium hypochlorite.
 
there are bleaches that contain chlorine
 
I was never any good at chemistry. That's why I'm crap at bonding.
 
Wes
:is(), :matches(), :any()
and still not a usable one. man i hate css
 
6:18 AM
Happiness: Tidying up some shopping bags and a packet of gingernuts falling out into your hand.
 
Wes
that would remind me i am fat :B
 
I tend to put that reminder aside when I remember I've got a sucky day coming up. I'm teaching another person my code and I'm being absolutely ****ed by imposter syndrome. They don't teach you how to deal with that one when you're learning at uni.
 
Wes
impostor syndrome is not that bad when you realize most of people is... i mean except niki joe ecc :D and in all fields.... 4 different mechanics still have no clue why my car rattles sometimes
 
Rp9
hi
 
6:34 AM
not yet, it's very early ...
I signed up on dev.to yesterday, I used PHP as the Company, I obviously intended to write something about PHP, but it's gone from memory ... was anything particularly interesting happening yesterday that for some reason isn't on my twitter feed or on reddit (I looked there) ?
it might have happened before yesterday ... urm, I'm totally blank ...
 
uhhhhh... Nikita said union types was going to voting, someone submitted 50 error reports about opcache, voices of the elephpant panel discussion was an interesting listen to?
 
not a single bell is being rung, do naming topics you remember from the podcast, it's possible i listened to that ?
 
It was the 25 years of PHP one talking about the needs of casuals vs business
 
ah maybe 25 years
I think that's it, thankyou
 
np. I'm thinking I'll add that podcast to my regular listening list, I usually just do phpinternals news
 
6:43 AM
I mentioned 25 years in my "introduction post", so that looks like the train of thought I was on ...
I'm not even sure if dev.to is a good platform for that sort of thing, but it does come up on my twitter feed a fair amount ... what's your impression of it's reach ?
voices comes up on my twitter feed, but it's mostly not that interesting to me ...
 
I'd honestly never heard of it until you mentioned it, but I'd say im a pretty poor sample.
 
fair enough
know of anywhere that isn't medium (which is a bit generic) that accepts third party articles ?
 
Nothing springs to mind, I think Medium pretty much stole the show on that one.
 
well i'm not sure of what the content of this thing is going to be, but I know who I want to speak too ... they're all developers, and dev.to seemed like a good candidate ... but this morning I wonder how important the link even is and why I didn't want to write on my blog in the first place ...
 
From a discovery point of view, especially in the long tail, i'd probably look to the likes of medium, then drop the links on the likes of twitter and reddit.
Maybe even hit up derrick to talk about it?
 
7:21 AM
I can't think of a good reason not to use medium, probably just do that ...
 
Ah fun, PHP exploit PoC's posted to r/netsec again
 
Sessions aren't working – #78741
 
The guy apparently didn't even wait until new versions were published, as soon as the patch hit git the PoC was posted
 
8:00 AM
fiduciary of, relating to, or involving a confidence or trust: such as
 
Morning
@cmb Ok, good, checking it right now...
 
8:29 AM
morns
 
8:51 AM
mooooooin
 
mornin guys
I can see a lot of discussions about purifying stdlib functions error handling debating fine-grained exceptions or error values and got a question.
Cause I'm unable to spend as much time as needed to look through all the conversation - that's too spammy.
 
Could potentially returning a tuple or typed struct be a solution for stdlib functions returning result and error code/message whatever be a solution?
I mean if functions like for eg. mkdir() could return a something like : {bool, int} or different shape would it be a good idea?
I mean returning two values a return value and for eg. errcode
But then it would be more like a go and would require to use list all the time [$val, $err] = mkdir($tmpDir);
 
I have an ajax call to abc.php and their I have written windows.location.href='www.google.com'; which is used to redirect to google.com domain. But when ajax executed it just fetch google.com html content in the ajax and do not redirect.
How?
 
cmb
@DaveRandom, thanks for the stream_tty_* API suggestion! From what I can tell (don't know anything about raw mode options, fe), this makes perfect sense (modulo the combined getters/setters). How to proceed? Would it make sense to draft a working PoC with FFI?
 
9:05 AM
Ahhh don't listen to me above I think that would require an additional destruction way without the list, like $val1, $val2, $val3 = someFuncCallOrExpression(); then it would not require changing currently existing code if only first value matters
Ok, found a better example file_get_contents(string $filename, /* the rest of args */): (string,bool) this way functions would be able to return multiple values like in go and there is no need to examine type of first value even if it's an empty string and evaluates to false the error existence could be in second value, so when using this function I could write: $content, $error = file_get_contents($filename); - now does that make sense?
And this could be no BC break for new API maybe in some namespace or with some package prefix in a future
 
9:26 AM
@JoeWatkins I prefer reading things on your blog than shitty medium, but okay :-D
 
cmb
@Derick, just noticed that 7.4.0RC4 ships with ZE 3.4.0-dev
 
@MarkR from the viewpoint of an open-source project that sucks. From the viewpoint of an unpaid hacker who "wants to be the first to publish" it's understandable
 
cmb
@Sjon, scanning NEWS for CVEs doesn't require any hacker skills, though
@brzuchal, I think these changes would be too much for PHP 8, due to the amount of required work.
 
@cmb I am also not a huge fan of combined getters and setters, ftr, I did that mostly to align with the existing vt100 windows function thingy, but that is a trivial refactor. I'm still working on the last couple of bits (specifically, x-platform getting the terminal dimensions and a windows-specific function to read low-level input events) but I am going to try and put a PoC impl together over the weekend
 
@cmb Agree, but do you think returning multiple values could be considered in a future as a way to expose new API with return values and error values?
I can see many functions could use them without a need to promote warnings to exceptions debate, like that:
`strpos(string $haystack, mixed $needle, int $offset = 0): (int,false)` called like this `$pos, $found = strpos(‘foo’, ‘bar’);`
`preg_match(string $pattern, string $subject): (int,bool)` called like this `$match, $error = preg_match(…);`
 
9:40 AM
@bwoebi I only just realized that typed properties perform autoloading, while argument types don't
Is there a reason for that?
Triggering autoload is slightly more correct because it can handle class aliases, but this seems like a weird inconsistency
Might be a leftover from the time where we needed resolved types for references?
 
@NikiC IIRC you intentionally added it to typed props, just for resolving class aliases?
 
@bwoebi For inheritance only (we do it there for arg types as well)
 
ah no, you added it to union types for class alias resolution
 
@cmb looking at bugs.php.net/bug.php?id=78599 I'm pretty sure they are released by the person that found it?
 
@NikiC Hm, what's the overhead in a typical frameworky project if we were to autoload always on args?
 
9:49 AM
I'd expect not high, as it would essentially only happen on error (or first time on class alias)
but well, we don't load for instanceof checks either
 
cmb
@Sjon, well, fair enough
 
I feel like we probably should make property types consistent for 7.4 and load everything (if we want) in php 8
 
cmb
@DaveRandom, +1 :)
@brzuchal, I haven't actually thought about that, but find these error returns a bit strange.
 
@NikiC not sure whether we need to defer that to PHP 8. Yeah, we are late in the release cycle, and we probably should make it consistent. But whether we change args or typed props, does it really matter?
I tend to want to autoload everything right now in PHP 7.4
don't like it too much to release something new with a planned (small) semantics change in the immediate next version without a good reason (consistency is not a good enough reason)
 
@bwoebi I'm not really sure if we want to change it
For example, not doing autoloading side-steps the question of how autoloading and union types behave ^^
 
9:54 AM
@NikiC well, you anyway have that question for inheritance
 
@bwoebi inheritance is tricky ^^ but avoids doing any class loading unless strictly necessary
 
@NikiC yeah, that's why I'm wondering about the overhead if we were to always autoload
 
@bwoebi For inheritance overhead is very high, but chances are good that the type hint may never be used at all
 
@NikiC yep, the latter part is what I'm wondering about - what's that overhead of autoloading things which don't get used outside of typehints?
 
@bwoebi I don't have any specific data, but it can clearly have a pretty bad worst case situation
Where you end up loading a whole graph of classes that you don't use
 
9:59 AM
Yeah hm.
 
Which (apart from loading perf itself) will also take up SHM space
 
sounds sane to not autoload then
 
10:45 AM
Morgens
 
cmb
\o
 
Wes
\o
 
\o
 
Wes
today went running for the first time after the operation \o/... could've done earlier but i was lazy
 
What does that mean? 🤔
Oh i see.
 
Wes
10:51 AM
it's a head and an arm, a person waving
\o
 |
/\
 
you forgot to add the thing
 
Wes
gross
 
Wes
11:08 AM
@NikiC and everybody. So my idea is that exceptions shouldn't be used unless they are fatal, that is, what you'd call unchecked exceptions. Truly exceptional error conditions, Not data "validation" errors. That said, you can't avoid them for certain things. for example if you want to return a validation error from a constructor you can only use exceptions. Here comes the question. What do you think of the following solutions:
1- introduce checked exceptions and hope people would not abuse them like they did in java (it's the people, not the programming language)
dave, levi, pee, cmb, bwoebi ^
 
@Wes What would you call a database connection error?
That would, conceptually, be a checked exception, it can be specifically predicted in advance. But I would still want it to be a thrown exception.
 
Wes
not exceptional?
 
@Wes 4. use named constructors
 
@Wes An error connecting to the database is not exceptional?
How about disk failure while reading a file?
 
Wes
well, it is subjective
 
11:11 AM
@Wes I validate before hitting the constructor
 
@Wes Let me ask it another way. How would you otherwise handle database connection errors?
Check for NULL? isConnectionSuccessful()?
 
Anything wrong in the constructor is an exception
 
Also, re: 2 - That you found the behavior very surprising should be a clue for you that it's probably not an amazing solution, as it violates the law of least WTF.
In fact, that particular feature of returning from constructors in JavaScript was, IIRC, put there by Facebook to solve a Facebook specific problem, because they are on the committee.
Not for any novel technical reasoning.
 
Wes
@MadaraUchiha i don't
 
@Wes Really? Even when you can recover?
Say, by retrying?
 
Wes
11:15 AM
in that case i wouldn't use an exception
 
The entire point of the catch part of try/catch is the ability to recover
There is literally no point to exceptions, if you can't catch them and recover. Just use E_CHUCK_NORRIS_ERROR that is unrecoverable in any form, and be done with it. No need to add the extra complication.
 
Wes
catch and finally allow me to do cleanups
meaning i don't want to resume normal execution, but i want to terminate gracefully
 
@Wes I disagree (with the sentiments, not the factual correctness of what you said).
catch allows you to recover, and you can elect not to recover by not catching.
finally allows you to execute some code whether the try was successful or not.
It is a catch-all exception handler that allows you to do cleanups
 
How can I write cmd > $TARGET in a way that allows setting $TARGET to something like 1 or 2?
 
Wes
but of course exceptions were meant to do something but after years of usage the reality is that they are a disaster
 
11:20 AM
And a disposer (which doesn't exist in PHP per say) that allows you to dispose of resources.
 
Assuming that /dev/stdout are not accessible
 
@Wes That's because y'all are using exceptions for things that aren't exceptions, I agree with that. Just not with where you put the line.
Database connection errors are Exceptions, checked Exceptions--in fact, and they are recoverable.
Validation errors aren't exceptions, especially not in a validation function whose entire point is to find the validation errors. Validation errors are expected in that context, not exceptional.
But a connection failing, or a disk failing, or the power going out, are all exceptional situations, that sometimes can be recovered from.
 
@JoeWatkins washing elephants? releases?
 
I think that what you're missing is disposers (see Java's "try with resources" and C#'s "using")
This prevents the whole try {} catch {} finally{try{} catch{}} mess when disposing of things
 
#0  0x00007f4c0290c3cb in xhprof_execute_ex ()
#1  0x000055bc574e4ecb in zend_call_function ()
#2  0x000055bc575138a9 in zend_call_method ()
#3  0x000055bc573f010e in zif_spl_autoload_call ()
#4  0x00007f4c0290d166 in xhprof_execute_ex ()
#5  0x000055bc574e50d3 in zend_call_function ()
#6  0x000055bc574e5471 in zend_lookup_class_ex ()
#7  0x000055bc574e5e28 in zend_fetch_class_by_name ()
 
11:26 AM
@Wes JavaScript's exception system is far more loose than PHP's (you can throw 'lol'; for crying out loud), and yet the community as a whole is much more responsible in their use of exceptions in general in JavaScript than they are in PHP. Like you said, "it's not the language, it's the people"
 
Other than just include/require'ing a file, or using eval, is there any other, maybe quite unusual way of autoloading a class in PHP?
 
@Danack There are functions that trigger autoloading
 
Wes
@MadaraUchiha we can argue about databases and stuff but i was focusing more on the fact that in constructors i can only use exceptions, regardless the error is exceptional or not
 
@MadaraUchiha throw () => () => () => () => () => 'lel'
 
@brzuchal yes please. Tbh, this just needs better doc block+ return type support.
 
11:28 AM
@Wes But constructors can throw, the construction of an object might, in fact, fail.,
 
@PeeHaa got an example please?
 
IIRC is_a is an example that may autoload
 
@Danack Yeah, but TBH I think it would be a big BC break in ZE, cause returning multiple values could be a complex change to ZE, right?
 
Same for *_exists and is_subclass_of
 
Wes
@MadaraUchiha what if i want to return null instead
 
11:30 AM
@cmb Yay! it works under Win platform )) Only one test for function redefinition fails...
 
@Wes try, and replace with null in the catch
It is considered bad practice to do work in the constructor, but it is not illegal.
 
Assuming that's the unusual ways you are looking for @Danack
 
Say I have a class that represents a File, and I do the fopen and stuff in the constructor. And let's say, for the sake of argument, that fopen throws an exception if it fails.
 
Your new File() might now throw
 
11:32 AM
@brzuchal No? It'd just be an array, right? I do it in userland - return [$error, $results]; but it's annoying as docblock/return types don't support it, so autocomplete fails, which make me tired.
 
Which is perfectly legal, and even okay.
I would fine it extremely surprising if after a seemingly successful $file = new File(), the value of $file will be NULL.
The "promise" of a constructor is that after it is successfully completed, you have an object in usable and stable state.
Violating that promise does not come cheaply.
 
Wes
that's just because you are used to that
 
@Wes constructors are not functions
 
@Wes Anything else is just madness
 
they have no return value, anyway
 
11:34 AM
@DaveRandom ...yeah, that's a less travelled code path.
 
@Danack I bet @Ocramius has done something like that somewhere at some time
maybe not quite as egregious as that, but certainly something weirdly magical
 
Conceptually speaking, a constructor is a hook the language gives you to do stuff after the creation of an object (just like a destructor is a hook the language gives you to do stuff before the destruction of an object).
It is not a factory.
 
@PeeHaa More on the other side, after the engine has decided to load a class, what unusual things can be done to actually load that class. The context is a segafault, that looks a lot like a use after free on a string, but I don't have access to the code to debug currently.
 
A factory might return null in certain cases, a constructor may (or at least, should) not.
 
@Danack Good luck :P
 
Wes
11:36 AM
@PeeHaa explain why
 
cmb
@lisachenko, good news, thanks! I assume that you're looking into this failing test. :)
 
@Danack returning multiple values is different thing than returning an array, yes it cannot be done using docblock or proper type hint, it could be done with sort of anonymous struct typehint for eg function foo(): struct {string, bool} { /* function body */} but I was thinking about function foo(): (string, int) { return $content, $errcode; } and then calling it with only first returned value or both: $content = foo(); or $content, $errcode = foo();
 
@Wes Because I like to know whether my object is in a valid state?
 
The promise I mentioned ^
 
Wes
11:37 AM
@PeeHaa ? how would that prevent you to know that
 
@MadaraUchiha wrong terminology imo, constructors don't "return" anything, they have nowhere to return it to. The new operator creates an instance, runs the ctor as a void function using the instance as a $this context, and returns the instance
there is no return value, new either returns an object or it throws
 
@DaveRandom Yes, a constructor's return type is void.
 
@cmb yes, I'm trying to figure out why it fails... Method redefintion works well... Strange...
 
@Wes How would it? Without extra checks in random places
 
Wes
@MadaraUchiha ok but why the hook is good and god forbid the constructor is a factory
 
11:39 AM
@brzuchal "then calling it with only first returned value or both:" - my instinct is I don't like that. In particular as it means you can't figure out if the code was deliberately written to not use all the values, or it's just a bug. The Go style of throwing away values you don't want - like [_, $content] = foo(); is far nicer than having the code be ambiguous.
 
@Wes If you want to use a factory, use a factory, it's insanely easy to do, especially with static methods having access to private properties and methods on objects of their own instances (yes, that's a thing)
But that's just not what the constructor is.
 
Wes
are you reading from a book dude
why there should be a difference with a regular factory
and why you think it's good
 
@Danack Ok, then structs could be good feature, I need to put time on them
 
cool. And yes.
 
@Wes Why should you not use class User extends DatabaseConnection? It gives you access to the database connection, after all
Because that's not what extends is, even through it does exactly what you want.
 
11:41 AM
Naming question: if the log format is %h %l %u how do you call an individual element like %h?
 
Wes
@PeeHaa i am not following you. i am simply saying that functions like DateTime::createFromFormat are constructors that return false on error, while new DateTime() can only throw
 
@PeeHaa placeholders
 
thanks
 
@Wes They are not constructors, they are factory methods
 
^
 
Wes
11:42 AM
2 mins ago, by Wes
why there should be a difference with a regular factory
 
@Wes A factory function is a function that accepts stuff and returns something, hopefully a fully formed object.
A constructor is a function that accepts stuff, and has a context ($this), and prepares the state of $this, so that the object's state is usable.
 
Wes
while new Something returns cheese
 
By the time the constructor is invoked, the object is already created.
 
Wes
you are right, it's totally an entirely different thing
 
The difference is subtle, but it is there 🤷
 
Wes
11:44 AM
you don't need to differentiate
 
@Wes So just don't use constructors dude, make all your constructors private, and use static factory functions exclusively, and your problem is solved
The userland solution here isn't unthinkable or even particularly ugly.
 
@MadaraUchiha but it takes a tiny bit more typing !!!1! How do you epxect people to live with scuh a terribal birden!
 
Wes
@Danack yes, it's a stupid distinction
 
@Wes I think that idea would be better implemented in userland if function autoloading was present.
 
11:47 AM
@Wes To be perfectly honest, I also don't think that DateTime::createFromFormat() should ever return anything except for a DateTime object.
 
I think constructors are just sugar for static factory functions
 
There's a reason the C-style "return an error code and if you return 0 it's golden" way is no longer prominent.
DateTime::createFromFormat() should either return a fully formed DateTime, or throw a DateFormatException.
The only real reason that it's there as a static method to begin with, is because PHP has no method overloading.
You barely get those in Java, you just overload the constructor.
 
Wes
you just described what i would love php developers did less :P
 
@MadaraUchiha I think it should always return a DateTime class, but if it's invalid, a subclass of DateTime which contains a way to access the error
 
@bwoebi Invalid Date can be a valid state of the DateTime object.
 
Wes
11:50 AM
exceptions are overly abused, and everything is much worse as a consequence of the fact that they are essentially unchecked in php
 
@MadaraUchiha or that, yes.
 
But I'd rather it just throw an exception, really.
 
Wes
because nobody's gonna bother do @throws annotations
 
@Wes yes. and checked exceptions have their own set of problems
 
speak for yourself
 
11:51 AM
I love to abuse me some exceptions, but ultimately that's my responsibility
 
@MadaraUchiha and there is where we disagree
 
I'm not a huge fan of exceptions, mind you. I think Common Lisp did it much better with signals and restarts (where's @Florian when you need him?)
But figure a way to signal errors, and use them, no need to invent 42 different ways to do the same thing at the language level.
 
Wes
@bwoebi yes, i have a rfc ready for checked exceptions but i don't want to be the man who turns php into java first blood part 2
 
how would you declare it?
 
My only real problem with exceptions is that they irrevocably unwind the stack.
 
11:54 AM
legit use cases for exceptions: programmer errors (extends Error) and issues stemming from I/O issues, but not in low level I/O functions.
 
So your only real options are to handle it in-place, give up on the current execution, or use global (or global equivalents) to pass a handler from above.
Exceptions would have been far more useful if you could go up the stack, select a recovery strategy, and optionally go back down the stack and execute that strategy there.
 
Wes
@MarkR declare?
you need to read the motivations of the c# creator on c# having no checked exceptions
 
@MadaraUchiha like __except in windows SEH?
 
@bwoebi I have no idea what any of that means :D
 
Wes
i mean unchecked exceptions suck but abused checked is likely worse
 
IMHO anything which sends an E_WARNING should get converted into an exception, this is my own preference of course, and I enforce it with set_exception_handler... because I hate that a function sets error information "somewhere else" that you have to retrieve with some unrelated function call
 
Wes
there are programs with dozens of exception names in
public void bar() throws ............... infinite list here .......... {}
 
> EXCEPTION_CONTINUE_EXECUTION (-1) Exception is dismissed. Continue execution at the point where the exception occurred.
 
@bwoebi Not exactly, but close.
With common lisp, an expression might signal a Condition. The Condition can have strategies (Restarts) attached to it (as well as default strategies supplied by the language)
 
Surely that's just like shoving a global callback onto the top of a separate stack that gets invoked directly after an exception is called
 
12:00 PM
The Condition may be caught by any step higher up in the stack, and if a Restart is selected, it is executed in the context (with full lexical scope) of the place that signalled the Condition.
 
@MadaraUchiha so, sort of like signals for sigbus, sigsegv etc. which you can install handlers for?
 
The handler may also choose to recover at its own stack level (same as traditional Exceptions), and if you don't recover at any stage, the default is to break into the debugger.
@bwoebi Not quite, it's not an external source that fires a signal or an interrupt.
And the catcher may select a Restart offered by the Condition, or implement its own Restart.
For example, since Common Lisp has no statements (only expressions), one default Restart is replace-with, which just says "continue the execution where it started, and use this value in place of the expression that signaled"
In particular, consider this example: I have a log parser, it iterates a file line-by-line, and does something. Some of the log entries are malformed. I want that, during development, the program explodes if it encounters a malformed entry, but in production, I want to just skip the malformed entry and continue with the rest.
You can't easily do this with traditional exceptions, because you don't want the low level parser to know whether it's in production or development (it's a high level decision), but if you throw an error, and you don't handle it within the loop, you will break out of the loop and you can't implement the skip.
cc @bwoebi last 2 messages ^
 
Hello all. I'm trying to connect to a local mysql database (wamp server).

I'm following this tutorial http://www.androiddeft.com/connecting-android-app-remote-database-using-php-mysql/#Fetching_All_Movies_Retrieving_data_from_database (only followed the "Adding a new Movie" because I am not interested for the rest).

When I connect to the database (with db_connect.php on tutorial above) it successfully connects. However, when I try to make a POST request via postman, this is what I get https://ibb.co/gjwwhh3
 
12:20 PM
hello guys,

I'm trying to eleminate duplicates in pie chart
I've tried the SELECT DISTINCT but not helping , still getting duplicates

what should I use to selve the problem ? any advise ?

here is my code:

//include database connection
include 'db_connect.php';

//query all records from the database
$query = "SELECT DISTINCT * FROM cloud_team";

//execute the query
$result = $mysqli->query( $query );

//get number of rows returned
$num_results = $result->num_rows;

if( $num_results > 0){

while( $row = $result->fetch_assoc() ){
 
@MadaraUchiha ironically, you can do this with error handlers, if you trigger_error(), then you could decide whether to throw or "just" emit the warning
@MadaraUchiha you also need to consider that a program must be in a recoverable state at the place where the exception is thrown. I.e. in Lisp you are aware that you need to clean up after signalling. In PHP you just throw the exception and then the current scope may be in a not safe to continue state.
when you do emit a warning, you are aware that it will continue though
So, the way to go is sort of coding the soft way (emit warning) if we want to be able to be more resilient in production - and have it throw via error handler.
We just should have then named error handlers or something like that
But the foundations are there, just in form of error handling
 
12:36 PM
HI all
How can I use PECL for windows
I am using php 7.0
 
cmb
@Exception, you can check if there are suitable DLLs at windows.php.net/downloads/pecl/releases
Otherwise you'd have to compile the DLLs yourself.
Probably easier to upgrade to some support PHP version.
 
12:51 PM
Morning
 
@cmb what did he do to you? No-one deserves that
 
04:00 - 13:0013:00 - 00:00

« first day (3294 days earlier)      last day (1651 days later) »