 Obviously we're going to talk about why you should move to PHP 7 if you haven't already and how that process how we can help sort of automate that process to some extent. Yeah I've been introduced already so I don't have to say a whole lot anymore I guess. I'm from Belgium best known for Belgian beer and Belgian chocolate and other tasty yummy things and odd-looking buildings. This is an iron crystal magnified 65 billion times. I'm from a town very close to Antwerp where we have a beautiful abbey and castles and stuff like that. It's all very nice except when we have some snow that's what we get then. And smack in the middle of that I started a company about 17 years ago now called Cube Solutions. We do mostly PHP, we do a lot of training stuff, high scalability things and I've been doing open source for 21 years. I'm getting old. Okay and I've written a tool PHP compatibility which I'm going to talk about as well today. I used to write a tool called OpenX which is an advertising server and I've been doing talks like these for the last couple of years. So this this talk is in two parts. Part one is why should you upgrade so I'm going to talk about what's new in PHP 7.0 to 7.2 at this point. These are not good reasons to upgrade. It's cool to have the latest version. Yes it is cool but that's not a good reason to upgrade and especially not a good reason to upgrade is to annoy your sys admins but that kind of makes sense. Part two I'm going to talk about how to upgrade and how to automate some of that process. Don't expect me to provide some magical solution here. We can't solve everything but you'll notice that a lot of the stuff can be automated, a lot of the issues can be detected automatically. I'd like to start with a show of hands. I'd like to know who is running which version in production. Who is still running PHP 3 or PHP 4 anywhere in production? Yeah there is always at least one, there's two. Yes and it kind of makes sense because there's still code out there that was built by someone way back who is probably not working there anymore, who is maybe dead even. Yeah I mean I've seen it happen and yeah the code needs to be maintained but nobody dares to touch it really. Who's running 5.0 in production? Okay 5.1, 5.2, couple of hands, okay 5.3, yeah more hands, 5.4, yes even more, 5.5, not that many, 5.6, s could be expected, 6.0, yeah we skipped that one, 7.0, 7.1, okay 7.2, 8.0, no okay. So let's, I mean you'll notice I'm gonna give the actual numbers now that come from W3Tech which is actually a very nice site, it gives you an overview of not just PHP but a lot of other technologies and which versions are actually running, how exactly they gather their data comes from, you can find that information on the site. So it turns out I looked at the numbers in 2013, 2015 and now and so PHP 4 is luckily dropping but it's still almost 1% which means if you have a hundred websites running about 1% of them are still running PHP 4 which is kind of scary actually. PHP 5 still makes up the bulk 87.2% of all websites are still running, PHP websites are still running on PHP 5 and the biggest chunk of that is 5.3, 5.4 and 5.5, oh 5.6 has made a major leap now recently. PHP 7 accounts for only 12% but it's yeah it's getting there gradually of course. So these are the main worrying ones 5.2, 5.3, 5.4 have been end of life for a very long time but still they account for a massive amount of PHP installations, about 40 something percent, 50 percent almost of all PHP 5 installations. Main reason for that is for example Debian Squeezy the what is it 7.0 version is stuck on 5.3.3 which accounts for 12% of that and they provided no patches with their default distribution so no upgrades that's a big issue. So before I go and talk about 7.0 let's have a very quick recap or one slide recap of what we've actually done in 5, 5.3, 5.6 because you'll notice that a lot of has evolved in PHP but some of the stuff you might take for granted now but this is what we went through from 5.3 to 5.6 so we did namespaces that was a big one of course. We wouldn't have most modern frameworks today use namespaces so we wouldn't have all that functionality in there. Late static binding, closures of course a big one, better garbage collection that was really useful in PHP 5.4. Go to well yeah we can we can argue about that whether it's useful or not but it does serve a purpose every now and then. MySQL native driver performance gain yeah PHP 5.4 and 5.5 had massive performance gains. The short array syntax which I think everybody is gradually switching to finally. Traits were introduced a built-in web server that we can use for development which is kind of nice as well. Binary notation was introduced. We finally got rid of register globals magic quotes TPC and the thing that was actually not really safe which was called safe mode. We have generators now and we have a nice password hash function so that we don't have to write our own hashing function anymore. Anyone still using their own functions please switch to password hash and we have a built-in opcache so we don't need to install APC or accelerator and so on it's all built in. So that was a lot of stuff that we got in the 5.x release but of course it was time to move forward. Then again 5.6 has been out for a very long time and a lot of people are still not using it. 49.2% of all PHP 5 installations are still 5.4 and before which means you cannot run symphony 3 which means you cannot run Zen framework 3 and many other frameworks on it. That's kind of a problem for developers. So in a lot of companies production servers are maintained by system engineers and they don't like upgrading or they don't like touching something that's not broken and so yeah it's becoming a bigger and bigger problem for PHP developers if they cannot use the latest frameworks obviously. So let's talk about PHP 7. What has changed? Well we have new features. We'll talk about those. We'll have a look at some performance and memory usage improvements. We have a lot of consistency problems that have been resolved and a lot of things have been removed or deprecated and will be removed in future versions. Let's talk about new things. One of the big things. Scalar typing and return type declarations. So what you can do now is you can have a function, some function and then instead of having just your parameters to that function you can now specify hey this is an int or this is a string and I'm going to have this function return a boolean. This has been a long time coming. Some people didn't like it. Some people protested against it but we finally have it. So we have new scalar types in float, bool and string and we can have return types that can be specified and of course they can be one of those scalar types as well. So this is an extension on top of the fact that you can specify objects and arrays in the past. Now we can also have these new scalar types. Now there is still PHP always was a weekly type language and there is still a choice you can make. You can still use these as weak. So you can say okay I have that I parameter, that first parameter. It's an int yes but you can still give it a float. What will happen is PHP will just convert it to an int when the function is called but it's not going to complain. It's not going to tell you hey you're giving me a float but I'm expecting an int. It's just gonna say okay I'm just going to convert it. I'm just going to curse it. So PHP 5 style but it is actually going to convert it when the function is called. The alternative is using strong or strict typing in which case you need to define it at the top of the file. Now when I say the file I mean every single file where you want to use strict typing. To do that you declare strict types equals one. That means if you have let's say an index.php and you include a file in there if that included file has declared strict types equals one it's only valid for that file. If you include another file in it it's still only valid for that file and not the file you include within that file. So that's kind of important to realize that. If you declare strict types and you use the wrong type it's going to throw a type error which is a fatal error. Now in PHP 5 any fatal error would end the program. As we'll see in a minute PHP 7 has changed error handling strategy and you can actually catch a lot of the fatal errors. Returning null is actually also invalid. If you specify that a bull will be returned then returning null will give you a type error as well. So if you say I want to return an int either you return an int or you're going to get an error. There is a way around that we'll see that in a minute. Another new feature the null coalescing operator in PHP 5 if you wanted to get something from get or post and use that information but you weren't sure if the information was actually going to be there you would have to use is set and then use the ternary operator and then use the parameter and then some default in case it wasn't there. In PHP 7 we can make that a little bit shorter to question marks so it's going to use the parameter from the get string or it's going to use the default. And you can chain them so you can say okay I'm gonna try from get I'm gonna try from post and then I'm gonna use the default. So useful feature a little bit less typing which we all like. I had to put a rocket up there because another new feature is the spaceship operator. And if you look carefully it looks a little bit like what are they called from Star Wars. A tie fighter thank you. It looks a little bit like that which is why it's called the spaceship operator. What does it do it compares expressions. It's going to return minus one zero or one so easiest to illustrate with an example of course. If you compare one with one you're gonna get zero because there is no difference between the left side and the right side of the of the operator. If you compare one and three you're gonna get minus one because the left side is smaller than the right side. Five and two you're gonna get one because the left side is larger. The same goes for strings. A and A gives you zero. A and Z gives you minus one. Z and A gives you one. It also works on arrays. I don't have an example of it here but it's going to compare arrays one element at a time. If you give it a longer string it's going to compare one character at a time until it finds a difference. It finds no difference. It's going to return zero of course. So this is quite useful in many cases mostly in my opinion for for things that are not too complicated. I don't personally use it for anything like arrays. Another new feature in PCB 7.0 is the unicode code point escape syntax. It's a very complicated thing to basically say that you can use hexadecimal string and it will convert that hexadecimal string into a UTF-8 double coded string. So for example echo backslash U curly brace 2615 will output a coffee cup. This one I particularly like and it's something that you don't see mentioned when people talk about PHP 7.0 but if you have to un-serialize data coming from some API call or you stored something in the database or someone else stored something in the database and you need to work with that data then in many cases you don't know what's going to be in there. And of course you only want to get not only valid data but also data that is of the types that you really want. Now un-serializing means you're going to initialize classes in many cases and there's a new option in the un-serialize function that allows you to specify which classes are allowed. Now you could use the first one which is allowed classes and the second one which is false which kind of doesn't make sense because then you're telling un-serialize yeah go and un-serialize but don't allow anything which makes no sense. So you're going to get an object of the type PHP incomplete class. But if for example in the second in the second example you use allowed classes article and user you know that you're only going to get objects of the type article user or again PHP incomplete someone else someone push something else into it. So this is a good way of kind of restricting what is being un-serialized. Also 7.0 CSPRNG function this is a very useful feature to generate random data and not just generate random data but do it in a way that works the same way across all platforms. So depending on whether you're on Linux or Windows it's going to use completely different different libraries for that. For example on Linux it might use a number of libraries and then fall back eventually to dev you random on Windows it's going to use completely other libraries but it's going to generate random data that's cryptographically secure. So no messing around with weird self-created random stuff. There's two functions for that there's random bytes which you can give a length and it's going to produce a number of bytes randomly and there's random int which is obviously going to create a random int between min and max. Of course there are certain things that are deprecating PHP 7. One of them is the PHP 4 style constructor. Did anyone ever build PHP code with a PHP 4 style constructor? Yes some people have been coding for a very long time or have to have to make changes to PHP 4 code of course. So that's deprecated now. You can still do it it also work but it's going to be removed in probably PHP 8. The other thing you can still do but is deprecated and will give you any deprecated notice is when you make a static call to a method that is not defined as static. You can still do it it's not advisable and it's going to be removed anyway in the future. Another thing that is modified is pre-replace no longer supports backslash e which is basically telling pre-replace to do an eval which is kind of evil anyway so you have to use pre-replace callback as an alternative there which is if you do it properly a little bit safer a little bit better. So I said before that error handling has significantly changed in PHP 7 so most fatal errors that you encountered in PHP 5 have now become exceptions in PHP 7 so you can actually catch those. There's a new class called error which means also that if your PHP 5 code currently has a class called error you will need to rename that because it's going to conflict. All the error and exception classes they implement the throwable interface which is interesting to know and it's not just an implementation detail as we'll see in a minute. So when you encounter an error in this case let's imagine that you have a type error because you gave a float where an int was expected the error is thrown by PHP and it will bubble up through all the functions method calls that you have until it hits a matching catch block and then of course the code in that catch block is run. Now if it doesn't find a matching catch block it's going to go to the default exception handler, the default error handler. If that error handler doesn't exist then it's going to still throw a fatal error so you might still get fatal errors if you do not properly handle the errors or exceptions that are being thrown. This is probably unreadable at the back but these are all the errors and all the exceptions. The exceptions are pretty similar to what we already had in PHP 5. Not a lot of them have been I mean some of them have been added but the errors are completely brand new so we have an arithmetic error with a division by zero error we have that type error before we have even have a parse error which can be called for example if you do eval and you provide it with code that is actually not correct PHP code then it's going to throw a parse error. So what's important is that if you just do catch and then say exception as the type of what you're trying to catch it's not going to catch errors in PHP 7 and if you do catch error it's not going to catch exceptions so the only way to do it properly and to have code that works in PHP 5 and PHP 7 is to catch throwable which is the interface that both error and exception implement but that's not going to work in PHP 5 so you still have to catch exception for PHP 5 as well. It's kind of a workaround for as long as we're using PHP 5 and looking at how long we were still using PHP 4 in production in some places we will need this workaround for a while probably. Now set error handler always allows you to set your own error handling system so you would normally write a function handler and then you would assign that using set error handler however because of the same reasons it doesn't work when you give it a parameter exception. So if you wanted to work in PHP 5 and 7 you cannot specify a type anymore there which is kind of odd because a lot of people have been getting used to specifying a type you can't do that anymore unless of course you want to say oh I don't care about PHP 5 code I'm running everything on PHP 7 in that case you can again just specify throwable. Another change that might cause issues if you migrate code from PHP 5 to PHP 7 is the variable variable handling. This was caused actually by the fact that PHP now relies on the abstract syntax tree so that's basically when PHP is when PHP code is interpreted and turned into opcodes it's going to build an entire tree of what the code looks like you can actually retrieve that from PHP now and have a look at how exactly the code is structured internally but because of the changes that were made to implement that there have been a number of changes now this is this is basically a screenshot from the PHP manual it didn't feel like copying this all over because it's it's perfectly illustrates that whenever you have a specific expression the interpretation between PHP 5 and PHP 7 can be completely different. Luckily you can detect most of these most of the places where this might cause a problem however modifying it automatically is well difficult because you'll need to actually look at the code and say what was I doing here in PHP 5 and how do I need to modify it to make it work in PHP 7 so this is one of the things that could actually break applications now it was never a good idea to do things like that but we all did things that we're not too proud of I guess so it will require manual testing fixing and so on so some stuff was removed as well for example you cannot do global the global keyword and then use a variable variable behind that that's no longer allowed I don't think a lot of people ever did that but it's not possible anymore the salt option in the pretty new password hash function has been deprecated PHP will do that for you it will generate a salt that's good for you automatically other stuff that's been removed ereg is not there anymore the mssql extension is not there anymore the MySQL extension is not there anymore which means you'll have to use MySQL i MySQL native driver and so on we finally got rid of MySQL I mean sorry I don't mean we finally got rid of MySQL but the old module at least side base CT is not there and starting with PHP 7.1 encrypt is gone and we actually encountered last week we encountered a project where we're using brand new code we're using a very modern framework it's built on top of symphony 2.0 3 at this point but it's using mcrypt and so we cannot upgrade to PHP 7.1 on that one yeah as I said ereg was removed so all the functions of course removed call user method call user method array have been removed the DL function is still there but it's not there in PHP FPM anymore because it was causing some issues and everything related to post script type 1 fonts have has been removed as well that's long gone that's ancient history and then there's a lot of I and I function I and I settings that have been removed as well I'm not gonna go through these I'm not mentioning everything that's changed just like the most critical ones a couple of other things that have changed if you have an invalid octal in the past PHP we just cut it off and we just ignore now it's gonna throw a parse error which is catchable so you can actually give a nice error message to your users negative bit shifts should never have been there in the first place if you do it now you get an arithmetic error which again you can catch a division by zero now doesn't give a fatal error it actually gives you a division by zero error and hexadecimal strings are no longer numeric they are now actual strings and of course given the fact that we have a couple of new introductions into the types there are some new reserved keywords and there are some that have been reserved for future use as well like voyage iterable resource and so on they're not reserved today they're not you can still use them for other purposes but it's not recommended anymore however PHP 7 also kind of loosened restrictions on the use of keywords so one of the things you can do now within a class blah you can do function yield which is actually a function in PHP but you can now use it as a the name of a class of the of a method again which personally I don't like very much but it is allowed again to me it's very confusing if I see function yield I'm like what yield yield I know that but that's a function in PHP so very confusing and this has been deprecated for a very long time you cannot assign by reference on the new when you're using new creating a new object it's now going to give you a parser saying that you cannot do that although honestly I don't like the error message because it's not actually telling you what you did wrong it's just saying I didn't expect new which is kind of odd yeah ASP and script PHP tags have been removed I don't think anyone was using those anymore but still and a switch statement can no longer have more than one default block which is kind of silly anyway but yeah you can't do that and the date time zone warning that you used to get after PHP 5.3 if you didn't set it that's now been removed again so if you don't set it it's fine by default it's gonna set itself to UTC the biggest change I think performance and memory usage between five six and seven performance has gone up anywhere and it depends on which application you're using and depends on who's doing the testing really and who's showing the graphs and I'm not actually going to show you any graphs because there's plenty out of out there and they're all different but they all show anywhere between 200 and 300 percent increase of course if your code is three lines you're not going to notice if you're loading the entire symphony framework it's going to be a massive difference what do they do they optimize a lot of things in the core they took a lot more direct approaches less redirection inside the code they allocate a lot less memory for every single thing and every data structure has become smaller for every single data type actually and given the fact that we're constantly tossing data around that makes a huge difference of course memory usage up to 50 drop which of course gives you a big impact on large frameworks sort of things like WordPress or Drupal makes a huge difference so if for any reason I mean if there's if you're looking for a reason to upgrade to PHP 7 this is probably the biggest one because if you have 10 servers running today you could do with half tomorrow now most of these were 7.0 I'm quickly going to tell you what's new in 7.1 as well so I said before that if you want to if you specify that a bool has to be returned from a function and you return null it's going to give an error well that's true except in 7.1 you can specify a nullable type and you do that by pre-pending with a question mark so in this case you're actually saying I'm going to return an inch or I'm going to return null so that's possible now you're also going to get an exception in PHP 7.1 if you specify that you're expecting a parameter in your function and you're not actually passing one then you're going to get an argument count error other changes random s-rand you can still use them but they're actually just aliases now you cannot do this on a string anymore because a string is a string it's not an array although it is it consists of characters but still so you cannot append something to a string like that anymore you're going to get a fatal error the daytime constructor now by default uses microseconds whereas in the past it only uses use seconds that does mean if you create two day times even if you create them on the same second and you compare them they will be different now whereas in the past they were the same because you created them at the same moment yeah SSL version 2 has been dropped which is a very good thing for security reasons there's a new function called session GC garbage collection mostly useful if you have a low traffic site I'm gonna have to speed up apparently if you have a low traffic site garbage collection might not be cold enough if you have a high traffic site you don't want garbage collection to be called the whole time so this allows you to do it manually basically okay oops I was there already there's a new sodium extension which adds a lot of cryptographic stuff as well now and there is a new object type that you can specify so you can basically tell it I'm going to return an object without specifying which type new functionality for password hash newing new TLS version that's specified by default and some stuff that's removed as well create function is deprecated also load is deprecated as well now the magic at least and each is deprecated because we have for each which is much more efficient so the question is should you upgrade to PHP 7 today the answer is mostly yes unless of course you're using any of the functions extensions that have been removed or any of the functions that have been removed if you have no unit s or if you have no packages for PHP 7 available for your servers and you have to manually compile everything you might want to hold off then again it might be a good reason to reinstall your servers altogether or set up new ones postponing upgrades brings you to the problem of end of life whereas in the past the principle was yeah we'll see now the principle is whenever a minor release is brought out add to to that minor release and that one is end of life so and then you still get critical security patches for one year but you get no bug fixes that means as soon as 7.2 came out 7.0 became end of life so anyone who's done a lot of effort upgrading to 7.0 well you're gonna get critical security bug fixes and security fixes until probably the end of the year and then it's gonna be end of life and the same goes for when 7.3 is released 7.1 will be end of life and anyone still running 5.6 and there were a lot of people a lot of hands went up it's currently on security patches only and by the first of January it's going to be end of life no security patches whatsoever so that will be the end of the 5.x release so you have about 11 months well 10 and a half so if you're on PHP 7 or 7.1 start upgrading as well to the latest version again because of course that's the biggest one 87% still but yeah and I don't have to tell you main reasons are security performance framework support symphony 4 requires 7.1.3 Zen framework 3 requires still 5.6 Laravel 5.6 also requires 7.1.3 and it's just a good idea to keep every single developer motivated so that they can use the latest the latest tools so couple of ways you can upgrade of course you can run all your unit tests you can try to visit every single page on your website or you can try to automate it using static analysis and that's what we're gonna have a look at now so back in 2010 I had to do this for about 40 different projects when I was working to Belgian Railways there was code there from PHP 4 and PHP 5 and we had to migrate all that and I thought how am I gonna pull this off and then I thought I'm gonna try to automate it using our continuous integration environment we have some unit tests let me put all the projects in there even the ones that don't have unit tests and let me use a tool called PHP code sniffer who here uses PHP code sniffer was anyone yeah quite a few okay oops so PHP code sniffer was originally a pair package it's now available on the composer as well it's been mostly rebuilt recently for version 3 and it is actually designed to detect coding standard violations so it will tell you hey you're putting this curly brace there and you should be putting it on the next line or you need to use spaces instead of tabs that's what it was designed for it supports multiple standards so of course it supports things like psr2 but it also supports the Zen framework coding standard or any other that you might come up with yourself please don't and it is a static analysis tool that means it goes and analyzes your code without actually executing the code so it's gonna split up your code into what they call tokens so a token could be open curly bracket or false or a semicolon those are all tokens and it's gonna parse every single file separately so if you run it and I'm gonna show that now so I have here an index dot PHP so if you've installed it which you can do with composer you can run PHP CS code sniffer dash I and it will tell you the installed coding standards are and then you get a whole list and now I can just say okay I'm going to use a specific standards I'm going to use the Zen standard for example and I'm going to run it on my current directory which only has one file in this case and it will tell you oh look I found an opening brace of a class it must be on the line after the definition and so on or consider putting global function test in a static class so it will tell you everything that is not correct according to the coding standard switch back now that would be nice so I wrote a tool to do that migration called PHP compatibility and it is actually what they call a standard in PHP code sniffer you can install many of those standards each have different rule sets in there and the only purpose of PHP compatibility is to find compatibility issues so it's not actually coding standard it's just going to look for what it can find that might not be compatible with other PHP versions so it's going to detect deprecated functions deprecated extensions prohibited function names or class names and so on it works for anything starting from PHP 5 and above to make it work it's very simple if you use composer you can just install the package that's located on get up it's whim g slash PHP dash compatibility and then you have one step that you still need to do because you need to give code sniffer the location of the standard otherwise it doesn't know where to look for it so if PHP compatibility is the only coding standard that you have installed you can just add a script that's very easy I will put these slides online by the way so you can use this as a reference as well if you have more than one coding standard there are a couple of additional packages that you can install to automate that process as well if you don't use composer you can just download the package and again run config set and give it the path where you installed PHP compatibility so as I said PHP CS dash I tells you which standards are available and then you can actually just specify which standard you want to use now what's important is if you have a huge directory this could be very slow if you run this across a huge installation with a vendor directory that contains 300 packages it's not recommended you should never run it across the vendor packages they should do that themselves you should only run it across your code however you should definitely always use dash extensions there's no point in scanning JavaScript files or images or videos or something like that it's not going to contain PHP if you want to test for 7.0 compatibility you need to run your tests on a 7.0 installation of PHP otherwise it's not gonna recognize certain keywords and again it doesn't actually run the code which means it cannot detect every single incompatibility some things only happen when the code is actually running but it will provide you with a file name and a number of course so let's have a quick look at what that looks like so if I say no I'm not gonna run Zen I'm gonna run PHP compatibility I made a typo compatibility so I'm going to show you that file first so I have a file here and it's it has a for loop with a break in there for example a break with a parameter which is no longer allowed in recent versions I also have this little weird thing that I already mentioned before that's different it behaves differently in PHP 5 and PHP 7 I also have a PHP 4 style constructor here and I'm doing a new with by reference which is also of course not allowed so let's have a look if we run it across it it's going to tell you oh you're using a variable argument on the break which is correct that's forbidden since PHP 5.4 so that's an error you're having indirect access to variables it has changed left to right order and things like that so you might want to check that then there's the constructor which is currently deprecated so it's not an actual error it's a warning and then of course that new with by reference that is forbidden in PHP 7.0 so this is kind of the output you would get we'll run it across a couple of other things in a minute now by default it's going to check for the latest PHP version so in this case 7.2 is what what is defined in PHP compatibility but you can specify on runtime you can say no you need to test for 7.0 for example so source there here is the the directory you want to check of course or you can say I want you to check for 7.0 to 7.1 or anything 7.0 and higher which you can also do the opposite so you can say I'm coding on my machine I'm writing code in 7.2 but my production environment is running 5.6 for example so in that case you can specify oh come on let's say 5.4 yeah so you can tell now that I have one error less I think yeah so if I go to 5.2 for example it's going to do something completely different now it's going to complain about the fact that the int type declaration is not present in an older version so if you're writing code on 7.2 and you're trying to deploy it on 5.6 and you're not doing any checks you might actually break your production environment if you run this across it it will tell you you're using this functionality but that's not available on your server so the bool return type is not present in 5.6 having issues here okay now you can also disable warnings because sometimes you're going to get warnings about one specific rule in there you can create a phpcs.xml file and in there you can put something like yeah I'm using PHP compatibility but I want you to ignore that specific rule because of the fact that you know about it it's not a problem for your specific installation every now and then it will give a false positive it will tell you there's a problem here because you created a very complicated code maybe with a lot of a lot of curly braces in there a lot of other braces in there and it's going to say who I think this is a problem but in fact it might not be a problem also here you can specify the test version so this is a way of kind of automating on the continuous integration side of it there are a couple of other tools there is that will do the same thing for WordPress there's a PHP compatibility checker which actually uses PHP compatibility and it will run across all your plugins and tell you hey this plugin is not compatible with PHP 7 so don't upgrade your server because your WordPress will not work anymore and then you can have a look whether there's a new update for the plugin or maybe you need to switch to a different plugin but at least you know there's in PHP storm 10 and higher there is a PHP 7 compatibility inspection but it will do most of the inspection only on the parameter types it doesn't do a lot of the other things this one is a very interesting one and I know there's a talk tomorrow afternoon that will focus mostly on PHP 7 cc which is a very similar project to PHP compatibility it's slightly less up to date I think the last update was in April last year but it has very similar functionality and in that talk tomorrow I know is going to show some comparisons between the two so I'm actually very curious about that and then there's also fan which was built originally by Rasmus Lerdorf the creator of PHP which is a general static analyzer which does a lot more than just compatibility checks in fact the compatibility checks are very limited but it does a lot of other code checks that are very interesting to have a look at and this one actually is a docker image that uses all of the above you can just run it across your code and it will run all of those automatically and will give you a bunch of reports with all of the tools without having to manually install all of them so it's just kind of automated tool so to conclude there is no way to 100% detect all compatibility issues but if you can automate like 95% of it that's a big gain of course first install PHP compatibility or one of the other tools on a local machine but please use it in your continuous integration environment because today you might upgrade to PHP 7 but then you need to go to 7.3 at some point and 7.4 and then maybe 8 so it's going to help you all the time it's going to be a continuous non-stop check for your code so start upgrading how much time do I have left about 10 minutes for questions okay I'm gonna do one small little thing that I want to show I install Laravel and I thought I just run PHP compatibility with the latest version of course across that oh yeah so there is one very nice feature dash p gives you progress which for very big tests can be useful to see that actually something is happening and I noticed yesterday if I tell Laravel if I try it with the Laravel framework and I say PHP 7.1 that it's actually going to tell us that there is a problem and I should ignore warnings because we're gonna get a lot of warnings here yeah empty files will also be reported as hey there's no code in there that's a problem but you can ignore that you can in fact disable that warning altogether but you can tell that there's an E when it says error w is a warning and so what you can see here is that actually Laravel requires PHP 7.2 in fact the latest version which is not out it was a master so yeah a lot of the big frameworks and now actually on the very very latest version of PHP so upgrading is the the task at hand right now