/** * Add a property to this class * * @param CodeBase $code_base * A reference to the code base in which the ancestor exists * * @param Property $property * The property to copy onto this class * * @param Option<Type>|None $type_option * A possibly defined type used to define template * parameter types when importing the property * * @return void */ public function addProperty(CodeBase $code_base, Property $property, $type_option) { // Ignore properties we already have if ($this->hasPropertyWithName($code_base, $property->getName())) { return; } $property_fqsen = FullyQualifiedPropertyName::make($this->getFQSEN(), $property->getName()); if ($property->getFQSEN() !== $property_fqsen) { $property = clone $property; $property->setDefiningFQSEN($property->getFQSEN()); $property->setFQSEN($property_fqsen); try { // If we have a parent type defined, map the property's // type through it if ($type_option->isDefined() && $property->getUnionType()->hasTemplateType()) { $property->setUnionType($property->getUnionType()->withTemplateParameterTypeMap($type_option->get()->getTemplateParameterTypeMap($code_base))); } } catch (IssueException $exception) { Issue::maybeEmitInstance($code_base, $property->getContext(), $exception->getIssueInstance()); } } $code_base->addProperty($property); }
/** * @return void */ public function addProperty(CodeBase $code_base, Property $property) { // Ignore properties we already have if ($this->hasPropertyWithName($code_base, $property->getName())) { return; } $property_fqsen = FullyQualifiedPropertyName::make($this->getFQSEN(), $property->getName()); if ($property->getFQSEN() !== $property_fqsen) { $property = clone $property; $property->setFQSEN($property_fqsen); } $code_base->addProperty($property); }
/** * @return void */ public function addProperty(Property $property) { $this->property_map[$property->getFQSEN()->getNameWithAlternateId()] = $property; }
/** * @return array * Get a map from column name to row values for * this instance */ public function toRow() : array { return ['scope_name' => $this->primaryKeyValue(), 'fqsen' => (string) $this->property->getFQSEN(), 'name' => (string) $this->property->getName(), 'type' => (string) $this->property->getUnionType(), 'flags' => $this->property->getFlags(), 'context' => base64_encode(serialize($this->property->getContext())), 'is_deprecated' => $this->property->isDeprecated()]; }
/** * @param Property $property * Any property * * @param FullyQualifiedClassName $fqsen * The FQSEN to index the property by * * @return null */ public function addPropertyInScope(Property $property, FullyQualifiedClassName $fqsen) { $name = $property->getFQSEN()->getNameWithAlternateId(); $this->property_map[(string) $fqsen][$name] = $property; // For elements that aren't internal PHP classes if (!$property->getContext()->isInternal()) { // Associate the element with the file it was found in $this->getFileByPath($property->getContext()->getFile())->addPropertyFQSEN($property->getFQSEN()); } }