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
230
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
480
Better Code Design in PHP
afilina
0
650
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
170k Jobs a Day on GKE: Scaling Mercari's CI Platform - and What's Next for AI-Native Development
junyaokabe
0
110
Laravel Boostに学ぶ、AIにPHPを書かせる技術 〜OSSの実装から蒸留するエージェント制御の王道〜
kentaroutakeda
3
710
そこに3びきプロダクトがいるじゃろう——生成AI時代における“価値が届かない理由”の構造
kosuket
0
510
Built Our Own Background Agent at LayerX
layerx
PRO
10
5.6k
PHP初心者セッション2026 〜生成AIでは見えない裏側を知る:今だからLAMPを通して仕組みを学ぶ〜
kashioka
0
950
自動化したのに回らないテスト運用の壁ーAI時代の品質責任と生産性
mfunaki
1
140
数百円から始めるRuby電子工作
tarosay
0
160
yield再入門 #phpcon
o0h
PRO
0
1.1k
運用ダッシュボードの設計を誰も教えてくれないのだけどみなさんどうしてるんですか? - チームに監視するという文化を根付かせるための第一歩を踏みたい -
satoshi256kbyte
1
130
テーブルをDELETEした
yuzneri
0
140
the container ship “Apple Silicon”@WWDC26 Recap -Japan-\(region).swift
shingangan
0
130
メールのエイリアス機能を履き違えない
isshinfunada
0
240
Featured
See All Featured
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
340
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
23k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
240
Art, The Web, and Tiny UX
lynnandtonic
304
22k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
990
The Cult of Friendly URLs
andyhume
79
7k
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
1.2k
How to make the Groovebox
asonas
2
2.3k
Into the Great Unknown - MozCon
thekraken
41
2.7k
Designing for Performance
lara
611
70k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
390
Designing Powerful Visuals for Engaging Learning
tmiket
1
490
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