ocramius,
@ocramius@mastodon.social avatar

Looked again at a #PHP codebase written/maintained in PHP 5.5, where new code is designed and added on the existing app.

Made me realize that the only thing I miss from newer PHP versions is strict type checks, which came with PHP 7.0.

Everything else was provided by @psalm or @phpstan

From my PoV (person that reads internals, follows/votes on RFCs, etc.), there are almost zero feature additions that make newer PHP versions interesting.

Not justifying staying back: just noticed this.

saramg,
@saramg@fosstodon.org avatar

@ocramius @psalm @phpstan And people will still insist that upgrading is hard because the language is changing too fast. Sogh... :)

ocramius,
@ocramius@mastodon.social avatar

@saramg more like: "upgrading is hard because nobody writes automated software verification (tests)"

kboyd,
@kboyd@phpc.social avatar

@ocramius @saramg Just to push back a little; upgrading was hard for one of my projects, because it was based on a discontinued framework that would never be made to work with PHP8. Upgrading involved a full rewrite of framework touchpoints and orchestration, and there are still leftover quirks that haven't been fully solved.

But, yes, the many functional tests I had previously written helped a lot, once I hacked enough pieces together to get them running again.

karptonite,

@kboyd @ocramius @saramg I’m in a similar situation with a huge application based on multiple discontinued frameworks. We are on PHP 7.4, and upgrading further, when we do so, will be a major undertaking.

ramsey,
@ramsey@phpc.social avatar

@ocramius @psalm @phpstan I love PHPStan/Psalm, but if someone else is using my code, and they don’t use static analysis, then they’re out of luck, and their code could have sneaky bugs they don’t know about until it’s too late because my library didn’t guard against bad input.

ramsey,
@ramsey@phpc.social avatar

@ocramius @psalm @phpstan This is also why I’m not in support of erased types for generics within the language. That’s truly a case of “just use PHPStan/Psalm because you get the same benefits.”

ocramius,
@ocramius@mastodon.social avatar

@ramsey I gave up on that problem, and instead added tooling to enforce usage of SA 😁

https://github.com/Roave/you-are-using-it-wrong

heiglandreas,
@heiglandreas@phpc.social avatar

@ramsey If people want to shoot themselves in their own foot they will find amazing ways to do so. And even more amaz8ng ways to blame someone else.

There is NO safeguard against that.

After all there are still people out there that do not want to use composer. Not "they are not using it". They actively work against it.

Stop pampering those people!

/cc @ocramius @psalm @phpstan

heiglandreas,
@heiglandreas@phpc.social avatar

Yes! That includes WordPress!

I'd be interested in how many autoloaders there are in one WordPress site....

/cc @ramsey @ocramius @psalm @phpstan

SenseException,
@SenseException@phpc.social avatar

@heiglandreas @ramsey @ocramius @psalm @phpstan I'd be glad if they don't shoot in my foot.

ocramius,
@ocramius@mastodon.social avatar

@SenseException depends on total per-shot billable amount, TBH

I both provide foots to shoot oneself into, as well as foot maintenance/repair work.

SenseException,
@SenseException@phpc.social avatar

@ocramius Did you open a shooting gallery?

alessandrolai,
@alessandrolai@phpc.social avatar

@ocramius @psalm @phpstan i would bump that to at least 7.1 (nullable types, void).

I would agree with you, but recently I'm really enjoying refactoring code with enums, and that you can't do on 5.5 (without a lot of user land cruft).

ocramius,
@ocramius@mastodon.social avatar

@alessandrolai myclabs/enum was really good for a very long while

pwaring,
@pwaring@fosstodon.org avatar

@ocramius Type declarations for parameters, return types, and class members are the biggest win for me, even if strict type checks are not turned on. Before then every function and lots of variables had to have PHPDoc comments for IDEs to type-hint.

ocramius,
@ocramius@mastodon.social avatar

@pwaring yes, but I'm fine with using just the docblocks too (on PHP 5.5).

Makes zero difference, once a proper type checker is in place.

ocramius,
@ocramius@mastodon.social avatar

Note: strict type checks are interesting because they disable some implicit engine behavior (runtime type coercion at call time), so it's some sort of feature removal.

Ironic.

wyri,
@wyri@haxim.us avatar

@ocramius IIRC strictly typed also runs faster when typed, right? But yeah started noticing the same, only 8.1 with fibers was big for me. The rest are sweet to have, but @phpstan and @psalm take care of so much more than that.

edorian,
@edorian@phpc.social avatar

@wyri do strict types improve performance?

Do you have any benchmarks for that? That would be quite interesting.

I haven't seen much adoption on production applications (seen some more adoption in libraries).

While Stan/Psalm haven't changed much for all the code I've seen (over what big applications were already doing with phpstorm), but performance would be an interesting use case for strict types at least.

wyri,
@wyri@haxim.us avatar

@edorian IIRC from back when type hints were initially introduced: it goes down a different code path in the engine as it doesn't have to figure out the type of something, it either matches or fails. Let me see if I can find something on it

edorian,
@edorian@phpc.social avatar

@wyri nice!

I can also do some testing myself but if you find something I'll happily take it :)

wyri,
@wyri@haxim.us avatar

@edorian Let me know how those tests go, details are very little on this and https://wiki.php.net/rfc/scalar_type_hints_v5#behaviour_of_weak_type_checks seems to imply it but actual hard confirmation on the subject would be nice.

edorian,
@edorian@phpc.social avatar

@wyri

Very synthetic testing showing a 1-2% speedup.

Interesting but not quite enough to care? (Assuming I didn't make any errors here or that there are optimizations that make this a bad test).

<?php  
// declare(strict_types=1);  
$foo = 1;  
$bar = 'asd';

function baz(string $a, int $b) {  
 return $a . $b;  
}

$i = 10_000_000;

$x = '';  
while(--$i) {  
 $x .= baz($bar, $foo);  
}  
ocramius,
@ocramius@mastodon.social avatar

@wyri yup: it's obviously tons of renovation work going on under the hood, but there was no large paradigm shift anywhere.

If you brought PHP 5.5 on par with PHP 8.2 with bugfixes / security (not features), it would be almost as viable as the newer version.

This lack of radical change can be seen both in good and bad light.

rob,
@rob@akrabat.com avatar

@ocramius @wyri No-one wants a Perl 6 or Python 3 event in their language.

wyri,
@wyri@haxim.us avatar

@rob @ocramius Since #PHP 4.3 we have an event loop: https://www.php.net/stream_select

Also the language would need to rework how to run radically to make that feasible IMHO

ocramius,
@ocramius@mastodon.social avatar

@rob @wyri certainly: just saying that there wasn't a "can't do without" feature.

In fact, ::class was the last "can't do without", IMO :D

ciaran,
@ciaran@social.ciaranmc.com avatar

@ocramius @rob @wyri even that's just some string magic...

Generators are cool

wyri,
@wyri@haxim.us avatar

@ciaran @ocramius @rob fibers are cooler. But event loop + fibers + generators is the best

nanimal,

@ocramius @rob @wyri There was that fiber thingy back in 8.1 which was exiting for some people. Personally in want Generics baked into the language and oh! Collection, Map, Vector, monadic functions, an HTTP client baked into PHP, a pipe operator, something to replace ?:, something similar to go fmt, a test framework build into php, and a package manager.

nanimal,

@ocramius @rob @wyri Oh! And the deprecation of PHP arrays :3

kboyd,
@kboyd@phpc.social avatar

@nanimal @ocramius @rob @wyri Nooooooooooo! PHP arrays are my favourite thing across all languages I've worked with. Such a wonderful messy mess, they are.

chrastecky,
@chrastecky@phpc.social avatar

@nanimal @ocramius @rob @wyri Don't you already have a http client? With streams and the IO functions. Though it's very low level.

wyri,
@wyri@haxim.us avatar

@chrastecky @nanimal @ocramius @rob Fair, you could use file_get_contents as a HTTP client

Crell,
@Crell@phpc.social avatar

@ocramius @rob @wyri I'd put constructor promotion in that bucket, too. Sure you can just use a class name as a string, but ::class is way better. Same with CPP.

And all the null-handling tools. And match.

Really, modern PHP has evolved a ton. Not just in the type department.

ocramius,
@ocramius@mastodon.social avatar

@Crell meh: https://mastodon.social/@ocramius/111131225597921885

Null handling with PHP 8 was a nice API restriction.

koehnlein,
@koehnlein@mastodon.social avatar

deleted_by_author

  • Loading...
  • ocramius,
    @ocramius@mastodon.social avatar

    @koehnlein I did, but they are not ground-breaking: I could achieve that with @reactphp or similar, if that was the focus

  • All
  • Subscribed
  • Moderated
  • Favorites
  • php
  • ngwrru68w68
  • rosin
  • GTA5RPClips
  • osvaldo12
  • love
  • Youngstown
  • slotface
  • khanakhh
  • everett
  • kavyap
  • mdbf
  • DreamBathrooms
  • thenastyranch
  • magazineikmin
  • megavids
  • InstantRegret
  • normalnudes
  • tacticalgear
  • cubers
  • ethstaker
  • modclub
  • cisconetworking
  • Durango
  • anitta
  • Leos
  • tester
  • provamag3
  • JUstTest
  • All magazines