Skip to content

Commit

Permalink
Move deprecations into constructors.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Nov 4, 2017
1 parent 39ab9cc commit 3ddeac9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
12 changes: 10 additions & 2 deletions src/View/Helper/RssHelper.php
Expand Up @@ -14,10 +14,9 @@
*/
namespace Cake\View\Helper;

deprecationWarning('RssHelper is deprecated and will be removed in 4.0.0');

use Cake\Utility\Xml;
use Cake\View\Helper;
use Cake\View\View;

/**
* RSS Helper class for easy output RSS structures.
Expand Down Expand Up @@ -93,6 +92,15 @@ class RssHelper extends Helper
*/
public $version = '2.0';

/**
* {@inheritDoc}
*/
public function __construct(View $view, array $settings = [])
{
deprecationWarning('RssHelper is deprecated and will be removed in 4.0.0');
parent::__construct($view, $settings);
}

/**
* Returns an RSS document wrapped in `<rss />` tags
*
Expand Down
11 changes: 5 additions & 6 deletions src/View/Helper/SessionHelper.php
Expand Up @@ -14,11 +14,6 @@
*/
namespace Cake\View\Helper;

deprecationWarning(
'SessionHelper is deprecated and will be removed in 4.0.0. ' .
'Use request->session() instead.'
);

use Cake\View\Helper;
use Cake\View\View;

Expand All @@ -41,7 +36,11 @@ class SessionHelper extends Helper
*/
public function __construct(View $View, array $config = [])
{
trigger_error('SessionHelper has been deprecated. Use request->session() instead.', E_USER_DEPRECATED);
deprecationWarning(
'SessionHelper is deprecated and will be removed in 4.0.0. ' .
'Use request->session() instead.'
);

parent::__construct($View, $config);
}

Expand Down
7 changes: 4 additions & 3 deletions tests/TestCase/View/Helper/RssHelperTest.php
Expand Up @@ -24,6 +24,8 @@

/**
* RssHelperTest class
*
* @group deprecated
*/
class RssHelperTest extends TestCase
{
Expand All @@ -42,13 +44,12 @@ public function setUp()
{
parent::setUp();

$errorLevel = error_reporting();
error_reporting(E_ALL ^ E_USER_DEPRECATED);
$oldLevel = error_reporting(E_ALL ^ E_USER_DEPRECATED);

$this->View = new View();
$this->Rss = new RssHelper($this->View);

error_reporting($errorLevel);
error_reporting($oldLevel);
}

/**
Expand Down

0 comments on commit 3ddeac9

Please sign in to comment.