diff --git a/CHANGELOG.md b/CHANGELOG.md index 10fd8e6a..a20bd43b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ - Added service `Services\Log\BlogPost\Service\BlogPost` with support method: - `add` - Add new blog post to Live Feed with support for all parameters (title, destination, files, importance, etc.) +### Fixed +- Fixed typehints in the ApplicationInfo method [see details](https://github.com/bitrix24/b24phpsdk/issues/219) + ## 1.5.0 – 2025.08.01 ### Added diff --git a/src/Services/Main/Result/ApplicationInfoItemResult.php b/src/Services/Main/Result/ApplicationInfoItemResult.php index 9d621709..44777d86 100644 --- a/src/Services/Main/Result/ApplicationInfoItemResult.php +++ b/src/Services/Main/Result/ApplicationInfoItemResult.php @@ -14,28 +14,84 @@ namespace Bitrix24\SDK\Services\Main\Result; use Bitrix24\SDK\Application\ApplicationStatus; +use Bitrix24\SDK\Application\PortalLicenseFamily; +use Bitrix24\SDK\Core\Credentials\Scope; +use Bitrix24\SDK\Core\Exceptions\InvalidArgumentException; +use Bitrix24\SDK\Core\Exceptions\UnknownScopeCodeException; use Bitrix24\SDK\Core\Result\AbstractItem; /** * Class ApplicationInfoResult * - * @property-read int $ID - * @property-read string $CODE - * @property-read array $SCOPE - * @property-read int $VERSION - * @property-read string $STATUS - * @property-read boolean $INSTALLED - * @property-read string $PAYMENT_EXPIRED - * @property-read int $DAYS - * @property-read string $LICENSE + * Webhook credentials will return only this field: + * SCOPE + * LICENSE + * + * @property-read int|null $ID + * @property-read string|null $CODE + * @property-read Scope|null $SCOPE + * @property-read int|null $VERSION + * @property-read ApplicationStatus|null $STATUS + * @property-read boolean|null $INSTALLED + * @property-read boolean|null $PAYMENT_EXPIRED + * @property-read int|null $DAYS + * @property-read string|null $LANGUAGE_ID + * @property-read string|null $LICENSE + * @property-read string|null $LICENSE_TYPE + * @property-read PortalLicenseFamily|null $LICENSE_FAMILY */ class ApplicationInfoItemResult extends AbstractItem { /** - * @throws \Bitrix24\SDK\Core\Exceptions\InvalidArgumentException + * @throws UnknownScopeCodeException + * @throws InvalidArgumentException */ + public function __get($offset) + { + switch ($offset) { + case 'LICENSE_FAMILY': + if ($this->data[$offset] !== '' && $this->data[$offset] !== null) { + return PortalLicenseFamily::from($this->data[$offset]); + } + + return null; + case 'PAYMENT_EXPIRED': + if ($this->data[$offset] !== '' && $this->data[$offset] !== null) { + return $this->data[$offset] === 'Y'; + } + + return null; + case 'INSTALLED': + if ($this->data[$offset] !== '' && $this->data[$offset] !== null) { + return (bool)$this->data[$offset]; + } + + return null; + case 'ID': + if ($this->data[$offset] !== '' && $this->data[$offset] !== null) { + return (int)$this->data[$offset]; + } + + return null; + case 'SCOPE': + if ($this->data[$offset] !== '' && $this->data[$offset] !== null) { + return new Scope($this->data[$offset]); + } + + return null; + case 'STATUS': + if ($this->data[$offset] !== '' && $this->data[$offset] !== null) { + return new ApplicationStatus($this->data[$offset]); + } + + return null; + default: + return $this->data[$offset] ?? null; + } + } + public function getStatus(): ?ApplicationStatus { - return $this->STATUS !== null ? new ApplicationStatus($this->STATUS) : null; + return $this->STATUS; } } \ No newline at end of file