Completed
Push — status ( db8889 )
by Yuichi
09:56
created

App   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 207
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 12
lcom 1
cbo 3
dl 0
loc 207
rs 10
c 0
b 0
f 0

12 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A get() 0 8 1
A getSettings() 0 8 1
A getForm() 0 8 1
A getFields() 0 8 1
A getLayout() 0 8 1
A getViews() 0 8 1
A getAcl() 0 8 1
A getRecordAcl() 0 8 1
A getFieldAcl() 0 8 1
A getCustomize() 0 8 1
A getStatus() 0 8 1
1
<?php
2
3
namespace CybozuHttp\Api\Kintone;
4
5
use CybozuHttp\Client;
6
use CybozuHttp\Api\KintoneApi;
7
8
/**
9
 * @author ochi51 <[email protected]>
10
 */
11
class App
12
{
13
    /**
14
     * @var Client
15
     */
16
    private $client;
17
18
    public function __construct(Client $client)
19
    {
20
        $this->client = $client;
21
    }
22
23
    /**
24
     * Get app
25
     * https://cybozudev.zendesk.com/hc/ja/articles/202931674#step1
26
     *
27
     * @param integer $id
28
     * @param integer $guestSpaceId
29
     * @return array
30
     */
31
    public function get($id, $guestSpaceId = null)
32
    {
33
        $options = ['json' => ['id' => $id]];
34
35
        return $this->client
0 ignored issues
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Psr\Http\Message\StreamInterface as the method jsonSerialize() does only exist in the following implementations of said interface: CybozuHttp\Middleware\JsonStream.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
36
            ->get(KintoneApi::generateUrl('app.json', $guestSpaceId), $options)
37
            ->getBody()->jsonSerialize();
38
    }
39
40
    /**
41
     * Get app settings
42
     * https://cybozudev.zendesk.com/hc/ja/articles/204694170
43
     *
44
     * @param integer $id
45
     * @param integer $guestSpaceId
46
     * @param string $lang
47
     * @return array
48
     */
49
    public function getSettings($id, $guestSpaceId = null, $lang = 'default')
50
    {
51
        $options = ['json' => ['app' => $id, 'lang' => $lang]];
52
53
        return $this->client
0 ignored issues
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Psr\Http\Message\StreamInterface as the method jsonSerialize() does only exist in the following implementations of said interface: CybozuHttp\Middleware\JsonStream.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
54
            ->get(KintoneApi::generateUrl('app/settings.json', $guestSpaceId), $options)
55
            ->getBody()->jsonSerialize();
56
    }
57
58
    /**
59
     * Get app forms
60
     * https://cybozudev.zendesk.com/hc/ja/articles/201941834#step1
61
     *
62
     * @param integer $id
63
     * @param integer $guestSpaceId
64
     * @return array
65
     */
66
    public function getForm($id, $guestSpaceId = null)
67
    {
68
        $options = ['json' => ['app' => $id]];
69
70
        return $this->client
0 ignored issues
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Psr\Http\Message\StreamInterface as the method jsonSerialize() does only exist in the following implementations of said interface: CybozuHttp\Middleware\JsonStream.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
71
            ->get(KintoneApi::generateUrl('form.json', $guestSpaceId), $options)
72
            ->getBody()->jsonSerialize()['properties'];
73
    }
74
75
    /**
76
     * Get app form fields
77
     * https://cybozudev.zendesk.com/hc/ja/articles/204783170#anchor_getform_fields
78
     *
79
     * @param integer $id
80
     * @param integer $guestSpaceId
81
     * @param string $lang
82
     * @return array
83
     */
84
    public function getFields($id, $guestSpaceId = null, $lang = 'default')
85
    {
86
        $options = ['json' => ['app' => $id, 'lang' => $lang]];
87
88
        return $this->client
0 ignored issues
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Psr\Http\Message\StreamInterface as the method jsonSerialize() does only exist in the following implementations of said interface: CybozuHttp\Middleware\JsonStream.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
89
            ->get(KintoneApi::generateUrl('app/form/fields.json', $guestSpaceId), $options)
90
            ->getBody()->jsonSerialize();
91
    }
92
93
    /**
94
     * Get app form layout
95
     * https://cybozudev.zendesk.com/hc/ja/articles/204783170#anchor_getform_layout
96
     *
97
     * @param integer $id
98
     * @param integer $guestSpaceId
99
     * @param string $lang
100
     * @return array
101
     */
102
    public function getLayout($id, $guestSpaceId = null, $lang = 'default')
103
    {
104
        $options = ['json' => ['app' => $id, 'lang' => $lang]];
105
106
        return $this->client
0 ignored issues
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Psr\Http\Message\StreamInterface as the method jsonSerialize() does only exist in the following implementations of said interface: CybozuHttp\Middleware\JsonStream.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
107
            ->get(KintoneApi::generateUrl('app/form/layout.json', $guestSpaceId), $options)
108
            ->getBody()->jsonSerialize();
109
    }
110
111
    /**
112
     * Get app views
113
     * https://cybozudev.zendesk.com/hc/ja/articles/204529784
114
     *
115
     * @param integer $id
116
     * @param integer $guestSpaceId
117
     * @param string $lang
118
     * @return array
119
     */
120
    public function getViews($id, $guestSpaceId = null, $lang = 'default')
121
    {
122
        $options = ['json' => ['app' => $id, 'lang' => $lang]];
123
124
        return $this->client
0 ignored issues
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Psr\Http\Message\StreamInterface as the method jsonSerialize() does only exist in the following implementations of said interface: CybozuHttp\Middleware\JsonStream.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
125
            ->get(KintoneApi::generateUrl('app/views.json', $guestSpaceId), $options)
126
            ->getBody()->jsonSerialize();
127
    }
128
129
    /**
130
     * Get app acl
131
     * https://cybozudev.zendesk.com/hc/ja/articles/204529754
132
     *
133
     * @param integer $id
134
     * @param integer $guestSpaceId
135
     * @param string $lang
136
     * @return array
137
     */
138
    public function getAcl($id, $guestSpaceId = null, $lang = 'default')
139
    {
140
        $options = ['json' => ['app' => $id, 'lang' => $lang]];
141
142
        return $this->client
0 ignored issues
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Psr\Http\Message\StreamInterface as the method jsonSerialize() does only exist in the following implementations of said interface: CybozuHttp\Middleware\JsonStream.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
143
            ->get(KintoneApi::generateUrl('app/acl.json', $guestSpaceId), $options)
144
            ->getBody()->jsonSerialize();
145
    }
146
147
    /**
148
     * Get record acl
149
     * https://cybozudev.zendesk.com/hc/ja/articles/204791510
150
     *
151
     * @param integer $id
152
     * @param integer $guestSpaceId
153
     * @param string $lang
154
     * @return array
155
     */
156
    public function getRecordAcl($id, $guestSpaceId = null, $lang = 'default')
157
    {
158
        $options = ['json' => ['app' => $id, 'lang' => $lang]];
159
160
        return $this->client
0 ignored issues
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Psr\Http\Message\StreamInterface as the method jsonSerialize() does only exist in the following implementations of said interface: CybozuHttp\Middleware\JsonStream.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
161
            ->get(KintoneApi::generateUrl('record/acl.json', $guestSpaceId), $options)
162
            ->getBody()->jsonSerialize();
163
    }
164
165
    /**
166
     * Get field acl
167
     * https://cybozudev.zendesk.com/hc/ja/articles/204791520
168
     *
169
     * @param integer $id
170
     * @param integer $guestSpaceId
171
     * @param string $lang
172
     * @return array
173
     */
174
    public function getFieldAcl($id, $guestSpaceId = null, $lang = 'default')
175
    {
176
        $options = ['json' => ['app' => $id, 'lang' => $lang]];
177
178
        return $this->client
0 ignored issues
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Psr\Http\Message\StreamInterface as the method jsonSerialize() does only exist in the following implementations of said interface: CybozuHttp\Middleware\JsonStream.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
179
            ->get(KintoneApi::generateUrl('field/acl.json', $guestSpaceId), $options)
180
            ->getBody()->jsonSerialize();
181
    }
182
183
    /**
184
     * Get app JavaScript and CSS customize
185
     * https://cybozudev.zendesk.com/hc/ja/articles/204529824
186
     *
187
     * @param integer $id
188
     * @param integer $guestSpaceId
189
     * @return array
190
     */
191
    public function getCustomize($id, $guestSpaceId = null)
192
    {
193
        $options = ['json' => ['app' => $id]];
194
195
        return $this->client
0 ignored issues
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Psr\Http\Message\StreamInterface as the method jsonSerialize() does only exist in the following implementations of said interface: CybozuHttp\Middleware\JsonStream.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
196
            ->get(KintoneApi::generateUrl('app/customize.json', $guestSpaceId), $options)
197
            ->getBody()->jsonSerialize();
198
    }
199
200
    /**
201
     * Get app status list
202
     * https://cybozudev.zendesk.com/hc/ja/articles/216972946
203
     *
204
     * @param integer $id
205
     * @param string  $lang
206
     * @param integer $guestSpaceId
207
     * @return array
208
     */
209
    public function getStatus($id, $lang = 'ja', $guestSpaceId = null)
210
    {
211
        $options = ['json' => ['app' => $id, 'lang' => $lang]];
212
213
        return $this->client
0 ignored issues
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Psr\Http\Message\StreamInterface as the method jsonSerialize() does only exist in the following implementations of said interface: CybozuHttp\Middleware\JsonStream.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
214
            ->get(KintoneApi::generateUrl('app/status.json', $guestSpaceId), $options)
215
            ->getBody()->jsonSerialize();
216
    }
217
}