Permalink
Browse files

replaced string class references with class literals

  • Loading branch information...
mareckii committed Mar 29, 2017
1 parent 18359b8 commit 6e8b7469c302216a7e9b4621b477bf5c3d41b3ac
Showing with 266 additions and 213 deletions.
  1. +7 −3 config/test/config.php
  2. +1 −1 src/Ouzo/Core/Bootstrap.php
  3. +5 −2 src/Ouzo/Core/Db/Dialect/Dialect.php
  4. +4 −3 src/Ouzo/Core/Db/Dialect/DialectUtil.php
  5. +1 −1 src/Ouzo/Core/Db/WhereClause/ArrayWhereClause.php
  6. +2 −1 src/Ouzo/Core/Http/AcceptHeaderParser.php
  7. 0 src/Ouzo/Core/Logger/AbstractLogger.php
  8. +14 −7 src/Ouzo/Core/Tests/ControllerTestCase.php
  9. +1 −1 src/Ouzo/Goodies/Tests/StreamStub.php
  10. +2 −1 src/Ouzo/Goodies/Utilities/FluentFunction.php
  11. +1 −1 src/Ouzo/Goodies/Utilities/Inflector.php
  12. +4 −3 src/Ouzo/Goodies/Utilities/Path.php
  13. +1 −1 src/Ouzo/Inject/Injection/Annotation/DocCommentExtractor.php
  14. +3 −2 src/Ouzo/Inject/Injection/Bindings.php
  15. +1 −0 src/Ouzo/Inject/Injection/Injector.php
  16. +1 −1 src/Ouzo/Inject/Injection/InjectorConfig.php
  17. +3 −2 test/src/Ouzo/Core/AuthBasicControllerTest.php
  18. +2 −1 test/src/Ouzo/Core/BeforeFilterTest.php
  19. +7 −5 test/src/Ouzo/Core/ControllerFactoryTest.php
  20. +4 −2 test/src/Ouzo/Core/ControllerTest.php
  21. +6 −5 test/src/Ouzo/Core/Csrf/CsrfProtectorTest.php
  22. +1 −1 test/src/Ouzo/Core/Db/Dialect/MySqlDialectTest.php
  23. +2 −1 test/src/Ouzo/Core/Db/EmulatedPDOPreparedStatementExecutorTest.php
  24. +4 −3 test/src/Ouzo/Core/Db/ModelQueryBuilderTest.php
  25. +2 −1 test/src/Ouzo/Core/Db/PDOPreparedStatementExecutorTest.php
  26. +2 −1 test/src/Ouzo/Core/Db/StatementEmulatorTest.php
  27. +16 −12 test/src/Ouzo/Core/Db/StatementExecutorTest.php
  28. +24 −23 test/src/Ouzo/Core/Db/WhereClause/WhereClauseTest.php
  29. +2 −1 test/src/Ouzo/Core/ExceptionHandling/ErrorHandlerTest.php
  30. +2 −1 test/src/Ouzo/Core/FrontControllerDisplayOutputTest.php
  31. +1 −1 test/src/Ouzo/Core/Helper/FormHelperTest.php
  32. +5 −4 test/src/Ouzo/Core/ModelTest.php
  33. +6 −3 test/src/Ouzo/Core/Restriction/RegexpRestrictionTest.php
  34. +7 −5 test/src/Ouzo/Core/Routing/RouterTest.php
  35. +4 −4 test/src/Ouzo/Core/Tools/Model/Template/ClassStubPlaceholderReplacerTest.php
  36. +3 −2 test/src/Ouzo/Core/Tools/Model/Template/GeneratorTest.php
  37. +2 −2 test/src/Ouzo/Core/Tools/Model/Template/TableInfoTest.php
  38. +5 −3 test/src/Ouzo/Core/UriTest.php
  39. +2 −1 test/src/Ouzo/Core/View/ViewRendererFactoryTest.php
  40. +3 −3 test/src/Ouzo/Goodies/Tests/BooleanAssertTest.php
  41. +14 −14 test/src/Ouzo/Goodies/Tests/GeneralAssertTest.php
  42. +14 −13 test/src/Ouzo/Goodies/Utilities/DynamicProxyTest.php
  43. +3 −2 test/src/Ouzo/Goodies/Utilities/FilesTest.php
  44. +2 −1 test/src/Ouzo/Goodies/Utilities/Iterator/FluentIteratorTest.php
  45. +10 −9 test/src/Ouzo/Goodies/Utilities/JsonTest.php
  46. +6 −6 test/src/Ouzo/Goodies/Utilities/OptionalTest.php
  47. +4 −3 test/src/Ouzo/Goodies/Utilities/Valiadator/ValidateTest.php
  48. +50 −50 test/src/Ouzo/Inject/Injection/InjectorTest.php
View
@@ -1,18 +1,22 @@
<?php
use Ouzo\Db\Dialect\MySqlDialect;
use Ouzo\Db\Dialect\PostgresDialect;
use Ouzo\Db\Dialect\Sqlite3Dialect;
$db = getenv('db');
if ($db == 'mysql') {
$config['sql_dialect'] = '\\Ouzo\\Db\\Dialect\\MySqlDialect';
$config['sql_dialect'] = MySqlDialect::class;
$config['db']['user'] = 'travis';
$config['db']['pass'] = '';
$config['db']['driver'] = 'mysql';
$config['db']['host'] = '127.0.0.1';
$config['db']['port'] = '3306';
} else if ($db == 'sqlite3') {
$config['sql_dialect'] = '\\Ouzo\\Db\\Dialect\\Sqlite3Dialect';
$config['sql_dialect'] = Sqlite3Dialect::class;
$config['db']['driver'] = 'sqlite';
$config['db']['dsn'] = 'sqlite:ouzo_test';
} else {
$config['sql_dialect'] = '\\Ouzo\\Db\\Dialect\\PostgresDialect';
$config['sql_dialect'] = PostgresDialect::class;
$config['db']['user'] = 'postgres';
$config['db']['pass'] = '';
$config['db']['driver'] = 'pgsql';
@@ -107,6 +107,6 @@ private function includeRoutes()
private function createFrontController()
{
$injector = $this->injector ?: new Injector($this->injectorConfig);
return $injector->getInstance('\Ouzo\FrontController');
return $injector->getInstance(FrontController::class);
}
}
@@ -3,12 +3,15 @@
* Copyright (c) Ouzo contributors, http://ouzoframework.org
* This file is made available under the MIT License (view the LICENSE file for more information).
*/
namespace Ouzo\Db\Dialect;
use Ouzo\Db\JoinClause;
use Ouzo\Db\Query;
use Ouzo\Db\QueryType;
use Ouzo\Db\WhereClause\WhereClause;
use Ouzo\DbConnectionException;
use Ouzo\DbException;
use Ouzo\Utilities\Arrays;
use Ouzo\Utilities\Joiner;
@@ -247,9 +250,9 @@ public function buildQuery(Query $query)
public function getExceptionForError($errorInfo)
{
if ($this->isConnectionError($errorInfo)) {
return '\Ouzo\DbConnectionException';
return DbConnectionException::class;
}
return '\Ouzo\DbException';
return DbException::class;
}
/**
@@ -3,6 +3,7 @@
* Copyright (c) Ouzo contributors, http://ouzoframework.org
* This file is made available under the MIT License (view the LICENSE file for more information).
*/
namespace Ouzo\Db\Dialect;
use Ouzo\Db\JoinClause;
@@ -31,7 +32,7 @@ public static function buildWhereQuery($whereClauses)
{
$parts = FluentArray::from($whereClauses)
->filter(WhereClause::isNotEmptyFunction())
->map('\Ouzo\Db\Dialect\DialectUtil::buildWhereQueryPart')
->map([DialectUtil::class, 'buildWhereQueryPart'])
->toArray();
return implode(' AND ', Arrays::filterNotBlank($parts));
}
@@ -52,7 +53,7 @@ public static function buildWhereQueryPart(WhereClause $whereClause)
public static function buildJoinQuery($joinClauses)
{
$elements = FluentArray::from($joinClauses)
->map('\Ouzo\Db\Dialect\DialectUtil::buildJoinQueryPart')
->map([DialectUtil::class, 'buildJoinQueryPart'])
->toArray();
return implode(" ", $elements);
}
@@ -94,7 +95,7 @@ public static function buildAttributesPartForUpdate($updateAttributes)
public static function buildUsingQuery($usingClauses, $glue, $table, $alias)
{
$elements = FluentArray::from($usingClauses)
->map('\Ouzo\Db\Dialect\DialectUtil::buildUsingQueryPart')
->map([DialectUtil::class, 'buildUsingQueryPart'])
->toArray();
if ($usingClauses && $table) {
$tableElement = $table . ($alias ? " AS {$alias}" : "");
@@ -79,7 +79,7 @@ private static function _buildWhereKey($column, $value)
private static function _buildWhereKeyIn($column, array $array)
{
$useRestrictions = Arrays::any($array, Functions::isInstanceOf('\Ouzo\Restriction\Restriction'));
$useRestrictions = Arrays::any($array, Functions::isInstanceOf(Restriction::class));
if ($useRestrictions) {
return DialectUtil::joinClauses($array, 'OR', function (Restriction $restriction) use ($column) {
@@ -3,6 +3,7 @@
* Copyright (c) Ouzo contributors, http://ouzoframework.org
* This file is made available under the MIT License (view the LICENSE file for more information).
*/
namespace Ouzo\Http;
use Ouzo\Utilities\Arrays;
@@ -23,7 +24,7 @@ public static function parse($data)
$q = Arrays::getValue(self::extractParams($params), 'q');
$array[] = ['type' => $type, 'subtype' => $subtype, 'q' => $q];
}
usort($array, '\Ouzo\Http\AcceptHeaderParser::_compare');
usort($array, [AcceptHeaderParser::class, '_compare']);
return Arrays::toMap($array, function ($input) {
return $input['type'] . '/' . $input['subtype'];
}, function ($input) {
No changes.
@@ -3,12 +3,19 @@
* Copyright (c) Ouzo contributors, http://ouzoframework.org
* This file is made available under the MIT License (view the LICENSE file for more information).
*/
namespace Ouzo\Tests;
use Ouzo\Config;
use Ouzo\CookiesSetter;
use Ouzo\DownloadHandler;
use Ouzo\FrontController;
use Ouzo\HeaderSender;
use Ouzo\Injection\Injector;
use Ouzo\Injection\InjectorConfig;
use Ouzo\OutputDisplayer;
use Ouzo\RedirectHandler;
use Ouzo\SessionInitializer;
use Ouzo\Utilities\Arrays;
use Ouzo\Utilities\Json;
use Ouzo\Utilities\Strings;
@@ -31,7 +38,7 @@ public function __construct($name = null, array $data = [], $dataName = '')
$this->injectorConfig = new InjectorConfig();
$this->frontControllerBindings($this->injectorConfig);
$injector = new Injector($this->injectorConfig);
$this->frontController = $injector->getInstance('\Ouzo\FrontController');
$this->frontController = $injector->getInstance(FrontController::class);
}
private static function _prefixSystem()
@@ -196,12 +203,12 @@ public function getActualContent()
protected function frontControllerBindings(InjectorConfig $config)
{
$config->bind('\Ouzo\OutputDisplayer')->toInstance(new MockOutputDisplayer());
$config->bind('\Ouzo\HeaderSender')->toInstance(new MockHeaderSender());
$config->bind('\Ouzo\CookiesSetter')->toInstance(new MockCookiesSetter());
$config->bind('\Ouzo\RedirectHandler')->toInstance(new MockRedirectHandler());
$config->bind('\Ouzo\SessionInitializer')->toInstance(new MockSessionInitializer());
$config->bind('\Ouzo\DownloadHandler')->toInstance(new MockDownloadHandler());
$config->bind(OutputDisplayer::class)->toInstance(new MockOutputDisplayer());
$config->bind(HeaderSender::class)->toInstance(new MockHeaderSender());
$config->bind(CookiesSetter::class)->toInstance(new MockCookiesSetter());
$config->bind(RedirectHandler::class)->toInstance(new MockRedirectHandler());
$config->bind(SessionInitializer::class)->toInstance(new MockSessionInitializer());
$config->bind(DownloadHandler::class)->toInstance(new MockDownloadHandler());
}
protected function requestContext()
@@ -54,7 +54,7 @@ public function stream_close()
public static function register($streamName)
{
self::$streamName = $streamName;
stream_wrapper_register($streamName, '\Ouzo\Tests\StreamStub');
stream_wrapper_register($streamName, StreamStub::class);
}
public static function unregister()
@@ -3,6 +3,7 @@
* Copyright (c) Ouzo contributors, http://ouzoframework.org
* This file is made available under the MIT License (view the LICENSE file for more information).
*/
namespace Ouzo\Utilities;
/**
@@ -45,7 +46,7 @@ class FluentFunction
public function __call($name, $arguments)
{
$this->_functions[] = call_user_func_array('Ouzo\Utilities\Functions::' . $name, $arguments);
$this->_functions[] = call_user_func_array([Functions::class, $name], $arguments);
return $this;
}
@@ -181,7 +181,7 @@ class Inflector
public static function reset()
{
if (empty(self::$initialState)) {
self::$initialState = get_class_vars('Ouzo\Utilities\Inflector');
self::$initialState = get_class_vars(Inflector::class);
return;
}
foreach (self::$initialState as $key => $val) {
@@ -3,6 +3,7 @@
* Copyright (c) Ouzo contributors, http://ouzoframework.org
* This file is made available under the MIT License (view the LICENSE file for more information).
*/
namespace Ouzo\Utilities;
/**
@@ -50,8 +51,8 @@ public static function join()
*/
public static function joinWithTemp()
{
$args = array_merge([sys_get_temp_dir()], func_get_args());
return call_user_func_array('\Ouzo\Utilities\Path::join', $args);
$args = array_merge(array(sys_get_temp_dir()), func_get_args());
return call_user_func_array([Path::class, 'join'], $args);
}
/**
@@ -85,7 +86,7 @@ public static function joinWithTemp()
public static function normalize($path)
{
$parts = explode('/', trim($path, '/'));
$result = [];
$result = array();
foreach ($parts as $part) {
if ($part == '..' && !empty($result)) {
array_pop($result);
@@ -21,7 +21,7 @@ public function getMetadata($instance)
$doc = $property->getDocComment();
if (Strings::contains($doc, '@Inject')) {
if (preg_match("#@var ([\\\\A-Za-z0-9]*)#s", $doc, $matched)) {
$className = $matched[1];
$className = Strings::removePrefix($matched[1], "\\");
$name = $this->extractName($doc);
$annotations[$property->getName()] = ['name' => $name, 'className' => $className];
} else {
@@ -3,6 +3,7 @@
* Copyright (c) Ouzo contributors, http://ouzoframework.org
* This file is made available under the MIT License (view the LICENSE file for more information).
*/
namespace Ouzo\Injection;
class Bindings
@@ -13,7 +14,7 @@ class Bindings
public function __construct(InjectorConfig $config, $injector)
{
$this->config = $config;
$binder = new Binder('\Ouzo\Injection\Injector');
$binder = new Binder(Injector::class);
$this->injectorBinder = $binder->toInstance($injector);
}
@@ -24,7 +25,7 @@ public function __construct(InjectorConfig $config, $injector)
*/
public function getBinder($className, $name)
{
if ($className == '\Ouzo\Injection\Injector') {
if ($className == Injector::class) {
return $this->injectorBinder;
}
return $this->config->getBinder($className, $name);
@@ -7,6 +7,7 @@
use Ouzo\Injection\Annotation\AnnotationMetadataProvider;
use Ouzo\Injection\Annotation\DocCommentExtractor;
use Ouzo\Utilities\Strings;
class Injector
{
@@ -14,7 +14,7 @@ class InjectorConfig
public function bind($className, $name = '')
{
$className = Strings::prependIfMissing($className, '\\');
// $className = Strings::prependIfMissing($className, '\\');
$binder = new Binder($className, $name);
$this->binders[$className . '_' . $name] = $binder;
return $binder;
@@ -5,6 +5,7 @@
*/
use Ouzo\Config;
use Ouzo\Controller;
use Ouzo\Exception\UnauthorizedException;
use Ouzo\Extension\AuthBasicExtension;
use Ouzo\Routing\Route;
use Ouzo\Tests\CatchException;
@@ -58,7 +59,7 @@ public function shouldNotCallActionWhenNoCredentials()
CatchException::when($this)->get('/auth_sample/index');
//then
CatchException::assertThat()->isInstanceOf('\Ouzo\Exception\UnauthorizedException');
CatchException::assertThat()->isInstanceOf(UnauthorizedException::class);
}
/**
@@ -74,7 +75,7 @@ public function shouldNotCallActionWhenInvalidCredentials()
CatchException::when($this)->get('/auth_sample/index');
//then
CatchException::assertThat()->isInstanceOf('\Ouzo\Exception\UnauthorizedException');
CatchException::assertThat()->isInstanceOf(UnauthorizedException::class);
}
/**
@@ -4,6 +4,7 @@
* This file is made available under the MIT License (view the LICENSE file for more information).
*/
use Ouzo\Controller;
use Ouzo\ControllerFactory;
use Ouzo\Injection\InjectorConfig;
use Ouzo\Routing\Route;
use Ouzo\Tests\ControllerTestCase;
@@ -59,7 +60,7 @@ public function setUp()
protected function frontControllerBindings(InjectorConfig $config)
{
parent::frontControllerBindings($config);
$config->bind('\Ouzo\ControllerFactory')->toInstance(new MockControllerFactory());
$config->bind(ControllerFactory::class)->toInstance(new MockControllerFactory());
}
/**
@@ -3,6 +3,7 @@
* Copyright (c) Ouzo contributors, http://ouzoframework.org
* This file is made available under the MIT License (view the LICENSE file for more information).
*/
namespace Ouzo\Api;
use Ouzo\Controller;
@@ -16,6 +17,7 @@ public function test_action()
namespace Ouzo;
use Ouzo\Api\MultipleNsController;
use Ouzo\Injection\Injector;
use Ouzo\Routing\RouteRule;
use Ouzo\Tests\CatchException;
@@ -49,7 +51,7 @@ public function shouldResolveAction()
{
//given
$routeRule = new RouteRule('GET', '/simple_test/action1', 'simple_test', 'action1', false);
$factory = $this->injector->getInstance('\Ouzo\ControllerFactory');
$factory = $this->injector->getInstance(ControllerFactory::class);
$config = Config::getValue('global');
$_SERVER['REQUEST_URI'] = "{$config['prefix_system']}/simple_test/action1";
@@ -68,13 +70,13 @@ public function shouldThrowExceptionWhenControllerNotFound()
{
//given
$routeRule = new RouteRule('GET', '/simple_test/action', 'not_exists', 'action', false);
$factory = $this->injector->getInstance('\Ouzo\ControllerFactory');
$factory = $this->injector->getInstance(ControllerFactory::class);
//when
CatchException::when($factory)->createController($routeRule);
//then
CatchException::assertThat()->isInstanceOf('\Ouzo\ControllerNotFoundException');
CatchException::assertThat()->isInstanceOf(ControllerNotFoundException::class);
CatchException::assertThat()->hasMessage('Controller [NotExists] for URI [/simple_test/action] does not exist!');
}
@@ -85,12 +87,12 @@ public function shouldResolveControllerWithNamespace()
{
//given
$routeRule = new RouteRule('GET', '/api/multiple_ns/test_action', 'api/multiple_ns', 'test_action', true);
$factory = $this->injector->getInstance('\Ouzo\ControllerFactory');
$factory = $this->injector->getInstance(ControllerFactory::class);
//when
$currentController = $factory->createController($routeRule);
//then
$this->assertInstanceOf('\Ouzo\Api\MultipleNsController', $currentController);
$this->assertInstanceOf(MultipleNsController::class, $currentController);
}
}
Oops, something went wrong.

0 comments on commit 6e8b746

Please sign in to comment.