PHP code example of bakgul / laravel-tests-to-readme

1. Go to this page and download the library: Download bakgul/laravel-tests-to-readme library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

bakgul / laravel-tests-to-readme example snippets


class MyClassTest extends TestCase
{
    /** @test */
    public function my_test_method_does_things(): void
    {
        (new ToReadme([
            'test' => $this->getName();
            'class' => MyClass::class,
            'method' => 'doSomething',
            'args' => [1, 2],
            'message' => 'Anything you want to print.',
            'result' => 3
        ]))->write();

        // Your test ...
    }
}

// My test method does things.

// Anything you want to print.

(new MyClass)->doSomething(1, 2);

// 3

/**
 * It does some stuff
 * 
 * @param array $arr
 * @param int   $int
 * @return array
 */
 public function do($arr, $int) { return [$arr, $int]; }

/**
 * It does some stuff
 */
 public function do(array $arr, int $int): array

/**
 * It does some stuff
 * 
 * @param array $arr
 * @return array
 */
 public function do(array|string $arr) { return $arr; }

WARNINGS:
   - mismatched types.

/**
 * It does some stuff
 */
 public function do(array $arr, int $int): array