yabones 8 hours ago

Appears the big scary vulnerability that was announced recently is in 8.5+, so definitely upgrade your stuff if you're on a new version... For the rest of us in "debian land" running 8.3-8.4, looks like there's nothing to worry about for now.

https://github.com/php/php-src/security/advisories/GHSA-8mjj...

https://github.com/php/php-src/security/advisories/GHSA-2fjv...

The other Critical CVE looks very very difficult to actually exploit, since it has to do with a very specific configuration during startup.

https://github.com/php/php-src/security/advisories/GHSA-gr4f...

beberlei 13 hours ago

Most excited about the ZTS overhead reduction. If you are unfamiliar PHP can run either with or without thread safety (think using pthreads in PHP requests).

If the overhead can be further reduced (and people have ideas) then it could be that we only need ZTS mode anymore in the future and that can open up one avenue for PHP to get native async support similar to the existing parallel extension: https://github.com/krakjoe/parallel

More "hands-on" is the stream error handling improvements. This greatly improves the old file stream APIs to now allow throwing exceptions instead of returning false on errors:

  $context = stream_context_create([
    'stream' => [
        'error_mode' => StreamErrorMode::Exception,
    ],
  ]);

  try {
    $config = file_get_contents('/etc/app/config.json', context: $context);
  } catch (StreamException $e) {
    // handle error
  }
  • calvinmorrison 12 hours ago

    That's certainly a use case but I worry async opens the door for all the non PHP to come on in

  • jmyeet 10 hours ago

    Spawning threads in PHP is a mistake. The beauty of PHP is that a given request is single-threaded. Any IO/network bound calls allow off-thread code within that same async-await model. If you want to spawn threads, put it in an extension.

    • whalesalad 1 hour ago

      you are assuming that the work is happening inside of an http request context. what about background tasks? workers? cli tooling? etc.

  • gertop 7 hours ago

    Async is about IO, you can already do that in PHP with generators.

    Instead of let x = await func(); it's $x = yield from func();

    Also ZTS is more about running in threaded servers like Apache worker or IIS, it's not about user threads.

    • beberlei 4 hours ago

      Yes you need to combine it with Fiber's API but it works, but cumbersome, especially integrating with existing libraries and things that are for the shared nothing world.

      Most code in PHP would easily run in a thread, but working in Fibers requiring a complete rewrite.

p4bl0 9 hours ago

I'm a bit sad that there's still no way to limit the number of arguments of a user-defined function in the type system. The internal functions have that.

I know that introducing such a behavior by default could break existing code, but it seems relatively easy to introduce this feature in a backward compatible way by using the void type. For example :

    function foo (void) {}
    foo(42); // fatal error: foo() expects exactly 0 arguments, 1 given

    function bar ($a, $b, void) {}
    bar(1, 2, 3); // fatal error: bar() expects exactly 2 arguments, 3 given

    function baz ($a, $b=null, void) {}
    baz(1, 2, 3); // fatal error: baz() expects at most 2 arguments, 3 given
  • odder 5 hours ago

    What is their stance on breaking existing code?

    I was testing some PHP ~5 code in 8.3 and there was some questionable backwards compatibility decisions. eg methods that previously returned true / false to indicate success now threw errors, same message signature and all.

    • krick 4 hours ago

      PHP is EXTREMELY backwards-compatible in general. All breaking changes are (i.e. were up to this point) usually introduced very gradually, first emitting Notices and Warnings and not without a very good reason.

      • abanana 3 hours ago

        For a certain value of "gradually". Whether it's too fast or not comes down to opinion (and some of the changes themselves come down to a difference of opinion on how a given language feature "should" work), but it's the reason so many old sites are stuck on PHP5 - because it's not fully backwards-compatible.

        A poster phrased it well on here recently¹: "in general lots of users being on unsupported releases should also cause some reflection why that is. E.g. maybe support periods are too short or there are too many breaking changes with new releases."

        ¹ https://news.ycombinator.com/item?id=50194270

  • Tadpole9181 5 hours ago

    Probably possible to just set up PHPStan or Mago to do this statically, no?

  • duskwuff 4 hours ago

    > I know that introducing such a behavior by default could break existing code

    Specifically because older versions of PHP didn't have "..." arguments - variadic functions used func_get_args() to access their arguments.

nticompass 10 hours ago

I /finally/ just upgraded our PHP app from 7.4 to 8.3 (totally not just because of the PHP vulnerabilities). I can't wait to jump to 8.5, so I can use the pipe (`|>`) operator.

I'd love to upgrade to 8.6 so I can use function partials!

  • noir_lord 9 hours ago

    `|>` without PFA frequently ends up with longer code and isn't pretty because of the need to handle the first arg not been the one you want via closures which works but isn't really any better than just nesting them, so if I where you upgrading I'd get to 8.6 first and then start using pipes since you get both parts in that release.

    It was a smart decision to roll it out incrementally but it did create a weird gap there for a little bit but they did do it so kudos to the team.

    • OkayPhysicist 4 hours ago

      It's definitely the kind of feature that you want to bake in before you start implementing user-facing functions. Elixir does this right (the first argument to a standard library function is damn near always the one you'd want to pipe in), but other languages I've seen it in are far more hit or miss.

  • asimovDev 9 hours ago

    a lot of stuff will require changes when jumping from 8.3 to 8.4 and above. Don't forget to use Rector[0] if you haven't already. Helped me tremendously when going 7.4 > 8.4

    0 - https://getrector.com

    • nticompass 9 hours ago

      Rector is great! It's what I used to help migrate from PHP 7.4 to 8.3. I did still have to manually fix things and there was one spot where Rector broke the code, but I don't know what I'd've done without it.

ModernTimes 5 hours ago

Got hit with the deprecated metaphone() function, but Gemini wrote me a PHP native drop-in replacement, wish me luck.

williamdclt 9 hours ago

I can't make up my mind on FPA. On the one hand it's very elegant and I always feel like I need it when writing code, on the other hand it makes a function declaration look reaaaaally close to a function invocation, which is super confusing

  • jmyeet 8 hours ago

    So there are two potential problems being addressed by this.

    1. The chosen example is for PHP versions. That might just be the example but this sort of thing is a real problem. Personally I prefer something like the polyfill method as seen in Javascript where possible. Python has to deal with this too since it seems like every 3.x release now makes breaking changes. That might be just be their trivial example; or

    2. Closures. Looking at the linked doc that seems to be a use case. PHP suffers here (IMHO) from having a really poor type system. Having closure arguments as question marks seems... inelegant. I'd really prefer to be able to type those and also know that the variable I have itself is a callable of some kind. I always point to the Hack type system as a comparison here.

    So I dislike the name "partial function arguments" because it's unclear what the purpose is. If they're closures, call them closures. If PHP's PFA's can't bind variables (I didn't look into whether they could or not, call them something else?

    The word "partial" here is really what I'm having issue with. I'm reminded of partial classes from C#, which solved a problem of creating part of a class from, say, a config file. The first example I saw was WPF using XML to define UI elements where the framework compiled the XML into partial classes and you had to fill out the rest for it to compile. I guess it's a bit like declaring a header and then failing to link an implementation (in the C/C++ world).

grzes 2 hours ago

do you guys now if PHP 8.6 will be included in upcoming Debian Forky?

kijin 13 hours ago

Before you all get excited about the new version, patch the old version you're running now!

The PHP team announced that they're going to release a critical fix between 14:00 and 14:30 UTC today. Doesn't say whether 8.6 is affected too, but the vulnerability is probably at the top of their mind right now -- even more so than the 8.6 release.

  • beberlei 13 hours ago

    There are two separate teams handling both, the Release Managers and website team do PHP 8.6 and the Security team works on the vulnerability. :)

  • TimWolla 12 hours ago

    The PHP 8.6.0 stable release will include the fixes for all applicable vulnerabilities.

    • Joel_Mckay 9 hours ago

      And add a few more unknown CVE, as perpetual Beta and DevOps culture does by design.

      The old approach of out-pacing adversaries though mutation rates is over, given an entire FOSS code-audit looking/fuzzing for 0-days can now be done in under a day. In retrospect, over 700 reported LPE and 280 kernel CVE were dropped in the past 3 months from "LLM". This is not going to stop anytime soon.

      To be honest, its very nostalgic as kids would clown each others servers in the early days. Ultimately leading to a more robust OS for everyone. =3

  • faangguyindia 12 hours ago

    we run serverpilot, it auto patches our php server.

  • 1317 11 hours ago

    another one?

  • 40four 10 hours ago

    ”These releases are part of PHP’s regular four-week release cycle and will address security“

    So I’m not sure what you mean by “before you get excited”? This is their normal release cycle, not some new emergency patch release. Although based on recent events, I see how this could be confused.

    • bnycum 9 hours ago

      The notes say "The highest severity is CRITICAL.... Users are strongly encouraged to prepare to upgrade promptly once the releases become available. Technical details and fixed version numbers will be published alongside the releases."

      I'd say this sounds pretty serious.

      • 40four 8 hours ago

        No doubt, I’m sure they are indeed “critical”, my point is that this is part of the regular cadence of maintenance releases. Every PHP server SHOULD upgrade. But that’s no different than any other language, when a security/ maintenance release comes out, you upgrade.

        The parent comment seemed to be mistaking this for another unplanned security release like we had recently for the 2 RCE vulnerabilities.

        • philipwhiuk 3 hours ago

          There are critical vulns patched in the older releases at the same time.

jmyeet 9 hours ago

I'm honestly disappointed at the number of snark comments on HN about PHP. It's like posting 2007 memes. Yes, we all know the story of htmlspecialchars(). We can make fun of "global" when we don't realize "global" actually means "request scoped". We get it.

I've always viewed PHP as having these ideal features:

1. A stateless functional core. It's cheap to run and quick to start. Compare this to Java or even Python. There's no loading a bunch of class libraries;

2. Every request has an environment created then torn down. That means it's hard for a given request handler to leak memory or other resources. You compare this to, say, Java's servlet API (which only really existed because the startup costs were too high) where resource leaking is a real problem and then you get into GC and STW pauses; and

3. Every request is single-threaded. This is ideal. Async network/IO requests are handled via extensions. You should never need to spawn a thread in a request handler directly. You eliminate a whole class of bugs by doing this.

Is PHP perfect? No. The class separator as the backslash still offends me more than a decade later. I really wish Facebook's Hack had become PHP because it's got a vastly better type system, core collection classes (list, vec, dict) and it did things a decade ago that PHP is only added with this release (eg polling).

As for partial functions, the use case seems to be versioning? I actually prefer the Javascript polyfill method here where possible. Don't make users care about this kind of stuff.

  • ryangittins 9 hours ago

    As they say, there are two kind of programming languages: the ones people complain about and the ones no one uses!

    • senfiaj 4 hours ago

      Some ancient languages have massive usage for historical reasons, but it doesn't mean we should use them for new projects. COBOL is still heavily used in US finance system, it doesn't mean it's a good choice for a greenfield financial system or enterprise application. PHP's situation is better than COBOL, but it's not the best especially for complex enterprise systems. I myself work on such system using PHP and I know what I'm talking about. Type safety kinda sucks, we heavily rely on PHPDoc annotations for complex types, still, in many places no guarantee that the returned thing will not be null, or the returned array is a normal array or a sparse array, or that array contains only integers, etc. It's really annoying. Arrays suck badly, why on earth I need some hybrid of a hash map and an array? And this is why it has so many issues. And why should this be true "0.1" == ".1" when 2 different strings are compared?

  • idoubtit 8 hours ago

    My main worry with PHP is that its surface constantly grows. This means the language is

    1. more complex to use (it took years for some parsers to implement the PHP 8.4 property hooks, and I suppose few people can explain how they work with inheritance and traits), 2. more costly to maintain (I remember when the developer of PHP's JIT left, the PHP foundation was worried because no one could understand the JIT code), 3. and has more security risks (critical security releases will continue).

    I don't disagree with you, but the situation is more nuanced, and PHP's initial promises are now blurred.

    > 1. A stateless functional core. It's cheap to run and quick to start.

    Most modern codebases use a framework. And once you have to load Wordpress, Drupal, or even worse, Laravel, then it's no longer cheap and quick. So PHP added several layers of complexity to mitigate this: an opcode cache, a code-preload system...

    > 2. Every request has an environment created then torn down.

    That's no longer always true. When the code preload is enabled, a request can leak into another.

    > 3. Every request is single-threaded. [...] Async network/IO requests are handled via extensions.

    You mixing up two different things. The default PHP SAPIs have single-threaded request handlers (though IIRC the default deploy stack of Laravel differs). But the language has a native async feature through Fibers, from which coroutines can be implemented (see amphp/amp).

    So PHP on the server side is usually like JS on the client side (except for workers): single-threaded with async. Though I haven't seen much use of Fibers in the wild, it's in the language.

    • moebrowne 8 hours ago

      > once you have to load Wordpress, Drupal, or even worse, Laravel, then it's no longer cheap and quick

      The frameworks aren't slow: https://tideways.com/profiler/blog/php-benchmarks-8.6-vs-8.5...

      • idoubtit 4 hours ago

        From your own source, a basic demo with Laravel peaks at 95 requests/s/core. It's worse with Wordpress at less than 20 r/s/core. That's slow.

        The last round of TechEmpower web benchmarks computed the framework overhead. Depending on the task, the performance of Laravel was 5% to 20% of the native PHP code, i.e. 5 to 20 times slower. Source : https://www.techempower.com/benchmarks/#section=data-r23&tes...

        • moebrowne 1 hour ago

          These benchmarks are garbage, the last round was nearly 2 years ago, there's no explaination of where the "performance scores" come from and the GitHub repo is archived.

          The TideWays benchmark doesn't show the peak, it shows the rps for 15 sustained users.

          • TimWolla 1 hour ago

            > The TideWays benchmark doesn't show the peak, it shows the rps for 15 sustained users.

            Yes. And it's also not entirely representative of a production set-up. As an example Vegata is running on the same machine as PHP and the same is true for the MySQL server used by WordPress and Laravel. The tests are also running against a - except for worker count - stock installation to possibly highlight improvements by better INI defaults in newer PHP versions. This is all good enough to compare the different PHP versions against each other, since they are all equally affected by this. But it is thus by no means representative of what you can get out of a properly tuned production setup.

            Disclosure: I set up the benchmark and performed the measurements. PS: It's Tideways, lowercase 'w'.

    • ape4 7 hours ago

      It would be nice if you could request that unused parts be disabled. Maybe in the first line of your file.

    • jmyeet 4 hours ago

      > That's no longer always true. When the code preload is enabled, a request can leak into another.

      That's in the same bucket (to me) as, say, L1/2/3 cache leaking between CPU threads. That's resulted in real attacks but it's not really the fault of my programming. I would rather the bug be in the language or the compiler/interpreter or even the framework because it's more likely to get found and fixed than if it was only code written by me for me.

      As an aside, PHP eliminates a whole class of bugs that don't exist in, say, C/C++ eg string buffer overflows. Yes, the PHP engine can itself have buffer overflows but as per my previous point I trust the library developers and the volume of people who use and analyze it more than being totally correct with my own string handling.

      > But the language has a native async feature through Fibers, from which coroutines can be implemented (see amphp/amp).

      Only a single fiber runs your PHP request at any one time. This still fits the same model.

vdanielpop 13 hours ago

Can we not have animations that slow down my scroll on these kinds of pages? It's so pointless.

Edit: Thank you for pointing out the `prefers-reduced-motion` media feature, I did not have that enabled.

  • PetahNZ 13 hours ago

    I didn't notice any animations?

    • TimWolla 13 hours ago

      The page respects the `prefers-reduced-motion` media feature [1]. You might have enabled that preference.

      [1] https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/A...

      • gregoriol 11 hours ago

        Designers should not design things that users want to disable

        • Timon3 10 hours ago

          The vast majority of people prefer animations. If everything got left out that anyone wants to disable, we'd be left with `return 0`, if even that.

          • mrob 10 hours ago

            The vast majority of designers prefer animations. Without animations, there would be less jobs for designers. But I haven't seen any evidence that ordinary people prefer animations. Most ordinary people aren't even aware that it's possible to turn animations off, because the designers make this difficult.

            • jasonlotito 10 hours ago

              > But I haven't seen any evidence that ordinary people prefer animations.

              There are mountains of evidence supporting the idea that people prefer animated UIs over static UIs going back decades. This is true even in the world of TUIs, again, going back decades. I genuinely don't understand how you can make this statement so confidently.

              • edoceo 9 hours ago

                Where can I find this evidence?

                • stronglikedan 7 hours ago

                  Asking this in the age of AI says a lot...

              • simondotau 9 hours ago

                Maybe if the question is “hey was that fancy animation really cool?”

                Animation, used judiciously to communicate valuable information about the UX, is good. Most of the rest is only tolerable so long as it doesn’t slow anything down or change how scrolling works.

                • mrob 8 hours ago

                  A UI should be reactive rather than proactive. Any state changes should be explicitly requested by the user, who naturally knows what they requested, making "informative" animations redundant.

                  However, there is one legitimate use for UI animations: making it easier for spectators to follow what's happening. Spectators aren't the ones making the requests, so they can be confused if things happen too fast. Most computer use is not done for the benefit of spectators, so animations should be disabled by default, but it's beneficial to have the option of enabling them.

                  • Timon3 3 hours ago

                    > Any state changes should be explicitly requested by the user, who naturally knows what they requested, making "informative" animations redundant.

                    I can't really follow your thought process here for two reasons:

                    1. "Informative animations" (I interpret this as not-feedback-for-UI-interaction animations) are usually based on the response, not the request. So the user doesn't know the info which the animation communicates.

                    2. Most users immediately want some tiny acknowledgement of their request, e.g. a button's state changing (base -> pressed -> active/disabled). If the request takes longer than a few seconds, users really want a loading animation - otherwise they're less likely to wait until the response comes back, even if they know that it takes a long time. At least that's been my experience.

                    • mrob 3 hours ago

                      We had functionally complete GUIs in the 90s. If something takes more than a few milliseconds to respond after 3 decades of hardware progress there's definitely something wrong.

                      • Timon3 2 hours ago

                        If we're talking about local CRUD, sure, but that's a tiny minority of use cases. As soon as your application does network requests outside your LAN, less than a few milliseconds is impossible for most regular users and developers. That's not to mention tons and tons of processes that definitely take more than a few milliseconds, like: compiling a meaningfully big codebase, compressing/uncompressing most files, rendering a video, ...

                        Those are just a few examples. What is the "something" that's wrong with all of us?

          • nchmy 9 hours ago

            i despise most animations. Its only something that "product people" want

            • Timon3 4 hours ago

              Again, the vast majority of people prefer animated UIs to non-animated ones. My own anecdotal experiences in building UIs and talking to end users over both short and long time frames supports this.

nticompass 10 hours ago

Gotta love all the "PHP bad" comments that appear on any PHP post (regardless of what it's about). I, for one, am I excited about this release. Modern PHP (php8+) is pretty nice and a lot of the old "PHP bad" issues from back in the day are non-existent.

Though, I guess I've been a PHP developer for a long time now. Professionally, since 2012 and has a hobby years before that. I refuse to stop learning/using PHP!

Yes, there are other web server languages. Yes, PHP had its issues. Yes, legacy PHP can be pretty awful (ask me how I know). But, it's not going anywhere and all the "PHP bad" comments are not helpful.

  • DJBunnies 9 hours ago

    Indeed, I started typing out a few replies only to delete them after remembering what you've articulated.

    PHP (still!) rocks; I'm quite happy it's still relevant (and powers much of the internet.)

    But I'm an old man who got into the language during the 3-4 migration around 2000.

  • Jach 3 hours ago

    Yeah, the most shallow "PHP bad" comments are pretty annoying, but they sometimes have a point, and there are always new programmers who don't know any history. One of the bug fixes I saw today was for an issue that's been around for 20 years and is another consequence of PHP's decision (IMO a bad one) to have a unified "stream wrapper" API such that functions named, for example, file_get_contents(), can be passed a URL rather than a file. If that URL was httpS or HTTPS (i.e. an uppercase S), then the bug now fixed was that PHP would ignore TLS and initially connect over port 80 and make the initial request (along with sending whatever else) over plaintext. It could also successfully follow a redirect to actual https but hide that it leaked data in the initial request. This is just such a PHP thing. I've at times acted the apologist for PHP, it was my first language over 20 years ago so I'll always have some fondness for it, but in my heart I do think it fundamentally sucks and can't be evolved to stop sucking.

    The last time I did any professional work in PHP was probably 2012, though. Since then I've only maintained a couple things I originally made myself, and on rare occasions have written a standalone script or two (I think the last one was about 3 years ago) and it still makes me happy that I can just rsync things up to my site. Thankfully the maintenance work has been very minimal, but in contrast I've not been excited about any PHP changes since the early 5 days, and my upgrades from 5 to 7 to 8 were mostly just going "huh" (though sometimes "Eh? wtf") at the new features while being wary of breaking changes (the upgrade guides over the years have been helpful and there haven't been many breaking changes). When I look at modern PHP, it's structured quite differently to how my old waiting-to-be-rewritten maintenance sites are, and I don't like it, I just think it's become a worse Java, and most professional deployments seem to use a big framework and have a whole deployment workflow (vs. just copying a few files) so again why not just use a Java workflow that'll be at worst equally cumbersome but without all the PHP nonsense. On new language features specifically, I stopped getting excited over those in any language once I found my way to Lisp, where if you want some language feature, you don't have to wait for some committee to add it, you can just add it (or someone else has already added it, or it's always been there since before I was born). It's nice when other languages play catch-up, sure (though sometimes they implement something worse than not having it at all), but I can't ever muster excitement...

PaulHoule 3 hours ago

Love the partial function application syntax but it's a little scary to me that people are writing PHP scripts that use select, Xpoll, etc.

krick 4 hours ago

Ok, let's see what do we have in here.

Not a huge fan of partial function application syntax. Was it really necessary when you already have short anonymous function? What does it cost you to write that explicitly? Like, 10 extra characters? It is way more readable and clear what you mean when a variable has a name, not just `?`. WTF is `?`?

Pretty much the same for DocComments for params. Uh... why? I don't see anything wrong with the old way.

Duration class... well, we all already had duration classes in our projects, didn't we? It looks alright, but it's a real pity operator overloading isn't a native part of the language still. Why do we still have to `->add()` instead of `+`?

Similarly harmless but not hugely exciting are `clamp()` and `SortDirection`. The former isn't that hard to implement, but I don't think I ever did somehow, so thank you. SortDirection is literally just a built-in enum, not a huge deal. Libraries will still use their own implementations for a long time just to preserve back-compatibility.

Polling... Well, I'd usually opt for some other language instead of using PHP like that, but sometimes you need it.

Stream Error Handling and Readonly Defaults are great and overdue.

All in all, doesn't look to be a terribly exciting update.

  • moebrowne 1 hour ago

    > What does it cost you to write that explicitly? Like, 10 extra characters?

    The given example is 26 additional characters, and that's without any type declarations. Also calling closures isn't free, there is a small performance penalty.

        fn ($version) => version_compare($version, '8.6', '>=')
    

    vs

        version_compare(?, '8.6', '>=')
    
    

    > Pretty much the same for DocComments for params. Uh... why?

    The reason is that docblocks are used to attach meta data to code, like generics.

    > SortDirection is literally just a built-in enum, not a huge deal. Libraries will still use their own implementations for a long time just to preserve back-compatibility.

    Symfony at least conditionally defines a SortDirection enum in the global namespace: https://github.com/symfony/polyfill-php86/blob/1.x/Resources...

pwmglenn 11 hours ago

Partial application in PHP? WOW.

shdon 11 hours ago

I guess the clamp function really is needed, as even in their release notes, they did the clamping using min/max incorrectly.

Their PHP8.5 examples are written as:

  var_dump(max($value, min($lower_bound, $upper_bound)));

but that should be:

  var_dump(max($lower_bound, min($value, $upper_bound)));

/facepalm

  • TimWolla 11 hours ago

    > Their PHP8.5 examples are written as:

    That is false. The bounds are [0, 100] in both examples and 0 is correctly put as the first parameter to max() in 8.5.

  • 6510 8 hours ago

    I would actually write it like:

        $value = max($value, $lower_bound);
        $value = min($value, $upper_bound);
        var_dump($value);
    

    10 years from now I can thoughtlessly scan over that without having to think what is going on.

    This is great:

        clamp($value, $lower_bound, $upper_bound);
    

    It's even more readable.

    And since I cant stop typing... (sorry lol)

        $trucks  = trucks($ordernum);
        $boxes   = $boxes_per_truck * $trucks;
        $bananas = $bananas_per_box*$boxes;
        $bananas = max($bananas, $lower_bound);
        $bananas = min($bananas, $upper_bound);
        var_dump($bananas);
    

    In stead of:

        var_dump( max($lower_bound,min($boxes*$bananas_per_box*trucks($ordernum)*$boxes_per_truck,$upper_bound)));
    • tosti 6 hours ago

      Yes. Write code like how you would do math on paper. Code should be readable without syntax highlighting. Turn it off and it's easy to tell where readability is poor.

  • Heliodex 3 hours ago
        max($value, min($lower_bound, $upper_bound)) when $value < $lower_bound: $lower_bound
        max($value, min($lower_bound, $upper_bound)) when $value > $upper_bound: $value
        max($value, min($lower_bound, $upper_bound)) when $value is between them: $value
    
        max($lower_bound, min($value, $upper_bound)) when $value < $lower_bound: $lower_bound
        max($lower_bound, min($value, $upper_bound)) when $value > $upper_bound: $upper_bound
        max($lower_bound, min($value, $upper_bound)) when $value is between them: $value
    

    If the former was what's actually written then yeah, it would be incorrect. However, if you swapped arguments 1 and 2 for each clamp() call, they'd give the same result, and for what you say the PHP 8.5 example is written as, there's no call given where $value > $upper_bound.

    I don't know if this makes much sense, though that's all the more reason for needing clamp().

origini 13 hours ago

Ah yes the clamp() function good thats in

durmusk 10 hours ago

Hopefully not another php2shell

AuthorizedCust 9 hours ago

Why is this language still around?

I get the popularity and installed-base arguments, but I shudder when I see the code.

rarisma 11 hours ago

Perhaps it will contain something new that will come back to haunt us in six or so months.

phplovesong 12 hours ago

Still no builtin unicode support? What the hell is this? A web language that does not default to unicode, thats pretty weak for a language in 2026

  • vrubleg 11 hours ago

    The idea of UTF-16 strings in PHP 6 were a mistake. UTF-8 works in PHP just fine. New languages (e.g. Rust, Go, Swift) stick to UTF-8. UTF-16 is legacy that would be nice to get rid of where it's used (Java, C#, JS, WinAPI), but that is impossible because of backwards compatibility.

    • phplovesong 7 hours ago

      PHP6 was such a huge lol overall. The core devs seem so far gone its crazy. I see the odd php apologist every now and then, but luckily PHP use has been on the decline for the last decade and a half.

      • 40four 7 hours ago

        Obviously PHP 6 was a huge “lol”, they abandoned the version number completely. I didn’t start working with PHP until v7 so I missed all of that, but what does any of that have to do with v8.6? Seems like you just want to resurrect ancient buried arguments nobody is worried about anymore.

    • downsplat 7 hours ago

      Hindsight is 20/20, it's easy now to say that if Unicode had been utf8 from the start, no 16-bit encoding would have been needed anywhere. But someone had to think of it first, and in the real world, 16-bit came first and became quite entrenched.

  • downsplat 9 hours ago

    The php convention is that strings are bytes, but we store utf8 in them. Convert or validate at ingestion, transform using the mb_* family of functions, and be happy.

    • phplovesong 7 hours ago

      I have heard this exact answer for decades. The mb_slop_uppercase() is not, and should not be acceptable for any modern language.

      • downsplat 7 hours ago

        It's a big world out there, it's not like you don't have a choice. I quite like the model.

        Perl was famous for excellent native unicode support in its native string type, but the result was that you had to keep track of whether your variable was native unicode or octets, and many CPAN modules would try to transparently support both, in buggy ways. A richer system is not always an advantage.