The method is defined as follows:
Class maaper{
......
Public Function getProperties () {
function GetName ($reflectionProperties) {
return $reflectionProperties->name;
}
$domain = $this->get_domain ();
$reflectionProperties = $domain->getproperties (reflectionproperty::is_public);
$properties =array_map (' GetName ', $reflectionProperties);
return $properties;
}
......
}
The invocation process is as follows (note: $mapper _1, $mapper _2 is called at the same runtime):
$mapper _1=new mapper ();
$mapper _2=new mapper ();
Var_dump ($mapper _1->getproperties ()); return correctly
Var_dump ($mapper _2->getproperties ()); Error cannot redeclare getName ()
As follows:
Reply to discussion (solution)
Don't you read the wrong message?
Fatal error:cannot redeclare getName ()
Fatal error: Cannot re-declare getName ()
class maaper{
protected function ge Tname ($reflectionProperties) {
return $reflectionProperties->name;
}
Public Function getProperties () {
$domain = $this->get_domain ();
$reflectionProperties = $domain->getproperties (reflectionproperty::is_public);
$properties =array_map (Array ($this, ' getName '), $reflectionProperties);
return $properties;
}
can also be written
class maaper{
Public Function getProperties () {
$getName = function ($reflectionPropert ies) {
return $reflectionProperties->name;
};
$domain = $this->get_domain ();
$reflectionProperties = $domain->getproperties (reflectionproperty::is_public);
$properties =array_map ($getName, $reflectionProperties);
return $properties;
}
Don't you read the wrong message?
Fatal error:cannot redeclare getName ()
Fatal error: Cannot re-declare getName ()
class maaper{
protected function ge Tname ($reflectionProperties) {
return $reflectionProperties->name;
}
Public Function getProperties () {
$domain = $this->get_domain ();
$reflectionProperties = $domain->getproperties (reflectionproperty::is_public);
$properties =array_map (Array ($this, ' getName '), $reflectionProperties);
return $properties;
}
can also be written
class maaper{
Public Function getProperties () {
$getName = function ($reflectionPropert ies) {
return $reflectionProperties->name;
};
$domain = $this->get_domain ();
$reflectionProperties = $domain->getproperties (reflectionproperty::is_public);
$properties =array_map ($getName, $reflectionProperties);
return $properties;
}
Thank you very much
But why is there a re-declared error?
You have
$reflectionProperties = GetProperties (reflectionproperty::is_public), $domain;
is to re-enter the getProperties, then the function defined in GetProperties is not repeated in the definition?
You have
$reflectionProperties = GetProperties (reflectionproperty::is_public), $domain;
is to re-enter the getProperties, then the function defined in GetProperties is not repeated in the definition?
Although there are two calls $domain-getProperties but the getProperties here is defined in the class to which the $domain domain object belongs, there is no GetName method. The error message is not able to re-affirm the GetName method located in GetProperties in class mapper.
So.... That's not what it looks like.
function GetName ($reflectionProperties) {
return $reflectionProperties->name;
}
Define global functions wherever you are
function GetName ($reflectionProperties) {
return $reflectionProperties->name;
}
Define global functions wherever you are
In a language.
Thank you!!!