Skip to content

Commit 6e7f811

Browse files
author
Caitlin Bales (MSFT)
committed
Remove redundant constructors from PHP models
1 parent ed69bdd commit 6e7f811

File tree

2 files changed

+11
-38
lines changed

2 files changed

+11
-38
lines changed

Templates/PHP/Model/ComplexType.php.tt

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,6 @@ namespace Microsoft\Graph\Model;
1212
<#=writer.GetClassBlock(complex.Name.ToCheckedCase().ToString(), "Model")#>
1313
class <#=complex.Name.ToCheckedCase()#> extends Entity
1414
{
15-
/**
16-
* The array of properties available
17-
* to the model
18-
*
19-
* @var array(string => string)
20-
*/
21-
private $_propDict;
22-
/**
23-
* <#=complex.Name.ToCheckedCase()#> constructor
24-
*
25-
* @param array $propDict List of properties to set
26-
* Defaults to an empty array
27-
*
28-
* @return <#=complex.Name.ToCheckedCase()#>
29-
*/
30-
public function __construct($propDict=array())
31-
{
32-
parent::__construct();
33-
$this->_propDict = $propDict;
34-
return $this;
35-
}
36-
3715
/**
3816
* Gets the property dictionary of the <#=complex.Name.ToCheckedCase()#>
3917
*

Templates/PHP/Model/EntityType.php.tt

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,34 +25,29 @@ class <#=entity.Name.ToCheckedCase()#> extends Entity
2525
}
2626
#>
2727
{
28+
<#
29+
if (entity.Name.ToCheckedCase() == "Entity") {
30+
#>
2831
/**
2932
* The array of properties available
3033
* to the model
3134
*
3235
* @var array(string => string)
3336
*/
34-
private $_propDict;
37+
protected $_propDict;
3538

3639
/**
3740
* Construct a new <#=entity.Name.ToCheckedCase()#>
3841
*
3942
* @param array $propDict A list of properties to set
40-
*
41-
* @return <#=entity.Name.ToCheckedCase()#>
4243
*/
4344
function __construct($propDict = array())
4445
{
45-
<#
46-
if (!(entity.Name.ToCheckedCase() == "Entity")) {
47-
#>
48-
parent::__construct();
46+
$this->_propDict = $propDict;
47+
}
4948
<#
5049
}
5150
#>
52-
$this->_propDict = $propDict;
53-
return $this;
54-
}
55-
5651
/**
5752
* Gets the property dictionary of the <#=entity.Name.ToUpperFirstChar()#>
5853
*
@@ -70,11 +65,11 @@ foreach(var property in entity.Properties.Where(prop => prop.Type.GetTypeString(
7065
if (property.IsCollection()) {
7166
#>
7267

73-
/**
74-
* Gets the <#=property.Name#>
75-
*
76-
* @return array The <#=property.Name#>
77-
*/
68+
/**
69+
* Gets the <#=property.Name#>
70+
*
71+
* @return array The <#=property.Name#>
72+
*/
7873
public function get<#=property.Name.ToCheckedCase()#>()
7974
{
8075
if (array_key_exists("<#=property.Name.ToCamelize()#>", $this->_propDict)) {

0 commit comments

Comments
 (0)