Upgrade to Pro — share decks privately, control downloads, hide ads and more …

不要コード一斉摘発!自動でいらないコードを見つけるアレコレ

 不要コード一斉摘発!自動でいらないコードを見つけるアレコレ

PHPカンファレンス福岡2018のLT発表資料です。
以下の資料の改訂版となります。
https://speakerdeck.com/nazonohito51/regasipurodakutodeiranaikodowozi-dong-dejian-tuketakatuta?slide=1

Satoshi Kawashima

June 16, 2018
Tweet

More Decks by Satoshi Kawashima

Other Decks in Technology

Transcript

  1. ࣗಈͰ͍Βͳ͍ίʔυΛݟ͚ͭΔΞϨίϨ
    ઒ౡܛ(.01FQBCP *OD
    1)1ΧϯϑΝϨϯε෱Ԭ
    ෆཁίʔυҰ੪ఠൃʂ
    վ


    View full-size slide

  2. IUUQOB[POPIJUPKVHFNKQ
    ΞϓϦέʔγϣϯΤϯδχΞ
    ઒ౡܛ!OB[POPIJUP
    4)ࣄۀ෦+6(&.νʔϜ

    View full-size slide

  3. TDIPP͞ΜͰ-BSBWFMͷतۀΛ࡞Γ·ͨ͠

    View full-size slide

  4. ͍Βͳ͍ίʔυ࢒ͬͯ·ͤΜʁ

    View full-size slide

  5. ΊͬͪΌ͋Δ

    View full-size slide

  6. w ೥΋ͷαʔϏε
    w ίϐϖจԽͰඞཁແ͍ͷʹ͍࣋ͬͯͨίʔυͱ͔ͨ͘͞Μ
    ͋Δ
    w ͻͲ͍΋ͷ͸ϦϙδτϦ͝ͱίϐʔ͍ͯͨ͠
    ͏ͪͷ৔߹

    View full-size slide

  7. w ௐࠪίετ͕͔͔Δ
    w HSFQ͢Δͱ༨ܭͳ΋ͷ͕ͻ͔͔ͬΔ
    w ಡΉίʔυ͕ଟ͘ͳΔ
    w मਖ਼ίετ͕͔͔Δ
    w ඞཁͳίʔυ͕ͲΕ͔෼͔Βͳ͍͔Β݁ہશ෦௚͢
    w σϓϩΠίετ͕͔͔Δ
    ͍Βͳ͍ίʔυ͕࢒͍ͬͯΔͱ

    View full-size slide

  8. ૟আͷ࢓ํΛ͝঺հ͠·͢

    View full-size slide

  9. wຊ൪؀ڥͰ࣮ߦ͞Εͨͷ͸ཁΔίʔυ
    wຊ൪؀ڥͰ࣮ߦ͞Εͳ͍ͷ͸ཁΒͳ͍ίʔυ
    ͍Βͳ͍ίʔυͷݟ͚ͭํ
    ຊ൪؀ڥͰಈతղੳ͢Δ

    View full-size slide

  10. wϑΝΠϧϨϕϧͰղੳ
    wϑΝϯΫγϣϯϨϕϧͰղੳ
    wεςʔτϝϯτϨϕϧͰղੳ
    ࢥ͍͍ͭͨํ๏

    View full-size slide

  11. ϑΝΠϧϨϕϧͰղੳ

    View full-size slide

  12. w HFU@JODMVEFE@pMFT
    ͰSFRVJSF͞ΕͨQIQϑΝΠϧ͕BSSBZ
    ͰऔΕΔ
    w SFHJTUFS@TIVUEPXO@GVODUJPO
    Ͱऴྃ࣌ʹˢΛอଘ
    ϑΝΠϧϨϕϧͰղੳ
    [
    array (size=221)
    0 => string '/home/vagrant/code/public/index.php' (length=44)
    1 => string '/home/vagrant/code/prof_test/web.php' (length=45)
    2 => string '/home/vagrant/code/bootstrap/autoload.php' (length=50)
    3 => string '/home/vagrant/code/vendor/autoload.php' (length=47)
    4 => string '/home/vagrant/code/vendor/composer/autoload_real.php' (length=61)
    5 => string '/home/vagrant/code/vendor/composer/ClassLoader.php' (length=59)
    6 => string '/home/vagrant/code/vendor/composer/autoload_static.php' (length=63)
    7 => string '/home/vagrant/code/vendor/myclabs/deep-copy/src/DeepCopy/
    deep_copy.php' (length=79)

    View full-size slide

  13. ϑΝϯΫγϣϯϨϕϧͰղੳ

    View full-size slide

  14. w 1)1ίʔυ͔ΒϑΝϯΫγϣϯݺͼग़͠ΛϑοΫ͢Δ͜ͱ
    ͸ʢجຊతʹʣͰ͖ͳ͍
    w $ݴޠϨϕϧͷ֦ுʢ&YUFOTJPOʣͳΒՄೳ
    ϑΝϯΫγϣϯϨϕϧͰղੳ
    ϓϩϑΝΠϥΛ࢖༻͢Δ

    View full-size slide

  15. [
    array (size=1784)
    'Illuminate\Support\Collection::__construct==>Illuminate\Support
    \Collection::getArrayableItems' =>
    array (size=2)
    'ct' => int 31
    'wt' => int 37
    'Illuminate\Routing\Router::addWhereClausesToRoute==>Illuminate\Routing
    \Route::getAction' =>
    array (size=2)
    'ct' => int 44
    'wt' => int 129
    'Barryvdh\LaravelIdeHelper
    \IdeHelperServiceProvider::createLocalViewFactory==>Illuminate\View
    \Factory::addExtension' =>
    array (size=2)
    'ct' => int 1
    'wt' => int 16
    UJEFXBZT@YIQSPGͷղੳ݁Ռ
    ˡݺͼग़͠ݩݺͼग़͠ઌ
    ˡݺͼग़͠ճ਺
    ˡॲཧ࣌ؒ

    View full-size slide

  16. w 9IQSPG1)1
    w UJEFXBZT@YIQSPG1)1
    w UJEFXBZT༗ྉ4BB4ʢIUUQTUJEFXBZTDPNʣ
    w CBDLpSF༗ྉ4BB4ʢIUUQTCMBDLpSFJPʣ
    w 9EFCVHϓϩϑΝΠϥҎ֎ʹ΋৭ʑ͍ͭͯ͘Δͷ͕ෆ҆
    ϓϩϑΝΠϥͷछྨ

    View full-size slide

  17. ύϑΥʔϚϯε΁ͷӨڹ
    UJEFXBZT@YIQSPGͷ༗ແʹΑΔॲཧ࣌ؒ
    ॲཧ࣌ؒʢTFDʣ







    ϑΝϯΫγϣϯݺͼग़͠ճ਺ʢճʣ

    ϓϩϑΝΠϥ͋Γ
    ϓϩϑΝΠϥແ͠
    -BSBWFMͷ
    ϗʔϜը໘දࣔ



    View full-size slide

  18. εςʔτϝϯτϨϕϧͰͷղੳ

    View full-size slide

  19. w ຊ൪؀ڥͰίʔυΧόϨοδΛऔΔ
    w QIQECH͸8αʔόͱซ༻Ͱ͖ͳ͍ʢʹ9EFCVHҰ୒ʣ
    w ˞ຊ൪؀ڥʹ9EFCVHΛೖΕͯ͠·͏ϦεΫ͸ࠓճ৮Ε·
    ͤΜ
    εςʔτϝϯτϨϕϧͰղੳ

    View full-size slide

  20. [
    array (
    '/home/vagrant/code/vendor/guzzlehttp/promises/src/functions.php' =>
    array (
    21 => 1,
    42 => 1,
    66 => 1,
    92 => 1,
    108 => 1,
    122 => 1,
    147 => 1,
    174 => 1,
    ),
    '/home/vagrant/code/pwa_test/vendor/laravel/framework/src/Illuminate/Routing/Route.php' =>
    array (
    20 => 1,
    22 => 1,
    132 => 1,
    133 => 1,
    134 => 1,
    9EFCVHͷίʔυΧόϨοδ݁Ռ
    ˢղੳର৅ͷϑΝΠϧ
    ˡ࣮ߦ͞Εͨߦ൪߸

    View full-size slide

  21. w -BSBWFMͷϗʔϜը໘Ͱܭଌ
    w TFDTFD

    w ຊ౰ʹඞཁͳίʔυ͚ͩΛૂ͍ܸͪͰղੳ͢Δ
    ύϑΥʔϚϯε΁ͷӨڹ
    [
    xdebug_set_filter(
    XDEBUG_FILTER_CODE_COVERAGE,
    XDEBUG_PATH_WHITELIST,
    [__DIR__ . “/src/”]
    );
    ˡղੳର৅ΛϗϫΠτϦετͰ੍ݶ

    View full-size slide

  22. ࡟আͨ݁͠Ռ

    View full-size slide

  23. ϑΝΠϧϨϕϧͰ࡟আͨ݁͠Ռ






    ϑΝΠϧ਺ɿˠݸ
    ߦ਺ɿˠߦʢ࡟আʣ
    ϑΝΠϧ਺ɿˠݸ
    ߦ਺ɿˠߦʢ࡟আʣ
    ϑΝΠϧ਺ɿˠݸ
    ߦ਺ɿˠߦʢ࡟আʣ
    ϑΝΠϧ਺ɿˠݸ
    ߦ਺ɿˠߦʢ࡟আʣ

    View full-size slide

  24. օ͞Μ΋࡟আͯ͠Έͯ͸ʁ

    View full-size slide

  25. ͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠

    View full-size slide