PHP Classes

File: example.php

Recommend this page to a friend!
  Packages of Christos Drogidis   VSC Dobu Helper   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Class source
Class: VSC Dobu Helper
Create DoBu documentation blocks in Visual Studio
Author: By
Last change:
Date: 1 month ago
Size: 18,380 bytes
 

Contents

Class file image Download
<?php /* dobu { file:id(`2`),name(`create-dobu-class`) { ascoos { logo {` __ _ ___ ___ ___ ___ ___ ___ ___ / _V |/ / / __/ _ \ / _ \ / / / _ \ / / | (_| |\ \| (_| (_) | (_) |\ \ | (_) |\ \ \__,_|/__/ \___\___/ \___/ /__/ \___/ /__/ `}, name {`ASCOOS OS`}, version {`1.0.0`}, category {`Web OS`}, subcategory {`Web5 / WebAI`}, description {`A Web 5.0 and Web AI Kernel for decentralized web and IoT applications`}, creator {`Drogidis Christos`}, site {`https://www.ascoos.com`}, issues {`https://issues.ascoos.com`}, support {`support@ascoos.com`}, license {`[Commercial] http://docs.ascoos.com/lics/ascoos/AGL.html`}, copyright {`Copyright (c) 2007 - 2026, AlexSoft Software.`} }, project { package:langs { en {`DoBu code sample`}, el {`?????? ?????? DoBu`} }, subpackage:langs { en {`DoBu code sample for classes and methods`}, el {`?????? ?????? DoBu ??? ??????? ??? ????????`} }, category:langs { en {`Examples`}, el {`????????????`} }, subcategory:langs { en {`DoBu for classes`}, el {`DoBu ??? ???????`} }, source {`examples/create-dobu-class.php`}, description:langs { en {`This file is a complete example of docblock writing and DoBu structure.`}, el {`?? ?????? ???? ???????? ??? ???????????? ?????????? ???????? docblock, ????? DoBu`} }, fileNo {`2`}, version {`1.0.0`}, build {`15`}, created {`2026-02-12 09:25:03`}, updated {`2026-02-12 09:51:43`}, author {`Drogidis Christos`}, authorSite {`https://www.ascoos.com`}, support {`support@ascoos.com`}, license {`AGL-F (ASCOOS General License - FREE)`}, since {`1.0.0`}, sincePHP {`8.3.0+`} } } } */ declare(strict_types=1); namespace ASCOOS\OS\Kernel\MyClass; defined("ALEXSOFT_RUN_CMS") or die("Prohibition of Access."); defined("ASCOOS_OS_RUN") or die("Prohibition of Access."); use ASCOOS\OS\Kernel\Core\TObject; /****************************************************************************** * @startcode TMyClass *****************************************************************************/ /* dobu { class:id(`tmyclass`),name(`TMyClass`),extends(`TObject`),implements(``),namespace(`ASCOOS\OS\Kernel\MyClass`),hierarchy(`TObject, TMyClass`),version(`0.0.1`),since(`1.0.0`),sincePHP(`8.3.0`) { category:langs { en {`Objects`}, el {`???????????`} }, intro:langs { en {`Multilines Introduction Text`}, el {`??????? ????????? ????????? ???????`} }, summary:langs { en {`Creating a new Ascoos OS class.`}, el {`?????????? ???? ???? Ascoos OS ??????.`} }, desc:langs { en {`This class is a typical example of a prototype for the Ascoos ecosystem`}, el {`? ????? ???? ????? ??? ?????? ?????? ?????????? ??? ?? ??????????? Ascoos`} }, methods:active(`idx,toc`) { method:id(`construct`),name(`__construct`),syntax(`__construct(array $properties = [])`),return(`void`),langs { en {`Initializes the class with an array, and optional properties.`}, el {`??????????? ??? ????? ?? ???? ?????? ??? ???????????? ?????????.`} }, method:id(`getinstance`),name(`getInstance`),syntax(`&getInstance(array $properties = []): TMyClass`),return(`TMyClass&`),langs { en {`We see if the object is already loaded, otherwise we create a new load of the object`}, el {`???????? ??? ??????? ??? ????????? ?? ??????????? ?????? ???????????? ??? ??? ??????? ??? ????????????`} }, method:id(`blackscholesputdividend`),name(`blackScholesPutDividend`),syntax(`blackScholesPutDividend(float $spot, float $strike, float $riskFreeRate, float $dividendYield, float $volatility, float $timeToMaturity): float`),return(`float`),langs { en {`We see if the object is already loaded, otherwise we create a new load of the object`}, el {`???????? ??? ??????? ??? ????????? ?? ??????????? ?????? ???????????? ??? ??? ??????? ??? ????????????`} } } } } */ #[\AllowDynamicProperties] class TMyClass extends TObject { /* dobu { method:classid(`tmyclass`),id(`construct`),name(`__construct`),syntax(`__construct(array $properties = [])`),return(`void`),version(`1.0.0`) { category:langs { en {`Constructor`}, el {`?????????????`} }, intro:langs { en {`Constructors are ordinary methods which are called during the instantiation of their corresponding object. As such, they may define an arbitrary number of arguments, which may be required, may have a type, and may have a default value. `}, el {`?? ????????????? ????? ???????????? ??????? ??? ????????? ???? ??? ????????????? ??? ??????????? ???????????? ????. ?? ???????, ??????? ?? ?????????? ???? ????????? ?????? ?????????, ??? ?????? ?? ????? ???????????, ?????? ?? ????? ????, ??? ?????? ?? ????? ????????????? ????. `} }, summary:langs { en {`Constructor.`}, el {`?????????????.`} }, desc:langs { en {`Initialize the class. It must be called by the offspring if the classes are initialized.`}, el {`??????????? ??? ?????. ?????? ?? ???????? ??? ?? ?????????? ?? ?? ??????? ???????????????.`} }, params:active(`table:{name,type,default}`) { param:id(`properties`),name(`$properties`),type(`array`),default(`[]`),langs { en {`Initializes the class with optional properties.`}, el {`??????????? ??? ????? ?? ???????????? ?????????.`} } }, return:langs { en {`It doesn't return anything.`}, el {`??? ?????????? ??????.`} }, throws:langs { en {`It does not implement any exceptions.`}, el {`??? ???????? ????? ????????.`} } } } */ public function __construct(array $properties = []) { parent::__construct($properties); } /* dobu { method:classid(`tmyclass`),id(`getinstance`),name(`getInstance`),syntax(`&getInstance(array $properties = [])`),return(`TMyClass`),version(`1.0.0`) { category:langs { en {`Instance`}, el {`?????????????`} }, intro:langs { en {`Multilines Introduction Text`}, el {`??????? ????????? ????????? ???????`} }, summary:langs { en {`Instance.`}, el {`?????????????.`} }, desc:langs { en {`We see if the object is already loaded, otherwise we create a new load of the object.`}, el {`???????? ??? ??????? ??? ????????? ?? ??????????? ?????? ???????????? ??? ??? ??????? ??? ????????????`} }, params:active(`table:{name,type,default,langs}`) { param:id(`properties`),name(`$properties`),type(`array`),default(`[]`),langs { en {`An associative array of properties to initialize the class with.`}, el {`???? ????????????? ??????? ????????? ??? ??? ???????????? ??? ??????`} } }, return:type(`object`),value(`TMyClass`),langs { en {`Reference to the new instance.`}, el {`??????? ???? ??? ?????????.`} }, throws:langs { en {`It does not implement any exceptions.`}, el {`??? ???????? ????? ????????.`} } } } */ public static function &getInstance(array $properties = []): TMyClass { static $instance; if (!is_object($instance)) $instance = new TMyClass($properties); return $instance; } /* dobu { method:classid(`tmyclass`),id(`blackscholesputdividend`),name(`blackScholesPutDividend`),syntax(`blackScholesPutDividend(float $spot, float $strike, float $riskFreeRate, float $dividendYield, float $volatility, float $timeToMaturity)`),return(`float`),version(`1.0.0`),sincePHP(`8.3.0`) { category:langs { en {`Derivatives - Black?Scholes with Dividends`}, el {`???????? - Black?Scholes ?? ?????????`} }, intro:langs { en {`Multilines Introduction Text`}, el {`??????? ????????? ????????? ???????`} }, summary:langs { en {`Prices a European put option with continuous dividend yield q.`}, el {`??????? ??? ????????? put option ?? ?????? ??????????? ??????? q.`} }, desc:langs { en {`Extends the Black?Scholes put formula to include a continuous dividend yield on the underlying, using the (r ? q) drift and discounted underlying S? e^{-qT}.`}, el {`?????????? ??? ???? Black?Scholes ??? put ???? ?? ???????????? ?????? ??????????? ??????? ??? ??????????, ?? drift (r ? q) ??? ????????????? S? e^{-qT}.`} }, params:active(`table:{name,type}`) { param:id(`spot`),name(`$spot`),type(`float`),langs { en {`Current underlying price S?.`}, el {`???????? ???? ??????????? S?.`} }, param:id(`strike`),name(`$strike`),type(`float`),langs { en {`Strike price K.`}, el {`???? ????????? K.`} }, param:id(`riskFreeRate`),name(`$riskFreeRate`),type(`float`),langs { en {`Risk?free rate r.`}, el {`???????? ????? ??????? r.`} }, param:id(`dividendYield`),name(`$dividendYield`),type(`float`),langs { en {`Continuous dividend yield q.`}, el {`??????? ??????????? ??????? q.`} }, param:id(`volatility`),name(`$volatility`),type(`float`),langs { en {`Volatility ?.`}, el {`????????????? ?.`} }, param:id(`timeToMaturity`),name(`$timeToMaturity`),type(`float`),langs { en {`Time to maturity T (in years).`}, el {`?????? ????? ?? ???? T (?? ???).`} } }, formula:type(`latex`),value(`\[ P = K e^{-rT} N(-d_2) - S_0 e^{-qT} N(-d_1) \]`),analysis(` d? = [ln(S?/K) + (r ? q + ?²/2) T] / (? ?T) d? = d? ? ? ?T `),langs { en {`Uses the same d?, d? as the dividend?adjusted call, but applies the put payoff structure with discounted underlying and strike. Inputs: S?, K, r, q, ?, T. Output: put price with dividends.`}, el {`???????????? ?? ???? d?, d? ???? ??? call ?? ?????????, ???? ????????? ?? ???? payoff ??? put ?? ????????????? ?????????? ??? strike. ???????: S?, K, r, q, ?, T. ??????: ???? put ?? ?????????.`} }, example:type(`pre,code`),langs { all {`$putDiv = $math->blackScholesPutDividend(100, 100, 0.05, 0.02, 0.20, 1.0);`} }, input-convention:langs { en {`All interest rates (r, q), volatility (?), and dividend yield are given in **decimal form** (not percentage). Example: 5% ? 0.05`}, el {`??? ?? ???????? (r, q), ? ????????????? (?) ??? ? ??????????? ??????? ???????? ?? **???????? ?????** (??? ??????????). ??????????: 5% ? 0.05`} }, numerical-behavior:langs { en {` - When T ? 0 ? returns max(K - S?, 0) (intrinsic value) - When ? ? 0 ? returns discounted intrinsic value - When ? > 10 (1000%) ? uses asymptotic approximation to avoid overflow `}, el {` - ???? T ? 0 ? ?????????? max(K - S?, 0) (????????? ????) - ???? ? ? 0 ? ?????????? ??? ????????????? ???????? ???? - ???? ? > 10 (1000%) ? ???????????? ????????? ?????????? ??? ?? ?????????? ??????????? `} }, precision:langs { en {`Expected accuracy: ~1e-10 under typical market conditions. Uses the normal distribution CDF with double-precision accuracy (~15 decimal places)`}, el {`??????????? ????????: ~1e-10 ?? ??????? ???????? ??????. ???????????? cdf ???????????? ????????? ?? ???????? ?????? ????????? (~15 ???????? ?????)`} }, references:type(`ul`),langs { all {` - John C. Hull - "Options, Futures, and Other Derivatives" (10th ed.), Chapter 17, pp. 380?382 - Espen Gaarder Haug - "The Complete Guide to Option Pricing Formulas", Chapter 1 - Wilmott on Quantitative Finance, Vol 2, Section 8.3 `} }, see:langs { en {` - blackScholesCallDividend() - corresponding call for call - blackScholesPut() - without dividends - binomialPutEuropean() - alternative numerical method `}, el {` - blackScholesCallDividend() - ?????????? ????? ??? call - blackScholesPut() - ????? ????????? - binomialPutEuropean() - ??????????? ?????????? ??????? `} }, verification-cases:langs { en {` - Hull p.381, Example 17.1 ? expected value ? 6.58 - Haug Table 1.2, case 3 ? expected ? 4.2833 `}, el {` - Hull p.381, Example 17.1 ? ??????????? ???? ? 6.58 - Haug Table 1.2, case 3 ? ??????????? ? 4.2833 `} }, performance:langs { all {`~120?180 ns per call (AMD Ryzen 9 5950X, PHP 8.2 JIT)`} }, return:type(`float`),langs { en {`Put option price with dividends.`}, el {`???? put option ?? ?????????.`} }, throws:type(`InvalidArgumentException`),langs { en {`If volatility or time are non?positive.`}, el {`?? ? ????????????? ? ? ?????? ????? ?? ???????.`} } } } */ public function blackScholesPutDividend(float $spot, float $strike, float $riskFreeRate, float $dividendYield, float $volatility, float $timeToMaturity): float { return 0.0;} } /****************************************************************************** * @endcode TMyClass *****************************************************************************/ ?>