Skip to content

Commit

Permalink
Use fully qualified namespaces in imports.
Browse files Browse the repository at this point in the history
  • Loading branch information
Phally committed May 28, 2020
1 parent 44029cb commit 9d86829
Show file tree
Hide file tree
Showing 28 changed files with 318 additions and 252 deletions.
2 changes: 1 addition & 1 deletion .stickler.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
linters:
phpcs:
standard: CakePHP
standard: CakePHP3
extensions: 'php,ctp'
fixer: true

Expand Down
7 changes: 4 additions & 3 deletions src/Action/BaseAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Cake\Utility\Text;
use Crud\Core\BaseObject;
use Crud\Event\Subject;
use Exception;

/**
* Base Crud class
Expand Down Expand Up @@ -129,7 +130,7 @@ public function disable()
public function message($type, array $replacements = [])
{
if (empty($type)) {
throw new \Exception('Missing message type');
throw new Exception('Missing message type');
}

$crud = $this->_crud();
Expand All @@ -138,7 +139,7 @@ public function message($type, array $replacements = [])
if (empty($config)) {
$config = $crud->getConfig('messages.' . $type);
if (empty($config)) {
throw new \Exception(sprintf('Invalid message type "%s"', $type));
throw new Exception(sprintf('Invalid message type "%s"', $type));
}
}

Expand All @@ -155,7 +156,7 @@ public function message($type, array $replacements = [])
], $config);

if (!isset($config['text'])) {
throw new \Exception(sprintf('Invalid message config for "%s" no text key found', $type));
throw new Exception(sprintf('Invalid message config for "%s" no text key found', $type));
}

$config['params']['original'] = ucfirst(str_replace('{name}', $config['name'], $config['text']));
Expand Down
3 changes: 2 additions & 1 deletion src/Controller/ControllerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
namespace Crud\Controller;

use Cake\Controller\Exception\MissingActionException;
use LogicException;

/**
* Enable Crud to catch MissingActionException and attempt to generate response
Expand Down Expand Up @@ -47,7 +48,7 @@ public function invokeAction()
{
$request = $this->request;
if (!isset($request)) {
throw new \LogicException('No Request object configured. Cannot invoke action');
throw new LogicException('No Request object configured. Cannot invoke action');
}
if (!$this->isAction($request->getParam('action'))) {
throw new MissingActionException([
Expand Down
4 changes: 3 additions & 1 deletion src/Error/Exception/CrudException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php
namespace Crud\Error\Exception;

class CrudException extends \Exception
use Exception;

class CrudException extends Exception
{
}
4 changes: 3 additions & 1 deletion src/Event/Subject.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php
namespace Crud\Event;

use Exception;

/**
* Crud subject
*
Expand Down Expand Up @@ -104,7 +106,7 @@ public function shouldProcess($mode, $actions = [])
return !in_array($this->action, $actions);

default:
throw new \Exception('Invalid mode');
throw new Exception('Invalid mode');
}
}
}
4 changes: 2 additions & 2 deletions src/Template/Bake/Controller/controller.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ use Cake\Utility\Inflector;
$defaultModel = $name;
%>
<?php
namespace <%= $namespace %>\Controller<%= $prefix %>;
namespace <%= $namespace %>Controller<%= $prefix %>;

use <%= $namespace %>\Controller\AppController;
use use const Controller\AppController;<%= $namespace %>AppController;

/**
* <%= $name %> Controller
Expand Down
4 changes: 3 additions & 1 deletion tests/App/Model/Entity/Blog.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?php
namespace Crud\Test\App\Model\Entity;

class Blog extends \Cake\ORM\Entity
use Cake\ORM\Entity;

class Blog extends Entity
{

}
4 changes: 3 additions & 1 deletion tests/App/Model/Entity/User.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?php
namespace Crud\Test\App\Model\Entity;

class User extends \Cake\ORM\Entity
use Cake\ORM\Entity;

class User extends Entity
{

}
3 changes: 2 additions & 1 deletion tests/App/Model/Table/BlogsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
namespace Crud\Test\App\Model\Table;

use Cake\ORM\Query;
use Cake\ORM\Table;

class BlogsTable extends \Cake\ORM\Table
class BlogsTable extends Table
{
public $customOptions;

Expand Down
3 changes: 2 additions & 1 deletion tests/App/Model/Table/CrudExamplesTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
namespace Crud\Test\App\Model\Table;

use Cake\ORM\Query;
use Cake\ORM\Table;

/**
* Crud Example Model
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
*/
class CrudExamplesTable extends \Cake\ORM\Table
class CrudExamplesTable extends Table
{

public $alias = 'CrudExamples';
Expand Down
4 changes: 3 additions & 1 deletion tests/App/Model/Table/UsersTable.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?php
namespace Crud\Test\App\Model\Table;

class UsersTable extends \Cake\ORM\Table
use Cake\ORM\Table;

class UsersTable extends Table
{

}
5 changes: 4 additions & 1 deletion tests/App/Template/Blogs/view.ctp
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?php

use Cake\Utility\Inflector;

foreach (${$viewVar}->toArray() as $k => $v) {
echo "<dt>" . \Cake\Utility\Inflector::humanize($k) . "</dt>";
echo "<dt>" . Inflector::humanize($k) . "</dt>";
echo "<dd>";
echo $v;
echo "</dd>";
Expand Down
21 changes: 11 additions & 10 deletions tests/TestCase/Action/AddActionTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
namespace Crud\Test\TestCase\Action;

use Cake\Controller\Component\FlashComponent;
use Cake\Core\Plugin;
use Cake\Routing\DispatcherFactory;
use Cake\Routing\Router;
Expand Down Expand Up @@ -102,7 +103,7 @@ public function testActionPost()
'Controller.initialize',
['priority' => 11],
function ($event) {
$this->_controller->Flash = $this->getMockBuilder(\Cake\Controller\Component\FlashComponent::class)
$this->_controller->Flash = $this->getMockBuilder(FlashComponent::class)
->setMethods(['set'])
->disableOriginalConstructor()
->getMock();
Expand Down Expand Up @@ -147,7 +148,7 @@ public function testActionPostWithAddRedirect()
'Controller.initialize',
['priority' => 11],
function ($event) {
$this->_controller->Flash = $this->getMockBuilder(\Cake\Controller\Component\FlashComponent::class)
$this->_controller->Flash = $this->getMockBuilder(FlashComponent::class)
->setMethods(['set'])
->disableOriginalConstructor()
->getMock();
Expand Down Expand Up @@ -192,7 +193,7 @@ public function testActionPostWithEditRedirect()
'Controller.initialize',
['priority' => 11],
function ($event) {
$this->_controller->Flash = $this->getMockBuilder(\Cake\Controller\Component\FlashComponent::class)
$this->_controller->Flash = $this->getMockBuilder(FlashComponent::class)
->setMethods(['set'])
->disableOriginalConstructor()
->getMock();
Expand Down Expand Up @@ -236,7 +237,7 @@ public function testActionPostErrorSave()
'Controller.initialize',
['priority' => 11],
function ($event) {
$this->_controller->Flash = $this->getMockBuilder(\Cake\Controller\Component\FlashComponent::class)
$this->_controller->Flash = $this->getMockBuilder(FlashComponent::class)
->setMethods(['set'])
->disableOriginalConstructor()
->getMock();
Expand Down Expand Up @@ -289,7 +290,7 @@ public function testActionPostValidationErrors()
'Controller.initialize',
['priority' => 11],
function ($event) {
$this->_controller->Flash = $this->getMockBuilder(\Cake\Controller\Component\FlashComponent::class)
$this->_controller->Flash = $this->getMockBuilder(FlashComponent::class)
->setMethods(['set'])
->disableOriginalConstructor()
->getMock();
Expand Down Expand Up @@ -397,7 +398,7 @@ public function testApiCreate($method)
'Controller.initialize',
['priority' => 11],
function ($event) {
$this->_controller->Flash = $this->getMockBuilder(\Cake\Controller\Component\FlashComponent::class)
$this->_controller->Flash = $this->getMockBuilder(FlashComponent::class)
->setMethods(['set'])
->disableOriginalConstructor()
->getMock();
Expand Down Expand Up @@ -444,7 +445,7 @@ function ($event) {
return;
}

$this->_controller->Flash = $this->getMockBuilder(\Cake\Controller\Component\FlashComponent::class)
$this->_controller->Flash = $this->getMockBuilder(FlashComponent::class)
->setMethods(['set'])
->disableOriginalConstructor()
->getMock();
Expand Down Expand Up @@ -496,7 +497,7 @@ function ($event) {
return;
}

$this->_controller->Flash = $this->getMockBuilder(\Cake\Controller\Component\FlashComponent::class)
$this->_controller->Flash = $this->getMockBuilder(FlashComponent::class)
->setMethods(['set'])
->disableOriginalConstructor()
->getMock();
Expand Down Expand Up @@ -542,7 +543,7 @@ public function testStopAddWithDefaultSubjectSuccess()
'Controller.initialize',
['priority' => 11],
function ($event) {
$this->_controller->Flash = $this->getMockBuilder(\Cake\Controller\Component\FlashComponent::class)
$this->_controller->Flash = $this->getMockBuilder(FlashComponent::class)
->setMethods(['set'])
->disableOriginalConstructor()
->getMock();
Expand Down Expand Up @@ -596,7 +597,7 @@ public function testStopAddWithManuallySetSubjectSuccess()
'Controller.initialize',
['priority' => 11],
function ($event) {
$this->_controller->Flash = $this->getMockBuilder(\Cake\Controller\Component\FlashComponent::class)
$this->_controller->Flash = $this->getMockBuilder(FlashComponent::class)
->setMethods(['set'])
->disableOriginalConstructor()
->getMock();
Expand Down
Loading

0 comments on commit 9d86829

Please sign in to comment.