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
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
210
Upgrading Legacy to the Latest PHP Version
afilina
1
230
Better Code Design in PHP
afilina
0
330
Semi-Automated Refactoring and Upgrades with Rector
afilina
0
220
Better Code Design in PHP
afilina
1
490
Better Code Design in PHP
afilina
0
650
Adding Tests to Untestable Legacy Code
afilina
0
440
Upgrading Legacy to the Latest PHP Version
afilina
0
450
Semi-Automated Refactoring and Upgrades with Rector
afilina
0
360
Other Decks in Programming
See All in Programming
思考垂れ流し開発 ~音声入力 × AIエージェント × 開発ハーネスによる試行錯誤~
npostring
0
810
まだ間に合う!今年の夏こそSchemeのマクロ展開器を完全理解!
omasanori
0
620
PHPプロジェクトの結合バランスを可視化する #php_night
kajitack
0
200
「AI時代、配布するPythonコードをどう守るか: 難読化の実験と判断軸」 #PyconJP2026
pkshadeck
PRO
2
130
数年滞っていたダークモード対応をおよそ2週間で完了させる
chigichan24
0
650
型解析で実現する Go の言語内 DSL / Conference に Go! タイムテーブルの歩き方 for Gophers
mazrean
0
110
AWS Step Functions 大規模並列の壁を越える / jaws-sonic-2026-niigata-step-functions
kasacchiful
PRO
0
290
My Marp Sample
sinoue0108
0
140
20260828_品質と開発生産性を両立させる、AI時代のE2Eテストの考え方
magicpod
0
120
LL言語やWebフレームワークのPostgreSQL対応 〜DBの機能がユーザーに届くまで〜
kentaroutakeda
0
130
源内ハンズオン概要編
hideg
0
240
LLMは4年分のCompose移行を再現できるのか?実プロダクト279件のXMLで探る自動化の境界線
makun
0
350
Featured
See All Featured
Evolving SEO for Evolving Search Engines
ryanjones
0
280
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.9k
Tell your own story through comics
letsgokoyo
1
1.1k
Java REST API Framework Comparison - PWX 2021
mraible
34
9.7k
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
1
2.1k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
500
Building Flexible Design Systems
yeseniaperezcruz
330
41k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
56k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.7k
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
320
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.8k
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