PHP code example of tomasvotruba / type-coverage

1. Go to this page and download the library: Download tomasvotruba/type-coverage 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/ */

    

tomasvotruba / type-coverage example snippets


final class ConferenceFactory
{
    const SPEAKER_TAG = 'speaker';

    private $talkFactory;

    public function createConference(array $data)
    {
        $talks = $this->talkFactory->create($data);

        return new Conference($talks);
    }
}



declare(strict_types=1);
diff
 final class ConferenceFactory
 {
-    public const SPEAKER_TAG = 'speaker';
+    public const string SPEAKER_TAG = 'speaker';

-    private $talkFactory;
+    private TalkFactory $talkFactory;

-    public function createConference(array $data)
+    public function createConference(array $data): Conference
     {
         $talks = $this->talkFactory->create($data);

         return new Conference($talks);
     }
 }