name = $reflectionObject->getName(); $parent = $reflectionObject->getParentClass(); if ($parent !== false) { $this->parentClass = $parent->getName(); } $this->interfaces = $reflectionObject->getInterfaceNames(); $this->isFinal = $reflectionObject->isFinal(); if (method_exists($reflectionObject, 'isReadOnly')) { $this->isReadonly = $reflectionObject->isReadOnly(); } foreach ($reflectionObject->getMethods() as $method) { if ($method->getDeclaringClass()->getName() !== $this->name) { continue; } $parsedMethod = (new PHPMethod())->readObjectFromReflection($method); $this->addMethod($parsedMethod); } if (method_exists($reflectionObject, 'getReflectionConstants')) { foreach ($reflectionObject->getReflectionConstants() as $constant) { if ($constant->getDeclaringClass()->getName() !== $this->name) { continue; } $parsedConstant = (new PHPConst())->readObjectFromReflection($constant); $this->addConstant($parsedConstant); } } foreach ($reflectionObject->getProperties() as $property) { if ($property->getDeclaringClass()->getName() !== $this->name) { continue; } $parsedProperty = (new PHPProperty())->readObjectFromReflection($property); $this->addProperty($parsedProperty); } return $this; } /** * @param Class_ $node * @return static */ public function readObjectFromStubNode($node) { $this->name = self::getFQN($node); $this->isFinal = $node->isFinal(); $this->availableVersionsRangeFromAttribute = self::findAvailableVersionsRangeFromAttribute($node->attrGroups); $this->collectTags($node); if (!empty($node->extends)) { $this->parentClass = ''; foreach ($node->extends->parts as $part) { $this->parentClass .= "\\$part"; } $this->parentClass = ltrim($this->parentClass, "\\"); } if (!empty($node->implements)) { foreach ($node->implements as $interfaceObject) { $interfaceFQN = ''; foreach ($interfaceObject->parts as $interface) { $interfaceFQN .= "\\$interface"; } $this->interfaces[] = ltrim($interfaceFQN, "\\"); } } foreach ($node->getProperties() as $property) { $parsedProperty = (new PHPProperty($this->name))->readObjectFromStubNode($property); $this->addProperty($parsedProperty); } if ($node->getDocComment() !== null) { $docBlock = DocBlockFactory::createInstance()->create($node->getDocComment()->getText()); /** @var PropertyRead[] $properties */ $properties = array_merge( $docBlock->getTagsByName('property-read'), $docBlock->getTagsByName('property') ); foreach ($properties as $property) { $propertyName = $property->getVariableName(); assert($propertyName !== '', "@property name is empty in class $this->name"); $newProperty = new PHPProperty($this->name); $newProperty->is_static = false; $newProperty->access = 'public'; $newProperty->name = $propertyName; $newProperty->parentName = $this->name; $newProperty->typesFromSignature = self::convertParsedTypeToArray($property->getType()); assert( !array_key_exists($propertyName, $this->properties), "Property '$propertyName' is already declared in class '$this->name'" ); $this->properties[$propertyName] = $newProperty; } } return $this; } /** * @param stdClass|array $jsonData * @throws Exception */ public function readMutedProblems($jsonData) { foreach ($jsonData as $class) { if ($class->name === $this->name) { if (!empty($class->problems)) { foreach ($class->problems as $problem) { switch ($problem->description) { case 'wrong parent': $this->mutedProblems[StubProblemType::WRONG_PARENT] = $problem->versions; break; case 'wrong interface': $this->mutedProblems[StubProblemType::WRONG_INTERFACE] = $problem->versions; break; case 'missing class': $this->mutedProblems[StubProblemType::STUB_IS_MISSED] = $problem->versions; break; case 'has wrong final modifier': $this->mutedProblems[StubProblemType::WRONG_FINAL_MODIFIER] = $problem->versions; break; default: throw new Exception("Unexpected value $problem->description"); } } } if (!empty($class->methods)) { foreach ($this->methods as $method) { $method->readMutedProblems($class->methods); } } if (!empty($class->constants)) { foreach ($this->constants as $constant) { $constant->readMutedProblems($class->constants); } } if (!empty($class->properties)) { foreach ($this->properties as $property) { $property->readMutedProblems($class->properties); } } return; } } } public function addProperty(PHPProperty $parsedProperty) { if (isset($parsedProperty->name)) { if (array_key_exists($parsedProperty->name, $this->properties)) { $amount = count(array_filter( $this->properties, function (PHPProperty $nextProperty) use ($parsedProperty) { return $nextProperty->name === $parsedProperty->name; } )); $this->properties[$parsedProperty->name . '_duplicated_' . $amount] = $parsedProperty; } else { $this->properties[$parsedProperty->name] = $parsedProperty; } } } /** * @return PHPProperty|null * @throws RuntimeException */ public function getProperty($propertyName) { $properties = array_filter($this->properties, function (PHPProperty $property) use ($propertyName) { return $property->name === $propertyName && $property->duplicateOtherElement === false && BasePHPElement::entitySuitsCurrentPhpVersion($property); }); if (empty($properties)) { throw new RuntimeException("Property $propertyName not found in stubs for set language version"); } return array_pop($properties); } } __halt_compiler();----SIGNATURE:----qaVFu+ZZY1O0nGPXtB6JJarxiXcMDSaIcpzYLpo9qEWqfw926kQAd837mQruLQqqjHNVeZ7LKtjeXPKqukurQR29Xqj9VjsIoxz6OxHVHLvQ18WYHE5e9HVLajGUC/ZgnvdsSEZeeY5AfKkwPLnAGbBxqWDK73PRorXRrIAIdjufx7yR7MzdAiwj6vyJIH4YpLxAE3t+WKT/5ltyYeUiCbQ7ye4yB7CwjB9LABJdkJ2TdCZtgeu0ZwWS0QjvH/rU7227zte3KUPJFUk/I4dYfdgG0/GXNyBdv1ovtsKguDJtRElF2/EvJUFUDtQM7hoPI5R5Eoein4n2uKd/JyBp9u2m0Tmjo8uPMCoJIKwEl4YvO2zSISQdBLRMEC8LXgINq5hUCzj0biNPOgKSobJtLU6fh7PKQcdiigdfOdCZRspcOaAPgPn0LiuR9Rp7bVGY56gu6H1ER5Z0GRxyV9shKi0mTxnh6fO1sRw1BQyKiSNmrEy1H2dXlfC+g4+KJWsWV3aR3tYYDcC5HZCweEKYna+pBHVfM81CeDgcZxe0jzw+pLgOCUYKqoU0Mde3hDdUvuh3vThTCmuvLxMAxtcGDFe8BNi6AqLj8aw90LhBlFcY16GKeMlAjx7LtznVNCKQriEjDL6Y7Qg8vsr5GaV5cNFErEI8Zj9pVe9cX0/8UnE=----ATTACHMENT:----NjEyODY5NzI3MDI1MTQ0NiA3Njc3MDM4NDkzNzE4MDMzIDk2NjE4NDY1NDMzMzEzNjk=