Skip to content

Commit

Permalink
Версия для двух принятых PR + CS Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
IlyaSerdyuk committed Jul 19, 2019
1 parent b5511c4 commit c28a069
Show file tree
Hide file tree
Showing 107 changed files with 498 additions and 447 deletions.
14 changes: 7 additions & 7 deletions .php_cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ return PhpCsFixer\Config::create()
'no_useless_return' => true,
'no_whitespace_before_comma_in_array' => true,
'no_whitespace_in_blank_line' => true,
'non_printable_character' => true,
'not_operator_with_space' => true,
'non_printable_character' => ['use_escape_sequences_in_strings' => true],
'not_operator_with_space' => false,
'object_operator_without_whitespace' => true,
'ordered_imports' => true,
'phpdoc_add_missing_param_annotation' => true,
Expand Down Expand Up @@ -97,18 +97,18 @@ return PhpCsFixer\Config::create()
'space_after_semicolon' => ['remove_in_empty_for_expressions' => true],
'standardize_increment' => true,
'standardize_not_equals' => true,
'strict_comparison' => true,
'strict_param' => true,
'string_line_ending' => true,
// 'strict_comparison' => true,
// 'strict_param' => true,
// 'string_line_ending' => true,
'ternary_operator_spaces' => true,
'ternary_to_null_coalescing' => true,
'trailing_comma_in_multiline_array' => true,
'trim_array_spaces' => true,
'unary_operator_spaces' => false,
'unary_operator_spaces' => true,
'visibility_required' => ['property', 'method'],
'void_return' => false, // хорошо бы включить, но заебешься обновлять существующие проекты
'whitespace_after_comma_in_array' => true,
'yoda_style' => true,
// 'yoda_style' => true,
])
->setFinder($finder)
->setUsingCache(false)
Expand Down
6 changes: 3 additions & 3 deletions library/ZFE/Acl.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function __construct(Zend_Config $config)
protected function _loadRoles(Zend_Config $roles)
{
foreach ($roles as $name => $parents) {
if ( ! $this->hasRole($name)) {
if (!$this->hasRole($name)) {
if (empty($parents)) {
$parents = null;
} else {
Expand All @@ -61,7 +61,7 @@ protected function _loadResources(Zend_Config $resources)
foreach ($controllers as $controller => $actions) {
if ('all' === $controller) {
$controller = null;
} elseif ( ! $this->has($controller)) {
} elseif (!$this->has($controller)) {
$this->add(new Zend_Acl_Resource($controller));
}

Expand Down Expand Up @@ -104,7 +104,7 @@ protected function _loadResources(Zend_Config $resources)
*/
public function hasResource($resource)
{
return in_array($resource, $this->getResources(), true);
return in_array($resource, $this->getResources());
}

/**
Expand Down
6 changes: 3 additions & 3 deletions library/ZFE/Auth/Adapter/Doctrine.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public function setCredential($credential)
*/
public function getResultRowObject($returnColumns = null, $omitColumns = null)
{
if ( ! $this->_resultRow) {
if (!$this->_resultRow) {
return false;
}

Expand All @@ -249,7 +249,7 @@ public function getResultRowObject($returnColumns = null, $omitColumns = null)
if (null !== $returnColumns) {
$availableColumns = array_keys($this->_resultRow);
foreach ((array) $returnColumns as $returnColumn) {
if (in_array($returnColumn, $availableColumns, true)) {
if (in_array($returnColumn, $availableColumns)) {
$returnObject->{$returnColumn} = $this->_resultRow[$returnColumn];
}
}
Expand All @@ -260,7 +260,7 @@ public function getResultRowObject($returnColumns = null, $omitColumns = null)
if (null !== $omitColumns) {
$omitColumns = (array) $omitColumns;
foreach ($this->_resultRow as $resultColumn => $resultValue) {
if ( ! in_array($resultColumn, $omitColumns, true)) {
if (!in_array($resultColumn, $omitColumns)) {
$returnObject->{$resultColumn} = $resultValue;
}
}
Expand Down
24 changes: 13 additions & 11 deletions library/ZFE/Auth/Editor.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<?php

/*
* ZFE – платформа для построения редакторских интерфейсов.
*/

/**
* Class ZFE_Auth_Editor
*
* Класс программного контроля аутентификации пользователя
* Класс программного контроля аутентификации пользователя.
*/
class ZFE_Auth_Editor
{
Expand All @@ -18,8 +20,9 @@ public static function getInstance()
}

/**
* @return int
* @throws Zend_Auth_Exception
*
* @return int
*/
public function getId()
{
Expand All @@ -32,18 +35,20 @@ public function getId()
}

/**
* Возвращает аутентифицированного пользователя, если это допустимо
* Возвращает аутентифицированного пользователя, если это допустимо.
*
* @return Editors|null
* @throws Zend_Auth_Exception
*
* @return Editors|null
*/
public function get() : ?Editors
public function get(): ?Editors
{
return Editors::findForAuth($this->getId());
}

/**
* @param Editors $editor
*
* @throws Zend_Auth_Storage_Exception
*/
public function set(Editors $editor)
Expand All @@ -54,14 +59,11 @@ public function set(Editors $editor)
$auth->getStorage()->write(['id' => $editor->id]);
}

/**
*
*/
public function clear()
{
$auth = Zend_Auth::getInstance();
if ($auth->hasIdentity()) {
$auth->clearIdentity();
}
}
}
}
6 changes: 3 additions & 3 deletions library/ZFE/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ protected function _makeAuthData()
if (isset($identity['role']) && $canSwitchRoles) {
$role = $identity['role'];
}
} elseif (PHP_SAPI == 'cli' && isset($config->cli->userId)) {
} elseif (PHP_SAPI === 'cli' && isset($config->cli->userId)) {
$user = Editors::find($config->cli->userId);
}

Expand All @@ -202,7 +202,7 @@ protected function _makeAuthData()
* Пользователь может менять свою роль?
*
* @param Editors $user
*
*
* @return bool
*/
protected function _canSwitchRoles(Editors $user)
Expand Down Expand Up @@ -241,7 +241,7 @@ protected function _initLayout()
$layout = Zend_Layout::startMvc();
$layout->setViewBasePath($zfeResourcesPath . ':/views');

if ( ! Zend_Auth::getInstance()->hasIdentity()) {
if (!Zend_Auth::getInstance()->hasIdentity()) {
$layout->setLayout('layout_guest');
}

Expand Down
2 changes: 1 addition & 1 deletion library/ZFE/Console/Command/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public function setLogger(ZFE_Console_Logger $logger)
*/
public function getLogger()
{
if ( ! $this->_logger) {
if (!$this->_logger) {
$this->_logger = new ZFE_Console_Logger();
}

Expand Down
6 changes: 4 additions & 2 deletions library/ZFE/Console/Command/SphinxIndexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ZFE_Console_Command_SphinxIndexer extends ZFE_Console_Command_Abstract
/**
* Использовать простой общий индекс?
*
* @var boolean
* @var bool
*/
protected $_useSimpleCommonIndex = false;

Expand All @@ -49,7 +49,9 @@ public function execute(array $params = [])
echo " > <info>composer tool indexer {$example}</info>\n";
echo " > <info>composer tool indexer 1 4</info>\n";
return;
} elseif ('all' === $params[0]) {
}

if ('all' === $params[0]) {
$models = $this->_getAllModels();
} else {
$models = $params;
Expand Down
6 changes: 3 additions & 3 deletions library/ZFE/Console/Command/UserAdd.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ public function execute(array $params = [])
return;
}

$password = substr(uniqid('', true), 0, 8);
$password = mb_substr(uniqid('', true), 0, 8);

$item = new Editors();
$item->second_name = $login;
$item->login = $login;
$item->role = 'admin';
$item->setPassword($password);
$item->save();
print "Добавлен пользователь c логином <info>{$login}</info> и паролем <info>{$password}</info>.\n";

echo "Добавлен пользователь c логином <info>{$login}</info> и паролем <info>{$password}</info>.\n";
}
}
16 changes: 9 additions & 7 deletions library/ZFE/Console/CommandBroker.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class ZFE_Console_CommandBroker
*/
public static function getInstance()
{
if ( ! static::$_instance) {
if (!static::$_instance) {
static::$_instance = new static();
}
return static::$_instance;
Expand Down Expand Up @@ -90,7 +90,9 @@ public function loadCommands(string $path, string $prefix)
foreach ($directory as $file) { /** @var SplFileInfo $file */
if ($file->isDot()) {
continue;
} elseif ($file->isDir()) {
}

if ($file->isDir()) {
$name = $file->getBasename();
$this->loadCommands(
$path . DIRECTORY_SEPARATOR . $name,
Expand All @@ -107,9 +109,9 @@ public function loadCommands(string $path, string $prefix)
if (Zend_Loader::isReadable($fileName)) {
include_once $fileName;
if (class_exists($className, false)) {
if ( ! $this->hasCommandByClass($className)) {
if (!$this->hasCommandByClass($className)) {
$reflection = new ReflectionClass($className);
if ($reflection->isSubclassOf(ZFE_Console_Command_Abstract::class) && ! $reflection->isAbstract()) {
if ($reflection->isSubclassOf(ZFE_Console_Command_Abstract::class) && !$reflection->isAbstract()) {
$this->registerCommand($className);
}
}
Expand Down Expand Up @@ -139,7 +141,7 @@ public function registerCommand($command, ?string $name = null, bool $replace =
throw new ZFE_Console_Exception('Нельзя зарегистрировать команду без ключа.');
}

if (key_exists($name, $this->_commands) && ! $replace) {
if (key_exists($name, $this->_commands) && !$replace) {
$prevCommand = $this->_commands[$name];
if (is_object($prevCommand)) {
$prevCommand = get_class($prevCommand);
Expand Down Expand Up @@ -237,7 +239,7 @@ public function hasCommandByClass(string $class)
*/
public function getCommand(string $name)
{
if ( ! key_exists($name, $this->_commands)) {
if (!key_exists($name, $this->_commands)) {
throw new ZFE_Console_Exception("Команда '${name}' не зарегистрирована.");
}

Expand All @@ -247,7 +249,7 @@ public function getCommand(string $name)
$command = new $class();
}

if ( ! $command instanceof ZFE_Console_Command_Abstract) {
if (!$command instanceof ZFE_Console_Command_Abstract) {
throw new ZFE_Console_Exception('Команда не валидна.');
}

Expand Down
6 changes: 3 additions & 3 deletions library/ZFE/Console/Helper/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public function setColumnAligns(array $aligns)
public function setHeaders(array $headers)
{
$headers = array_values($headers);
if ( ! empty($headers) && ! is_array($headers[0])) {
if (!empty($headers) && !is_array($headers[0])) {
$headers = [$headers];
}

Expand Down Expand Up @@ -182,7 +182,7 @@ public function render(bool $echo = true)
$this->prepare();

$markup = $this->renderRowSeparator();
if ( ! empty($this->_headers)) {
if (!empty($this->_headers)) {
foreach ($this->_headers as $header) {
$markup .= $this->renderRow($header);
$markup .= $this->renderRowSeparator();
Expand All @@ -191,7 +191,7 @@ public function render(bool $echo = true)
foreach ($this->_rows as $row) {
$markup .= $this->renderRow($row);
}
if ( ! empty($this->_rows)) {
if (!empty($this->_rows)) {
$markup .= $this->renderRowSeparator();
}

Expand Down
2 changes: 1 addition & 1 deletion library/ZFE/Console/HelperBroker.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ZFE_Console_HelperBroker
*/
public static function getInstance()
{
if ( ! static::$_instance) {
if (!static::$_instance) {
static::$_instance = new static();
}
return static::$_instance;
Expand Down
6 changes: 3 additions & 3 deletions library/ZFE/Console/Tools.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function setCommandBroker(ZFE_Console_CommandBroker $broker)
*/
public function getCommandBroker()
{
if ( ! $this->_commandBroker) {
if (!$this->_commandBroker) {
$brokerClass = Zend_Registry::get('config')->console->commandBroker ?? 'ZFE_Console_CommandBroker';
$this->_commandBroker = $brokerClass::getInstance();
}
Expand Down Expand Up @@ -121,7 +121,7 @@ public function setHelperBroker(ZFE_Console_HelperBroker $broker)
*/
public function getHelperBroker()
{
if ( ! $this->_helperBroker) {
if (!$this->_helperBroker) {
$brokerClass = Zend_Registry::get('config')->console->helperBroker ?? 'ZFE_Console_HelperBroker';
$this->_helperBroker = $brokerClass::getInstance();
}
Expand Down Expand Up @@ -149,7 +149,7 @@ public function setLogger(ZFE_Console_Logger $logger)
*/
public function getLogger()
{
if ( ! $this->_logger) {
if (!$this->_logger) {
$loggerClass = Zend_Registry::get('config')->console->logger ?? 'ZFE_Console_Logger';
$this->_logger = new $loggerClass();
}
Expand Down
Loading

0 comments on commit c28a069

Please sign in to comment.