Completed
Pull Request — master (#243)
by Guilh
02:34
created

Metadata/ClassMetadata.php (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
/*
4
 * Copyright 2011 Johannes M. Schmitt <[email protected]>
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 * http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 */
18
19
namespace JMS\DiExtraBundle\Metadata;
20
21
use Metadata\ClassMetadata as BaseClassMetadata;
22
23
/**
24
 * class metadata
25
 */
26
class ClassMetadata extends BaseClassMetadata
27
{
28
    public $id;
29
    public $parent;
30
    public $scope;
31
    public $public;
32
    public $abstract;
33
    public $tags = array();
34
    public $arguments;
35
    public $methodCalls = array();
36
    public $lookupMethods = array();
37
    public $properties = array();
38
    /**
39
     * @deprecated since version 1.7, to be removed in 2.0. Use $initMethods instead.
40
     */
41
    public $initMethod;
42
    public $initMethods = array();
43
    public $environments = array();
44
    public $decorates;
45
    public $decoration_inner_name;
46
    public $deprecated;
47
48
    /**
49
     * @param string $env
50
     *
51
     * @return bool
52
     */
53
    public function isLoadedInEnvironment($env)
54
    {
55
        if (empty($this->environments)) {
56
            return true;
57
        }
58
59
        return in_array($env, $this->environments, true);
60
    }
61
62
    /**
63
     * @return string
64
     */
65
    public function serialize()
66
    {
67
        return serialize(array(
68
            $this->id,
69
            $this->parent,
70
            $this->scope,
71
            $this->public,
72
            $this->abstract,
73
            $this->tags,
74
            $this->arguments,
75
            $this->methodCalls,
76
            $this->lookupMethods,
77
            $this->properties,
78
            $this->initMethod,
0 ignored issues
show
Deprecated Code introduced by
The property JMS\DiExtraBundle\Metada...ssMetadata::$initMethod has been deprecated with message: since version 1.7, to be removed in 2.0. Use $initMethods instead.

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
79
            parent::serialize(),
80
            $this->environments,
81
            $this->decorates,
82
            $this->decoration_inner_name,
83
            $this->deprecated,
84
        ));
85
    }
86
87
    /**
88
     * @param string $str
89
     */
90
    public function unserialize($str)
91
    {
92
        $data = unserialize($str);
93
94
        // prevent errors if not all key's are set
95
        @list(
96
            $this->id,
97
            $this->parent,
98
            $this->scope,
99
            $this->public,
100
            $this->abstract,
101
            $this->tags,
102
            $this->arguments,
103
            $this->methodCalls,
104
            $this->lookupMethods,
105
            $this->properties,
106
            $this->initMethod,
0 ignored issues
show
Deprecated Code introduced by
The property JMS\DiExtraBundle\Metada...ssMetadata::$initMethod has been deprecated with message: since version 1.7, to be removed in 2.0. Use $initMethods instead.

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
107
            $parentStr,
108
            $this->environments,
109
            $this->decorates,
110
            $this->decoration_inner_name,
111
            $this->deprecated,
112
        ) = $data;
113
114
        parent::unserialize($parentStr);
115
    }
116
}
117