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

Growing the PHP core - One Test at a Time @Lara...

Growing the PHP core - One Test at a Time @LaraconEU 2021

I am a PHP core contributor and you can be too! You think you need to create a RFC for this or write and maintain a PHP extension or even write C code? Fear no more!
In this talk you will learn how you can become a PHP core contributor and give something back to the community by writing tests for PHP core without writing a single line of C code.

Want to know more? https://dev.to/realflowcontrol/growing-the-php-core-one-test-at-a-time-4g4k

Florian Engelhardt

January 19, 2021
Tweet

More Decks by Florian Engelhardt

Other Decks in Programming

Transcript

  1. If I have seen further it is only by standing

    on the shoulders of giants — Sir Isaac Newton
  2. COMPILING PHP FROM SOURCE COMPILING PHP FROM SOURCE COMPILING PHP

    FROM SOURCE COMPILING PHP FROM SOURCE COMPILING PHP FROM SOURCE * fork before cloning git clone [email protected]:php/php-src.git cd php-src ./buildconf ./configure make -j `nproc` ./sapi/cli/php -v
  3. RUN THE TESTS RUN THE TESTS RUN THE TESTS RUN

    THE TESTS RUN THE TESTS make TEST_PHP_ARGS=-j`nproc` test
  4. BASIC TEST BASIC TEST BASIC TEST BASIC TEST BASIC TEST

    --TEST-- strlen() function --SKIPIF-- <?php if (!extension_loaded('core')) echo 'skip'; ?> --FILE-- <?php var_dump(strlen('Hello World!')); ?> --EXPECT-- int(12) --CLEAN-- <?php unlink(__DIR__.'/file.tmp'); ?>
  5. WHAT TO TEST? WHAT TO TEST? WHAT TO TEST? WHAT

    TO TEST? WHAT TO TEST? nd latest scheduled build select Code Coverage section Azure Pipelines
  6. FIND SOMETHING RED FIND SOMETHING RED FIND SOMETHING RED FIND

    SOMETHING RED FIND SOMETHING RED ext/zlib/zlib.c in PHP 7.1
  7. WRITE A TEST WRITE A TEST WRITE A TEST WRITE

    A TEST WRITE A TEST the absence of the Accept-Encoding header the Accept-Encoding being gzip the Accept-Encoding being deflate the Accept-Encoding being anything else
  8. TIME FOR THE SOURCE! TIME FOR THE SOURCE! TIME FOR

    THE SOURCE! TIME FOR THE SOURCE! TIME FOR THE SOURCE! or ask the nice fellows over at the source phpc.chat
  9. --TEST-- zlib_get_coding_type() with gzip encoding --SKIPIF-- <?php if (!extension_loaded("zlib")) print

    "skip"; ?> --ENV-- HTTP_ACCEPT_ENCODING=gzip --FILE-- <?php ini_set('zlib.output_compression', 'Off'); $off = zlib_get_coding_type(); ini_set('zlib.output_compression', 'On'); $on = zlib_get_coding_type(); ini_set('zlib.output_compression', 'Off'); var_dump($off); var_dump($on); ?> --EXPECT-- bool(false) string(4) "gzip"
  10. WHAT HAVE WE LEARNED WHAT HAVE WE LEARNED WHAT HAVE

    WE LEARNED WHAT HAVE WE LEARNED WHAT HAVE WE LEARNED what looks simple, might be complex super globals are copy-on-write there are modify handlers for ini settings
  11. WHAT DO YOU GAIN? WHAT DO YOU GAIN? WHAT DO

    YOU GAIN? WHAT DO YOU GAIN? WHAT DO YOU GAIN? PHP will be more stable and reliable deeper understanding of how PHP works internaly phpt test format can be used in PHPUnit
  12. YOU CAN CALL YOURSELF A PHP CORE CONTRIBUTOR! YOU CAN

    CALL YOURSELF A PHP CORE CONTRIBUTOR! YOU CAN CALL YOURSELF A PHP CORE CONTRIBUTOR! YOU CAN CALL YOURSELF A PHP CORE CONTRIBUTOR! YOU CAN CALL YOURSELF A PHP CORE CONTRIBUTOR!