Skip to content

Commit

Permalink
Add a deprecation warning helper.
Browse files Browse the repository at this point in the history
This will make adding framework deprecation warnings we plan to add in
3.6.x simpler as they will be easier to write.
  • Loading branch information
markstory committed Aug 22, 2017
1 parent 40c0afc commit 8840b11
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/Core/functions.php
Expand Up @@ -248,3 +248,16 @@ function env($key, $default = null)
}

}

if (!function_exists('deprecationWarning')) {
/**
* Helper method for outputting deprecation warnings
*
* @param string $message The message to output as a deprecation warning.
* @return void
*/
function deprecationWarning($message)
{
trigger_error($message, E_USER_DEPRECATED);
}
}
9 changes: 9 additions & 0 deletions tests/TestCase/Core/FunctionsTest.php
Expand Up @@ -42,4 +42,13 @@ public function testEnv()
$this->assertEquals('0', env('ZERO'));
$this->assertEquals('0', env('ZERO', '1'));
}

/**
* @expectedException PHPUnit\Framework\Error\Deprecated
* @expectedExceptionMessage This is going away
*/
public function testDeprecationWarning()
{
deprecationWarning('This is going away');
}
}

0 comments on commit 8840b11

Please sign in to comment.