Skip to content

Commit

Permalink
Raise deprecation warning for Context::detect (#1334)
Browse files Browse the repository at this point in the history
* Raise deprecation warning for `Context::detect`

* .
  • Loading branch information
DerManoMann authored Oct 28, 2022
1 parent a69d91d commit b676979
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"ext-json": "*",
"doctrine/annotations": "^1.7",
"psr/log": "^1.1 || ^2.0 || ^3.0",
"symfony/deprecation-contracts": "^2 || ^3",
"symfony/finder": ">=2.2",
"symfony/yaml": ">=3.3"
},
Expand Down
7 changes: 7 additions & 0 deletions src/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ class Context
*/
private $parent;

public function clone()
{
return new Context(get_object_vars($this), $this->parent);
}

public function __construct(array $properties = [], ?Context $parent = null)
{
foreach ($properties as $property => $value) {
Expand Down Expand Up @@ -189,6 +194,8 @@ public function __debugInfo()
*/
public static function detect(int $index = 0): Context
{
trigger_deprecation('zircote/swagger-php', '4.0', 'Context detecting is deprecated');

$context = new Context();
$backtrace = debug_backtrace();
$position = $backtrace[$index];
Expand Down

0 comments on commit b676979

Please sign in to comment.