Skip to content

Commit 060ed79

Browse files
authored
Update examples/01-blog with latest best practices (#856)
1 parent fe6cb72 commit 060ed79

28 files changed

+893
-626
lines changed

examples/01-blog/Blog/AppContext.php

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
<?php
2+
3+
declare(strict_types=1);
4+
25
namespace GraphQL\Examples\Blog;
36

47
use GraphQL\Examples\Blog\Data\User;
@@ -8,18 +11,10 @@
811
*/
912
class AppContext
1013
{
11-
/**
12-
* @var string
13-
*/
14-
public $rootUrl;
14+
public string $rootUrl;
1515

16-
/**
17-
* @var User
18-
*/
19-
public $viewer;
16+
public User $viewer;
2017

21-
/**
22-
* @var \mixed
23-
*/
24-
public $request;
18+
/** @var array<string, mixed> */
19+
public array $request;
2520
}

examples/01-blog/Blog/Data/Comment.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,28 @@
11
<?php
2-
namespace GraphQL\Examples\Blog\Data;
32

3+
declare(strict_types=1);
4+
5+
namespace GraphQL\Examples\Blog\Data;
46

57
use GraphQL\Utils\Utils;
68

79
class Comment
810
{
9-
public $id;
11+
public int $id;
1012

11-
public $authorId;
13+
public int $authorId;
1214

13-
public $storyId;
15+
public int $storyId;
1416

15-
public $parentId;
17+
public ?int $parentId = null;
1618

17-
public $body;
19+
public string $body;
1820

19-
public $isAnonymous;
21+
public bool $isAnonymous = true;
2022

23+
/**
24+
* @param array<string, mixed> $data
25+
*/
2126
public function __construct(array $data)
2227
{
2328
Utils::assign($this, $data);

0 commit comments

Comments
 (0)