Completed
Push — master ( 2f6f8a...727969 )
by Carl
04:09
created

FlashMsgTest::testNotice()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 30
Code Lines 20

Duplication

Lines 30
Ratio 100 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 30
loc 30
rs 8.8571
cc 2
eloc 20
nc 2
nop 0
1
<?php
2
3
namespace helikopterspark\FlashMsg;
4
5
/**
6
 * A test class
7
 *
8
 */
9
 class FlashMsgTest extends \PHPUnit_Framework_TestCase {
0 ignored issues
show
Coding Style introduced by
As per PSR2, the opening brace for this class should be on a new line.
Loading history...
10
11
    /**
12
     * Test
13
     *
14
     * @return void
15
     */
16 View Code Duplication
     public function testSetMessage() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
17
         // Setup
18
        $message = new \helikopterspark\FlashMsg\FlashMsg();
19
        $di = new \Anax\DI\CDIFactoryDefault();
20
        $message->setDI($di);
0 ignored issues
show
Documentation introduced by
$di is of type object<Anax\DI\CDIFactoryDefault>, but the function expects a object<Anax\DI\class>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
21
22
        $di->setShared('session', function () {
23
            $session = new \Anax\Session\CSession();
24
            $session->configure(ANAX_APP_PATH . 'config/session.php');
25
            $session->name();
26
            //$session->start();
0 ignored issues
show
Unused Code Comprehensibility introduced by
84% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
27
            return $session;
28
        });
29
30
        $di->setShared('flashmessage', function() use ($di){
31
        	$flashMessages = new \helikopterspark\FlashMsg\FlashMsg();
32
        	$flashMessages->setDI($di);
0 ignored issues
show
Documentation introduced by
$di is of type object<Anax\DI\CDIFactoryDefault>, but the function expects a object<Anax\DI\class>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
33
        	return $flashMessages;
34
        });
35
36
        // Test
37
        $type = 'Alert';
38
        $text = 'Message text';
39
40
        $message->flashmessage->setMessage('Alert', 'Message text');
0 ignored issues
show
Documentation introduced by
The property flashmessage does not exist on object<helikopterspark\FlashMsg\FlashMsg>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
41
        $res = $di->session->get('flashmsgs');
42
        foreach ($res as $key => $value) {
43
            $this->assertEquals($type, $value['type'], "Type mismatch.");
44
            $this->assertEquals($text, $value['content'], "Content mismatch.");
45
        }
46
     }
47
48
     /**
49
      * Test
50
      *
51
      * @return void
52
      */
53 View Code Duplication
      public function testAlert() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
54
          // Setup
55
          $message = new \helikopterspark\FlashMsg\FlashMsg();
56
          $di = new \Anax\DI\CDIFactoryDefault();
57
          $message->setDI($di);
0 ignored issues
show
Documentation introduced by
$di is of type object<Anax\DI\CDIFactoryDefault>, but the function expects a object<Anax\DI\class>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
58
59
          $di->setShared('session', function () {
60
              $session = new \Anax\Session\CSession();
61
              $session->configure(ANAX_APP_PATH . 'config/session.php');
62
              $session->name();
63
              return $session;
64
          });
65
66
          $di->setShared('flashmessage', function() use ($di){
67
          	$flashMessages = new \helikopterspark\FlashMsg\FlashMsg();
68
          	$flashMessages->setDI($di);
0 ignored issues
show
Documentation introduced by
$di is of type object<Anax\DI\CDIFactoryDefault>, but the function expects a object<Anax\DI\class>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
69
          	return $flashMessages;
70
          });
71
72
          // Test
73
          $type = 'alert';
74
          $text = 'Alert flash message';
75
76
          $message->flashmessage->alert('Alert flash message');
0 ignored issues
show
Documentation introduced by
The property flashmessage does not exist on object<helikopterspark\FlashMsg\FlashMsg>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
77
          $res = $di->session->get('flashmsgs');
78
          foreach ($res as $key => $value) {
79
              $this->assertEquals($type, $value['type'], "Type mismatch.");
80
              $this->assertEquals($text, $value['content'], "Content mismatch.");
81
          }
82
      }
83
84
      /**
85
       * Test
86
       *
87
       * @return void
88
       */
89 View Code Duplication
       public function testError() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
90
           // Setup
91
           $message = new \helikopterspark\FlashMsg\FlashMsg();
92
           $di = new \Anax\DI\CDIFactoryDefault();
93
           $message->setDI($di);
0 ignored issues
show
Documentation introduced by
$di is of type object<Anax\DI\CDIFactoryDefault>, but the function expects a object<Anax\DI\class>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
94
95
           $di->setShared('session', function () {
96
               $session = new \Anax\Session\CSession();
97
               $session->configure(ANAX_APP_PATH . 'config/session.php');
98
               $session->name();
99
               return $session;
100
           });
101
102
           $di->setShared('flashmessage', function() use ($di){
103
           	$flashMessages = new \helikopterspark\FlashMsg\FlashMsg();
104
           	$flashMessages->setDI($di);
0 ignored issues
show
Documentation introduced by
$di is of type object<Anax\DI\CDIFactoryDefault>, but the function expects a object<Anax\DI\class>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
105
           	return $flashMessages;
106
           });
107
108
           // Test
109
           $type = 'error';
110
           $text = 'Error flash message';
111
112
           $message->flashmessage->error('Error flash message');
0 ignored issues
show
Documentation introduced by
The property flashmessage does not exist on object<helikopterspark\FlashMsg\FlashMsg>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
113
           $res = $di->session->get('flashmsgs');
114
           foreach ($res as $key => $value) {
115
               $this->assertEquals($type, $value['type'], "Type mismatch.");
116
               $this->assertEquals($text, $value['content'], "Content mismatch.");
117
           }
118
       }
119
120
       /**
121
        * Test
122
        *
123
        * @return void
124
        */
125 View Code Duplication
        public function testInfo() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
126
            // Setup
127
            $message = new \helikopterspark\FlashMsg\FlashMsg();
128
            $di = new \Anax\DI\CDIFactoryDefault();
129
            $message->setDI($di);
0 ignored issues
show
Documentation introduced by
$di is of type object<Anax\DI\CDIFactoryDefault>, but the function expects a object<Anax\DI\class>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
130
131
            $di->setShared('session', function () {
132
                $session = new \Anax\Session\CSession();
133
                $session->configure(ANAX_APP_PATH . 'config/session.php');
134
                $session->name();
135
                return $session;
136
            });
137
138
            $di->setShared('flashmessage', function() use ($di){
139
            	$flashMessages = new \helikopterspark\FlashMsg\FlashMsg();
140
            	$flashMessages->setDI($di);
0 ignored issues
show
Documentation introduced by
$di is of type object<Anax\DI\CDIFactoryDefault>, but the function expects a object<Anax\DI\class>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
141
            	return $flashMessages;
142
            });
143
144
            // Test
145
            $type = 'info';
146
            $text = 'Info flash message';
147
148
            $message->flashmessage->info('Info flash message');
0 ignored issues
show
Documentation introduced by
The property flashmessage does not exist on object<helikopterspark\FlashMsg\FlashMsg>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
149
            $res = $di->session->get('flashmsgs');
150
            foreach ($res as $key => $value) {
151
                $this->assertEquals($type, $value['type'], "Type mismatch.");
152
                $this->assertEquals($text, $value['content'], "Content mismatch.");
153
            }
154
        }
155
156
        /**
157
         * Test
158
         *
159
         * @return void
160
         */
161 View Code Duplication
         public function testNotice() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
162
             // Setup
163
             $message = new \helikopterspark\FlashMsg\FlashMsg();
164
             $di = new \Anax\DI\CDIFactoryDefault();
165
             $message->setDI($di);
0 ignored issues
show
Documentation introduced by
$di is of type object<Anax\DI\CDIFactoryDefault>, but the function expects a object<Anax\DI\class>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
166
167
             $di->setShared('session', function () {
168
                 $session = new \Anax\Session\CSession();
169
                 $session->configure(ANAX_APP_PATH . 'config/session.php');
170
                 $session->name();
171
                 return $session;
172
             });
173
174
             $di->setShared('flashmessage', function() use ($di){
175
             	$flashMessages = new \helikopterspark\FlashMsg\FlashMsg();
176
             	$flashMessages->setDI($di);
0 ignored issues
show
Documentation introduced by
$di is of type object<Anax\DI\CDIFactoryDefault>, but the function expects a object<Anax\DI\class>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
177
             	return $flashMessages;
178
             });
179
180
             // Test
181
             $type = 'notice';
182
             $text = 'Notice flash message';
183
184
             $message->flashmessage->notice('Notice flash message');
0 ignored issues
show
Documentation introduced by
The property flashmessage does not exist on object<helikopterspark\FlashMsg\FlashMsg>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
185
             $res = $di->session->get('flashmsgs');
186
             foreach ($res as $key => $value) {
187
                 $this->assertEquals($type, $value['type'], "Type mismatch.");
188
                 $this->assertEquals($text, $value['content'], "Content mismatch.");
189
             }
190
         }
191
192
         /**
193
          * Test
194
          *
195
          * @return void
196
          */
197 View Code Duplication
          public function testSuccess() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
198
              // Setup
199
              $message = new \helikopterspark\FlashMsg\FlashMsg();
200
              $di = new \Anax\DI\CDIFactoryDefault();
201
              $message->setDI($di);
0 ignored issues
show
Documentation introduced by
$di is of type object<Anax\DI\CDIFactoryDefault>, but the function expects a object<Anax\DI\class>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
202
203
              $di->setShared('session', function () {
204
                  $session = new \Anax\Session\CSession();
205
                  $session->configure(ANAX_APP_PATH . 'config/session.php');
206
                  $session->name();
207
                  return $session;
208
              });
209
210
              $di->setShared('flashmessage', function() use ($di){
211
              	$flashMessages = new \helikopterspark\FlashMsg\FlashMsg();
212
              	$flashMessages->setDI($di);
0 ignored issues
show
Documentation introduced by
$di is of type object<Anax\DI\CDIFactoryDefault>, but the function expects a object<Anax\DI\class>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
213
              	return $flashMessages;
214
              });
215
216
              // Test
217
              $type = 'success';
218
              $text = 'Success flash message';
219
220
              $message->flashmessage->success('Success flash message');
0 ignored issues
show
Documentation introduced by
The property flashmessage does not exist on object<helikopterspark\FlashMsg\FlashMsg>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
221
              $res = $di->session->get('flashmsgs');
222
              foreach ($res as $key => $value) {
223
                  $this->assertEquals($type, $value['type'], "Type mismatch.");
224
                  $this->assertEquals($text, $value['content'], "Content mismatch.");
225
              }
226
          }
227
228
          /**
229
           * Test
230
           *
231
           * @return void
232
           */
233 View Code Duplication
           public function testWarning() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
234
               // Setup
235
               $message = new \helikopterspark\FlashMsg\FlashMsg();
236
               $di = new \Anax\DI\CDIFactoryDefault();
237
               $message->setDI($di);
0 ignored issues
show
Documentation introduced by
$di is of type object<Anax\DI\CDIFactoryDefault>, but the function expects a object<Anax\DI\class>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
238
239
               $di->setShared('session', function () {
240
                   $session = new \Anax\Session\CSession();
241
                   $session->configure(ANAX_APP_PATH . 'config/session.php');
242
                   $session->name();
243
                   return $session;
244
               });
245
246
               $di->setShared('flashmessage', function() use ($di){
247
               	$flashMessages = new \helikopterspark\FlashMsg\FlashMsg();
248
               	$flashMessages->setDI($di);
0 ignored issues
show
Documentation introduced by
$di is of type object<Anax\DI\CDIFactoryDefault>, but the function expects a object<Anax\DI\class>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
249
               	return $flashMessages;
250
               });
251
252
               // Test
253
               $type = 'warning';
254
               $text = 'Warning flash message';
255
256
               $message->flashmessage->warning('Warning flash message');
0 ignored issues
show
Documentation introduced by
The property flashmessage does not exist on object<helikopterspark\FlashMsg\FlashMsg>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
257
               $res = $di->session->get('flashmsgs');
258
               foreach ($res as $key => $value) {
259
                   $this->assertEquals($type, $value['type'], "Type mismatch.");
260
                   $this->assertEquals($text, $value['content'], "Content mismatch.");
261
               }
262
           }
263
264
           /**
265
            * Test
266
            *
267
            * @return void
268
            */
269
            public function testOutputMsgs() {
270
                // Setup
271
                $message = new \helikopterspark\FlashMsg\FlashMsg();
272
                $di = new \Anax\DI\CDIFactoryDefault();
273
                $message->setDI($di);
0 ignored issues
show
Documentation introduced by
$di is of type object<Anax\DI\CDIFactoryDefault>, but the function expects a object<Anax\DI\class>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
274
275
                $di->setShared('session', function () {
276
                    $session = new \Anax\Session\CSession();
277
                    $session->configure(ANAX_APP_PATH . 'config/session.php');
278
                    $session->name();
279
                    return $session;
280
                });
281
282
                $di->setShared('flashmessage', function() use ($di){
283
                	$flashMessages = new \helikopterspark\FlashMsg\FlashMsg();
284
                	$flashMessages->setDI($di);
0 ignored issues
show
Documentation introduced by
$di is of type object<Anax\DI\CDIFactoryDefault>, but the function expects a object<Anax\DI\class>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
285
                	return $flashMessages;
286
                });
287
288
                // Test
289
                $html = '<div class="alert"><p>Alert flash message</p></div>';
290
                $html .= '<div class="error"><p>Error flash message</p></div>';
291
                $html .= '<div class="info"><p>Info flash message</p></div>';
292
                $html .= '<div class="notice"><p>Notice flash message</p></div>';
293
                $html .= '<div class="warning"><p>Warning flash message</p></div>';
294
                $html .= '<div class="success"><p>Success flash message</p></div>';
295
296
                $message->flashmessage->alert('Alert flash message');
0 ignored issues
show
Documentation introduced by
The property flashmessage does not exist on object<helikopterspark\FlashMsg\FlashMsg>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
297
                $message->flashmessage->error('Error flash message');
0 ignored issues
show
Documentation introduced by
The property flashmessage does not exist on object<helikopterspark\FlashMsg\FlashMsg>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
298
                $message->flashmessage->info('Info flash message');
0 ignored issues
show
Documentation introduced by
The property flashmessage does not exist on object<helikopterspark\FlashMsg\FlashMsg>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
299
                $message->flashmessage->notice('Notice flash message');
0 ignored issues
show
Documentation introduced by
The property flashmessage does not exist on object<helikopterspark\FlashMsg\FlashMsg>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
300
                $message->flashmessage->warning('Warning flash message');
0 ignored issues
show
Documentation introduced by
The property flashmessage does not exist on object<helikopterspark\FlashMsg\FlashMsg>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
301
                $message->flashmessage->success('Success flash message');
0 ignored issues
show
Documentation introduced by
The property flashmessage does not exist on object<helikopterspark\FlashMsg\FlashMsg>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
302
                $htmloutput = $message->flashmessage->outputMsgs();
0 ignored issues
show
Documentation introduced by
The property flashmessage does not exist on object<helikopterspark\FlashMsg\FlashMsg>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
303
304
                $this->assertEquals($html, $htmloutput, "Output does not match.");
305
            }
306
307
            /**
308
             * Test
309
             *
310
             * @return void
311
             */
312
             public function testClearMessages() {
313
                 // Setup
314
                 $message = new \helikopterspark\FlashMsg\FlashMsg();
315
                 $di = new \Anax\DI\CDIFactoryDefault();
316
                 $message->setDI($di);
0 ignored issues
show
Documentation introduced by
$di is of type object<Anax\DI\CDIFactoryDefault>, but the function expects a object<Anax\DI\class>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
317
318
                 $di->setShared('session', function () {
319
                     $session = new \Anax\Session\CSession();
320
                     $session->configure(ANAX_APP_PATH . 'config/session.php');
321
                     $session->name();
322
                     return $session;
323
                 });
324
325
                 $di->setShared('flashmessage', function() use ($di){
326
                 	$flashMessages = new \helikopterspark\FlashMsg\FlashMsg();
327
                 	$flashMessages->setDI($di);
0 ignored issues
show
Documentation introduced by
$di is of type object<Anax\DI\CDIFactoryDefault>, but the function expects a object<Anax\DI\class>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
328
                 	return $flashMessages;
329
                 });
330
331
                 // Test
332
                 $message->flashmessage->alert('Alert flash message');
0 ignored issues
show
Documentation introduced by
The property flashmessage does not exist on object<helikopterspark\FlashMsg\FlashMsg>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
333
                 $message->flashmessage->error('Error flash message');
0 ignored issues
show
Documentation introduced by
The property flashmessage does not exist on object<helikopterspark\FlashMsg\FlashMsg>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
334
                 $message->flashmessage->info('Info flash message');
0 ignored issues
show
Documentation introduced by
The property flashmessage does not exist on object<helikopterspark\FlashMsg\FlashMsg>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
335
                 $message->flashmessage->notice('Notice flash message');
0 ignored issues
show
Documentation introduced by
The property flashmessage does not exist on object<helikopterspark\FlashMsg\FlashMsg>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
336
                 $message->flashmessage->warning('Warning flash message');
0 ignored issues
show
Documentation introduced by
The property flashmessage does not exist on object<helikopterspark\FlashMsg\FlashMsg>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
337
                 $message->flashmessage->success('Success flash message');
0 ignored issues
show
Documentation introduced by
The property flashmessage does not exist on object<helikopterspark\FlashMsg\FlashMsg>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
338
339
                 $this->assertTrue($di->session->has('flashmsgs'));
340
                 $message->flashmessage->clearMessages();
0 ignored issues
show
Documentation introduced by
The property flashmessage does not exist on object<helikopterspark\FlashMsg\FlashMsg>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
341
                 $res = $di->session->get('flashmsgs');
342
                 $this->assertTrue(count($res) === 0);
343
             }
344
 }
345