Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Modernize Your PHP Code
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Anna Filina
June 10, 2015
Programming
360
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Modernize Your PHP Code
Anna Filina
June 10, 2015
More Decks by Anna Filina
See All by Anna Filina
Surviving a Symfony Upgrade
afilina
1
200
Upgrading Legacy to the Latest PHP Version
afilina
1
220
Better Code Design in PHP
afilina
0
320
Semi-Automated Refactoring and Upgrades with Rector
afilina
0
220
Better Code Design in PHP
afilina
1
470
Better Code Design in PHP
afilina
0
640
Adding Tests to Untestable Legacy Code
afilina
0
430
Upgrading Legacy to the Latest PHP Version
afilina
0
440
Semi-Automated Refactoring and Upgrades with Rector
afilina
0
350
Other Decks in Programming
See All in Programming
PHPだって関数型したい 〜できること、できないこと〜 / fp-in-php
jsoizo
1
250
What's New in Android 2026
veronikapj
0
230
AWS CDK を「作」ってみた 〜フルスクラッチで見えた CDK の裏側〜 / aws-cdk-from-scratch
gotok365
3
2.6k
AI時代の仕事技芸論〜ソフトウェア開発で「遊ぶように働く」職人的熟達のすすめ(スクフェス仙台 2026バージョン)
kuranuki
0
730
Build-to-own AI: Agentic Development for Humans
inesmontani
PRO
0
100
分散システム、なんですぐ死んでしまうん?耐障害性を高めたいあなたのためのレジリエンスパターン入門
mshibuya
7
7k
AWS DevOps AgentのAzure接続機能を検証して見えた活用法/Use Cases Verified for the AWS DevOps Agent's Azure Connectivity Feature
masakiokuda
0
140
関数型プログラミングのメリットって何だろう?
wanko_it
0
200
これからAgentCoreを触る方へトレンドはGatewayです
har1101
6
510
[RVD26] Vibe Architecture en 2040 : Darwin a-t-il (enfin) eu raison des architectes ?
alexandretouret
0
110
FDEが実現するAI駆動経営の現在地
gonta
2
230
AI がコードを書く時代における新卒エンジニアの仕事風景 (2026) / New Graduate Engineers in the Era of AI Coding (2026)
sushichan044
0
240
Featured
See All Featured
sira's awesome portfolio website redesign presentation
elsirapls
0
310
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
11k
HDC tutorial
michielstock
2
760
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
Fireside Chat
paigeccino
42
4k
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
1
430
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
Art, The Web, and Tiny UX
lynnandtonic
304
22k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
340
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
350
The Limits of Empathy - UXLibs8
cassininazir
1
550
Transcript
foolab.ca | @foolabca Modernize Your PHP Code IPC, Berlin -
June 10, 2015
Anna Filina • Developer • Problem solver • Teacher •
Advisor • FooLab + ConFoo 2
Objectives • Simplify code • Improve design • Increase maintainability
• Make coding more pleasant 3
Namespaces // 5.3 // Avoid name collisions between classes. $my_user
= new MyProject\Entity\User(); $lib_user = new SomeLibrary\Entity\User(); // Alias to long names. use Company\Project\Framework\Entity as Entity $user = new Entity\User(); // Try Composer! 4
Closures / Anonymous Functions // 5.3 // Assign to a
variable $filter_function = function($item) { ... }; 5
Closures / Anonymous Functions // Callback functions $products = array(
array("name" => "Skyrim", "price" => 30), array("name" => "Destiny", "price" => 50) ); $results = array_filter($products, function($item) { return $item["price"] <= 40; }); 6
Traits // 5.4 // Import groups of properties and methods
trait TextOverlay { function setText() { ... } function setFontSize() { ... } } trait ImageBackground { function setUrl() { ... } } class FacebookQuote { use TextOverlay; use ImageBackground; } 7
Finally // 5.5 // Practical if you want to execute
code whether there is or no exception. try { create_temp_file(); write_to_temp_file(); output_temp_file(); } catch(SomeException $e) { echo "Some error"; } finally { delete_temp_file(); } 8
Short Array Syntax // 5.4 // Hard to read a
complex structure. $products = array( array( "name" => "Skyrim", "price" => 30, "requirements" => array( "os" => array("Win XP", "Win Vista", "Win 7"), "ram" => 2048 ) ), array( "name" => "Diablo 3", "price" => 50, "requirements" => array( "os" => array("Win XP", "Win Vista", "Win 7", "Win 8"), "ram" => 1024 ) ) ); 9
Short Array Syntax $products = [ [ "name" => "Skyrim",
"price" => 30, "requirements" => [ "os" => [ "Win XP", "Win Vista", "Win 7" ], "ram" => 2048 ] ], [ "name" => "Diablo 3", "price" => 50, "requirements" => [ "os" => ["Win XP", "Win Vista", "Win 7", "Win 8"], "ram" => 1024 ] ] ]; 10
Password Functions // 5.5 $pass = password_hash("mypass", PASSWORD_BCRYPT, [ "cost"
=> 12, "salt" => mcrypt_create_iv(22, MCRYPT_DEV_URANDOM) ]); // Between .25 et .50 seconds if (password_verify($form_password, $db_password)) {...} 11
Foreach With List // 5.5 $shape = [ [0, 0],
[2, 4], [4, 0] ]; foreach ($shape as list($x, $y)) { line_to_coords($x, $y); } 12
Argument Unpacking // 5.6 function addToCart($qty, $name, $price) {...} $product
= ["Civilization V", 40]; addToCart(1, ...$product); // addToCart(1, $product[0], $product[1]); 13
Anna Filina • Development: PHP, JS, etc. • Fix problems:
bugs, performance, etc. • Workshops: testing, Symfony, AngularJS, API, etc. • Advisor: testing strategy, legacy code, etc. 14
@afilina afilina.com