|  | 
| 1 |  | -<?php | 
|  | 1 | +<?php // phpcs:disable | 
| 2 | 2 | 
 | 
| 3 | 3 | declare(strict_types=1); | 
| 4 | 4 | 
 | 
| 5 |  | -namespace PhpStubs\WordPress\Core\Tests; | 
|  | 5 | +use PhpStubs\WordPress\Core\Tests\Faker; | 
| 6 | 6 | 
 | 
| 7 |  | -use function add_shortcode; | 
|  | 7 | +$tag = Faker::nonEmptyString(); | 
| 8 | 8 | 
 | 
| 9 | 9 | // Incorrect $tag | 
| 10 | 10 | add_shortcode(1, Faker::callable()); | 
|  | 
| 13 | 13 | // Maybe incorrect $tag | 
| 14 | 14 | add_shortcode(Faker::string(), Faker::callable()); | 
| 15 | 15 | 
 | 
|  | 16 | +// Incorrect $callback | 
|  | 17 | +add_shortcode($tag, static function(): void {}); // Incorrect return type | 
|  | 18 | +add_shortcode($tag, static function(string $atts): string {return Faker::string();}); // Incorrect $atts type | 
|  | 19 | +add_shortcode($tag, static function(array $atts, string $content): string {return Faker::string();}); // Incorrect $content type (must accept null) | 
|  | 20 | +add_shortcode($tag, static function(array $atts, ?string $content, bool $tag): string {return Faker::string();}); // Incorrect $tag type | 
|  | 21 | +add_shortcode($tag, 'addShortcodeVoid'); // Incorrect callback return type | 
|  | 22 | +add_shortcode($tag, 'addShortcodeIntDoc'); // Incorrect callback return type | 
|  | 23 | + | 
| 16 | 24 | // Correct $tag | 
| 17 | 25 | add_shortcode('0', Faker::callable()); // '0' is a valid tag | 
| 18 | 26 | add_shortcode('tag', Faker::callable()); | 
| 19 |  | -add_shortcode(Faker::nonEmptyString(), Faker::callable()); // '0' is a valid tag | 
| 20 |  | -add_shortcode(Faker::nonFalsyString(), Faker::callable()); | 
|  | 27 | +add_shortcode($tag, Faker::callable()); | 
|  | 28 | + | 
|  | 29 | +// Correct $callback | 
|  | 30 | +add_shortcode($tag, static function(): string {return '';}); | 
|  | 31 | +add_shortcode($tag, static function(array $atts): string {return '';}); | 
|  | 32 | +add_shortcode($tag, static function(array $atts, ?string $content): string {return '';}); | 
|  | 33 | +add_shortcode($tag, static function(array $atts, ?string $content, string $tag): string {return '';}); | 
|  | 34 | +add_shortcode($tag, 'addShortcodeStringDoc'); | 
|  | 35 | + | 
|  | 36 | +function addShortcodeVoid(): void {} | 
|  | 37 | +function addShortcodeString(): string {return Faker::string();} | 
|  | 38 | + | 
|  | 39 | +/** @return int */ | 
|  | 40 | +function addShortcodeIntDoc() {return Faker::int();} | 
|  | 41 | + | 
|  | 42 | +/** @return string */ | 
|  | 43 | +function addShortcodeStringDoc() {return Faker::string();} | 
0 commit comments