{"id":15022095,"url":"https://github.com/php/pecl-php-operator","last_synced_at":"2025-10-04T19:18:40.302Z","repository":{"id":7217750,"uuid":"8524642","full_name":"php/pecl-php-operator","owner":"php","description":"Operator overloading for Objects","archived":false,"fork":false,"pushed_at":"2020-10-01T13:13:17.000Z","size":32,"stargazers_count":126,"open_issues_count":1,"forks_count":16,"subscribers_count":19,"default_branch":"master","last_synced_at":"2025-01-29T21:22:06.473Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://pecl.php.net/package/operator","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/php.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-03-02T18:03:58.000Z","updated_at":"2025-01-08T17:57:50.000Z","dependencies_parsed_at":"2022-09-04T22:52:27.959Z","dependency_job_id":null,"html_url":"https://github.com/php/pecl-php-operator","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php%2Fpecl-php-operator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php%2Fpecl-php-operator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php%2Fpecl-php-operator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php%2Fpecl-php-operator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/php","download_url":"https://codeload.github.com/php/pecl-php-operator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237224787,"owners_count":19275086,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-09-24T19:57:27.095Z","updated_at":"2025-10-04T19:18:35.235Z","avatar_url":"https://github.com/php.png","language":"C","readme":"# Operator overloading extension for PHP7\n\n## Usage\n\nImplement magic methods in a class to provide operator overloading automatically, for example:\n\n```php\nclass C {\n  private $value = 0;\n  public function __add($delta) {\n    $this-\u003evalue += $delta;\n    return $this;\n  }\n\n  public function __toString() {\n    return strval($this-\u003evalue);\n  }\n}\n\n$c = new C;\nvar_dump($c + 5); // object(C)#1 { [\"C:value:private\"]=\u003e5 }\n```\n\nThe following overload methods are supported:\n\n| Operator | Method |\n|:---:| --- |\n| $o + $arg | `__add($arg)` |\n| $o - $arg | `__sub($arg)` |\n| $o * $arg | `__mul($arg)` |\n| $o / $arg | `__div($arg)` |\n| $o % $arg | `__mod($arg)` |\n| $o ** $arg | `__pow($arg)` |\n| $o \u003c\u003c $arg | `__sl($arg)` |\n| $o \u003e\u003e $arg | `__sr($arg)` |\n| $o . $arg | `__concat($arg)` |\n| $o \u0026#x7c; $arg | `__bw_or($arg)` |\n| $o \u0026 $arg | `__bw_and($arg)` |\n| $o ^ $arg | `__bw_xor($arg)` |\n| ~$o | `__bw_not()` |\n| $o === $arg | `__is_identical($arg)` |\n| $o !== $arg | `__is_not_identical($arg)` |\n| $o == $arg | `__is_equal($arg)` |\n| $o != $arg | `__is_not_equal($arg)` |\n| $o \u003c $arg | `__is_smaller($arg)` |\n| $o \u003c= $arg | `__is_smaller_or_equal($arg)` |\n| $o \u003e $arg | `__is_greater($arg)` \u0026#42; |\n| $o \u003e= $arg | `__is_greater_or_equal($arg)` \u0026#42; |\n| $o \u003c=\u003e $arg | `__cmp($arg)` |\n| ++$o | `__pre_inc()` |\n| $o++  | `__post_inc()` |\n| --$o | `__pre_dec()` |\n| $o-- | `__post_dec()` |\n| $o = $arg | `__assign($arg)` |\n| $o += $arg | `__assign_add($arg)` |\n| $o -= $arg | `__assign_sub($arg)` |\n| $o *= $arg | `__assign_mul($arg)` |\n| $o /= $arg | `__assign_div($arg)` |\n| $o %= $arg | `__assign_mod($arg)` |\n| $o **= $arg | `__assign_pow($arg)` |\n| $o \u003c\u003c= $arg | `__assign_sl($arg)` |\n| $o \u003e\u003e= $arg | `__assign_sr($arg)` |\n| $o .= $arg | `__assign_concat($arg)` |\n| $o \u0026#x7c;= $arg | `__assign_bw_or($arg)` |\n| $o \u0026= $arg | `__assign_bw_and($arg)` |\n| $o ^= $arg | `__assign_bw_xor($arg)` |\n\n\u0026#42; - `__is_greater()` and `__is_greater_or_equal()` require a rebuild of the main PHP runtime using the [included patch](php7-is_greater.diff). Withtout this patch, `$a \u003e $b` is automatically remapped to `$b \u003c $a` by the engine.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp%2Fpecl-php-operator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphp%2Fpecl-php-operator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp%2Fpecl-php-operator/lists"}