Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
型を意識したPHPアプリケーション開発
Search
shin1x1
October 08, 2017
Technology
11k
5
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
型を意識したPHPアプリケーション開発
2017/10/08 PHPカンファレンス2017
https://github.com/shin1x1/phpcon2017
shin1x1
October 08, 2017
More Decks by shin1x1
See All by shin1x1
Xdebug と IDE による デバッグ実行の仕組みを見る / Exploring-How-Debugging-Works-with-Xdebug-and-an-IDE
shin1x1
0
730
抽象化という思考のツール - 開発現場での活用 - / Abstraction-as-a-Tool-for-Thinking-in-dev
shin1x1
0
170
抽象化という思考のツール - 理解と活用 - / Abstraction-as-a-Tool-for-Thinking
shin1x1
1
1.6k
php-fpm がリクエスト処理する仕組みを追う / Tracing-How-php-fpm-Handles-Requests
shin1x1
6
4.2k
PHP ユーザのための OpenTelemetry 入門 / phpcon2024-opentelemetry
shin1x1
3
2.5k
PHPコードの実行モデルを理解する / Understanding-the-PHP-Execution-Model
shin1x1
2
3.4k
制約の力 - 状態を限定する -
shin1x1
6
5.9k
Apple Silicon Mac 時代の PHP 開発環境構築 2021 / php-dev-env-on-m1-mac-era
shin1x1
2
4.9k
Docker イメージのマルチアーキテクチャビルド / docker-muti-arch-build
shin1x1
1
590
Other Decks in Technology
See All in Technology
パッチ更新でterraform initが落ちた日
grimoh
1
140
Post AI時代のリファクタリング実践記 / Refactoring in the post AI era
kaminashi
1
280
専門領域のAIをどう評価するか
bengo4com
2
290
その Valkey 使いこなしていますか?
onk
PRO
5
1.6k
S3 Filesで挑む! 八戸せんべい汁の食べ頃問題
usanchuu
0
120
ソフトウェア ファクトリー - 再現性のあるソフトウェアの工場づくり / Software factory
iktakahiro
6
5.1k
Conditional PED-ANOVA: Hyperparameter Importance in Hierarchical & Dynamic Search Spaces
pfn
PRO
0
140
JAWS-UGグッズ職人仕事の流儀
kentapapa
0
120
⾮構造化データを価値に変える AI エージェント基盤とその組織
ivry_presentationmaterials
0
200
Tofu-Controller lightning talk @ Containerday 2026
gionn
0
120
TinyGoでオブザーバビリティ?OpenTelemetryはTinyGoで使えるのか / Is OpenTelemetry available in TinyGo environment?
ymotongpoo
2
140
Gemini Intelligence 入門 ― AppFunctions と Gemini Nano
takuroabe
0
290
Featured
See All Featured
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
1
3.4k
A Tale of Four Properties
chriscoyier
163
24k
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
300
Why Our Code Smells
bkeepers
PRO
340
58k
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
580
Fashionably flexible responsive web design (full day workshop)
malarkey
409
67k
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
300
Embracing the Ebb and Flow
colly
88
5.2k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
460
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
2
2.9k
Transcript
ܕΛҙࣝͨ͠ 1)1ΞϓϦέʔγϣϯ։ൃ ɹ!shin1x1 2017//08 phpcon 2017
https://php-genba.shin1x1.com/
D .BTBTIJ4IJOCBSB!TIJOY ΞδΣϯμ w1)1ͷܕγεςϜ wܕએݴΛར༻ͨ͠ίʔυ࣮ wυϝΠϯಛԽܕͷ࣮5JQT w͍͞͝ʹ
1)1ͷܕγεςϜ
&MPRVFOU 3FQPTJUPSZ $foo = 123; echo gettype($foo), PHP_EOL; => integer
$foo = 'Hello'; echo gettype($foo), PHP_EOL; => string $foo = [1, 2, 3]; echo gettype($foo), PHP_EOL; => array มܕΛ࣋ͨͳ͍ɺ͕ܕΛ࣋ͭ
&MPRVFOU 3FQPTJUPSZ echo 10 + 5, PHP_EOL; => 15 ԋࢉࢠJOUܕͱqPBUܕ͕ର
҉తܕม
&MPRVFOU 3FQPTJUPSZ echo 10 + "5", PHP_EOL; => 15 TUSJOH͕JOUʹม͞ΕΔ
҉తܕม
&MPRVFOU 3FQPTJUPSZ echo 10 + "5e", PHP_EOL; => 15 ҉తܕม
&MPRVFOU 3FQPTJUPSZ echo 10 + "5e2", PHP_EOL; => ??? ҉తܕม
&MPRVFOU 3FQPTJUPSZ echo 10 + "5e2", PHP_EOL; => 510 ҉తܕม
&MPRVFOU 3FQPTJUPSZ 5e2 ʢ5=Ծ෦, 2=ࢦ෦, 10=جʣ => 5 * (10
** 2) => 500 ˞ࢦදه
&MPRVFOU 3FQPTJUPSZ <?php declare(strict_types=1); function double(int $i): int { return
$i * 2; } double(1); // 2 double(“5e”); // TypeError ܕએݴ
D .BTBTIJ4IJOCBSB!TIJOY 1)1ͷܕγεςϜ w͕ܕΛ࣋ͭ w҉తܕมͰॊೈʹ։ൃ wܕએݴͰݫີʹ։ൃ wϢʔβ͕ελΠϧΛબͰ͖Δ
ܕΛ׆༻ͨ͠1)1ίʔυͷ࣮
D .BTBTIJ4IJOCBSB!TIJOY FY੫ࠐΈՁ֨ͷࢉग़ wՁ֨ ফඅ੫ খҎԼΓࣺͯ wՁ֨ਖ਼ͷ
wফඅ੫খͱ͢Δʢʣ
D .BTBTIJ4IJOCBSB!TIJOY %FNP wܕએݴແ͠ wεΧϥʔܕͰܕએݴ wϢʔβఆٛܕͰܕએݴ
D .BTBTIJ4IJOCBSB!TIJOY %FNP https://github.com/shin1x1/phpcon2017
D .BTBTIJ4IJOCBSB!TIJOY υϝΠϯʹಛԽͨ͠ܕΛ࡞Δ wΞϓϦέʔγϣϯυϝΠϯΛදݱ wυϝΠϯϧʔϧΛݕূ wܕએݴʹΑΔදݱͱڧ੍
&MPRVFOU 3FQPTJUPSZ // ܕએݴແ͠ function calculate($price, $taxRate) // υϝΠϯಛԽܕͰܕએݴ function
calculate( Price $price, TaxRate $taxRate): PriceWithTax
υϝΠϯಛԽܕͷ࣮5JQT
D .BTBTIJ4IJOCBSB!TIJOY ҆қʹܧঝΛΘͳ͍ wܧঝݩΫϥεܕͷద߹Λ͙ wܧঝݩϝιουؚ͕·Εͯ͠·͏ wҕৡτϨΠτͰڞ༗
&MPRVFOU 3FQPTJUPSZ // ܧঝ final class PriceWithTax extends Price {}
ܧঝ $price = PriceWithTaxCalculator::calculate($price, $taxRate); // PriceWithTax Price ܕͳͷͰಈ͍ͯ͠·͏ $price = PriceWithTaxCalculator::calculate($price, $taxRate);
D .BTBTIJ4IJOCBSB!TIJOY Πϛϡʔλϒϧʹ͢Δͱ҆શ wશίϯετϥΫλ wෆม݅ݕূ͕ҰͰࡁΉ wϛϡʔλϒϧͳΒݕূ
D .BTBTIJ4IJOCBSB!TIJOY ϑΝΫτϦϝιου wίϯετϥΫλΛQSJWBUF wϑΝΫτϦϝιου wҾʹΑΔόϦΤʔγϣϯ
&MPRVFOU 3FQPTJUPSZ ϑΝΫτϦϝιου public static function of(float $value): self {
return new self($value); } public static function ofByInt(int $value): self { return new self($value / 100); }
&MPRVFOU 3FQPTJUPSZ ϑΝΫτϦϝιου // float TaxRate::of(0.08); // int TaxRate::ofByInt(8);
D .BTBTIJ4IJOCBSB!TIJOY ։ൃͰͷܕݕࠪ wࣗಈςετ $* w1IQ4UPSN w1IBO
D .BTBTIJ4IJOCBSB!TIJOY 1IQ4UPSN wΤσΟλ ϦΞϧλΠϜͳνΣοΫ w*OTQFDU$PEFT ϓϩδΣΫτશମΛҰׅνΣοΫ w6TBHFTPG ܕͷར༻ҰཡΛྻڍ
D .BTBTIJ4IJOCBSB!TIJOY 1IBO w1)1Ͱ࣮͞Εͨ$-*πʔϧ wܕෆҰகTUSJDUҧͳͲΛݕ w$*Ͱܕݕࠪ https://github.com/phan/phan
͍͞͝ʹ
wܕએݴͰܕΛڧ੍ wυϝΠϯΛܕͰදݱ wܕͰؾ͍͍࣋ͪ։ൃΛ D .BTBTIJ4IJOCBSB!TIJOY ܕΛ׆༻ͨ͠։ൃ
D .BTBTIJ4IJOCBSB!TIJOY !TIJOY !TIJOY D .BTBTIJ4IJOCBSB!TIJOY