9 ms·
PHP 7.2.0 Released
- rurban 9y agoLiterally only object as new typehint, not the classname of the object? This doesn't really help much. https://wiki.php.net/rfc/object-typehint https://wiki.php.net/rfc/object-typehint Looks like they went back into perl-mode
- TazeTSchnitzel 9y agoI actually have a patch and draft RFC for a classname type declaration, but I'm not sure whether to do anything with it.
- deleted 9y ago[deleted]
- pgl 9y agoYou can do this in methods by putting the class name before the argument.
- tylerjwilk00 9y agoClass based type hinting has already been available since 2004 with 5.0 [1] This release adds support for the general standard object type. [1] http://php.net/manual/en/functions.arguments.php#functions.arguments.type-declaration http://php.net/manual/en/functions.arguments.php#functions.a...
- rurban 9y agoOk, that makes sense. Thanks
- Belphemur 9y agoYou can already type name your classes and even primitive type. You don't have only "object".
- Can_Not 9y agoPreviously you could only specify class names and interfaces, now you can specify object (any object of any class, including StdClass). Mostly only a way to type hint "not array or any scalars". The class names has been around a while and is usually way more useful.
- TazeTSchnitzel 9y agoIt's weird for a bug fix I wrote to be top of the list of features. PHP 7.2 is not the most eventful release.
- pgl 9y agoHow comes a bug fix has an RFC?
- TazeTSchnitzel 9y agoIt's a long-standing and documented issue; there wasn't the will to fix it. In that sense it's “not” a bug. It's also, well, just complicated and potentially controversial enough (significant performance decrease!) to warrant one.
- Narutu 9y agoYes, strange for a bug fix to be top of a list of features, however... I don't agree that it's "not the most eventful" release:- libsodium being included into the core is a big tick in the box in terms of maturing as a language; modern - secure - cryptography out of the box.
- weberc2 9y agoI'm surprised PHP hasn't had this for a while. Isn't PHP nearly 20 years old? Is it common for web languages to grow so old before they get crypto in the standard library?
- Narutu 9y agoYou are right, of course, but nonetheless this is a significant step forward for the language (and the ecosystem as a whole). I do hope that - just like yourself, I am sure - the next significant step is more organically and proactively developed, and not treated (at least in the wider communtity's eyes) as a belated addition to a bewildered leviathan.
- Can_Not 9y ago
- JepZ 9y ago> Counting of non-countable objects Sounds like fun :D But actually, the RFC suggests to add warning, so nothing too special :-/
- ChrisSD 9y agoWhat is PHP like nowadays? I know it has a bad reputation and a history of kitchen sink design but have they managed to tame it into something more sensible? Do the docs help steer developers away from legacy issues and common bad patterns? Would anyone recommend it for new projects?
- romanovcode 9y ago> What is PHP like nowadays? Would anyone recommend it for new projects? It is not bad at all but since there are so many good/better alternatives I would never start a fresh project with PHP nowadays. The only reason would be if you have a team with PHP experts - then PHP would be the obvious choice.
- matdehaast 9y agoUnsexy yes, but stable and works a charm for most of the scale people here will deal with. What alternative would you suggest for newer projects?
- bpicolo 9y agoIf you’re looking towards hosting on shared style infra, php is still the choice. Also if you just have experienced PHP devs Python is a pretty great alternative - it gives you more breadth to go wide than PHP does (batch processing, hadoop, machine learning, whatever really) but really there are like 10-20 different languages in the ecosystem that are all viable candidates.
- donatj 9y agoPersonally working with PHP at a pretty large scale (hundreds of thousands of requests per second), I think it’s scaling is far simpler, easier, and cheaper than a lot of other options I have used, in particular node. The simple threading model applies to many cores and across a large fleet of servers with basically zero effort.
- melicerte 9y agoAgreed 100%, someone should give names and strength compared to PHP instead of just saying alternatives are better.
- velmu 9y agoSeems like a solid gradually improving release and according to some benchmarks [1] and notes from the development team, improved performance as well. Nothing like the jump the ecosystem enjoyed from 5.6 to 7.0, but still around 10% on average. [1] https://symfony.fi/entry/php-7-1-vs-7-2-benchmarks-with-docker-and-symfony-flex https://symfony.fi/entry/php-7-1-vs-7-2-benchmarks-with-dock...
- deleted 9y ago[deleted]
- devwastaken 9y agoOne of the biggest improvements is that Libsodium is now built-in. https://dev.to/paragonie/php-72-the-first-programming-language-to-add-modern-cryptography-to-its-standard-library https://dev.to/paragonie/php-72-the-first-programming-langua... No more Mcrypt, less cases of having to use OpenSSL and using it wrong. This is a huge security step towards the future.
- drostie 9y agoThe other thing is that they have partially fixed the most "wat" bug in PHP: for some arrays that aren't even all that hard to come by when interacting with JS, the following code could change `count($arr)`: foreach ($arr as $key => $val) { $arr[$key] = f($key, $val); } The issue is that `$key` could be a string describing an integer, but `$arr[$key]` will automatically see that you're using a string-int and convert it to an int-int, setting a different key than the internal one. It's only a partial fix but it hits the most common case: you have a JSON payload that happens to have an index of objects which happens to have been given numeric keys: { "abcdef": {"prop1": "hello", "prop2": 123}, "987132": {"prop1": "world", "prop2": 456} } If your framework hands JSON to you as a StdClass object then you would typically convert this to an associative array since that's semantically what it is: as opposed to the internal entities, which in this case appear to be full-fledged objects. (The difference is that the keys of a full-fledged object should be known in advance at a data-schema level and have a control structure of getting/setting `->prop_name`; the keys of a dictionary should be user-settable and have a control structure of `foreach ($dict as $key => $val) {}`.) So the bug still maybe exists in some fringe cases as the underlying cause is not treated, but it is now autofixed by the common idiom of casting `$dict = (array) $params->dict`.
- megous 9y agoI would typically write: foreach ($arr as $key => &$val) $val = f($key, $val); This would avoid this issue, while bing simpler.
- cletus 9y agoI use Hack now (I work for Facebook) and i kinda like it, at least in comparison to any untyped languages. So, serious question... Is there really any reason to use PHP over Have?
- donatj 9y agoUbiquity? Easy installs?
- krapp 9y agoI like Hack as well, although just as a hobbyist, but it doesn't seem to have gotten a lot of traction. Hosting options appear limited, and support for HHVM seems to be decreasing, rather than increasing. Many developers seem hesitant to use anything tied to Facebook after the React patent license controversy. Hack's biggest success thus far seems to be serving as a wakeup call to PHP itself. What it needs as a language is some version of PHP's ubiquitous hosting infrastructure, preferably one that supports calling Composer with HHVM and allows XHP as well, and actually gets updated and maintained (I'm looking at you Openshift.)
- muglug 9y agoYes. HHVM has now explicitly diverged from PHP, so compatibility with PHP 7 code is not guaranteed, and so too any given PHP 7 library. If you work for Facebook (or Slack), this is not a problem. You still have talented engineers working to improve the language. But there also isn't the guarantee that those improvements will benefit the average use case. Also PHP is available everywhere. HHVM, not so much.
- jrs95 9y agoThis has been a huge disappointment for me. Hack seemed really promising, but some of the decisions they've made really seem to have strangled any hope of there being much of an ecosystem outside a few companies that are heavily invested in it.
- pjmlp 9y agoISP hosting.
- pabl0rg 9y agoI will use PHP 7.2 on projects I maintain. However, starting a web project with Kotlin in 2017 has a minimally larger set-up cost (have to understand gradle or kobalt) than PHP, but is definitely a better option. Check out http4k or ktor and squash (orm)
- theodorejb 9y agoOne of the most significant changes in PHP 7.2 is actually the list of features that it deprecates. Among other things, this includes: - Unquoted strings - The __autoload() method - The track_errors ini setting and $php_errormsg variable - create_function() - each() - The $errcontext argument Numerous internal optimizations and language improvements will become possible in PHP 8 when these features are removed. http://php.net/manual/en/migration72.deprecated.php http://php.net/manual/en/migration72.deprecated.php
- aviso5 9y agoAwesome