Completed
Push — master ( b4dd2a...679ce7 )
by Craig
11:55
created

AbstractRouteEntity::getDefaults()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Routes.
4
 *
5
 * @copyright Zikula contributors (Zikula)
6
 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License
7
 * @author Zikula contributors <[email protected]>.
8
 * @link http://www.zikula.org
9
 * @link http://zikula.org
10
 * @version Generated by ModuleStudio 0.7.4 (http://modulestudio.de).
11
 */
12
13
namespace Zikula\RoutesModule\Entity\Base;
14
15
use Doctrine\ORM\Mapping as ORM;
16
use Gedmo\Mapping\Annotation as Gedmo;
17
use Symfony\Component\Validator\Constraints as Assert;
18
use Zikula\Core\Doctrine\EntityAccess;
19
use Zikula\RoutesModule\Traits\StandardFieldsTrait;
20
use Zikula\RoutesModule\Validator\Constraints as RoutesAssert;
21
22
/**
23
 * Entity class that defines the entity structure and behaviours.
24
 *
25
 * This is the base entity class for route entities.
26
 * The following annotation marks it as a mapped superclass so subclasses
27
 * inherit orm properties.
28
 *
29
 * @ORM\MappedSuperclass
30
 *
31
 * @abstract
32
 */
33
abstract class AbstractRouteEntity extends EntityAccess
34
{
35
    /**
36
     * Hook standard fields behaviour embedding createdBy, updatedBy, createdDate, updatedDate fields.
37
     */
38
    use StandardFieldsTrait;
39
40
    /**
41
     * @var string The tablename this object maps to
42
     */
43
    protected $_objectType = 'route';
44
    
45
    /**
46
     * @ORM\Id
47
     * @ORM\GeneratedValue(strategy="AUTO")
48
     * @ORM\Column(type="integer", unique=true)
49
     * @Assert\Type(type="integer")
50
     * @Assert\NotNull()
51
     * @Assert\LessThan(value=1000000000)
52
     * @var integer $id
53
     */
54
    protected $id = 0;
55
    
56
    /**
57
     * the current workflow state
58
     * @ORM\Column(length=20)
59
     * @Assert\NotBlank()
60
     * @RoutesAssert\ListEntry(entityName="route", propertyName="workflowState", multiple=false)
61
     * @var string $workflowState
62
     */
63
    protected $workflowState = 'initial';
64
    
65
    /**
66
     * @ORM\Column(length=255)
67
     * @Assert\NotBlank()
68
     * @RoutesAssert\ListEntry(entityName="route", propertyName="routeType", multiple=false)
69
     * @var string $routeType
70
     */
71
    protected $routeType = 'additional';
72
    
73
    /**
74
     * @ORM\Column(length=255, nullable=true)
75
     * @Assert\Length(min="0", max="255")
76
     * @var string $replacedRouteName
77
     */
78
    protected $replacedRouteName = '';
79
    
80
    /**
81
     * @ORM\Column(length=255)
82
     * @Assert\NotBlank()
83
     * @Assert\Length(min="0", max="255")
84
     * @var string $bundle
85
     */
86
    protected $bundle = '';
87
    
88
    /**
89
     * @ORM\Column(length=255)
90
     * @Assert\NotBlank()
91
     * @Assert\Length(min="0", max="255")
92
     * @var string $controller
93
     */
94
    protected $controller = '';
95
    
96
    /**
97
     * @ORM\Column(name="route_action", length=255)
98
     * @Assert\NotBlank()
99
     * @Assert\Length(min="0", max="255")
100
     * @var string $action
101
     */
102
    protected $action = '';
103
    
104
    /**
105
     * @ORM\Column(name="route_path", length=255)
106
     * @Assert\NotBlank()
107
     * @Assert\Length(min="0", max="255")
108
     * @var string $path
109
     */
110
    protected $path = '';
111
    
112
    /**
113
     * @ORM\Column(length=255, nullable=true)
114
     * @Assert\Length(min="0", max="255")
115
     * @var string $host
116
     */
117
    protected $host = '';
118
    
119
    /**
120
     * @ORM\Column(length=255)
121
     * @Assert\NotBlank()
122
     * @RoutesAssert\ListEntry(entityName="route", propertyName="schemes", multiple=true)
123
     * @var string $schemes
124
     */
125
    protected $schemes = 'http';
126
    
127
    /**
128
     * @ORM\Column(length=255)
129
     * @Assert\NotBlank()
130
     * @RoutesAssert\ListEntry(entityName="route", propertyName="methods", multiple=true)
131
     * @var string $methods
132
     */
133
    protected $methods = 'GET';
134
    
135
    /**
136
     * @ORM\Column(type="boolean")
137
     * @Assert\IsTrue(message="This option is mandatory.")
138
     * @Assert\Type(type="bool")
139
     * @var boolean $prependBundlePrefix
140
     */
141
    protected $prependBundlePrefix = true;
142
    
143
    /**
144
     * @ORM\Column(type="boolean")
145
     * @Assert\IsTrue(message="This option is mandatory.")
146
     * @Assert\Type(type="bool")
147
     * @var boolean $translatable
148
     */
149
    protected $translatable = true;
150
    
151
    /**
152
     * @ORM\Column(length=255, nullable=true)
153
     * @Assert\Length(min="0", max="255")
154
     * @var string $translationPrefix
155
     */
156
    protected $translationPrefix = '';
157
    
158
    /**
159
     * @ORM\Column(name="route_defaults", type="array")
160
     * @Assert\NotBlank()
161
     * @Assert\Type(type="array")
162
     * @var array $defaults
163
     */
164
    protected $defaults = [];
165
    
166
    /**
167
     * @ORM\Column(type="array")
168
     * @Assert\NotNull()
169
     * @Assert\Type(type="array")
170
     * @var array $requirements
171
     */
172
    protected $requirements = [];
173
    
174
    /**
175
     * @ORM\Column(name="route_condition", length=255, nullable=true)
176
     * @Assert\Length(min="0", max="255")
177
     * @var string $condition
178
     */
179
    protected $condition = '';
180
    
181
    /**
182
     * @ORM\Column(length=255, nullable=true)
183
     * @Assert\Length(min="0", max="255")
184
     * @var string $description
185
     */
186
    protected $description = '';
187
    
188
    /**
189
     * @Gedmo\SortablePosition
190
     * @ORM\Column(type="integer")
191
     * @Assert\Type(type="integer")
192
     * @Assert\NotNull()
193
     * @Assert\LessThan(value=100000000000)
194
     * @var integer $sort
195
     */
196
    protected $sort = 0;
197
    
198
    /**
199
     * @Gedmo\SortableGroup
200
     * @ORM\Column(name="sort_group", length=255)
201
     * @Assert\NotNull()
202
     * @Assert\Length(min="0", max="255")
203
     * @var string $group
204
     */
205
    protected $group = '';
206
    
207
    
208
    
209
    /**
210
     * RouteEntity constructor.
211
     *
212
     * Will not be called by Doctrine and can therefore be used
213
     * for own implementation purposes. It is also possible to add
214
     * arbitrary arguments as with every other class method.
215
     */
216
    public function __construct()
217
    {
218
    }
219
    
220
    /**
221
     * Returns the _object type.
222
     *
223
     * @return string
224
     */
225
    public function get_objectType()
226
    {
227
        return $this->_objectType;
228
    }
229
    
230
    /**
231
     * Sets the _object type.
232
     *
233
     * @param string $_objectType
234
     *
235
     * @return void
236
     */
237
    public function set_objectType($_objectType)
238
    {
239
        if ($this->_objectType != $_objectType) {
240
            $this->_objectType = $_objectType;
241
        }
242
    }
243
    
244
    
245
    /**
246
     * Returns the id.
247
     *
248
     * @return integer
249
     */
250
    public function getId()
251
    {
252
        return $this->id;
253
    }
254
    
255
    /**
256
     * Sets the id.
257
     *
258
     * @param integer $id
259
     *
260
     * @return void
261
     */
262
    public function setId($id)
263
    {
264
        if (intval($this->id) !== intval($id)) {
265
            $this->id = intval($id);
266
        }
267
    }
268
    
269
    /**
270
     * Returns the workflow state.
271
     *
272
     * @return string
273
     */
274
    public function getWorkflowState()
275
    {
276
        return $this->workflowState;
277
    }
278
    
279
    /**
280
     * Sets the workflow state.
281
     *
282
     * @param string $workflowState
283
     *
284
     * @return void
285
     */
286
    public function setWorkflowState($workflowState)
287
    {
288
        if ($this->workflowState !== $workflowState) {
289
            $this->workflowState = isset($workflowState) ? $workflowState : '';
290
        }
291
    }
292
    
293
    /**
294
     * Returns the route type.
295
     *
296
     * @return string
297
     */
298
    public function getRouteType()
299
    {
300
        return $this->routeType;
301
    }
302
    
303
    /**
304
     * Sets the route type.
305
     *
306
     * @param string $routeType
307
     *
308
     * @return void
309
     */
310
    public function setRouteType($routeType)
311
    {
312
        if ($this->routeType !== $routeType) {
313
            $this->routeType = isset($routeType) ? $routeType : '';
314
        }
315
    }
316
    
317
    /**
318
     * Returns the replaced route name.
319
     *
320
     * @return string
321
     */
322
    public function getReplacedRouteName()
323
    {
324
        return $this->replacedRouteName;
325
    }
326
    
327
    /**
328
     * Sets the replaced route name.
329
     *
330
     * @param string $replacedRouteName
331
     *
332
     * @return void
333
     */
334
    public function setReplacedRouteName($replacedRouteName)
335
    {
336
        if ($this->replacedRouteName !== $replacedRouteName) {
337
            $this->replacedRouteName = $replacedRouteName;
338
        }
339
    }
340
    
341
    /**
342
     * Returns the bundle.
343
     *
344
     * @return string
345
     */
346
    public function getBundle()
347
    {
348
        return $this->bundle;
349
    }
350
    
351
    /**
352
     * Sets the bundle.
353
     *
354
     * @param string $bundle
355
     *
356
     * @return void
357
     */
358
    public function setBundle($bundle)
359
    {
360
        if ($this->bundle !== $bundle) {
361
            $this->bundle = isset($bundle) ? $bundle : '';
362
        }
363
    }
364
    
365
    /**
366
     * Returns the controller.
367
     *
368
     * @return string
369
     */
370
    public function getController()
371
    {
372
        return $this->controller;
373
    }
374
    
375
    /**
376
     * Sets the controller.
377
     *
378
     * @param string $controller
379
     *
380
     * @return void
381
     */
382
    public function setController($controller)
383
    {
384
        if ($this->controller !== $controller) {
385
            $this->controller = isset($controller) ? $controller : '';
386
        }
387
    }
388
    
389
    /**
390
     * Returns the action.
391
     *
392
     * @return string
393
     */
394
    public function getAction()
395
    {
396
        return $this->action;
397
    }
398
    
399
    /**
400
     * Sets the action.
401
     *
402
     * @param string $action
403
     *
404
     * @return void
405
     */
406
    public function setAction($action)
407
    {
408
        if ($this->action !== $action) {
409
            $this->action = isset($action) ? $action : '';
410
        }
411
    }
412
    
413
    /**
414
     * Returns the path.
415
     *
416
     * @return string
417
     */
418
    public function getPath()
419
    {
420
        return $this->path;
421
    }
422
    
423
    /**
424
     * Sets the path.
425
     *
426
     * @param string $path
427
     *
428
     * @return void
429
     */
430
    public function setPath($path)
431
    {
432
        if ($this->path !== $path) {
433
            $this->path = isset($path) ? $path : '';
434
        }
435
    }
436
    
437
    /**
438
     * Returns the host.
439
     *
440
     * @return string
441
     */
442
    public function getHost()
443
    {
444
        return $this->host;
445
    }
446
    
447
    /**
448
     * Sets the host.
449
     *
450
     * @param string $host
451
     *
452
     * @return void
453
     */
454
    public function setHost($host)
455
    {
456
        if ($this->host !== $host) {
457
            $this->host = $host;
458
        }
459
    }
460
    
461
    /**
462
     * Returns the schemes.
463
     *
464
     * @return string
465
     */
466
    public function getSchemes()
467
    {
468
        return $this->schemes;
469
    }
470
    
471
    /**
472
     * Sets the schemes.
473
     *
474
     * @param string $schemes
475
     *
476
     * @return void
477
     */
478
    public function setSchemes($schemes)
479
    {
480
        if ($this->schemes !== $schemes) {
481
            $this->schemes = isset($schemes) ? $schemes : '';
482
        }
483
    }
484
    
485
    /**
486
     * Returns the methods.
487
     *
488
     * @return string
489
     */
490
    public function getMethods()
491
    {
492
        return $this->methods;
493
    }
494
    
495
    /**
496
     * Sets the methods.
497
     *
498
     * @param string $methods
499
     *
500
     * @return void
501
     */
502
    public function setMethods($methods)
503
    {
504
        if ($this->methods !== $methods) {
505
            $this->methods = isset($methods) ? $methods : '';
506
        }
507
    }
508
    
509
    /**
510
     * Returns the prepend bundle prefix.
511
     *
512
     * @return boolean
513
     */
514
    public function getPrependBundlePrefix()
515
    {
516
        return $this->prependBundlePrefix;
517
    }
518
    
519
    /**
520
     * Sets the prepend bundle prefix.
521
     *
522
     * @param boolean $prependBundlePrefix
523
     *
524
     * @return void
525
     */
526
    public function setPrependBundlePrefix($prependBundlePrefix)
527
    {
528
        if (boolval($this->prependBundlePrefix) !== boolval($prependBundlePrefix)) {
529
            $this->prependBundlePrefix = boolval($prependBundlePrefix);
530
        }
531
    }
532
    
533
    /**
534
     * Returns the translatable.
535
     *
536
     * @return boolean
537
     */
538
    public function getTranslatable()
539
    {
540
        return $this->translatable;
541
    }
542
    
543
    /**
544
     * Sets the translatable.
545
     *
546
     * @param boolean $translatable
547
     *
548
     * @return void
549
     */
550
    public function setTranslatable($translatable)
551
    {
552
        if (boolval($this->translatable) !== boolval($translatable)) {
553
            $this->translatable = boolval($translatable);
554
        }
555
    }
556
    
557
    /**
558
     * Returns the translation prefix.
559
     *
560
     * @return string
561
     */
562
    public function getTranslationPrefix()
563
    {
564
        return $this->translationPrefix;
565
    }
566
    
567
    /**
568
     * Sets the translation prefix.
569
     *
570
     * @param string $translationPrefix
571
     *
572
     * @return void
573
     */
574
    public function setTranslationPrefix($translationPrefix)
575
    {
576
        if ($this->translationPrefix !== $translationPrefix) {
577
            $this->translationPrefix = $translationPrefix;
578
        }
579
    }
580
    
581
    /**
582
     * Returns the defaults.
583
     *
584
     * @return array
585
     */
586
    public function getDefaults()
587
    {
588
        return $this->defaults;
589
    }
590
    
591
    /**
592
     * Sets the defaults.
593
     *
594
     * @param array $defaults
595
     *
596
     * @return void
597
     */
598
    public function setDefaults($defaults)
599
    {
600
        if ($this->defaults !== $defaults) {
601
            $this->defaults = isset($defaults) ? $defaults : '';
0 ignored issues
show
Documentation Bug introduced by
It seems like isset($defaults) ? $defaults : '' can also be of type string. However, the property $defaults is declared as type array. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
602
        }
603
    }
604
    
605
    /**
606
     * Returns the requirements.
607
     *
608
     * @return array
609
     */
610
    public function getRequirements()
611
    {
612
        return $this->requirements;
613
    }
614
    
615
    /**
616
     * Sets the requirements.
617
     *
618
     * @param array $requirements
619
     *
620
     * @return void
621
     */
622
    public function setRequirements($requirements)
623
    {
624
        if ($this->requirements !== $requirements) {
625
            $this->requirements = isset($requirements) ? $requirements : '';
0 ignored issues
show
Documentation Bug introduced by
It seems like isset($requirements) ? $requirements : '' can also be of type string. However, the property $requirements is declared as type array. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
626
        }
627
    }
628
    
629
    /**
630
     * Returns the condition.
631
     *
632
     * @return string
633
     */
634
    public function getCondition()
635
    {
636
        return $this->condition;
637
    }
638
    
639
    /**
640
     * Sets the condition.
641
     *
642
     * @param string $condition
643
     *
644
     * @return void
645
     */
646
    public function setCondition($condition)
647
    {
648
        if ($this->condition !== $condition) {
649
            $this->condition = $condition;
650
        }
651
    }
652
    
653
    /**
654
     * Returns the description.
655
     *
656
     * @return string
657
     */
658
    public function getDescription()
659
    {
660
        return $this->description;
661
    }
662
    
663
    /**
664
     * Sets the description.
665
     *
666
     * @param string $description
667
     *
668
     * @return void
669
     */
670
    public function setDescription($description)
671
    {
672
        if ($this->description !== $description) {
673
            $this->description = $description;
674
        }
675
    }
676
    
677
    /**
678
     * Returns the sort.
679
     *
680
     * @return integer
681
     */
682
    public function getSort()
683
    {
684
        return $this->sort;
685
    }
686
    
687
    /**
688
     * Sets the sort.
689
     *
690
     * @param integer $sort
691
     *
692
     * @return void
693
     */
694
    public function setSort($sort)
695
    {
696
        if (intval($this->sort) !== intval($sort)) {
697
            $this->sort = intval($sort);
698
        }
699
    }
700
    
701
    /**
702
     * Returns the group.
703
     *
704
     * @return string
705
     */
706
    public function getGroup()
707
    {
708
        return $this->group;
709
    }
710
    
711
    /**
712
     * Sets the group.
713
     *
714
     * @param string $group
715
     *
716
     * @return void
717
     */
718
    public function setGroup($group)
719
    {
720
        if ($this->group !== $group) {
721
            $this->group = isset($group) ? $group : '';
722
        }
723
    }
724
    
725
    
726
    
727
    /**
728
     * Returns the formatted title conforming to the display pattern
729
     * specified for this entity.
730
     *
731
     * @return string The display title
732
     */
733
    public function getTitleFromDisplayPattern()
734
    {
735
        $formattedTitle = ''
736
                . $this->getPath()
737
                . ' ('
738
                . $this->getSort()
739
                . ')';
740
    
741
        return $formattedTitle;
742
    }
743
    
744
    /**
745
     * Return entity data in JSON format.
746
     *
747
     * @return string JSON-encoded data
748
     */
749
    public function toJson()
750
    {
751
        return json_encode($this->toArray());
752
    }
753
    
754
    /**
755
     * Creates url arguments array for easy creation of display urls.
756
     *
757
     * @return array The resulting arguments list
758
     */
759
    public function createUrlArgs()
760
    {
761
        $args = [];
762
    
763
        $args['id'] = $this['id'];
764
    
765
        if (property_exists($this, 'slug')) {
766
            $args['slug'] = $this['slug'];
767
        }
768
    
769
        return $args;
770
    }
771
    
772
    /**
773
     * Create concatenated identifier string (for composite keys).
774
     *
775
     * @return String concatenated identifiers
776
     */
777
    public function createCompositeIdentifier()
778
    {
779
        $itemId = $this['id'];
780
    
781
        return $itemId;
782
    }
783
    
784
    /**
785
     * Determines whether this entity supports hook subscribers or not.
786
     *
787
     * @return boolean
788
     */
789
    public function supportsHookSubscribers()
790
    {
791
        return false;
792
    }
793
    
794
    /**
795
     * Returns an array of all related objects that need to be persisted after clone.
796
     * 
797
     * @param array $objects The objects are added to this array. Default: []
798
     * 
799
     * @return array of entity objects
800
     */
801
    public function getRelatedObjectsToPersist(&$objects = []) 
0 ignored issues
show
Unused Code introduced by
The parameter $objects is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
802
    {
803
        return [];
804
    }
805
    
806
    /**
807
     * ToString interceptor implementation.
808
     * This method is useful for debugging purposes.
809
     *
810
     * @return string The output string for this entity
811
     */
812
    public function __toString()
813
    {
814
        return 'Route ' . $this->createCompositeIdentifier() . ': ' . $this->getTitleFromDisplayPattern();
815
    }
816
    
817
    /**
818
     * Clone interceptor implementation.
819
     * This method is for example called by the reuse functionality.
820
     * Performs a quite simple shallow copy.
821
     *
822
     * See also:
823
     * (1) http://docs.doctrine-project.org/en/latest/cookbook/implementing-wakeup-or-clone.html
824
     * (2) http://www.php.net/manual/en/language.oop5.cloning.php
825
     * (3) http://stackoverflow.com/questions/185934/how-do-i-create-a-copy-of-an-object-in-php
826
     */
827
    public function __clone()
828
    {
829
        // if the entity has no identity do nothing, do NOT throw an exception
830
        if (!($this->id)) {
831
            return;
832
        }
833
    
834
        // otherwise proceed
835
    
836
        // unset identifiers
837
        $this->setId(0);
838
    
839
        $this->setCreatedBy(null);
0 ignored issues
show
Documentation introduced by
null is of type null, but the function expects a object<Zikula\UsersModule\Entity\UserEntity>.

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...
840
        $this->setCreatedDate(null);
0 ignored issues
show
Documentation introduced by
null is of type null, but the function expects a object<DateTime>.

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...
841
        $this->setUpdatedBy(null);
0 ignored issues
show
Documentation introduced by
null is of type null, but the function expects a object<Zikula\UsersModule\Entity\UserEntity>.

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...
842
        $this->setUpdatedDate(null);
0 ignored issues
show
Documentation introduced by
null is of type null, but the function expects a object<DateTime>.

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...
843
    
844
    }
845
}
846