SlideShare une entreprise Scribd logo
1  sur  19
PHP 7 – A look at the future
by Radu Murzea
25 July 2015
Agenda
 A bit of History
 Most important new features of PHP 7
 Mini-demo of each one
 Q&A
PHP – A bit of high-level history
PHP < 5
1995 - 2008
PHP with
most known
features
Zend
Engine 1
PHP – A bit of high-level history
PHP < 5
1995 - 2008 2004 - 2017
PHP 5
PHP with
most known
features
Zend
Engine 1
Zend
Engine 2
New
Object-Oriented
Model
PHP – A bit of high-level history
PHP < 5
1995 - 2008 2004 - 2017 2015 - ?
PHP 5 PHP 7
PHP with
most known
features
Zend
Engine 1
Zend
Engine 2
Zend
Engine 3
New
Object-Oriented
Model
Keep reading
AST-based Compilation
Separation of parser and compiler
 Higher Maintainability
 Decouple syntax issues from technical issues
Performance Improvement
 Usually 10 – 20 % faster
 But requires more memory
Removes many syntax limitations
 See “Uniform Variable Syntax” Chapter
Reference
 https://wiki.php.net/rfc/abstract_syntax_tree
AST
looks
like this
Uniform Variable Syntax
Consistent left-to-right variable dereferencing
 Stuff like this is now possible:
 $foo['bar']->baz->oof()::$rab
 explode(‘|’, $x)[3]
 $foo()[‘bar’]()
 foo()()
 (function() { return 1+2+3; })()
 ‘Foo’::$bar
Reference
 https://wiki.php.net/rfc/uniform_variable_syntax
Return Type Declarations (I)
Motivation
 Prevent unintended return values
 Document return type in a way that is not easily removed (like phpdoc
comments)
Rules
 In case of inheritance -> invariant enforcement
 If return type is declared, NULL may not be returned
 Not allowed on __construct(), __destruct() and __clone()
 Multiple return types are NOT allowed
Return Type Declarations (II)
Reference
 https://wiki.php.net/rfc/return_types
Example
class MyClass {
function a() { //return type is optional
return 123;
}
function b(): int { //fatal error - "int" doesn't exist
return 123;
}
function c(): ClassB { //fatal error - can't return null here
return null;
}
}
Anonymous Classes (I)
Motivation
 Anonymous classes are frequently used in other languages (Java, C#)
Basic Rules
 Instantiating requires providing values to constructor arguments
 Inheritance and Traits works just like for named classes
 Attempting to serialize will result in an ERROR
Use Cases
 In very simple cases, where dedicated file + class-doc = overkill
 When it’s small + you need it only once during execution
 When you don’t want to hit the autoloader for extremely simple classes
 Primitive support for situations where inner classes would make sense
Reference
 https://wiki.php.net/rfc/anonymous_classes
Anonymous Classes (II)
Examples
$x = new class(123) {
public function __construct($a) {
$this->a = $a;
}
};
(new class extends SomeClass implements SomeInterface {
public function init() { /* ... */ }
})->doStuff();
class MyClass extends MyOtherClass {
public function getInstance() {
return new class implements MyInt { /* ... */ };
}
}
Many Fatal Errors become Exceptions
Motivation
 Execution immediately aborted, cannot be recovered from
 finally blocks or __destructor() s are not called
Solution
Reference
 https://wiki.php.net/rfc/engine_exceptions_for_php7
 https://wiki.php.net/rfc/throwable-interface
 https://trowski.com/2015/06/24/throwable-exceptions-and-errors-in-php7/
Context Sensitive Lexer
Motivation
 PHP reserved words prevent good/natural API designs
Example
This is now possible:
Finder::for(‘project’)
->where(‘name’)->like(‘%secret%’)
->and(‘priority’, ‘>’, 9)
->or(‘code’)->in([‘4’, ‘5’, ‘7’])
->and()->not(‘created_at’)->between([$t1, $t2])
->list($limit, $offset);
Reference
 https://wiki.php.net/rfc/context_sensitive_lexer
Grouping Use Declarations (I)
Motivation
 Cut verbosity when importing classes, functions or constants
 Easier to identify which entities belong to the same module
Reference
 https://wiki.php.net/rfc/group_use_declarations
Example
This:
use FooBarStuffA;
use FooBarStuffB as MyB;
becomes this:
use FooBar{
StuffA,
StuffB as MyB
};
Null Coalesce Operator
Motivation
 Operations like “if data exists, use it; otherwise use default” are quite
cumbersome to do
Description/Examples
 Denoted by ??
 Returns result of 1st operand if it exists and is not NULL; otherwise
returns 2nd operand
 The following 2 statements are equivalent:
 $a = isset($_GET[‘a’]) ? $_GET[‘a’] : ‘default’;
 $a = $_GET[‘a’] ?? ‘default’;
 The following 2 statements are equivalent as well:
 if (($a = A::$value) === null) { $a = $default; }
 $a = A::$value ?? $default;
Reference
 https://wiki.php.net/rfc/isset_ternary
Unicode Code Point Escape Syntax
Motivation
 Proper escape syntax for Unicode characters
 Support for more than 16-bit-length BPM characters
 Syntax is u{xxxxxx} – with variable length
Examples
 echo "u{202E}Right-to-left text";
will print: txet tfel-ot-thgiR
 echo “u{1F602}”; //Emoji – Face with Tears of Joy
will print:
Reference
 https://wiki.php.net/rfc/unicode_escape
Performance – MediaWiki – Requests/s
 Source: http://talks.php.net/velocity15#/mwbench
Performance – Wordpress - Latency
 Source: http://talks.php.net/velocity15#/wpbench
Q & A

Contenu connexe

Tendances (20)

Php mysql ppt
Php mysql pptPhp mysql ppt
Php mysql ppt
 
PHP Workshop Notes
PHP Workshop NotesPHP Workshop Notes
PHP Workshop Notes
 
php basics
php basicsphp basics
php basics
 
PHP
PHPPHP
PHP
 
PHP7 is coming
PHP7 is comingPHP7 is coming
PHP7 is coming
 
Introduction to php basics
Introduction to php   basicsIntroduction to php   basics
Introduction to php basics
 
Php introduction
Php introductionPhp introduction
Php introduction
 
Introduction to php php++
Introduction to php php++Introduction to php php++
Introduction to php php++
 
PHP Basics
PHP BasicsPHP Basics
PHP Basics
 
Web-App Remote Code Execution Via Scripting Engines
Web-App Remote Code Execution Via Scripting EnginesWeb-App Remote Code Execution Via Scripting Engines
Web-App Remote Code Execution Via Scripting Engines
 
Basics PHP
Basics PHPBasics PHP
Basics PHP
 
PHP
PHPPHP
PHP
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
 
Php a dynamic web scripting language
Php   a dynamic web scripting languagePhp   a dynamic web scripting language
Php a dynamic web scripting language
 
PHP from soup to nuts Course Deck
PHP from soup to nuts Course DeckPHP from soup to nuts Course Deck
PHP from soup to nuts Course Deck
 
Php
PhpPhp
Php
 
Php manish
Php manishPhp manish
Php manish
 
Constructor and encapsulation in php
Constructor and encapsulation in phpConstructor and encapsulation in php
Constructor and encapsulation in php
 
Php Presentation
Php PresentationPhp Presentation
Php Presentation
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 

En vedette

A new tool for measuring performance in Drupal 8 - Drupal Dev Days Montpellier
A new tool for measuring performance in Drupal 8 - Drupal Dev Days MontpellierA new tool for measuring performance in Drupal 8 - Drupal Dev Days Montpellier
A new tool for measuring performance in Drupal 8 - Drupal Dev Days MontpellierLuca Lusso
 
Caching with Memcached and APC
Caching with Memcached and APCCaching with Memcached and APC
Caching with Memcached and APCBen Ramsey
 
Optimizing Drupal Performance Zend Acquia Whitepaper Feb2010
Optimizing Drupal Performance Zend Acquia Whitepaper Feb2010Optimizing Drupal Performance Zend Acquia Whitepaper Feb2010
Optimizing Drupal Performance Zend Acquia Whitepaper Feb2010xlight
 
How PHP Works ?
How PHP Works ?How PHP Works ?
How PHP Works ?Ravi Raj
 
The Php Life Cycle
The Php Life CycleThe Php Life Cycle
The Php Life CycleXinchen Hui
 
Apache Server Tutorial
Apache Server TutorialApache Server Tutorial
Apache Server TutorialJagat Kothari
 

En vedette (6)

A new tool for measuring performance in Drupal 8 - Drupal Dev Days Montpellier
A new tool for measuring performance in Drupal 8 - Drupal Dev Days MontpellierA new tool for measuring performance in Drupal 8 - Drupal Dev Days Montpellier
A new tool for measuring performance in Drupal 8 - Drupal Dev Days Montpellier
 
Caching with Memcached and APC
Caching with Memcached and APCCaching with Memcached and APC
Caching with Memcached and APC
 
Optimizing Drupal Performance Zend Acquia Whitepaper Feb2010
Optimizing Drupal Performance Zend Acquia Whitepaper Feb2010Optimizing Drupal Performance Zend Acquia Whitepaper Feb2010
Optimizing Drupal Performance Zend Acquia Whitepaper Feb2010
 
How PHP Works ?
How PHP Works ?How PHP Works ?
How PHP Works ?
 
The Php Life Cycle
The Php Life CycleThe Php Life Cycle
The Php Life Cycle
 
Apache Server Tutorial
Apache Server TutorialApache Server Tutorial
Apache Server Tutorial
 

Similaire à PHP7 - A look at the future

Drupal 8 meets to symphony
Drupal 8 meets to symphonyDrupal 8 meets to symphony
Drupal 8 meets to symphonyBrahampal Singh
 
Simplify your professional web development with symfony
Simplify your professional web development with symfonySimplify your professional web development with symfony
Simplify your professional web development with symfonyFrancois Zaninotto
 
Patterns in Python
Patterns in PythonPatterns in Python
Patterns in Pythondn
 
Edp bootstrapping a-software_company
Edp bootstrapping a-software_companyEdp bootstrapping a-software_company
Edp bootstrapping a-software_companyGanesh Kulkarni
 
Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...
Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...
Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...King Foo
 
Spl in the wild - zendcon2012
Spl in the wild - zendcon2012Spl in the wild - zendcon2012
Spl in the wild - zendcon2012Elizabeth Smith
 
Drupal Best Practices
Drupal Best PracticesDrupal Best Practices
Drupal Best Practicesmanugoel2003
 
Embrace dynamic PHP
Embrace dynamic PHPEmbrace dynamic PHP
Embrace dynamic PHPPaul Houle
 
Tips
TipsTips
Tipsmclee
 
PowerShell 101
PowerShell 101PowerShell 101
PowerShell 101Thomas Lee
 
Building Web Applications with Zend Framework
Building Web Applications with Zend FrameworkBuilding Web Applications with Zend Framework
Building Web Applications with Zend FrameworkPhil Brown
 
003 web-apps-using-kohana-arafat-rahman-101107191139-phpapp02
003 web-apps-using-kohana-arafat-rahman-101107191139-phpapp02003 web-apps-using-kohana-arafat-rahman-101107191139-phpapp02
003 web-apps-using-kohana-arafat-rahman-101107191139-phpapp02Julio Pari
 
Living With Legacy Code
Living With Legacy CodeLiving With Legacy Code
Living With Legacy CodeRowan Merewood
 
Automatic testing and quality assurance for WordPress plugins and themes
Automatic testing and quality assurance for WordPress plugins and themesAutomatic testing and quality assurance for WordPress plugins and themes
Automatic testing and quality assurance for WordPress plugins and themesOtto Kekäläinen
 
Performance tuning with zend framework
Performance tuning with zend frameworkPerformance tuning with zend framework
Performance tuning with zend frameworkAlan Seiden
 

Similaire à PHP7 - A look at the future (20)

Drupal 8 meets to symphony
Drupal 8 meets to symphonyDrupal 8 meets to symphony
Drupal 8 meets to symphony
 
Simplify your professional web development with symfony
Simplify your professional web development with symfonySimplify your professional web development with symfony
Simplify your professional web development with symfony
 
Patterns in Python
Patterns in PythonPatterns in Python
Patterns in Python
 
PHP 5
PHP 5PHP 5
PHP 5
 
Edp bootstrapping a-software_company
Edp bootstrapping a-software_companyEdp bootstrapping a-software_company
Edp bootstrapping a-software_company
 
Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...
Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...
Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...
 
Current state-of-php
Current state-of-phpCurrent state-of-php
Current state-of-php
 
Spl in the wild - zendcon2012
Spl in the wild - zendcon2012Spl in the wild - zendcon2012
Spl in the wild - zendcon2012
 
Drupal Best Practices
Drupal Best PracticesDrupal Best Practices
Drupal Best Practices
 
Embrace dynamic PHP
Embrace dynamic PHPEmbrace dynamic PHP
Embrace dynamic PHP
 
Spl in the wild
Spl in the wildSpl in the wild
Spl in the wild
 
Tips
TipsTips
Tips
 
PowerShell 101
PowerShell 101PowerShell 101
PowerShell 101
 
Building Web Applications with Zend Framework
Building Web Applications with Zend FrameworkBuilding Web Applications with Zend Framework
Building Web Applications with Zend Framework
 
003 web-apps-using-kohana-arafat-rahman-101107191139-phpapp02
003 web-apps-using-kohana-arafat-rahman-101107191139-phpapp02003 web-apps-using-kohana-arafat-rahman-101107191139-phpapp02
003 web-apps-using-kohana-arafat-rahman-101107191139-phpapp02
 
Effective PHP. Part 4
Effective PHP. Part 4Effective PHP. Part 4
Effective PHP. Part 4
 
Living With Legacy Code
Living With Legacy CodeLiving With Legacy Code
Living With Legacy Code
 
PHP 5.3
PHP 5.3PHP 5.3
PHP 5.3
 
Automatic testing and quality assurance for WordPress plugins and themes
Automatic testing and quality assurance for WordPress plugins and themesAutomatic testing and quality assurance for WordPress plugins and themes
Automatic testing and quality assurance for WordPress plugins and themes
 
Performance tuning with zend framework
Performance tuning with zend frameworkPerformance tuning with zend framework
Performance tuning with zend framework
 

Dernier

TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 

Dernier (20)

TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 

PHP7 - A look at the future

  • 1. PHP 7 – A look at the future by Radu Murzea 25 July 2015
  • 2. Agenda  A bit of History  Most important new features of PHP 7  Mini-demo of each one  Q&A
  • 3. PHP – A bit of high-level history PHP < 5 1995 - 2008 PHP with most known features Zend Engine 1
  • 4. PHP – A bit of high-level history PHP < 5 1995 - 2008 2004 - 2017 PHP 5 PHP with most known features Zend Engine 1 Zend Engine 2 New Object-Oriented Model
  • 5. PHP – A bit of high-level history PHP < 5 1995 - 2008 2004 - 2017 2015 - ? PHP 5 PHP 7 PHP with most known features Zend Engine 1 Zend Engine 2 Zend Engine 3 New Object-Oriented Model Keep reading
  • 6. AST-based Compilation Separation of parser and compiler  Higher Maintainability  Decouple syntax issues from technical issues Performance Improvement  Usually 10 – 20 % faster  But requires more memory Removes many syntax limitations  See “Uniform Variable Syntax” Chapter Reference  https://wiki.php.net/rfc/abstract_syntax_tree AST looks like this
  • 7. Uniform Variable Syntax Consistent left-to-right variable dereferencing  Stuff like this is now possible:  $foo['bar']->baz->oof()::$rab  explode(‘|’, $x)[3]  $foo()[‘bar’]()  foo()()  (function() { return 1+2+3; })()  ‘Foo’::$bar Reference  https://wiki.php.net/rfc/uniform_variable_syntax
  • 8. Return Type Declarations (I) Motivation  Prevent unintended return values  Document return type in a way that is not easily removed (like phpdoc comments) Rules  In case of inheritance -> invariant enforcement  If return type is declared, NULL may not be returned  Not allowed on __construct(), __destruct() and __clone()  Multiple return types are NOT allowed
  • 9. Return Type Declarations (II) Reference  https://wiki.php.net/rfc/return_types Example class MyClass { function a() { //return type is optional return 123; } function b(): int { //fatal error - "int" doesn't exist return 123; } function c(): ClassB { //fatal error - can't return null here return null; } }
  • 10. Anonymous Classes (I) Motivation  Anonymous classes are frequently used in other languages (Java, C#) Basic Rules  Instantiating requires providing values to constructor arguments  Inheritance and Traits works just like for named classes  Attempting to serialize will result in an ERROR Use Cases  In very simple cases, where dedicated file + class-doc = overkill  When it’s small + you need it only once during execution  When you don’t want to hit the autoloader for extremely simple classes  Primitive support for situations where inner classes would make sense Reference  https://wiki.php.net/rfc/anonymous_classes
  • 11. Anonymous Classes (II) Examples $x = new class(123) { public function __construct($a) { $this->a = $a; } }; (new class extends SomeClass implements SomeInterface { public function init() { /* ... */ } })->doStuff(); class MyClass extends MyOtherClass { public function getInstance() { return new class implements MyInt { /* ... */ }; } }
  • 12. Many Fatal Errors become Exceptions Motivation  Execution immediately aborted, cannot be recovered from  finally blocks or __destructor() s are not called Solution Reference  https://wiki.php.net/rfc/engine_exceptions_for_php7  https://wiki.php.net/rfc/throwable-interface  https://trowski.com/2015/06/24/throwable-exceptions-and-errors-in-php7/
  • 13. Context Sensitive Lexer Motivation  PHP reserved words prevent good/natural API designs Example This is now possible: Finder::for(‘project’) ->where(‘name’)->like(‘%secret%’) ->and(‘priority’, ‘>’, 9) ->or(‘code’)->in([‘4’, ‘5’, ‘7’]) ->and()->not(‘created_at’)->between([$t1, $t2]) ->list($limit, $offset); Reference  https://wiki.php.net/rfc/context_sensitive_lexer
  • 14. Grouping Use Declarations (I) Motivation  Cut verbosity when importing classes, functions or constants  Easier to identify which entities belong to the same module Reference  https://wiki.php.net/rfc/group_use_declarations Example This: use FooBarStuffA; use FooBarStuffB as MyB; becomes this: use FooBar{ StuffA, StuffB as MyB };
  • 15. Null Coalesce Operator Motivation  Operations like “if data exists, use it; otherwise use default” are quite cumbersome to do Description/Examples  Denoted by ??  Returns result of 1st operand if it exists and is not NULL; otherwise returns 2nd operand  The following 2 statements are equivalent:  $a = isset($_GET[‘a’]) ? $_GET[‘a’] : ‘default’;  $a = $_GET[‘a’] ?? ‘default’;  The following 2 statements are equivalent as well:  if (($a = A::$value) === null) { $a = $default; }  $a = A::$value ?? $default; Reference  https://wiki.php.net/rfc/isset_ternary
  • 16. Unicode Code Point Escape Syntax Motivation  Proper escape syntax for Unicode characters  Support for more than 16-bit-length BPM characters  Syntax is u{xxxxxx} – with variable length Examples  echo "u{202E}Right-to-left text"; will print: txet tfel-ot-thgiR  echo “u{1F602}”; //Emoji – Face with Tears of Joy will print: Reference  https://wiki.php.net/rfc/unicode_escape
  • 17. Performance – MediaWiki – Requests/s  Source: http://talks.php.net/velocity15#/mwbench
  • 18. Performance – Wordpress - Latency  Source: http://talks.php.net/velocity15#/wpbench
  • 19. Q & A