« first day (4275 days earlier)      last day (656 days later) » 

5:50 AM
@Crell I just realized what I often do and probably many developers who use Psalm for eg. the preconditions could help get rid of many pseudotypes used by static analysis tools
/**
 * @param A::FOO | A::BAR $s
 */
function foo(string $s) ensure $s === A::FOO || $s === A::BAR : string {
  switch ($s) {
    case A::FOO:
      return 'hello';

    case A::BAR:
      return 'goodbye';
  }
}
taking the examples from psalm documentation
the same goes for `positive-int`, `non-empty-string`, `non-empty-array` etc.
and also most of `@psalm-assert` statements
 
6:04 AM
but I didn't get from the article how returning on multiple channels might work
*require instead of ~ensure~
 
 
1 hour later…
7:30 AM
oh, I get it in form of error codes and exceptions
 
cmb
7:58 AM
@LeviMorrison Oh, an easteregg! Just set a cookie MD=1 and request a page.
 
8:35 AM
@brzuchal That really should just be an enum now.
 
@Derick yes, in this specific situation ofc it should
in subject of contracts I found they raised proposal in 2015 github.com/dotnet/roslyn/issues/119 to get them as a part of language syntax
then it turned into another proposal in 2017 github.com/dotnet/csharplang/issues/105
and the topic is still open
 
Can type hint or return type cost performance issue? I use them a lot in my app
 
@Mwthreex That is not an optimisation you should worry about.
 
 
4 hours later…
Wes
12:29 PM
i just found someone in their (early 20s maybe) that has never unzipped a file before
i had to explain it
are you from the past
 
everybody is from the past...
 
"This photo is of me when I was younger"...
 
yeah, no shit :-D
 
12:56 PM
Welp I'm working on making the DBA test suit run in parallel, so tests can run even faster (probably not that much tho because only 70 tests)
 
cmb
1:15 PM
@Girgias Are we running most of the DBA tests only with 1 handler (which likely would be flatfile)?
 
gettype(...func_get_args())
gettype() expects exactly 1 argument, 0 given
when the function args is empty, what is the return of ...func_get_args() ? None ?
 
@cmb It shouldn't, CI should run the tests with the different handlers as the dba_handler.inc file is included for different driver tests
But now that you said that we do have a bunch of redundant tests that I'll get rid of while refactoring the test suite
@Mwthreex You do know the documentation exists right?
 
@Girgias Can you guide to this particular issue ?
 
@Mwthreex No read the docs
 
Which part of doc i mean ?
 
1:20 PM
???? Just read the function doc
 
@Girgias What is the return of ...func_get_args() ? it return None but except Null
 
Bruh
Do you even know what ... does?
Also you really shouldn't be using func_get_args()
 
If there function doesnt have any args and when we call ...func_get_args(), What it return to us ?
I try to find the answer by gettype(...func_get_args()) but it failed
 
cmb
1:35 PM
@Girgias But this is only a single test for each driver, and while the test is somewhat comprehensive, some functions are not tested by that test (e.g. dba_optimize() and dba_sync()). Maybe we should introduce redirect tests?
 
@cmb I'm already redoing the whole test suite, so I can add optimize and sync test support for each driver
 
cmb
cool
 
And I've found a MemoryLeak bug in an unexpected way so that's neat
 
1:48 PM
@brzuchal Totally skunkworking (and this wouldn't work for PHP):
fn divide (arg2: int, arg2: int)
  requires arg1 > 1,
  requires is_positive(arg1)
  channel<return> float ensures is_positive // same as return float
  channel<error> DivByZero // same as error DivByZero {

  if (arg1 == 0) {
    error DivByZero;
  }
  return self / arg1;
};
Where you could in theory define any number of returning channels, and the caller would have some way to determine which channel was used for the return. Which... ends up being isomorphic to an Either monad.
 
@Crell ok but if we wanna avoid adding unlimited amount of channels then error could just be a new keyword and that's it
Think of an use case where you end up with more than 2?
 
Right. I think it would be cool to have an unlimited number, but in practice 2 is probably sufficient. And that's basically what Midori ended up with, and what Rust does using Result.
 
Anyway, preconditions, postconditions and invariants would be a start if ever.
class Email {
    public function __construct(public string $value) invariant filter_var($value, FILTER_VALIDATE_EMAIL) {}
}
Wonder how that could work
class Email {
    public function __construct(public string $value) {}
    invariant filter_var($value, FILTER_VALIDATE_EMAIL);
}
Or maybe this
 
cmb
You could mostly do this with some AST manipulation; preconditions are assert()s at the beginning, postconditions are assert()s at the end of a function. Class invariants are assert()s at the beginning and the end of methods.
 
2:12 PM
Yeah, that's basically what Midori did, it seems. The require/ensure directives turned into assertions at the start/end of the function. But that meant they were still static analyzeable and served to communicate to developers and tooling what the rules were.
Give or take quibbling over syntax, that seems quite doable for PHP.
Midori also had the ability to compile those assertions away if it could statically guarantee they were always true, which is probably a lot harder for PHP.
 
cmb
@Crell I'm in favor for supporting design by contract. We would need to figure out some details, though, like how to do assertions regarding the return value.
 
Not knowing how that part works internally, I'd imagine either we'd need to generate the assertion opcodes for each return statement (easy but bad) or force return values through some choke point operation where the assertion opcodes can be generated (harder, but probably better).
 
cmb
2:37 PM
I wasn't that far. :) I merely wondered how to express postconditions regarding the return value, since there is not necessarily a variable involved. In some other languages, you can say post result > 10, but how to express that in PHP?
bugs.php.net hates me :(
 
Oh, I see.
 
@cmb A possibility obviously is to assign meaning to a standalone dollar sign
 
cmb
2:52 PM
Good idea!
 
$$ T_BLING
 
Most recent proposal for C# from my links seems to be a variable called result
public int Add(int val1, int val2)
   ensures result <= int.MaxValue
{
   //This line would result in an exception when checked mode is turned on
   return val1 + val2; // <- this fails the contract. int.MaxValue + int.MaxValue is larger than int.MaxValue
}
 
I have found a 22 year old comment in the docs. I am keeping it for posterity.
 
:D
In general assertion exceptions are abortions and cannot be caught, right?
Or am I messing something.
 
3:07 PM
Currently, assertions throw an Error, which means they could be caught but you really shouldn't.
 
cmb
^ that
 
Ohhhh right. IMO the should be more like exit
 
Well... there's really several different classes of unhappy path that all should be handled differently, and PHP's current tooling doesn't conform well to any of them.
This is an area I've been informally looking into, but I feel like I should do serious research in. It's a fascinating topic and most languages fail at it. (The Midori model described in that article is the best I've seen so far, but I don't think it's necessarily perfect yet.)
 
@brzuchal No, exit()/die() are silent failures, the fact that they are exceptions mean they blow up and give you good information
You can also catch a TypeError or a ValueError although 99% of the time you don't want to, but it's IMHO a very useful feature to be able to do that the couple of times you want
 
@Crell do you have this on your GH somewhere?
 
3:20 PM
Just local at the moment, but happy to share it.
 
I'm curious to see what it has
 
I think it would be a good thing to expand into a full setup and usage script.
 
Me too :P
 
The PHP 8.1 image I'm using is apparently quite out of date... :-)
 
Just a bit lol
I like it. After working at a place that has a makefile for a lot of stuff, I'm coming to prefer it
 
4:29 PM
@Girgias Invaluable for things like Amp. I want buggy code or assertion failures to hit the logger, not bring down the entire server.
 
@Trowski And for testing php-src for error cases, so you don't need one test per failure for stuff which is not a parser/compile time error
 
4:42 PM
@cmb I'm pretty sure the "tests" for dba_optimize and sync are utterly useless and don't actually test their functionality
 
cmb
@Girgias At least dba_optimize.phpt is (and also it asserts that the handler is flatfile, which is an implementation that shouldn't exist). However, the only meaningful check I could see is that the filesize should decrease after the call (and not even for all handlers).
 
Yeah that's what I imagine it should do
 
cmb
Most handlers implement it as NOP, though. heap.space/…
 
5:02 PM
@Tiffany How could we evolve that into something more complete that we can tell people to use?
@cmb I don't know that I've done a snippet entity yet, but I can give it a shot. (re mkdir docs.)
 
cmb
@Crell There is already something roughly suitable. Maybe we should use that.
 
Oh, yeah, that should be close enough. I'll drop that in. Stand by.
Hm, the tip says "filename", but the param is actually "directory". Do we care? :-)
 
 
2 hours later…
6:53 PM
I made first of the PRs for php-master github.com/php/web-master/pull/15
 
7:04 PM
@Crell I have a couple of ... not even ideas, but more like feelings on how, but I'll need to think on it
 
7:14 PM
@Tiffany OK. No rush on my end, it does what I need it to for now. Just seems like something that could be helpful for others in the future.
 
8:13 PM
Go home, strtotime, you're drunk: 3v4l.org/dHqTd
The second line there has got to be a bug...
 
@Crell Fixed, it'd probably break nice amount of production applications. :D
 
Dear god in heaven, how did this language ever survive???
 
No one answers stackoverflow.com/questions/72821382. Is it clear? It's about optimization algorithm. Can someone do it please? Thanks.
 
Oh my god, it gets worse: 3v4l.org/hisi3b
 
8:31 PM
Ahahahah.
 
9:08 PM
Oh good. And I'm getting a parse error on CI that I don't get locally. That's fun.
@cmb github.com/php/doc-en/pull/1669/files - CI doesn't like the refsect1 here with no role, but my local is fine with it. What should I be doing there instead?
 

« first day (4275 days earlier)      last day (656 days later) »