acumen consulting php development

The Pros and Cons PHP 7.0 Migration

With the planned date for PHP 7’s release rapidly approaching, the PHP internals group is hard at work trying to fix our beloved language as much as possible by both removing artifacts and adding some long desired features. There are many features we could discuss, but in this post, I’d like to focus on three that grabbed my attention.

Recently 5.7 has been moving down the ladder in favor of web developemnt directly to 7. What this means there will be no new version between 5.6 and 7 – even if the new version was only to serve as a warning light to those still stuck on outdated code. Originally, 5.7 was not supposed to have new features, but was supposed to throw out notices and warnings of deprecation about code that’s about to change in v7.

It would also warn about some keywords that are to be reserved in PHP 7, so that people can bring their code up to speed with a sort of “automatic” compatibility checker in the form of an entire PHP version. The thing is, however, as I argue in the newsletter, that most people technologically competent enough to follow PHP in its upgrade path by keeping up with the most recent version aren’t generally the type of people to actually be using code that might break in PHP 7.

Return Types

With a vast majority voting “yes”, PHP is finally getting return types.  Starting with PHP 7, we’ll finally be able to indicate proper return types on functions in the form of:

function foo(): array {
    return [];
}

An improvement? Definitely! But perfect? Sadly, no:

  • the return types can only be what we have for types right now, meaning no scalar values, no return types like string, int, bool, etc. This means that your methods and functions that return such values will still be unsigned. You can remedy this by returning instances of wrappers for such values, but that’s overkill in the vast majority of cases.
  • no multiple return types. If your function returns either an array, or an Iterator object, there’s no way to indicate that via, for example, array|Iterator as we do in docblocks.

Some people also complained about the type declaration being after the closing parenthesis of the argument list, rather than before the function name, but to me, this is nitpicking. Popular languages such as modern C++ use the “after” syntax, and like the RFC states, this preserves the possibility of searching for “function foo” without any necessary regex modifications. What’s more, this is in line with what HHVM uses, so it’s an added unintended compatibility bonus.

Some complaints are about the “strictification” of PHP, but you really find the value of this when you start coding against interfaces or inheriting other people’s code. Besides, as long as it’s optional and its existence does not in any way affect PHP’s general performance or stability, there’s no harm in it. Complaining about it is, to me, akin to complaining about OOP being added to PHP when procedural spaghetti worked so well for most cases back then. Languages evolve, and this is a step in the right direction.


Removing Artifacts

The upcoming version proposes to remove PHP4 style constructors.  Communities anger on this makes me wonder – if you’ve kept such a codebase alive for so long, is there really a need to upgrade to PHP 7? And if there is a need to upgrade to PHP 7, is it not easier to simply hunt down the offending classes and fix their constructors? Surely this is something you can delegate to juniors, given enough unit tests in your code base to make sure it all goes well? And if you don’t have unit tests, if your app is a mess, do you really hope to benefit in any way from moving to PHP 7? Wouldn’t you be better off Modernizing your Application first?

The sentence “This means that code which I wrote 10 years ago should still run today, and should still run 10 years from now.” is, to me, madness – you definitely and absolutely should not expect this of ANY language across major versions.

Granted, some coders are right in that it would take effort to remove the feature, while it would take none to leave it in. But in the long run, it will take more collective effort to fix the problems these constructors sometimes cause, than to remove it now.

My advice to those fearing PHP 7 is – stop. If you don’t want to upgrade, don’t. If you could be on 5.3 or 5.2 for so long (looking at you, CodeIgniter), you can be on 5.6 for another decade – but let us have modern PHP. Leave progress up to those who are willing to accept it.


Scalar type declarations

Scalar type declarations come in two flavours: coercive (default) and strict. The following types for parameters can now be enforced (either coercively or strictly): strings (string), integers (int), floating-point numbers (float), and booleans (bool). They augment the other types introduced in PHP 5: class names, interfaces, array and callable.

<?php
// Coercive mode
function sumOfInts(int ...$ints)
{
return array_sum($ints);
}var_dump(sumOfInts(2, '3', 4.1));

PHP 7

The quick list of changes:

  • PHPNG (next generation of Zend Engine)
  • Scalar type declarations
  • Return type declarations
  • Spaceship operator
  • Anonymous classes
  • Generator return expressions
  • Generator delegation
  • Performance
  • Error handling (Exceptions)
  • Extension API changes

Conclusion

As usual, there’s no shortage of drama in PHP land. Like all major revolutions throughout history, the 7 revolution will also be spilling some blood before producing something awesome. PHP 7 is still a long way off, so even if you’re caught in the crossfire of musket shots, there’s ample time to get to cover. Unless you’ve been sleeping under tank tracks, then there’s little either side can do to help you.

What do you think of these RFCs? How do you feel about PHP 7 in general? Is it heading in the direction you’d like it to head in? Let us know – we want to hear your thoughts!

WP CMS

The latest variation of WordPress CMS is packed with your typical functions, maintaining ease-to-use functions and for that reason, the listing of functions has increased greatly over the years, along with theme variety makes it easy to generate income.

If you also include excellent plug-ins, Constant Updates, a WP Support community that is second-to-none, SEO made super easy and just Setting up a WordPress website is affordable.

Nevertheless besides blog writing tool, WordPress is among the very best platform for Web Development, uncomplicated to utilize and also versatile.

Why WordPress Development is very useful for business

1. It is Safe and secure.
Since WordPress is a popular CMS, it should not be surprising that it’s a target for hackers. The WordPress take the the secuity of its user very seriously.
2.It is  Easy to use.
The WordPress is very easy it is to use. The platform is user-friendly, intuitive and easy to learn. In fact, you can learn how to use wordPress in a matter of minutes.
3. Lots of support.
WordPress is provides lots of support. This is in part to the extensive WordPress community where you can troubleshoot any question or concern through the WordPress
4. Easy to manage
WordPress is equipped with a built-in updater for security purposes, WordPress also notifies you whenever there are updates for your themes and plugins. This makes managing your WordPress  site a breeze, since you’ll always be current on the latest updates. That will keep your site safe and fresh.