12 ms·
Upcoming changes in PHP 7.1
- maaaats 10y agoThis is just an excerpt from https://dotdev.co/upcoming-changes-in-php-7-1-76ebea53b820#.yjkkwzdtx https://dotdev.co/upcoming-changes-in-php-7-1-76ebea53b820#....
- pori 10y agoMy favorite feature is definitely the square bracket destructuring syntax. This is great for bringing tuple-esque operations to the language.
- elgenie 10y agoIt doesn't bring tuple-esque operations to the language; it's a shorter alternate syntax for the already existing "list()" destructuring syntax.
- spdionis 10y agoBut honestly with the shorter syntax it feels much more natural, compared to the weird "list" construct. Just an opinion though.
- stiGGG 10y agoi dunno, i found that kind of special functions which are actually language constructs like list(), isset(), etc always ugly. Ok, some more syntax sugar to let these things not look like normal functions is of course an improvement, but i wish they would do some more radical changes to the language. Why not add multiple return values like in golang to achieve that syntax? Isn't exactly that list() should emulate in some way? Than deprecate that list() crap and throw it away in 7.2. But instead they will keep that list "function" forever along that new bracket syntax because they are afraid some code from the 90s would break. On the other hand they don't stop adding minor complete irrelevant changes that break existing code from yesterday.
- tegansnyder 10y agoThat is a more comprehensive list. Thanks for sharing.
- sideproject 10y agoOff topic, but curious - Is there any discussion on whether there will be a support for a good concurrent programming in PHP in the future? (e.g. channels in Go & Elixir) - of course, you might say "you're using the wrong tool.."
- kevinmgranger 10y agoThere's amphp[1], and a community effort to make the different sync frameworks interoperable[2]. 1: http://amphp.org/ http://amphp.org/ 2: https://github.com/async-interop https://github.com/async-interop
- m4tthumphrey 10y agoReact has been around for a while - http://reactphp.org/ http://reactphp.org/
- goldbrick 10y agoThis is not really concurrency, though, it just makes PHP resemble NodeJS.
- raspasov 10y agoI don't know if you can classify it as "good" concurrent programming but there's this https://github.com/krakjoe/pthreads https://github.com/krakjoe/pthreads EDIT "pthreads v3 is restricted to operating in CLI only" - from the project page.
- sideproject 10y agoThis one does look promising. I didn't know they re-written it for PHP7. But still looks like an early days. Might wait a bit!
- raspasov 10y agoIf I were you I'd explore a language that goes beyond those low level concurrency constructs because they can be extremely tricky to get right. Clojure and Elixir would be my top choices and the final choice depends on the kind of system you're trying to build.
- codeulike 10y ago... Note the syntax isn’t the usual double pipe || operator that we associate with or, rather a single pipe | character ... ... PHP 7.1 introduces visibility modifiers to constants ... ... With PHP 7.1 it is now possible to specify that a function has a void return type, i.e. it performs an action but does not return anything ... ... Example four contains numeric values, so everything else is stripped out, and the sum of those are used to calculate the total of 10. But it would still be nice to see a warning, as this may not be intended behaviour ... Good to see PHP continues to introduce new inconsistencies while striving to break existing code by fixing old ones. Best of both worlds! edit: OK this was uncharitable and technically some of them are not inconsistencies, just things I thought were weird. I know PHP is widely used and considered useful and will stay with us forever. But I found those snippets interesting.
- moonshinefe 10y agoWhich inconsistencies are those? Functions that return; or don't return at all already return null in PHP.
- codeulike 10y agoI suppose its not an inconsistency as such, but I included it because I thought it was funny.
- naranha 10y agoI wonder why PHP includes more and more type checks and visibility features, when all those checks are performed at runtime. What good does it do when your code suddenly throws a fatal error at runtime because you did not respect the type specification. I mean, I get that type checks are useful for IDEs, but enforcing these rules at runtime using fatal errors just does not make any sense to me.
- TazeTSchnitzel 10y agoIf they're not enforced at runtime, then they're unsound if you have typed code calling untyped code. And as the maker of the sibling comment notes, runtime type checks still catch errors earlier than no type checks. Moreover, having these declarations actually be part of the language, even if the interpreter itself cannot enforce them ahead-of-time, means tooling can be built around it, and we can use them for optimisations in the VM (which PHP 7.1 does: we elide type checks on certain arithmetic operations for operands of known types). If you want to ensure type safety before the program actually runs, you can of course let your IDE or static analyser check that for you.
- naranha 10y agoPHP looks more and more like Java.
- arenaninja 10y agoIt can, though it doesn't have to, at all. PHP still has a very low entry barrier compared to Java. You can opt in to all of the syntactic sugar, or none at all, which is the way it should be.
- mr_than 10y agoOr Typescript...but that makes me happy. IDE help and type checking that code you haven't touched in months is so worth it
- TazeTSchnitzel 10y agoI'm more excited by some features not detailed in the article. Return type declarations, which were introduced in PHP 7.0, are being enhanced somewhat. First, it's now possible to declare nullable return types (previously all return types did not permit null): public function getFoo(): ?int; (You can also use ? on parameter and property types.) Second, we now have a void return type for functions where there is no useful return value: public function handle(): void; (Disclaimer: I wrote the void return type RFC and implementation, so I'm biased here.) We're also getting type declarations for class properties: class Person { public string $name; public int $age; public bool $isEmployee; } There's a few other things as well. The list() syntax (destructuring assignment) has been shortened to [] and now lets you specify keys (disclaimer: I was involved in both of these). Also, trying to add non-numeric strings together with + now produces a warning (disclaimer: also me).
- elgenie 10y agoIt's pretty amusing to read some of the PHP RFCs and see the verbal gymnastics taken to avoid saying "look, we're just taking this directly from Hack" :)
- TazeTSchnitzel 10y agoThere's certainly a lot of stuff inspired by Hack. If Hack did something well, sometimes PHP copies it. The syntax of all PHP 7's new type stuff is very close to Hack's. Though the details may differ significantly. Hack and PHP's type systems are only superficially the same (AOT rather than runtime validation, disabling or ignoring type checks versus using "weak" type checks, type inference vs. no type inference, etc.), for example.
- deleted 10y ago[deleted]
- coldtea 10y agoWell, Hack was in turn based on PHP, so?
- nkozyra 10y ago
- xiaq 10y ago> Catching multiple exception types > Support class constant visibility Reminds me of what Rob Pike once said, "[Java, JavaScript (ECMAScript), Typescript, C#, C++, Hack (PHP), and more] are converging into a single huge language".
- blowski 10y agoAs someone who works predominantly with PHP and JavaScript, but has spent some time with Java, Ruby and Python - I actually agree with you! Bob says "I wish PHP had this thing from Java" and Alice says "I wish Java had this thing from PHP". I don't think it's necessarily a bad thing.
- xyience 10y agoIt makes me really envious of those who went deep down the Lisp path and haven't had to look back. They don't have to spend time keeping up with the latest developments instead of pursuing some other goal, they have it all already.
- stiGGG 10y agoPHP should actually renamed to Javascript, but there is already that weird Lisp like scripting language claiming that name. If u ask me, there is somethin wrong in our matrix...
- CiPHPerCoder 10y agoNot mentioned in the article: Several RFCs being voted on or discussed right now. Also, https://wiki.php.net/rfc/libsodium https://wiki.php.net/rfc/libsodium
- ericbarnes 10y agoHere is the real link: https://dotdev.co/upcoming-changes-in-php-7-1-76ebea53b820#.8lix9htbv https://dotdev.co/upcoming-changes-in-php-7-1-76ebea53b820#....
- vesak 10y agoAnyone know if they are planning to fix ==, < and >? I kinda feel that declare(strict_types=1) could and should fix those without too much trouble.
- lsaferite 10y agoNested try/catch/finally blocks won't lose return values anymore. Yay. https://bugs.php.net/bug.php?id=72188 https://bugs.php.net/bug.php?id=72188
- mrweasel 10y agoI haven't touched PHP in a long time, but the later releases makes me want to try it for a couple of small projects. Is there any good introduction for people how "know" PHP4 and want to get started with PHP7, using best practises?
- regularjack 10y agohttp://www.phptherightway.com http://www.phptherightway.com might be of some help
- xyience 10y agoI don't know PHP 7 yet, but I'd say there's plenty to learn just in PHP 5 if you haven't kept up since PHP 4. Perhaps a piecewise approach would be best, starting with the 'proper' C++/Java-esque version of OOP that I'd say is the biggest feature of PHP 5...
- greatdipper 10y agoDon't use Php. Just don't. It is a stupid, stupid piece of crap. It is very hard, even for people with more than 10 years of experience, to know all the potential gotchas that are hidden deep inside this death trap of a language [1] You will be surprised how casual the actual core development of the language is. Tiny behaviours are added, modified and removed with little or no thought and with as little justification as "This doesn't make sense to me" or without any sort of notice at all [3].. [2] Here is how Php 7 tries to "improve" security of a function... And the community. Is there a more shittier community than that of this language? It is dominated by people with drama loving, infantile minds. Keep as far as possible from this language, if you have to work with it, wear on a mental condom before you start and never involve in any kind of Php discussions. [1] https://www.reddit.com/r/PHP/comments/41bm7j/new_rfc_allow_specifying_keys_in_list/cz1novq https://www.reddit.com/r/PHP/comments/41bm7j/new_rfc_allow_s... [2] https://www.reddit.com/r/PHP/comments/3j88v4/something_about_php_7_i_just_saw_in_rlolphp_why/ https://www.reddit.com/r/PHP/comments/3j88v4/something_about... [3] http://stackoverflow.com/questions/14703363/why-is-the-standard-session-lifetime-24-minutes-1440-seconds/37176824#37176824 http://stackoverflow.com/questions/14703363/why-is-the-stand...
- TryAgainMaybe 10y agoPHP is a widely-used mature tool for website development. It can be used in good or bad ways by good or bad people. Nothing more, nothing less. No need for the fanatical absolutism.
- gog 10y agoPHP community is huge and you are generalizing things from your limited experience. The language is not perfect (is any?) but it works and delivers business value. If it's not your cup of tee, that is fine, but I don't see you promoting better solutions, just bashing on PHP. Some people think that that is cool, well, it's not.
- greatdipper 10y agoBashing Php should be encouraged just like bashing any other bad practice.. For example. Take the case of MySQL injection. People does not hand wave SQL injection vulnerabilities by saying. "Na, It haven't happened to me ever, even after 10 years of making websites using mysql". Just like that. Use of PHP IS a bad practice today.
- madman2890 10y agowho gives a fuck
- JonoBB 10y agoCan we please change the link to the original article (https://dotdev.co/upcoming-changes-in-php-7-1-76ebea53b820#.gdl1ig553 https://dotdev.co/upcoming-changes-in-php-7-1-76ebea53b820#....) "Learning Laravel" is a known plagiarist, who has a habit of ripping off content from other Laravel sites.
- CiPHPerCoder 10y agoYeah. I'll email 'dang in case he's not active at the moment.
- peterbixa 10y agoIt's just a summary of the post. Are Facebook and other sites doing something wrong as well?
- CiPHPerCoder 10y agoIt adds no value. It doesn't belong on HN; the original article on dotdev.co does, however. The "ads by carbon" certainly don't cast this particular website in a good light, either.
- krapp 10y agoIt's not a summary of the post, it's just part of the actual post copied and pasted in. Facebook and other sites make it clear that what you're looking at is a summary meant to lead you to another site - they don't disguise it as content.
- deleted 10y ago[deleted]
- detaro 10y agoSubmitting a facebook post about a different post instead of the post itself is against HN rules as well, yes.
- peterbixa 10y agoDon't you see the read more link? The author is listed there, too. Don't ignore all the things.
- Navarr 10y agoCan we replace this with the link to the article it stole?
- conmarap 10y agoI'm saying this in the nicest possible way: I hate PHP and hope the project dies tomorrow. And it's funny because I use it at my job everyday. I suppose that's why I've grown to loath it that much. I should say that it is great for some things and it is very easy to stage and cheap to maintain, but it is a language from the previous century that has massively failed to adapt to current programmatic trends and patterns. And I shouldn't even start on its API, which to this day seems like the equivalent of a two year old child's drawing. Laravel and Eloquent made things a bit better, but still... Man, this language is a hot mess.
- chatmasta 10y agoSupporting http/2 SERVER_PUSH seems cool at first glance, but doesn't it significantly increase the attack service for RCE vulnerabilities, being that it accepts arbitrary content from remote servers and passes it into a callback function? It looks like PHP implemented SERVER_PUSH [0] via libcurl [1], openly described as a "work in progress." I'm sure all the code is "well written", both in PHP and libcurl, but I can't shake the feeling that we'll see at least one significant vulnerability as a result of this new feature. The two github issues on the feature, one referencing a segfault caused by a double-free [2], and one caused by server-specific protocol issues [3], do not help to assuage my worry. [0] https://wiki.php.net/rfc/curl_http2_push https://wiki.php.net/rfc/curl_http2_push [1] https://daniel.haxx.se/blog/2015/06/03/server-push-to-curl/ https://daniel.haxx.se/blog/2015/06/03/server-push-to-curl/ [2] https://github.com/curl/curl/issues/529 https://github.com/curl/curl/issues/529 [3] https://github.com/curl/curl/issues/530 https://github.com/curl/curl/issues/530
- joesmo 10y agoDeprecating mcrypt this way is clearly a mistake regardless of how ineffective it is as an extension or how unmaintained it is. Almost every framework I've seen makes use of it. In almost 9 years, it was not communicated to the community at all that this was based on unmaintained, buggy code, and now they just want to yank it in a minor upgrade? WTF? At the very least, there should be collaboration with people who maintain frameworks that use mcrypt as pretty much every major framework (ZF, Symfony, Laravel, etc.) does. This should be done in a major version upgrade like the one that just happened.
- CiPHPerCoder 10y agoThe release process specifically allows an extension to be deprecated and then punted to PECL. As for frameworks, I and others have already been going around (for years before the mcrypt deprecation came up) switching things to use OpenSSL (and, for that matter, authenticated encryption) instead of mcrypt. https://paragonie.com/blog/2015/05/if-you-re-typing-word-mcrypt-into-your-code-you-re-doing-it-wrong https://paragonie.com/blog/2015/05/if-you-re-typing-word-mcr... To date: ZF, CodeIgniter, Symfony, Laravel, and CakePHP all support OpenSSL instead of Mcrypt, as do many, many more. You get E_DEPRECATED in 7.1 then in 7.2 you can still pecl install mcrypt ...if you really have a need to support abandonware.