SlideShare uma empresa Scribd logo
1 de 23
John Coggeshall
@coogle
http://www.coggeshall.org/
A PEEK AT PHP 7.0
WELCOME!
• The CV
• PHP Core contributor (author of ext/tidy)
• PHP Developer since 96’
• Published lots of things
• Spoken lots of places
Melted Metal!
Love the boat!
ALL THE THINGS : PHP 7
• PHP 7 is the next major iteration of the PHP language
• Awesome new language features
• More sanity / consistency
• More speed!
• But wait, what happened to PHP 6?
• PHP 6 is dead.
• The short version: PHP 6’s big push was going to be Unicode support, but there
wasn’t enough developers to get that done so the tree stagnated and died.
• When will PHP 7 be released?
• Best guess: GA Fall, 2015
Warning
Everything I say here could be wrong.
… It’s probably not
… A lot of it is already implemented
… I probably got the date wrong
… There aren’t RFCs for everything
… At least I didn’t write a book on PHP 6
ERROR HANDLING
THE DEATH OF E_STRICT
• E_STRICT was our way of telling developers they were doing it wrong ™
• In PHP 7, E_STRICT is gone, and anything that was E_STRICT has been upgraded to
one of the following:
• Nothing (we just removed the E_STRICT error because it was dumb)
• Make it an E_DEPRECATED error (probably should have ran with this from the
beginning)
• Promote it to an E_NOTICE or E_WARNING (we’re serious about not letting you do
these things, knock it off)
Oh, Yeah! Hell, No.
28 4
https://wiki.php.net/rfc/reclassify_e_strict
CALL TO MEMBER FUNCTION OF
…ARG!!
• A really common error in PHP 5+ is “Call to member function blah() of non object”
• Basically, you tried to call a method on something that wasn’t an object (typically
NULL)
• $foo->bar->baz();
• In PHP 5, this is a fatal error and your application blows up
• In PHP 7 this has been changed to an E_RECOVERABLE_ERROR making it something
you can, you know, recover from in your application
Oh, Yeah! Hell, No.
32 0
https://wiki.php.net/rfc/catchable-call-to-member-of-
non-object
ENGINE EXCEPTIONS
• PHP 7 introduces the concept of using Exceptions for engine-level error handling to
replace E_ERROR, etc.
• Many / Most common error conditions will be converted to exceptions
• Future error conditions will, if possible, be implemented as exceptions
• Also introduced a revamped Exception object model
• BaseException
• EngineException
• ParseException
• Exception
• …
• Note: Existing catch code will not catch these new exceptions (clever)
Oh, Yeah! Hell, No.
60 2
Oh, Yeah! Hell, No.
39 19
https://wiki.php.net/rfc/engine_exceptions_for_php7
OBJECTS ‘N STUFF
WAIT.. THIS WAS BROKEN??
• In current versions of PHP, some internal classes could fail in the constructor and return a
object that, for all intensive purposes, was broken.
• In PHP 7, all internal classes throw exceptions in their constructors to prevent broken
instances
<?php
// Reflection function is not meant to accept an array (E_WARNING)
$reflection = new ReflectionFunction([]);
// Blows up
var_dump($reflection->getParameters());
Oh, Yeah! Hell, No.
32 1
https://wiki.php.net/rfc/internal_constructor_behaviour
SPEAKING OF CONSTRUCTORS..
• Also in PHP 7, the PHP 4 (circa 2000 – 15 years old) style of object constructors having
the same name as the class are one step closer to dying to the relief of all serious
developers.
• Methods named the same thing as the class (i.e. Filter::filter()) are just methods now
• Constructors are called __construct()
• In PHP 7 if it looks like you are using this horrible behavior it will now yell at you with an
E_DEPRECIATED
Oh, Yeah! Hell, No.
50 4
https://wiki.php.net/rfc/remove_php4_constructors
SIMPLIFIED USE STATEMENTS
• In PHP 7 we have added the notion of use statement “groups”
• Cleans up the top of our scripts
use FooBarClassA;
use FooBarClassB;
use FooBarClassC;
use FooBar{ClassA, ClassB, ClassC};
https://wiki.php.net/rfc/group_use_declarations
Oh, Yeah! Hell, No.
39 19
LANGUAGE FEATURES
SPACESHIPS!
https://wiki.php.net/rfc/combined-comparison-operator
• PHP 7 Introduces the “Combined Comparison Operator” (a.k.a. the Spaceship operator)
Operator <=> Equivalent
$a < $b ( $a <=> $b) === -1
$a <= $b ($a <=> $b) === -1 || ($a <=> $b) === 0
$a == $b ($a <=> $b) === 0
$a != $b ($a <=> $b) !== 0
$a >= $b ($a <=> $b) === 1 || ($a <=> $b) === 0
$a > $b ($a <=> $b) === 1
Oh, Yeah! Hell, No.
43 11
?? OPERATOR
• No, that wasn’t a placeholder in my slides
• The ?? Operator, or Null Coalesce Operator which allows us to set default values for
variables when the variable doesn’t exist.
• Cleaner than trying to use ?: or other approaches
https://wiki.php.net/rfc/isset_ternary
Oh, Yeah! Hell, No.
31 3
<?php
// Useful for when you want to set default values for variables
$user = $_GET[‘user’] ?? ‘nobody’;
RETURN TYPES
• My personal war over the years has included this one
• Return type-hints will finally be part of PHP in PHP 7
• Doesn’t support “nullable” types (yet)
<?php
// Useful for when you want to set default values for variables
function returnsArray(): array {
return [‘happy’, ‘days’];
}
Oh, Yeah! Hell, No.
47 3
https://wiki.php.net/rfc/return_types
UNIFORM VARIABLE SYNTAX
• PHP has some… complicated|odd|dumb|insane variable syntax possibilities
• $foo->$bar[‘baz’]()
• There are a lot of inconsistencies in the way we resolve variables when they get a little
crazy
• In PHP 7, we are introducing a uniform syntax and fixing all of those issues
https://wiki.php.net/rfc/uniform_variable_syntax
Oh, Yeah! Hell, No.
30 1
<?php
$foo()[‘bar’](); // Call closure in array from return value
[$obj1, $obj2][0]->prop; // Access $obj1->prop
returnString(){0}; // Return first character
$foo::$bar::$baz; // Stacked static calls
$foo->bar()::baz(); // Stacked mixed calls
$foo()(); // Stacked function calls
$foo->bar()(); // Stacked method calls
WE STILL HAD THAT?
• Arcane open tags for PHP scripts are no longer supported in PHP 7
• ASP-style <% %>
• HTML-style <script language=“php”></script>
• Also, Hexadecimal support for “numeric strings” has been removed
• Before: ‘0x01’ == ‘1’ (true)
• Before: (int)’0x01’ == (int)’1’ (false, wtf?)
• Now: ‘0x01’ == ‘1’ (false)
Oh, Yeah! Hell, No.
26 8
Oh, Yeah! Hell, No.
29 0
https://wiki.php.net/rfc/remove_hex_support_in_numeric_strings
https://wiki.php.net/rfc/remove_alternative_php_tags
SCALAR TYPE HINTS
• PHP 7 will have support for scalar type hinting in addition to the already supported
complex-type hinting
• Introduces the notion of declare(strict_types=1) directives
• Per-file directive
• Put at the top of the file, will enforce strict typing of return values
• Caller file counts, not source file
Oh, Yeah! Hell, No.
108 48
https://wiki.php.net/rfc/scalar_type_hints_v5
<?php
declare(strict_types=1);
function add(float $a, float $b) : float {
return $a + $b;
}
add(1, 2); // retval = float(3)
NEW LIST() BEHAVIOR
• The list() statement(?) is a odd thing in PHP used to extract array values into variables
• list($a, $b, $c) = [1, 2, 3]; // $a = 1, $b = 2, $c = 3
• In PHP 7 there are a couple of changes to the behavior
• list() now assigns variables left-to-right instead of right-to left
• list() no longer supports extracting values from strings
<?php
$a = []
list($a[], $a[], $a[]) = [1, 2 ,3];
// OLD: $a = [3, 2, 1];
// NEW: $a = [1, 2, 3];
https://wiki.php.net/rfc/abstract_syntax_tree
https://wiki.php.net/rfc/fix_list_behavior_inconsistency
GO JOHNNY, GO!
• The so-called PHPNG
branch of PHP has been
merged as the basis for
the engine in PHP 7
• Translation: PHP most of
the time is a lot faster than
before
• One step closer to
effective meaningful JIT
for PHP
Oh, Yeah! Hell, No.
47 2
https://wiki.php.net/rfc/phpng
KEEP UP TO DATE WITH THE LATEST
• PHP 7 like all things is going to be a moving target until it is done
• There is a VirtualBox of PHP 7 to toy around with maintained by Rasmus Lerdorf
• https://github.com/rlerdorf/php7dev
• The PHP RFC Wiki is also a great source of more details on everything we’ve discussed
and the things currently being considered
• https://wiki.php.net/rfc
John Coggeshall
@coogle
http://www.coggeshall.org/
THANK YOU / QUESTIONS?

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

Streams, sockets and filters oh my!
Streams, sockets and filters oh my!Streams, sockets and filters oh my!
Streams, sockets and filters oh my!
 
Last train to php 7
Last train to php 7Last train to php 7
Last train to php 7
 
HHVM and Hack: A quick introduction
HHVM and Hack: A quick introductionHHVM and Hack: A quick introduction
HHVM and Hack: A quick introduction
 
PHP7: Hello World!
PHP7: Hello World!PHP7: Hello World!
PHP7: Hello World!
 
HipHop Virtual Machine
HipHop Virtual MachineHipHop Virtual Machine
HipHop Virtual Machine
 
Introduction to php php++
Introduction to php php++Introduction to php php++
Introduction to php php++
 
Why choose Hack/HHVM over PHP7
Why choose Hack/HHVM over PHP7Why choose Hack/HHVM over PHP7
Why choose Hack/HHVM over PHP7
 
PHP
PHPPHP
PHP
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
PHP - Introduction to PHP
PHP -  Introduction to PHPPHP -  Introduction to PHP
PHP - Introduction to PHP
 
PHP 5.3
PHP 5.3PHP 5.3
PHP 5.3
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
 
Dev traning 2016 basics of PHP
Dev traning 2016   basics of PHPDev traning 2016   basics of PHP
Dev traning 2016 basics of PHP
 
PHP Comprehensive Overview
PHP Comprehensive OverviewPHP Comprehensive Overview
PHP Comprehensive Overview
 
PHP7 is coming
PHP7 is comingPHP7 is coming
PHP7 is coming
 
Perl Moderno
Perl ModernoPerl Moderno
Perl Moderno
 
Php.ppt
Php.pptPhp.ppt
Php.ppt
 
PHP 良好實踐 (Best Practice)
PHP 良好實踐 (Best Practice)PHP 良好實踐 (Best Practice)
PHP 良好實踐 (Best Practice)
 
Spl in the wild - zendcon2012
Spl in the wild - zendcon2012Spl in the wild - zendcon2012
Spl in the wild - zendcon2012
 
Basics PHP
Basics PHPBasics PHP
Basics PHP
 

Semelhante a Peek at PHP 7

Preparing code for Php 7 workshop
Preparing code for Php 7 workshopPreparing code for Php 7 workshop
Preparing code for Php 7 workshopDamien Seguy
 
Php7 HHVM and co
Php7 HHVM and coPhp7 HHVM and co
Php7 HHVM and coweltling
 
TAKING PHP SERIOUSLY - Keith Adams
TAKING PHP SERIOUSLY - Keith AdamsTAKING PHP SERIOUSLY - Keith Adams
TAKING PHP SERIOUSLY - Keith AdamsHermes Alves
 
Php7 hhvm and co
Php7 hhvm and coPhp7 hhvm and co
Php7 hhvm and coPierre Joye
 
What To Expect From PHP7
What To Expect From PHP7What To Expect From PHP7
What To Expect From PHP7Codemotion
 
The new features of PHP 7 - Enrico Zimuel - Codemotion Milan 2016
The new features of PHP 7 - Enrico Zimuel - Codemotion Milan 2016The new features of PHP 7 - Enrico Zimuel - Codemotion Milan 2016
The new features of PHP 7 - Enrico Zimuel - Codemotion Milan 2016Codemotion
 
PHP Basics and Demo HackU
PHP Basics and Demo HackUPHP Basics and Demo HackU
PHP Basics and Demo HackUAnshu Prateek
 
Upstate CSCI 450 PHP Chapters 5, 12, 13
Upstate CSCI 450 PHP Chapters 5, 12, 13Upstate CSCI 450 PHP Chapters 5, 12, 13
Upstate CSCI 450 PHP Chapters 5, 12, 13DanWooster1
 
Php Crash Course - Macq Electronique 2010
Php Crash Course - Macq Electronique 2010Php Crash Course - Macq Electronique 2010
Php Crash Course - Macq Electronique 2010Michelangelo van Dam
 
What's new in PHP 7.1
What's new in PHP 7.1What's new in PHP 7.1
What's new in PHP 7.1Simon Jones
 
Winter%200405%20-%20Beginning%20PHP
Winter%200405%20-%20Beginning%20PHPWinter%200405%20-%20Beginning%20PHP
Winter%200405%20-%20Beginning%20PHPtutorialsruby
 
Winter%200405%20-%20Beginning%20PHP
Winter%200405%20-%20Beginning%20PHPWinter%200405%20-%20Beginning%20PHP
Winter%200405%20-%20Beginning%20PHPtutorialsruby
 
Embrace dynamic PHP
Embrace dynamic PHPEmbrace dynamic PHP
Embrace dynamic PHPPaul Houle
 

Semelhante a Peek at PHP 7 (20)

Migrating to PHP 7
Migrating to PHP 7Migrating to PHP 7
Migrating to PHP 7
 
Preparing code for Php 7 workshop
Preparing code for Php 7 workshopPreparing code for Php 7 workshop
Preparing code for Php 7 workshop
 
Php7 HHVM and co
Php7 HHVM and coPhp7 HHVM and co
Php7 HHVM and co
 
TAKING PHP SERIOUSLY - Keith Adams
TAKING PHP SERIOUSLY - Keith AdamsTAKING PHP SERIOUSLY - Keith Adams
TAKING PHP SERIOUSLY - Keith Adams
 
Php7 hhvm and co
Php7 hhvm and coPhp7 hhvm and co
Php7 hhvm and co
 
What To Expect From PHP7
What To Expect From PHP7What To Expect From PHP7
What To Expect From PHP7
 
Welcome to hack
Welcome to hackWelcome to hack
Welcome to hack
 
The new features of PHP 7 - Enrico Zimuel - Codemotion Milan 2016
The new features of PHP 7 - Enrico Zimuel - Codemotion Milan 2016The new features of PHP 7 - Enrico Zimuel - Codemotion Milan 2016
The new features of PHP 7 - Enrico Zimuel - Codemotion Milan 2016
 
The new features of PHP 7
The new features of PHP 7The new features of PHP 7
The new features of PHP 7
 
PHP Basics and Demo HackU
PHP Basics and Demo HackUPHP Basics and Demo HackU
PHP Basics and Demo HackU
 
Prersentation
PrersentationPrersentation
Prersentation
 
Upstate CSCI 450 PHP Chapters 5, 12, 13
Upstate CSCI 450 PHP Chapters 5, 12, 13Upstate CSCI 450 PHP Chapters 5, 12, 13
Upstate CSCI 450 PHP Chapters 5, 12, 13
 
Php Crash Course - Macq Electronique 2010
Php Crash Course - Macq Electronique 2010Php Crash Course - Macq Electronique 2010
Php Crash Course - Macq Electronique 2010
 
Materi Dasar PHP
Materi Dasar PHPMateri Dasar PHP
Materi Dasar PHP
 
Php mysql
Php mysqlPhp mysql
Php mysql
 
PHP - Introduction to PHP Fundamentals
PHP -  Introduction to PHP FundamentalsPHP -  Introduction to PHP Fundamentals
PHP - Introduction to PHP Fundamentals
 
What's new in PHP 7.1
What's new in PHP 7.1What's new in PHP 7.1
What's new in PHP 7.1
 
Winter%200405%20-%20Beginning%20PHP
Winter%200405%20-%20Beginning%20PHPWinter%200405%20-%20Beginning%20PHP
Winter%200405%20-%20Beginning%20PHP
 
Winter%200405%20-%20Beginning%20PHP
Winter%200405%20-%20Beginning%20PHPWinter%200405%20-%20Beginning%20PHP
Winter%200405%20-%20Beginning%20PHP
 
Embrace dynamic PHP
Embrace dynamic PHPEmbrace dynamic PHP
Embrace dynamic PHP
 

Mais de John Coggeshall

Virtualization for Developers
Virtualization for DevelopersVirtualization for Developers
Virtualization for DevelopersJohn Coggeshall
 
ZF2 Modules: Events, Services, and of course, modularity
ZF2 Modules: Events, Services, and of course, modularityZF2 Modules: Events, Services, and of course, modularity
ZF2 Modules: Events, Services, and of course, modularityJohn Coggeshall
 
PHP Development for Google Glass using Phass
PHP Development for Google Glass using PhassPHP Development for Google Glass using Phass
PHP Development for Google Glass using PhassJohn Coggeshall
 
Virtualization for Developers
Virtualization for DevelopersVirtualization for Developers
Virtualization for DevelopersJohn Coggeshall
 
Development with Vagrant
Development with VagrantDevelopment with Vagrant
Development with VagrantJohn Coggeshall
 
Introduction to Zend Framework 2
Introduction to Zend Framework 2Introduction to Zend Framework 2
Introduction to Zend Framework 2John Coggeshall
 
10 things not to do at a Startup
10 things not to do at a Startup10 things not to do at a Startup
10 things not to do at a StartupJohn Coggeshall
 
Virtualization for Developers
Virtualization for DevelopersVirtualization for Developers
Virtualization for DevelopersJohn Coggeshall
 
Building PHP Powered Android Applications
Building PHP Powered Android ApplicationsBuilding PHP Powered Android Applications
Building PHP Powered Android ApplicationsJohn Coggeshall
 
Ria Applications And PHP
Ria Applications And PHPRia Applications And PHP
Ria Applications And PHPJohn Coggeshall
 
Apache Con 2008 Top 10 Mistakes
Apache Con 2008 Top 10 MistakesApache Con 2008 Top 10 Mistakes
Apache Con 2008 Top 10 MistakesJohn Coggeshall
 
Ria Development With Flex And PHP
Ria Development With Flex And PHPRia Development With Flex And PHP
Ria Development With Flex And PHPJohn Coggeshall
 
Top 10 Scalability Mistakes
Top 10 Scalability MistakesTop 10 Scalability Mistakes
Top 10 Scalability MistakesJohn Coggeshall
 
Enterprise PHP: A Case Study
Enterprise PHP: A Case StudyEnterprise PHP: A Case Study
Enterprise PHP: A Case StudyJohn Coggeshall
 
Building Dynamic Web Applications on i5 with PHP
Building Dynamic Web Applications on i5 with PHPBuilding Dynamic Web Applications on i5 with PHP
Building Dynamic Web Applications on i5 with PHPJohn Coggeshall
 
Migrating from PHP 4 to PHP 5
Migrating from PHP 4 to PHP 5Migrating from PHP 4 to PHP 5
Migrating from PHP 4 to PHP 5John Coggeshall
 

Mais de John Coggeshall (20)

Virtualization for Developers
Virtualization for DevelopersVirtualization for Developers
Virtualization for Developers
 
ZF2 Modules: Events, Services, and of course, modularity
ZF2 Modules: Events, Services, and of course, modularityZF2 Modules: Events, Services, and of course, modularity
ZF2 Modules: Events, Services, and of course, modularity
 
PHP Development for Google Glass using Phass
PHP Development for Google Glass using PhassPHP Development for Google Glass using Phass
PHP Development for Google Glass using Phass
 
Virtualization for Developers
Virtualization for DevelopersVirtualization for Developers
Virtualization for Developers
 
Development with Vagrant
Development with VagrantDevelopment with Vagrant
Development with Vagrant
 
Introduction to Zend Framework 2
Introduction to Zend Framework 2Introduction to Zend Framework 2
Introduction to Zend Framework 2
 
10 things not to do at a Startup
10 things not to do at a Startup10 things not to do at a Startup
10 things not to do at a Startup
 
Virtualization for Developers
Virtualization for DevelopersVirtualization for Developers
Virtualization for Developers
 
Puppet
PuppetPuppet
Puppet
 
Building PHP Powered Android Applications
Building PHP Powered Android ApplicationsBuilding PHP Powered Android Applications
Building PHP Powered Android Applications
 
Ria Applications And PHP
Ria Applications And PHPRia Applications And PHP
Ria Applications And PHP
 
Beyond the Browser
Beyond the BrowserBeyond the Browser
Beyond the Browser
 
Apache Con 2008 Top 10 Mistakes
Apache Con 2008 Top 10 MistakesApache Con 2008 Top 10 Mistakes
Apache Con 2008 Top 10 Mistakes
 
Ria Development With Flex And PHP
Ria Development With Flex And PHPRia Development With Flex And PHP
Ria Development With Flex And PHP
 
Top 10 Scalability Mistakes
Top 10 Scalability MistakesTop 10 Scalability Mistakes
Top 10 Scalability Mistakes
 
Enterprise PHP: A Case Study
Enterprise PHP: A Case StudyEnterprise PHP: A Case Study
Enterprise PHP: A Case Study
 
Building Dynamic Web Applications on i5 with PHP
Building Dynamic Web Applications on i5 with PHPBuilding Dynamic Web Applications on i5 with PHP
Building Dynamic Web Applications on i5 with PHP
 
PHP Security Basics
PHP Security BasicsPHP Security Basics
PHP Security Basics
 
Migrating from PHP 4 to PHP 5
Migrating from PHP 4 to PHP 5Migrating from PHP 4 to PHP 5
Migrating from PHP 4 to PHP 5
 
Ajax and PHP
Ajax and PHPAjax and PHP
Ajax and PHP
 

Último

Indian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
Indian Escort in Abu DHabi 0508644382 Abu Dhabi EscortsIndian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
Indian Escort in Abu DHabi 0508644382 Abu Dhabi EscortsMonica Sydney
 
Meaning of On page SEO & its process in detail.
Meaning of On page SEO & its process in detail.Meaning of On page SEO & its process in detail.
Meaning of On page SEO & its process in detail.krishnachandrapal52
 
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样ayvbos
 
"Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency""Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency"growthgrids
 
Vip Firozabad Phone 8250092165 Escorts Service At 6k To 30k Along With Ac Room
Vip Firozabad Phone 8250092165 Escorts Service At 6k To 30k Along With Ac RoomVip Firozabad Phone 8250092165 Escorts Service At 6k To 30k Along With Ac Room
Vip Firozabad Phone 8250092165 Escorts Service At 6k To 30k Along With Ac Roommeghakumariji156
 
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girls
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girlsRussian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girls
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girlsMonica Sydney
 
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrStory Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrHenryBriggs2
 
APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53APNIC
 
Microsoft Azure Arc Customer Deck Microsoft
Microsoft Azure Arc Customer Deck MicrosoftMicrosoft Azure Arc Customer Deck Microsoft
Microsoft Azure Arc Customer Deck MicrosoftAanSulistiyo
 
75539-Cyber Security Challenges PPT.pptx
75539-Cyber Security Challenges PPT.pptx75539-Cyber Security Challenges PPT.pptx
75539-Cyber Security Challenges PPT.pptxAsmae Rabhi
 
原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查
原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查
原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查ydyuyu
 
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge GraphsEleniIlkou
 
Russian Escort Abu Dhabi 0503464457 Abu DHabi Escorts
Russian Escort Abu Dhabi 0503464457 Abu DHabi EscortsRussian Escort Abu Dhabi 0503464457 Abu DHabi Escorts
Russian Escort Abu Dhabi 0503464457 Abu DHabi EscortsMonica Sydney
 
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查ydyuyu
 
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdfpdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdfJOHNBEBONYAP1
 
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
20240510 QFM016 Irresponsible AI Reading List April 2024.pdfMatthew Sinclair
 
Real Men Wear Diapers T Shirts sweatshirt
Real Men Wear Diapers T Shirts sweatshirtReal Men Wear Diapers T Shirts sweatshirt
Real Men Wear Diapers T Shirts sweatshirtrahman018755
 
Trump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts SweatshirtTrump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts Sweatshirtrahman018755
 
20240508 QFM014 Elixir Reading List April 2024.pdf
20240508 QFM014 Elixir Reading List April 2024.pdf20240508 QFM014 Elixir Reading List April 2024.pdf
20240508 QFM014 Elixir Reading List April 2024.pdfMatthew Sinclair
 
Power point inglese - educazione civica di Nuria Iuzzolino
Power point inglese - educazione civica di Nuria IuzzolinoPower point inglese - educazione civica di Nuria Iuzzolino
Power point inglese - educazione civica di Nuria Iuzzolinonuriaiuzzolino1
 

Último (20)

Indian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
Indian Escort in Abu DHabi 0508644382 Abu Dhabi EscortsIndian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
Indian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
 
Meaning of On page SEO & its process in detail.
Meaning of On page SEO & its process in detail.Meaning of On page SEO & its process in detail.
Meaning of On page SEO & its process in detail.
 
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
 
"Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency""Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency"
 
Vip Firozabad Phone 8250092165 Escorts Service At 6k To 30k Along With Ac Room
Vip Firozabad Phone 8250092165 Escorts Service At 6k To 30k Along With Ac RoomVip Firozabad Phone 8250092165 Escorts Service At 6k To 30k Along With Ac Room
Vip Firozabad Phone 8250092165 Escorts Service At 6k To 30k Along With Ac Room
 
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girls
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girlsRussian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girls
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girls
 
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrStory Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
 
APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53
 
Microsoft Azure Arc Customer Deck Microsoft
Microsoft Azure Arc Customer Deck MicrosoftMicrosoft Azure Arc Customer Deck Microsoft
Microsoft Azure Arc Customer Deck Microsoft
 
75539-Cyber Security Challenges PPT.pptx
75539-Cyber Security Challenges PPT.pptx75539-Cyber Security Challenges PPT.pptx
75539-Cyber Security Challenges PPT.pptx
 
原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查
原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查
原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查
 
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
 
Russian Escort Abu Dhabi 0503464457 Abu DHabi Escorts
Russian Escort Abu Dhabi 0503464457 Abu DHabi EscortsRussian Escort Abu Dhabi 0503464457 Abu DHabi Escorts
Russian Escort Abu Dhabi 0503464457 Abu DHabi Escorts
 
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
 
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdfpdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
 
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
 
Real Men Wear Diapers T Shirts sweatshirt
Real Men Wear Diapers T Shirts sweatshirtReal Men Wear Diapers T Shirts sweatshirt
Real Men Wear Diapers T Shirts sweatshirt
 
Trump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts SweatshirtTrump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts Sweatshirt
 
20240508 QFM014 Elixir Reading List April 2024.pdf
20240508 QFM014 Elixir Reading List April 2024.pdf20240508 QFM014 Elixir Reading List April 2024.pdf
20240508 QFM014 Elixir Reading List April 2024.pdf
 
Power point inglese - educazione civica di Nuria Iuzzolino
Power point inglese - educazione civica di Nuria IuzzolinoPower point inglese - educazione civica di Nuria Iuzzolino
Power point inglese - educazione civica di Nuria Iuzzolino
 

Peek at PHP 7

  • 2. WELCOME! • The CV • PHP Core contributor (author of ext/tidy) • PHP Developer since 96’ • Published lots of things • Spoken lots of places Melted Metal! Love the boat!
  • 3. ALL THE THINGS : PHP 7 • PHP 7 is the next major iteration of the PHP language • Awesome new language features • More sanity / consistency • More speed! • But wait, what happened to PHP 6? • PHP 6 is dead. • The short version: PHP 6’s big push was going to be Unicode support, but there wasn’t enough developers to get that done so the tree stagnated and died. • When will PHP 7 be released? • Best guess: GA Fall, 2015
  • 4. Warning Everything I say here could be wrong. … It’s probably not … A lot of it is already implemented … I probably got the date wrong … There aren’t RFCs for everything … At least I didn’t write a book on PHP 6
  • 6. THE DEATH OF E_STRICT • E_STRICT was our way of telling developers they were doing it wrong ™ • In PHP 7, E_STRICT is gone, and anything that was E_STRICT has been upgraded to one of the following: • Nothing (we just removed the E_STRICT error because it was dumb) • Make it an E_DEPRECATED error (probably should have ran with this from the beginning) • Promote it to an E_NOTICE or E_WARNING (we’re serious about not letting you do these things, knock it off) Oh, Yeah! Hell, No. 28 4 https://wiki.php.net/rfc/reclassify_e_strict
  • 7. CALL TO MEMBER FUNCTION OF …ARG!! • A really common error in PHP 5+ is “Call to member function blah() of non object” • Basically, you tried to call a method on something that wasn’t an object (typically NULL) • $foo->bar->baz(); • In PHP 5, this is a fatal error and your application blows up • In PHP 7 this has been changed to an E_RECOVERABLE_ERROR making it something you can, you know, recover from in your application Oh, Yeah! Hell, No. 32 0 https://wiki.php.net/rfc/catchable-call-to-member-of- non-object
  • 8. ENGINE EXCEPTIONS • PHP 7 introduces the concept of using Exceptions for engine-level error handling to replace E_ERROR, etc. • Many / Most common error conditions will be converted to exceptions • Future error conditions will, if possible, be implemented as exceptions • Also introduced a revamped Exception object model • BaseException • EngineException • ParseException • Exception • … • Note: Existing catch code will not catch these new exceptions (clever) Oh, Yeah! Hell, No. 60 2 Oh, Yeah! Hell, No. 39 19 https://wiki.php.net/rfc/engine_exceptions_for_php7
  • 10. WAIT.. THIS WAS BROKEN?? • In current versions of PHP, some internal classes could fail in the constructor and return a object that, for all intensive purposes, was broken. • In PHP 7, all internal classes throw exceptions in their constructors to prevent broken instances <?php // Reflection function is not meant to accept an array (E_WARNING) $reflection = new ReflectionFunction([]); // Blows up var_dump($reflection->getParameters()); Oh, Yeah! Hell, No. 32 1 https://wiki.php.net/rfc/internal_constructor_behaviour
  • 11. SPEAKING OF CONSTRUCTORS.. • Also in PHP 7, the PHP 4 (circa 2000 – 15 years old) style of object constructors having the same name as the class are one step closer to dying to the relief of all serious developers. • Methods named the same thing as the class (i.e. Filter::filter()) are just methods now • Constructors are called __construct() • In PHP 7 if it looks like you are using this horrible behavior it will now yell at you with an E_DEPRECIATED Oh, Yeah! Hell, No. 50 4 https://wiki.php.net/rfc/remove_php4_constructors
  • 12. SIMPLIFIED USE STATEMENTS • In PHP 7 we have added the notion of use statement “groups” • Cleans up the top of our scripts use FooBarClassA; use FooBarClassB; use FooBarClassC; use FooBar{ClassA, ClassB, ClassC}; https://wiki.php.net/rfc/group_use_declarations Oh, Yeah! Hell, No. 39 19
  • 14. SPACESHIPS! https://wiki.php.net/rfc/combined-comparison-operator • PHP 7 Introduces the “Combined Comparison Operator” (a.k.a. the Spaceship operator) Operator <=> Equivalent $a < $b ( $a <=> $b) === -1 $a <= $b ($a <=> $b) === -1 || ($a <=> $b) === 0 $a == $b ($a <=> $b) === 0 $a != $b ($a <=> $b) !== 0 $a >= $b ($a <=> $b) === 1 || ($a <=> $b) === 0 $a > $b ($a <=> $b) === 1 Oh, Yeah! Hell, No. 43 11
  • 15. ?? OPERATOR • No, that wasn’t a placeholder in my slides • The ?? Operator, or Null Coalesce Operator which allows us to set default values for variables when the variable doesn’t exist. • Cleaner than trying to use ?: or other approaches https://wiki.php.net/rfc/isset_ternary Oh, Yeah! Hell, No. 31 3 <?php // Useful for when you want to set default values for variables $user = $_GET[‘user’] ?? ‘nobody’;
  • 16. RETURN TYPES • My personal war over the years has included this one • Return type-hints will finally be part of PHP in PHP 7 • Doesn’t support “nullable” types (yet) <?php // Useful for when you want to set default values for variables function returnsArray(): array { return [‘happy’, ‘days’]; } Oh, Yeah! Hell, No. 47 3 https://wiki.php.net/rfc/return_types
  • 17. UNIFORM VARIABLE SYNTAX • PHP has some… complicated|odd|dumb|insane variable syntax possibilities • $foo->$bar[‘baz’]() • There are a lot of inconsistencies in the way we resolve variables when they get a little crazy • In PHP 7, we are introducing a uniform syntax and fixing all of those issues https://wiki.php.net/rfc/uniform_variable_syntax Oh, Yeah! Hell, No. 30 1 <?php $foo()[‘bar’](); // Call closure in array from return value [$obj1, $obj2][0]->prop; // Access $obj1->prop returnString(){0}; // Return first character $foo::$bar::$baz; // Stacked static calls $foo->bar()::baz(); // Stacked mixed calls $foo()(); // Stacked function calls $foo->bar()(); // Stacked method calls
  • 18. WE STILL HAD THAT? • Arcane open tags for PHP scripts are no longer supported in PHP 7 • ASP-style <% %> • HTML-style <script language=“php”></script> • Also, Hexadecimal support for “numeric strings” has been removed • Before: ‘0x01’ == ‘1’ (true) • Before: (int)’0x01’ == (int)’1’ (false, wtf?) • Now: ‘0x01’ == ‘1’ (false) Oh, Yeah! Hell, No. 26 8 Oh, Yeah! Hell, No. 29 0 https://wiki.php.net/rfc/remove_hex_support_in_numeric_strings https://wiki.php.net/rfc/remove_alternative_php_tags
  • 19. SCALAR TYPE HINTS • PHP 7 will have support for scalar type hinting in addition to the already supported complex-type hinting • Introduces the notion of declare(strict_types=1) directives • Per-file directive • Put at the top of the file, will enforce strict typing of return values • Caller file counts, not source file Oh, Yeah! Hell, No. 108 48 https://wiki.php.net/rfc/scalar_type_hints_v5 <?php declare(strict_types=1); function add(float $a, float $b) : float { return $a + $b; } add(1, 2); // retval = float(3)
  • 20. NEW LIST() BEHAVIOR • The list() statement(?) is a odd thing in PHP used to extract array values into variables • list($a, $b, $c) = [1, 2, 3]; // $a = 1, $b = 2, $c = 3 • In PHP 7 there are a couple of changes to the behavior • list() now assigns variables left-to-right instead of right-to left • list() no longer supports extracting values from strings <?php $a = [] list($a[], $a[], $a[]) = [1, 2 ,3]; // OLD: $a = [3, 2, 1]; // NEW: $a = [1, 2, 3]; https://wiki.php.net/rfc/abstract_syntax_tree https://wiki.php.net/rfc/fix_list_behavior_inconsistency
  • 21. GO JOHNNY, GO! • The so-called PHPNG branch of PHP has been merged as the basis for the engine in PHP 7 • Translation: PHP most of the time is a lot faster than before • One step closer to effective meaningful JIT for PHP Oh, Yeah! Hell, No. 47 2 https://wiki.php.net/rfc/phpng
  • 22. KEEP UP TO DATE WITH THE LATEST • PHP 7 like all things is going to be a moving target until it is done • There is a VirtualBox of PHP 7 to toy around with maintained by Rasmus Lerdorf • https://github.com/rlerdorf/php7dev • The PHP RFC Wiki is also a great source of more details on everything we’ve discussed and the things currently being considered • https://wiki.php.net/rfc