diff --git a/.php_cs b/.php_cs
index d402504..5d352fe 100644
--- a/.php_cs
+++ b/.php_cs
@@ -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,
@@ -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)
diff --git a/library/ZFE/Acl.php b/library/ZFE/Acl.php
index a4a0ae8..94d88a6 100644
--- a/library/ZFE/Acl.php
+++ b/library/ZFE/Acl.php
@@ -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 {
@@ -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));
}
@@ -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());
}
/**
diff --git a/library/ZFE/Auth/Adapter/Doctrine.php b/library/ZFE/Auth/Adapter/Doctrine.php
index 9a4f110..4b693e1 100644
--- a/library/ZFE/Auth/Adapter/Doctrine.php
+++ b/library/ZFE/Auth/Adapter/Doctrine.php
@@ -240,7 +240,7 @@ public function setCredential($credential)
*/
public function getResultRowObject($returnColumns = null, $omitColumns = null)
{
- if ( ! $this->_resultRow) {
+ if (!$this->_resultRow) {
return false;
}
@@ -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];
}
}
@@ -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;
}
}
diff --git a/library/ZFE/Auth/Editor.php b/library/ZFE/Auth/Editor.php
index 2431c21..2a1c1f3 100644
--- a/library/ZFE/Auth/Editor.php
+++ b/library/ZFE/Auth/Editor.php
@@ -1,9 +1,11 @@
getId());
}
/**
* @param Editors $editor
+ *
* @throws Zend_Auth_Storage_Exception
*/
public function set(Editors $editor)
@@ -54,9 +59,6 @@ public function set(Editors $editor)
$auth->getStorage()->write(['id' => $editor->id]);
}
- /**
- *
- */
public function clear()
{
$auth = Zend_Auth::getInstance();
@@ -64,4 +66,4 @@ public function clear()
$auth->clearIdentity();
}
}
-}
\ No newline at end of file
+}
diff --git a/library/ZFE/Bootstrap.php b/library/ZFE/Bootstrap.php
index 9c7d545..da740c5 100644
--- a/library/ZFE/Bootstrap.php
+++ b/library/ZFE/Bootstrap.php
@@ -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);
}
@@ -202,7 +202,7 @@ protected function _makeAuthData()
* Пользователь может менять свою роль?
*
* @param Editors $user
- *
+ *
* @return bool
*/
protected function _canSwitchRoles(Editors $user)
@@ -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');
}
diff --git a/library/ZFE/Console/Command/Abstract.php b/library/ZFE/Console/Command/Abstract.php
index 4aa456d..8c33bf9 100644
--- a/library/ZFE/Console/Command/Abstract.php
+++ b/library/ZFE/Console/Command/Abstract.php
@@ -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();
}
diff --git a/library/ZFE/Console/Command/SphinxIndexer.php b/library/ZFE/Console/Command/SphinxIndexer.php
index 68d1841..ae13178 100644
--- a/library/ZFE/Console/Command/SphinxIndexer.php
+++ b/library/ZFE/Console/Command/SphinxIndexer.php
@@ -22,7 +22,7 @@ class ZFE_Console_Command_SphinxIndexer extends ZFE_Console_Command_Abstract
/**
* Использовать простой общий индекс?
*
- * @var boolean
+ * @var bool
*/
protected $_useSimpleCommonIndex = false;
@@ -49,7 +49,9 @@ public function execute(array $params = [])
echo " >
/', '', $output); } diff --git a/library/ZFE/File.php b/library/ZFE/File.php index 880d86d..a3eef66 100644 --- a/library/ZFE/File.php +++ b/library/ZFE/File.php @@ -430,7 +430,7 @@ public function hasIcon($has = null) if (null === $this->_hasIcon) { $iconClass = $this->getIconClass(); - $this->_hasIcon = ! empty($iconClass); + $this->_hasIcon = !empty($iconClass); } return $this->_hasIcon; @@ -460,7 +460,7 @@ public function hasPreview($has = null) if (null === $this->_hasPreview) { $url = $this->getPreviewUrl(); - $this->_hasPreview = ! empty($url); + $this->_hasPreview = !empty($url); } return $this->_hasPreview; @@ -490,7 +490,7 @@ public function canDownload($can = null) if (null === $this->_canDownload) { $url = $this->getDownloadUrl(); - $this->_canDownload = ! empty($url); + $this->_canDownload = !empty($url); } return $this->_canDownload; @@ -520,7 +520,7 @@ public function canView($can = null) if (null === $this->_canView) { $url = $this->getViewUrl(); - $this->_canView = ! empty($url); + $this->_canView = !empty($url); } return $this->_canView; @@ -550,7 +550,7 @@ public function canEdit($can = null) if (null === $this->_canEdit) { $url = $this->getEditUrl(); - $this->_canEdit = ! empty($url); + $this->_canEdit = !empty($url); } return $this->_canEdit; @@ -580,7 +580,7 @@ public function canDelete($can = null) if (null === $this->_canDelete) { $url = $this->getDeleteUrl(); - $this->_canDelete = ! empty($url); + $this->_canDelete = !empty($url); } return $this->_canDelete; @@ -692,8 +692,8 @@ public function __construct($params) */ public static function makePath($path) { - if ( ! file_exists($path)) { - if ( ! @mkdir($path, 0755, true)) { + if (!file_exists($path)) { + if (!@mkdir($path, 0755, true)) { throw new Exception("Mkdir failed for path '{$path}'"); } } @@ -756,7 +756,7 @@ public static function safeFilename($filename, $ext = null) } if ($ext) { - if (in_array($ext, self::$_blackExtensions, true)) { + if (in_array($ext, self::$_blackExtensions)) { $ext = '_' . $ext; } @@ -779,7 +779,7 @@ public static function safeFilename($filename, $ext = null) */ public static function generationPath($basePath, $id = 0, $ext = '', $isUrl = false, $andRand = false) { - if ( ! $isUrl) { + if (!$isUrl) { $basePath = realpath($basePath); } @@ -787,7 +787,7 @@ public static function generationPath($basePath, $id = 0, $ext = '', $isUrl = fa $fileName = array_pop($strparts); $subPath = implode('/', $strparts); - if ( ! $isUrl && ! file_exists($basePath . '/' . $subPath)) { + if (!$isUrl && !file_exists($basePath . '/' . $subPath)) { self::makePath($basePath . '/' . $subPath); self::fixPath($basePath, $subPath); } @@ -808,7 +808,7 @@ public static function generationPath($basePath, $id = 0, $ext = '', $isUrl = fa */ public static function getIconByFileName($name) { - if ( ! is_string($name) || empty($name)) { + if (!is_string($name) || empty($name)) { return null; } diff --git a/library/ZFE/Form/Decorator/Feedback.php b/library/ZFE/Form/Decorator/Feedback.php index 4bf1c61..0c215d1 100755 --- a/library/ZFE/Form/Decorator/Feedback.php +++ b/library/ZFE/Form/Decorator/Feedback.php @@ -18,7 +18,7 @@ public function render($content) $element = $this->getElement(); $container = $element->getDecorator('Container'); - if ( ! empty($container)) { + if (!empty($container)) { $classes = explode(' ', $container->getOption('class')); $container->setOption('class', implode(' ', array_diff($classes, ['has-feedback']))); } diff --git a/library/ZFE/Form/Decorator/FileValue.php b/library/ZFE/Form/Decorator/FileValue.php index 8d269e1..2a9737d 100644 --- a/library/ZFE/Form/Decorator/FileValue.php +++ b/library/ZFE/Form/Decorator/FileValue.php @@ -30,7 +30,7 @@ public function render($content) $id = $element->getName(); if ('multiple' === $element->getAttrib('multiple')) { - if ( ! count($files = $element->getFiles())) { + if (!count($files = $element->getFiles())) { return $content; } } else { @@ -91,8 +91,8 @@ protected function _renderFile(ZFE_File $file, $disabled = false) } } - if ($file->canDelete() && ! $disabled) { - if ( ! $file->hasPreview()) { + if ($file->canDelete() && !$disabled) { + if (!$file->hasPreview()) { $value .= ' '; } $value .= '' diff --git a/library/ZFE/Form/Decorator/HorizontalControls.php b/library/ZFE/Form/Decorator/HorizontalControls.php index be425be..1ef9575 100644 --- a/library/ZFE/Form/Decorator/HorizontalControls.php +++ b/library/ZFE/Form/Decorator/HorizontalControls.php @@ -11,12 +11,12 @@ public function render($content) $element = $this->getElement(); $class = ' ' . $this->getOption('class'); - if (in_array(mb_substr($element->getType(), -10), ['_FileImage', '_FileAudio'], true)) { + if (in_array(mb_substr($element->getType(), -10), ['_FileImage', '_FileAudio'])) { $class .= ' form-control-static'; } $class = trim($class); - if ( ! empty($class)) { + if (!empty($class)) { $this->setOption('class', $class); } diff --git a/library/ZFE/Form/Default/Profile.php b/library/ZFE/Form/Default/Profile.php index 875f161..8856215 100644 --- a/library/ZFE/Form/Default/Profile.php +++ b/library/ZFE/Form/Default/Profile.php @@ -82,7 +82,7 @@ protected function _addPasswordsElements() public function isValid($data) { // Да, костыль, но без него не работает, а делать в ручную очень многословно - if ( ! empty($data['password_new'])) { + if (!empty($data['password_new'])) { $this->getElement('password_new2')->setRequired(true); } diff --git a/library/ZFE/Form/Edit/AutoGeneration.php b/library/ZFE/Form/Edit/AutoGeneration.php index 1b305ef..a7eeef3 100644 --- a/library/ZFE/Form/Edit/AutoGeneration.php +++ b/library/ZFE/Form/Edit/AutoGeneration.php @@ -66,13 +66,13 @@ public function init() $table = Doctrine_Core::getTable($modelName); foreach ($table->getColumnNames() as $columnName) { - if ( ! in_array($columnName, $ignoreFields, true) && ! $this->getElement($columnName)) { + if (!in_array($columnName, $ignoreFields) && !$this->getElement($columnName)) { $method = $fieldMethods[$columnName] ?? 'addElementForColumn'; $this->{$method}($columnName); } } - if ($table->hasColumn('status') && ! in_array('status', $ignoreFields, true)) { + if ($table->hasColumn('status') && !in_array('status', $ignoreFields)) { $this->addElementStatus(); } } diff --git a/library/ZFE/Form/Element/Autocomplete.php b/library/ZFE/Form/Element/Autocomplete.php index 7cf2cfe..8c42102 100644 --- a/library/ZFE/Form/Element/Autocomplete.php +++ b/library/ZFE/Form/Element/Autocomplete.php @@ -30,14 +30,14 @@ public function setValue($value) return $this; } - if ( ! is_array($value)) { + if (!is_array($value)) { return $this; } // Допускаются только значения с заголовками - if ( ! empty($value['title'])) { + if (!empty($value['title'])) { // Значения без ID допускаются, только если - if ( ! empty($value['id']) || $this->getAttrib('canCreate')) { + if (!empty($value['id']) || $this->getAttrib('canCreate')) { $this->_value = $value; } } diff --git a/library/ZFE/Form/Element/File.php b/library/ZFE/Form/Element/File.php index 85f0977..5bacbf7 100644 --- a/library/ZFE/Form/Element/File.php +++ b/library/ZFE/Form/Element/File.php @@ -13,14 +13,14 @@ public function getAttribs() { $attribs = parent::getAttribs(); - if ( ! key_exists('data-type', $attribs)) { + if (!key_exists('data-type', $attribs)) { $dateType = $this->getDataType(); if ($dateType) { $attribs['data-type'] = $dateType; } } - if ( ! key_exists('accept', $attribs)) { + if (!key_exists('accept', $attribs)) { $allowExtensions = $this->getAllowExtensions(); $allowMimeTypes = $this->getAllowMimeTypes(); if ($allowExtensions || $allowMimeTypes) { @@ -51,7 +51,7 @@ public function getAttribs() */ public function setDateType($dateType) { - if ( ! in_array($dateType, $this->dateTypesValid, true)) { + if (!in_array($dateType, $this->dateTypesValid)) { throw new ZFE_Form_Exception('Не допустимый тип данных элемента загрузки файлов.'); } @@ -80,7 +80,7 @@ public function getDataType() */ public function addAllowExtension($extension) { - if ( ! in_array($extension, $this->_allowExtensions, true)) { + if (!in_array($extension, $this->_allowExtensions)) { if ('.' !== $extension[0]) { throw new ZFE_Form_Exception('Разрешенные расширения должны начинаться с точки.'); } @@ -147,7 +147,7 @@ public function getAllowExtensions() */ public function addAllowMimeType($mimeType) { - if ( ! in_array($mimeType, $this->_allowMimeTypes, true)) { + if (!in_array($mimeType, $this->_allowMimeTypes)) { $this->_allowMimeTypes[] = $mimeType; } diff --git a/library/ZFE/Form/Extensions.php b/library/ZFE/Form/Extensions.php index b49d143..eb4a7fb 100644 --- a/library/ZFE/Form/Extensions.php +++ b/library/ZFE/Form/Extensions.php @@ -38,7 +38,7 @@ public function populateFiles(ZFE_Model_AbstractRecord $item) */ public function getDefaultDecoratorsByElementType($type) { - if (in_array($type, ['range', 'duration'], true)) { + if (in_array($type, ['range', 'duration'])) { if (is_array($this->_simpleElementDecorators)) { return $this->_simpleElementDecorators; } @@ -101,11 +101,11 @@ public function getDefaultDecoratorsByElementType($type) */ public function createElement($type, $name, $options = null) { - if (in_array($type, ['range', 'duration'], true)) { + if (in_array($type, ['range', 'duration'])) { if (null === $options) { $options = ['class' => 'form-control']; } elseif (key_exists('class', $options)) { - if ( ! mb_strstr($options['class'], 'form-control')) { + if (!mb_strstr($options['class'], 'form-control')) { $options['class'] .= ' form-control'; $options['class'] = trim($options['class']); } diff --git a/library/ZFE/Model/AbstractRecord.php b/library/ZFE/Model/AbstractRecord.php index afe4b65..20a3baa 100644 --- a/library/ZFE/Model/AbstractRecord.php +++ b/library/ZFE/Model/AbstractRecord.php @@ -223,7 +223,7 @@ public function toArray($deep = true, $prefixKey = false) { $array = parent::toArray($deep, $prefixKey); - if ( ! is_array($array)) { + if (!is_array($array)) { return $array; } @@ -283,7 +283,7 @@ public function fromArray(array $array, $deep = true) { foreach ($array as $key => $value) { if ('month' === $key || 'month_' === mb_substr($key, 0, 6)) { - if ( ! empty($array[$key]) && preg_match('/[0-9]{4}\-[0-1][0-9]/', $array[$key])) { + if (!empty($array[$key]) && preg_match('/[0-9]{4}\-[0-1][0-9]/', $array[$key])) { $array[$key] .= '-01'; } else { $array[$key] = null; @@ -330,7 +330,7 @@ public static function isMergeable() */ public function isDeleted() { - if ( ! $this->contains('deleted')) { + if (!$this->contains('deleted')) { return false; } @@ -351,9 +351,9 @@ public function canUndeleted() } /** - * Режим миграции + * Режим миграции. * - * @var boolean + * @var bool */ public static $migrationMode = false; @@ -364,7 +364,7 @@ public function setUp() { parent::setUp(); - if ( ! self::$migrationMode) { + if (!self::$migrationMode) { $this->actAs(new ZFE_Model_Template_History()); $this->actAs(new ZFE_Model_Template_SoftDelete()); } diff --git a/library/ZFE/Model/AbstractRecord/Autocomplete.php b/library/ZFE/Model/AbstractRecord/Autocomplete.php index a923ad5..8548083 100644 --- a/library/ZFE/Model/AbstractRecord/Autocomplete.php +++ b/library/ZFE/Model/AbstractRecord/Autocomplete.php @@ -101,7 +101,7 @@ public static function getAutocompleteOptions($field) $custom = static::$autocompleteCols[$field]; // Проверяем, является ли поле автокомплитом - if ( ! key_exists($field, static::$autocompleteCols)) { + if (!key_exists($field, static::$autocompleteCols)) { return false; } @@ -109,7 +109,7 @@ public static function getAutocompleteOptions($field) /** @var ZFE_Model_Table $table */ $table = Doctrine_Core::getTable(static::class); $relAlias = $table->getModelNameForColumn($field); - $relModel = ! empty($custom['relModel']) ? $custom['relModel'] : $relAlias; + $relModel = !empty($custom['relModel']) ? $custom['relModel'] : $relAlias; $default = [ 'label' => static::getFieldName($field), 'source' => $relModel::getAutocompleteUrl(), @@ -133,7 +133,7 @@ public static function getAutocompleteOptions($field) public static function getMultiAutocompleteOptions($field) { // Проверяем, является ли поле автокомплитом - if ( ! key_exists($field, static::$multiAutocompleteCols)) { + if (!key_exists($field, static::$multiAutocompleteCols)) { return false; } @@ -144,7 +144,7 @@ public static function getMultiAutocompleteOptions($field) } $relAlias = $custom['relAlias']; - $relModel = ! empty($custom['relModel']) ? $custom['relModel'] : $relAlias; + $relModel = !empty($custom['relModel']) ? $custom['relModel'] : $relAlias; /** @var ZFE_Model_Table $table */ $table = Doctrine_Core::getTable(static::class); @@ -226,12 +226,12 @@ protected function _linkOneByIdTitle($alias, $id, $title) { $title = trim($title); - if ( ! empty($id)) { + if (!empty($id)) { if ($this->{$alias}->exists() && $this->{$alias}->id === $id) { return; } $this->link($alias, $id); - } elseif ( ! empty($title)) { + } elseif (!empty($title)) { $modelName = $this->getTable()->getRelation($alias)->getClass(); $item = new $modelName(); $item->setTitle($title); @@ -264,7 +264,7 @@ protected function _multiAutocompleteToArray(array $array) 'priority' => 0, ]; - if ( ! empty($options['sortable'])) { + if (!empty($options['sortable'])) { $rel = $this->getTable()->getRelation($alias); if ($rel instanceof Doctrine_Relation_Association) { $modelClassName = $rel->getAssociationTable()->getComponentName(); @@ -302,7 +302,7 @@ protected function _multiAutocompleteFromArray(array $array) foreach (static::$multiAutocompleteCols as $key => $options) { $options = static::getMultiAutocompleteOptions($key); - if ( ! isset($array[$key])) { + if (!isset($array[$key])) { $array[$key] = []; } @@ -323,7 +323,7 @@ protected function _multiAutocompleteFromArray(array $array) } $this->_linkIds($alias, $ids); - if ( ! empty($options['sortable'])) { + if (!empty($options['sortable'])) { $rel = $this->getTable()->getRelation($alias); if ($rel instanceof Doctrine_Relation_Association) { $modelClassName = $rel->getAssociationTable()->getComponentName(); diff --git a/library/ZFE/Model/AbstractRecord/Autocomplete/Searcher.php b/library/ZFE/Model/AbstractRecord/Autocomplete/Searcher.php index bfec3a3..26fa139 100644 --- a/library/ZFE/Model/AbstractRecord/Autocomplete/Searcher.php +++ b/library/ZFE/Model/AbstractRecord/Autocomplete/Searcher.php @@ -86,13 +86,13 @@ protected static function _getSphinxQueryForAutocomplete(array $params = []) $q->where('attr_deleted', 0); } - if ( ! empty($params['term']) && $term = trim($params['term'])) { + if (!empty($params['term']) && $term = trim($params['term'])) { $q->match('*', $term); } else { $term = null; } - if (isset($params['exclude']) && ! empty($params['exclude'])) { + if (isset($params['exclude']) && !empty($params['exclude'])) { $exclude = []; foreach (explode(',', $params['exclude']) as $id) { $exclude[] = (int) $id; @@ -150,7 +150,7 @@ protected static function _getDoctrineQueryForAutocomplete(array $params = []) } // Add check Exclude ids - if (isset($params['exclude']) && ! empty($params['exclude'])) { + if (isset($params['exclude']) && !empty($params['exclude'])) { $q->andWhereIn('x.id', explode(',', $params['exclude']), true); } diff --git a/library/ZFE/Model/AbstractRecord/Duplicates.php b/library/ZFE/Model/AbstractRecord/Duplicates.php index 566e11f..ad96997 100644 --- a/library/ZFE/Model/AbstractRecord/Duplicates.php +++ b/library/ZFE/Model/AbstractRecord/Duplicates.php @@ -70,7 +70,7 @@ protected static function _getGroupsByDuplicate($duplicate) } } - if ( ! empty($weights)) { + if (!empty($weights)) { $q->addSelect('(' . implode(' + ', $weights) . ') weight'); } else { $q->addSelect('0 weight'); diff --git a/library/ZFE/Model/AbstractRecord/Getters.php b/library/ZFE/Model/AbstractRecord/Getters.php index cfcd5c5..e0e0b45 100644 --- a/library/ZFE/Model/AbstractRecord/Getters.php +++ b/library/ZFE/Model/AbstractRecord/Getters.php @@ -109,17 +109,17 @@ public function getStatus($color = true) */ public static function getFieldName($field, $default = null) { - if ( ! empty(static::$nameFields[$field])) { + if (!empty(static::$nameFields[$field])) { return static::$nameFields[$field]; } - if ( ! empty(static::$_nameBaseFields[$field])) { + if (!empty(static::$_nameBaseFields[$field])) { return static::$_nameBaseFields[$field]; } $table = Doctrine_Core::getTable(static::class); $definition = $table->getColumnDefinition($field); - if ( ! empty($definition['comment'])) { + if (!empty($definition['comment'])) { return $definition['comment']; } @@ -153,7 +153,7 @@ public static function isDictionaryField($field) */ public static function getDictionary($field) { - if ( ! static::isDictionaryField($field)) { + if (!static::isDictionaryField($field)) { throw new ZFE_Model_Exception('Обращение к неопределенному словарю'); } diff --git a/library/ZFE/Model/AbstractRecord/HistoryHiddenFields.php b/library/ZFE/Model/AbstractRecord/HistoryHiddenFields.php index 0cec6bd..b8f3f2f 100644 --- a/library/ZFE/Model/AbstractRecord/HistoryHiddenFields.php +++ b/library/ZFE/Model/AbstractRecord/HistoryHiddenFields.php @@ -33,7 +33,7 @@ protected static function _clearHistoryHiddenFields() */ protected static function _addHistoryHiddenFields(array $fields) { - if ( ! is_array(static::$_historyHiddenFields)) { + if (!is_array(static::$_historyHiddenFields)) { static::_clearHistoryHiddenFields(); } diff --git a/library/ZFE/Model/AbstractRecord/MultiCheckOrSelect.php b/library/ZFE/Model/AbstractRecord/MultiCheckOrSelect.php index c5c2139..e73a768 100644 --- a/library/ZFE/Model/AbstractRecord/MultiCheckOrSelect.php +++ b/library/ZFE/Model/AbstractRecord/MultiCheckOrSelect.php @@ -39,7 +39,7 @@ trait ZFE_Model_AbstractRecord_MultiCheckOrSelect public static function getMultiCheckOrSelectOptions($field, $multiOptions = []) { // Проверяем, является ли поле автокомплитом - if ( ! key_exists($field, static::$multiCheckOrSelectCols)) { + if (!key_exists($field, static::$multiCheckOrSelectCols)) { return false; } @@ -52,7 +52,7 @@ public static function getMultiCheckOrSelectOptions($field, $multiOptions = []) $alias = $options['relAlias']; // не будем пересобирать варианты, если они уже собраны - if ( ! empty($multiOptions)) { + if (!empty($multiOptions)) { $options['multiOptions'] = $multiOptions; } else { $options['multiOptions'] = $alias::getKeyValueList(); @@ -77,7 +77,7 @@ protected function _multiCheckOrSelectToArray(array $array) protected function _multiCheckOrSelectFromArray(array $array) { foreach (static::$multiCheckOrSelectCols as $key => $options) { - if ( ! isset($array[$key])) { + if (!isset($array[$key])) { $array[$key] = []; } diff --git a/library/ZFE/Model/AbstractRecord/Sphinx.php b/library/ZFE/Model/AbstractRecord/Sphinx.php index c0fe946..847891c 100644 --- a/library/ZFE/Model/AbstractRecord/Sphinx.php +++ b/library/ZFE/Model/AbstractRecord/Sphinx.php @@ -45,7 +45,7 @@ public static function getSphinxIndexName() $model = static::class; if (empty(static::$_sphinxIndexName[$model])) { $config = ZFE_Sphinx::config(); - if ( ! isset($config->index->{$model})) { + if (!isset($config->index->{$model})) { throw new ZFE_Model_Exception("Индекс {$model} не найден в конфигурации."); } static::$_sphinxIndexName[$model] = $config->index->{$model}; @@ -93,7 +93,7 @@ public static function getSphinxIndexSqlPath() } else { $path = $config->sqlQuery->{$model}; } - if ( ! file_exists($path)) { + if (!file_exists($path)) { throw new ZFE_Exception("SQL-запрос {$path} не найден."); } static::$_sphinxIndexSqlPath[$model] = $path; diff --git a/library/ZFE/Model/AbstractRecord/Urls.php b/library/ZFE/Model/AbstractRecord/Urls.php index 8856f0c..4e33dc3 100644 --- a/library/ZFE/Model/AbstractRecord/Urls.php +++ b/library/ZFE/Model/AbstractRecord/Urls.php @@ -128,11 +128,11 @@ public function getHistoryDiffUrl($rightVersion = null, $leftVersion = null) $rightVersion = (int) $rightVersion; $leftVersion = (int) $leftVersion; - if ( ! $rightVersion) { // По умолчанию, текущая версия + if (!$rightVersion) { // По умолчанию, текущая версия $rightVersion = $this->version; } - if ( ! $leftVersion) { // По умолчанию, предыдущая перед правой + if (!$leftVersion) { // По умолчанию, предыдущая перед правой $leftVersion = $rightVersion > 1 ? $rightVersion - 1 : 1; diff --git a/library/ZFE/Model/Default/Editors.php b/library/ZFE/Model/Default/Editors.php index e02605e..3da6bd3 100644 --- a/library/ZFE/Model/Default/Editors.php +++ b/library/ZFE/Model/Default/Editors.php @@ -141,7 +141,7 @@ abstract class ZFE_Model_Default_Editors extends BaseEditors */ public function fromArray(array $array, $deep = true) { - if ( ! empty($array['password'])) { + if (!empty($array['password'])) { $salt = $array['password_salt'] ?? null; $this->setPassword($array['password'], $salt); } @@ -218,9 +218,9 @@ public function getNameWithContactInfo() { $name = $this->getFullName(); - if ( ! empty($this->email)) { + if (!empty($this->email)) { $name .= ' (' . $this->email . ')'; - } elseif ( ! empty($this->phone)) { + } elseif (!empty($this->phone)) { $name .= ' (' . $this->phone . ')'; } diff --git a/library/ZFE/Model/Default/PersonTrait.php b/library/ZFE/Model/Default/PersonTrait.php index 0d5e417..b32ca80 100644 --- a/library/ZFE/Model/Default/PersonTrait.php +++ b/library/ZFE/Model/Default/PersonTrait.php @@ -5,7 +5,7 @@ */ /** - * Стандартная функциональность для моделей персон + * Стандартная функциональность для моделей персон. */ trait ZFE_Model_Default_PersonTrait { @@ -18,11 +18,11 @@ public function getShortName() { $name = $this->second_name . ' '; - if ( ! empty($this->first_name)) { + if (!empty($this->first_name)) { $name .= mb_substr($this->first_name, 0, 1) . '.'; } - if ( ! empty($this->middle_name)) { + if (!empty($this->middle_name)) { $name .= mb_substr($this->middle_name, 0, 1) . '.'; } @@ -38,11 +38,11 @@ public function getFullName() { $name = $this->second_name; - if ( ! empty($this->first_name)) { + if (!empty($this->first_name)) { $name .= ' ' . $this->first_name; } - if ( ! empty($this->middle_name)) { + if (!empty($this->middle_name)) { $name .= ' ' . $this->middle_name; } @@ -50,7 +50,7 @@ public function getFullName() } /** - * @inheritDoc + * {@inheritdoc} */ public function getTitle() { @@ -62,10 +62,10 @@ public function getTitle() } /** - * @inheritDoc + * {@inheritdoc} */ public static function getKeyValueList($keyField = 'id', $valueField = "CONCAT_WS(' ', second_name, first_name, middle_name)", $where = null, $order = 'KEY_FIELD ASC', $groupby = null, $filterByStatus = null) { return parent::getKeyValueList($keyField, $valueField, $where, $order, $groupby); } -} \ No newline at end of file +} diff --git a/library/ZFE/Model/Default/Tasks.php b/library/ZFE/Model/Default/Tasks.php index 37718e1..ba15b9b 100644 --- a/library/ZFE/Model/Default/Tasks.php +++ b/library/ZFE/Model/Default/Tasks.php @@ -10,20 +10,20 @@ abstract class ZFE_Model_Default_Tasks extends BaseTasks { /** - * @inheritdoc + * {@inheritdoc} */ public function setUp() { parent::setUp(); - $nestedset0 = new Doctrine_Template_NestedSet(array( + $nestedset0 = new Doctrine_Template_NestedSet([ 'hasManyRoots' => true, 'rootColumnName' => 'root_id', - )); + ]); $this->actAs($nestedset0); } /** - * @inheritdoc + * {@inheritdoc} */ public function preInsert($event) { @@ -41,6 +41,7 @@ public function getPerformerCode() /** * @param string $code + * * @return ZFE_Model_Default_Tasks */ public function setPerformerCode(string $code) @@ -59,6 +60,7 @@ public function getRelatedId() /** * @param int $itemId + * * @return ZFE_Model_Default_Tasks */ public function setRelatedId(int $itemId) @@ -77,6 +79,7 @@ public function getState() /** * @param int $state + * * @return ZFE_Model_Default_Tasks */ public function setState(int $state) @@ -95,6 +98,7 @@ public function getScheduledAt() /** * @param DateTime $dt + * * @return ZFE_Model_Default_Tasks */ public function setScheduledAt(DateTime $dt) @@ -113,6 +117,7 @@ public function getErrors() /** * @param string $errors + * * @return ZFE_Model_Default_Tasks */ public function setErrors(string $errors) @@ -131,6 +136,8 @@ public function getDoneAt() /** * @param mixed $done_at + * @param mixed $doneAt + * * @return ZFE_Model_Default_Tasks */ public function setDoneAt($doneAt) @@ -164,9 +171,10 @@ public function saveAsRoot() /** * @param ZFE_Model_Default_Tasks $task + * * @return ZFE_Model_Default_Tasks */ - public function saveAsChildOf(ZFE_Model_Default_Tasks $task) + public function saveAsChildOf(self $task) { $this->created_at = new Doctrine_Expression('NOW()'); $this->related_id = $task->getRelatedId(); @@ -177,4 +185,4 @@ public function saveAsChildOf(ZFE_Model_Default_Tasks $task) $this->getNode()->insertAsLastChildOf($task); return $this; } -} \ No newline at end of file +} diff --git a/library/ZFE/Model/Table.php b/library/ZFE/Model/Table.php index 6320bd4..91bdf14 100644 --- a/library/ZFE/Model/Table.php +++ b/library/ZFE/Model/Table.php @@ -27,15 +27,15 @@ class ZFE_Model_Table extends Doctrine_Table */ public function getElementTypeForColumn($columnName) { - if ( ! isset($this->_columns[$columnName])) { + if (!isset($this->_columns[$columnName])) { throw new ZFE_Model_Exception('Невозможно получить тип столбца: столбец "' . $columnName . '" не определен в модели "' . $this->getClassnameToReturn() . '"'); } - if ( ! isset($this->_formInfo[$columnName]) || ! isset($this->_formInfo[$columnName]['type'])) { + if (!isset($this->_formInfo[$columnName]) || !isset($this->_formInfo[$columnName]['type'])) { $formConfig = Zend_Registry::get('config')->forms; $modelName = $this->getClassnameToReturn(); - if (in_array($columnName, $modelName::$booleanFields, true)) { + if (in_array($columnName, $modelName::$booleanFields)) { $form = 'checkbox'; } @@ -52,7 +52,7 @@ public function getElementTypeForColumn($columnName) $form = 'select'; } - if ( ! isset($form)) { + if (!isset($form)) { switch ($this->_columns[$columnName]['type']) { case 'integer': case 'float': @@ -97,7 +97,7 @@ public function getElementTypeForColumn($columnName) */ public function getElementMaxLengthForColumn($columnName) { - if ( ! isset($this->_columns[$columnName])) { + if (!isset($this->_columns[$columnName])) { throw new ZFE_Model_Exception('Невозможно получить максимальную длину столбца: столбец "' . $columnName . '" не определен в модели "' . $this->getClassnameToReturn() . '"'); } @@ -117,7 +117,7 @@ public function getElementMaxLengthForColumn($columnName) */ public function isElementRequiredForColumn($columnName) { - if ( ! isset($this->_columns[$columnName])) { + if (!isset($this->_columns[$columnName])) { throw new ZFE_Model_Exception('Невозможно проверить обязательность столбца: столбец "' . $columnName . '" не определен в модели "' . $this->getClassnameToReturn() . '"'); } @@ -137,7 +137,7 @@ public function isElementRequiredForColumn($columnName) */ public function isElementPositiveForColumn($columnName) { - if ( ! isset($this->_columns[$columnName])) { + if (!isset($this->_columns[$columnName])) { throw new ZFE_Model_Exception('Невозможно проверить беззнаковость столбца: столбец "' . $columnName . '" не определен в модели "' . $this->getClassnameToReturn() . '"'); } @@ -157,11 +157,11 @@ public function isElementPositiveForColumn($columnName) */ public function getElementLabelForColumn($columnName) { - if ( ! isset($this->_columns[$columnName])) { + if (!isset($this->_columns[$columnName])) { throw new ZFE_Model_Exception('Невозможно получить заголовок столбца: столбец "' . $columnName . '" не определен в модели "' . $this->getClassnameToReturn() . '"'); } - if ( ! isset($this->_formInfo[$columnName]) || ! isset($this->_formInfo[$columnName]['label'])) { + if (!isset($this->_formInfo[$columnName]) || !isset($this->_formInfo[$columnName]['label'])) { $modelName = $this->getClassnameToReturn(); $this->_formInfo[$columnName]['label'] = $modelName::getFieldName($columnName); } @@ -178,11 +178,11 @@ public function getElementLabelForColumn($columnName) */ public function getElementValidatorsForColumn($columnName) { - if ( ! isset($this->_columns[$columnName])) { + if (!isset($this->_columns[$columnName])) { throw new ZFE_Model_Exception('Невозможно получить валидаторы столбца: столбец "' . $columnName . '" не определен в модели "' . $this->getClassnameToReturn() . '"'); } - if ( ! isset($this->_formInfo[$columnName]) || ! isset($this->_formInfo[$columnName]['validators'])) { + if (!isset($this->_formInfo[$columnName]) || !isset($this->_formInfo[$columnName]['validators'])) { $maxLength = $this->getElementMaxLengthForColumn($columnName); $validators = []; @@ -207,7 +207,7 @@ public function getElementValidatorsForColumn($columnName) if (isset($this->_columns[$columnName]['scale'])) { $max = str_repeat('9', $maxLength - $this->_columns[$columnName]['scale']) . '.' . str_repeat('9', $this->_columns[$columnName]['scale']); - } elseif ( ! $maxLength) { + } elseif (!$maxLength) { break; } else { $max = str_repeat('9', $maxLength); @@ -338,7 +338,7 @@ public function getElementOptionsForColumn($columnName) } else { throw new ZFE_Model_Exception('Невозможно получить допустимые значения для столбца "' . $columnName . '" модели "' . $modelName . '"'); } - if ( ! $options['required']) { + if (!$options['required']) { $list = [null => ''] + $list; } $options['multiOptions'] = $list; diff --git a/library/ZFE/Model/Template/BaseZfeFields.php b/library/ZFE/Model/Template/BaseZfeFields.php index e3d1d1a..d06134c 100644 --- a/library/ZFE/Model/Template/BaseZfeFields.php +++ b/library/ZFE/Model/Template/BaseZfeFields.php @@ -81,7 +81,7 @@ class ZFE_Model_Template_BaseZfeFields extends Doctrine_Template 'default' => '0', 'comment' => 'Статус', ], - 'disabled' => false, + 'disabled' => false, ], ]; diff --git a/library/ZFE/Model/Template/History.php b/library/ZFE/Model/Template/History.php index 6ffa957..837d479 100644 --- a/library/ZFE/Model/Template/History.php +++ b/library/ZFE/Model/Template/History.php @@ -65,7 +65,7 @@ public function saveHistory($mode, $noWarning = false) { if ($this->_listener) { $this->_listener->saveHistory($mode); - } elseif ( ! $noWarning) { + } elseif (!$noWarning) { trigger_error('Не возможно установить флаг записи и учета истории ' . 'при отключенном обработчике истории.', E_USER_WARNING); } @@ -120,7 +120,7 @@ public function getStateForVersion($version) ; foreach ($history as $action) { /** @var History $action */ - if ( ! empty($action->column_name) && $state->contains($action->column_name)) { + if (!empty($action->column_name) && $state->contains($action->column_name)) { $state->{$action->column_name} = $action->content_old; $state->version = $action->content_version; } diff --git a/library/ZFE/Model/Template/Listener/History.php b/library/ZFE/Model/Template/Listener/History.php index 4f3af1b..3327762 100644 --- a/library/ZFE/Model/Template/Listener/History.php +++ b/library/ZFE/Model/Template/Listener/History.php @@ -42,7 +42,7 @@ public function saveHistory($mode = null) */ protected function _getCurrentUserId() { - if ( ! Zend_Registry::isRegistered('user')) { + if (!Zend_Registry::isRegistered('user')) { return null; } @@ -198,11 +198,11 @@ public function postUpdate(Doctrine_Event $event) $hiddenColumns = $invokerModelName::getHistoryHiddenFields(); foreach ($newData as $column => $newValue) { - if (in_array($column, $ignoreColumns, true)) { + if (in_array($column, $ignoreColumns)) { continue; } - if (in_array($column, $hiddenColumns, true)) { + if (in_array($column, $hiddenColumns)) { $newValue = null; } elseif ($newValue instanceof Doctrine_Expression) { $newValue = (string) $newValue; diff --git a/library/ZFE/Model/Template/Listener/SoftDelete.php b/library/ZFE/Model/Template/Listener/SoftDelete.php index d1c8635..b320273 100644 --- a/library/ZFE/Model/Template/Listener/SoftDelete.php +++ b/library/ZFE/Model/Template/Listener/SoftDelete.php @@ -62,7 +62,7 @@ public function preDqlSelect(Doctrine_Event $event) $field = $params['alias'] . '.deleted'; $query = $event->getQuery(); - if ($table->hasField('deleted') && ! $query->isHard()) { + if ($table->hasField('deleted') && !$query->isHard()) { if (empty($params['component']['ref'])) { $query->addWhere($field . ' IS NULL OR ' . $field . ' = 0'); } diff --git a/library/ZFE/Paginator.php b/library/ZFE/Paginator.php index 4797ad1..f7610fe 100644 --- a/library/ZFE/Paginator.php +++ b/library/ZFE/Paginator.php @@ -67,7 +67,7 @@ protected function __construct() */ public static function getInstance() { - if ( ! self::$_instance) { + if (!self::$_instance) { self::$_instance = new static(); } @@ -119,7 +119,7 @@ public function setPageNumber($pageNumber) */ public function getPageNumber() { - if ( ! $this->_pageNumber) { + if (!$this->_pageNumber) { $this->setPageNumber($this->_request->getParam('page', 1)); } return $this->_pageNumber; @@ -162,7 +162,7 @@ public function setUri(ZFE_Uri $uri) */ public function getUri() { - if ( ! $this->_uri) { + if (!$this->_uri) { $this->setUri(ZFE_Uri_Route::fromRequest($this->_request)); } return $this->_uri; @@ -175,7 +175,7 @@ public function getUri() */ public function getUrl() { - if ( ! $this->_uri) { + if (!$this->_uri) { $this->setUri(ZFE_Uri_Route::fromRequest($this->_request)); } return $this->_uri->getUri(); @@ -190,7 +190,7 @@ public function getUrl() */ public function getPager() { - if ( ! ($this->_pager instanceof Doctrine_Pager)) { + if (!($this->_pager instanceof Doctrine_Pager)) { throw new Zend_Exception('Component Paginator not executed'); } return $this->_pager; diff --git a/library/ZFE/Plugin/Acl.php b/library/ZFE/Plugin/Acl.php index bc378aa..d51cc65 100644 --- a/library/ZFE/Plugin/Acl.php +++ b/library/ZFE/Plugin/Acl.php @@ -44,7 +44,7 @@ public function preDispatch(Zend_Controller_Request_Abstract $request) $controller = $request->getControllerName(); $action = $request->getActionName(); - if ( ! $this->isAllowed($controller, $action)) { + if (!$this->isAllowed($controller, $action)) { $this->_attack($request); } } @@ -59,7 +59,7 @@ public function preDispatch(Zend_Controller_Request_Abstract $request) */ public function isAllowed($resource, $privilege = null) { - if ( ! $this->_acl->has($resource)) { + if (!$this->_acl->has($resource)) { throw new Zend_Controller_Action_Exception("Ресурс {$resource} не найден", 404); } diff --git a/library/ZFE/Searcher/Abstract.php b/library/ZFE/Searcher/Abstract.php index b1b5ef5..2bc744c 100644 --- a/library/ZFE/Searcher/Abstract.php +++ b/library/ZFE/Searcher/Abstract.php @@ -78,7 +78,7 @@ public function getParamsFromRequest() * * @param array $params */ - public function filterIdsParam(& $params) + public function filterIdsParam(&$params) { if (empty($params['ids'])) { return $params; diff --git a/library/ZFE/Searcher/Doctrine.php b/library/ZFE/Searcher/Doctrine.php index 6b697b8..f30104f 100644 --- a/library/ZFE/Searcher/Doctrine.php +++ b/library/ZFE/Searcher/Doctrine.php @@ -41,7 +41,7 @@ public function setQueryBuilder(ZFE_Searcher_QueryBuilder_Interface $builder) */ public function getQueryBuilder() { - if ( ! $this->_queryBuilder) { + if (!$this->_queryBuilder) { $this->_queryBuilder = new ZFE_Searcher_QueryBuilder_Doctrine($this->_modelName); } @@ -62,7 +62,7 @@ public function search(array $params = null) $revertHash = $params['rh'] ?? null; $resultNumber = $params['rn'] ?? null; - if ( ! empty($resultNumber) && ! empty($revertHash)) { + if (!empty($resultNumber) && !empty($revertHash)) { $query->offset($resultNumber - 1); $query->limit(1); $item = $query->fetchOne(); diff --git a/library/ZFE/Searcher/QueryBuilder/Abstract.php b/library/ZFE/Searcher/QueryBuilder/Abstract.php index 861460c..c4b5781 100644 --- a/library/ZFE/Searcher/QueryBuilder/Abstract.php +++ b/library/ZFE/Searcher/QueryBuilder/Abstract.php @@ -123,7 +123,7 @@ protected function _order() { $order = $this->getParam('order'); - if ( ! empty($order)) { + if (!empty($order)) { $pos = mb_strrpos($order, '_'); $field = mb_substr($order, 0, $pos); $direction = mb_strtoupper(mb_substr($order, $pos + 1)); diff --git a/library/ZFE/Searcher/QueryBuilder/Doctrine.php b/library/ZFE/Searcher/QueryBuilder/Doctrine.php index 9a3ace6..62855b6 100644 --- a/library/ZFE/Searcher/QueryBuilder/Doctrine.php +++ b/library/ZFE/Searcher/QueryBuilder/Doctrine.php @@ -36,7 +36,7 @@ protected function _create() protected function _filters() { $title = trim((string) $this->getParam('title')); - if ( ! empty($title)) { + if (!empty($title)) { $this->_query->addWhere('LOWER(' . ($this->_modelName)::$titleField . ') LIKE LOWER(?)', '%' . $title . '%'); } @@ -61,7 +61,7 @@ protected function _caseForIds() protected function _caseForTrash() { if (($this->_modelName)::isRemovable() && ($this->_modelName)::$saveHistory) { - if ( ! $this->hasParam('ids')) { + if (!$this->hasParam('ids')) { if ($this->getParam('deleted')) { $this->_query->addWhere('x.deleted = 1'); $this->_query->setHard(true); diff --git a/library/ZFE/Searcher/QueryBuilder/HistoryDoctrine.php b/library/ZFE/Searcher/QueryBuilder/HistoryDoctrine.php index 39dd423..880b10c 100644 --- a/library/ZFE/Searcher/QueryBuilder/HistoryDoctrine.php +++ b/library/ZFE/Searcher/QueryBuilder/HistoryDoctrine.php @@ -14,7 +14,7 @@ protected function _filters() parent::_filters(); $editorId = trim((string) $this->getParam('editor')); - if ( ! empty($editorId)) { + if (!empty($editorId)) { $this->_query->addWhere('x.user_id = ?', $editorId); } diff --git a/library/ZFE/Searcher/QueryBuilder/Sphinx.php b/library/ZFE/Searcher/QueryBuilder/Sphinx.php index 1396f92..3e0bda2 100644 --- a/library/ZFE/Searcher/QueryBuilder/Sphinx.php +++ b/library/ZFE/Searcher/QueryBuilder/Sphinx.php @@ -54,7 +54,7 @@ public function setIndexName($name) */ public function getIndexName() { - if ( ! $this->_indexName) { + if (!$this->_indexName) { $modelName = $this->_modelName; $this->_indexName = $modelName::getSphinxIndexName(); } @@ -160,7 +160,7 @@ public function _advancedFilters() case 'rt_attr_multi': case 'rt_attr_multi_64': $items = $this->getParam($fieldName, []); - if (is_array($items) && ! empty($items)) { + if (is_array($items) && !empty($items)) { $ids = array_map(function ($data) { return (int) $data['id']; }, $items); diff --git a/library/ZFE/Searcher/Sphinx.php b/library/ZFE/Searcher/Sphinx.php index e754c89..8a05ae5 100644 --- a/library/ZFE/Searcher/Sphinx.php +++ b/library/ZFE/Searcher/Sphinx.php @@ -45,7 +45,7 @@ public function search(array $params = null) $revertHash = $params['rh'] ?? null; $resultNumber = $params['rn'] ?? null; - if ( ! empty($resultNumber) && ! empty($revertHash)) { + if (!empty($resultNumber) && !empty($revertHash)) { $sphinxQuery->option('max_matches', $resultNumber + 1); $sphinxQuery->offset($resultNumber - 1); $sphinxQuery->limit(1); @@ -65,7 +65,8 @@ public function search(array $params = null) $sphinxResult = $sphinxQuery ->limit($count) ->option('max_matches', $count) - ->execute(); + ->execute() + ; } $ids = ZFE_Sphinx::fetchIds($sphinxResult); @@ -104,7 +105,7 @@ public function setSphinxQueryBuilder(ZFE_Searcher_QueryBuilder_Interface $build */ public function getSphinxQueryBuilder() { - if ( ! $this->_sphinxQueryBuilder) { + if (!$this->_sphinxQueryBuilder) { $this->_sphinxQueryBuilder = new ZFE_Searcher_QueryBuilder_Sphinx($this->_modelName); } @@ -131,7 +132,7 @@ public function setDoctrineQueryBuilder(ZFE_Searcher_QueryBuilder_Interface $bui */ public function getDoctrineQueryBuilder() { - if ( ! $this->_doctrineQueryBuilder) { + if (!$this->_doctrineQueryBuilder) { $this->_doctrineQueryBuilder = new ZFE_Searcher_QueryBuilder_Doctrine($this->_modelName); } diff --git a/library/ZFE/Sphinx.php b/library/ZFE/Sphinx.php index 3397e62..9f26120 100644 --- a/library/ZFE/Sphinx.php +++ b/library/ZFE/Sphinx.php @@ -19,7 +19,7 @@ class ZFE_Sphinx */ public static function config() { - if ( ! self::$_config) { + if (!self::$_config) { self::$_config = Zend_Registry::get('config')->sphinx; } return self::$_config; @@ -117,7 +117,7 @@ public static function fetchOneId(SphinxQL $query) public static function fetchOne(SphinxQL $query, $table) { $id = self::fetchOneId($query); - if ( ! $id) { + if (!$id) { return null; } return ZFE_Query::create() diff --git a/library/ZFE/SqlManipulator.php b/library/ZFE/SqlManipulator.php index 159624c..bb4ddfc 100644 --- a/library/ZFE/SqlManipulator.php +++ b/library/ZFE/SqlManipulator.php @@ -53,7 +53,7 @@ public function orderBy($orderBy = null) $parser = new PHPSQLParser\PHPSQLParser(); $orderByMap = $parser->parse('ORDER BY ' . $orderBy)['ORDER']; - if ( ! isset($this->_map['ORDER']) || 0 === count($this->_map['ORDER'])) { + if (!isset($this->_map['ORDER']) || 0 === count($this->_map['ORDER'])) { $this->_map['ORDER'] = []; } @@ -72,7 +72,7 @@ public function limit($limit = null, $offset = null) $this->_map['LIMIT']['rowcount'] = $limit; if (is_int($offset) && $offset >= 0) { $this->_map['LIMIT']['offset'] = $offset; - } elseif ( ! isset($this->_map['LIMIT']['offset'])) { + } elseif (!isset($this->_map['LIMIT']['offset'])) { $this->_map['LIMIT']['offset'] = ''; } } diff --git a/library/ZFE/Tasks/Exception.php b/library/ZFE/Tasks/Exception.php index 5bfa827..b63b314 100644 --- a/library/ZFE/Tasks/Exception.php +++ b/library/ZFE/Tasks/Exception.php @@ -1,12 +1,12 @@ config->performers as $performerClassName) { - $performer = new $performerClassName; if ($performer instanceof ZFE_Tasks_Performer) { $this->performers[$performer->getCode()] = $performer; } else { - throw new ZFE_Tasks_Exception("Класс $performerClassName не является классом-исполнителем"); + throw new ZFE_Tasks_Exception("Класс ${performerClassName} не является классом-исполнителем"); } } } /** * @param Zend_Log $logger + * * @return $this */ public function setLogger(Zend_Log $logger) @@ -73,28 +80,32 @@ public function setLogger(Zend_Log $logger) /** * @param $message * @param int $level + * * @return $this - * @throws Zend_Log_Exception */ protected function log($message, $level = Zend_Log::INFO) { - if ($this->logger) $this->logger->log($message, $level); + if ($this->logger) { + $this->logger->log($message, $level); + } return $this; } /** - * Найти все повторные задачи для указанной + * Найти все повторные задачи для указанной. + * + * @param ZFE_Model_Default_Tasks $task * - * @param Tasks $task * @return Doctrine_Collection|null */ - public function findAllRevisionsFor(Tasks $task) + public function findAllRevisionsFor(ZFE_Model_Default_Tasks $task) { $table = Doctrine_Core::getTable('Tasks'); $q = $table->createQuery('x') ->select('x.*') ->where('x.id != ?', $task->id) - ->orderBy('x.id DESC'); + ->orderBy('x.id DESC') + ; $treeObject = $table->getTree(); $treeObject->setBaseQuery($q); @@ -107,11 +118,11 @@ public function findAllRevisionsFor(Tasks $task) } /** - * Для данной записи найди задачу, которая - * уже ранее была запланирована и еще не выполнена + * Для данной записи найди задачу, которая уже запланирована, но еще не выполнена. * * @param Doctrine_Record $record - * @param string $code + * @param string $code + * * @return null|ZFE_Model_Default_Tasks */ public function findOnePlanned(Doctrine_Record $record, string $code) @@ -122,19 +133,19 @@ public function findOnePlanned(Doctrine_Record $record, string $code) ->addWhere('x.performer_code = ?', $code) ->addWhere('x.state = ?', static::STATE_TODO) ->limit(1) - ->orderBy('x.id asc'); + ->orderBy('x.id asc') + ; $task = $q->fetchOne(); return $task ?: null; } /** - * Найти все задачи для выполнения + * Найти все задачи для выполнения. * - * @param int $limit + * @param int $limit * @param bool $onDemand возвращать ленивую коллекцию? - * @return Doctrine_Collection_OnDemand|Doctrine_Collection * - * @throws Doctrine_Query_Exception + * @return Doctrine_Collection_OnDemand|Doctrine_Collection */ public function findAllToDo(int $limit = 100, $onDemand = true) { @@ -145,7 +156,8 @@ public function findAllToDo(int $limit = 100, $onDemand = true) ->where('x.state = ?', static::STATE_TODO) ->addWhere('x.scheduled_at is null OR (x.scheduled_at is not null AND x.scheduled_at < NOW())') ->orderBy('x.created_at ASC') - ->limit($limit); + ->limit($limit) + ; if ($onDemand) { $q->setHydrationMode(Doctrine_Core::HYDRATE_ON_DEMAND); } @@ -154,14 +166,15 @@ public function findAllToDo(int $limit = 100, $onDemand = true) } /** - * Подобрать исполнителя для запланированной задачи + * Подобрать исполнителя для запланированной задачи. * - * @param Tasks $task - * @return ZFE_Tasks_Performer + * @param ZFE_Model_Default_Tasks $task * * @throws ZFE_Tasks_Exception + * + * @return ZFE_Tasks_Performer */ - public function assign(Tasks $task) + public function assign(ZFE_Model_Default_Tasks $task) { $code = $task->getPerformerCode(); if (!array_key_exists($code, $this->performers)) { @@ -171,14 +184,6 @@ public function assign(Tasks $task) return $this->performers[$code]; } - /** - * - * - * @param Doctrine_Collection_OnDemand $tasks - * @throws ZFE_Tasks_Exception - * @throws Zend_Log_Exception - */ - /** * Главный метод, который: * 1. перебирает данные задачи @@ -186,20 +191,19 @@ public function assign(Tasks $task) * 3. передает задачу на исполнение * 4. сохраняет результат * - * Возвращает кол-во успешно выполненных задач + * Возвращает кол-во успешно выполненных задач. * * @param Doctrine_Collection_OnDemand $tasks - * @return int * - * @throws Zend_Log_Exception + * @return int */ final public function manage(Doctrine_Collection_OnDemand $tasks) { $managed = 0; - foreach ($tasks as $task) { - - /** @var ZFE_Model_Default_Tasks $task */ - if ($task->getState() === static::STATE_DONE) continue; + foreach ($tasks as $task) { /** @var ZFE_Model_Default_Tasks $task */ + if ($task->getState() === static::STATE_DONE) { + continue; + } try { $performer = $this->assign($task); @@ -207,37 +211,38 @@ final public function manage(Doctrine_Collection_OnDemand $tasks) $this->log($e->getMessage(), Zend_Log::ERR); continue; } + try { $performer->perform($task->getRelatedId()); $task = $this->finish($task); $this->log("{$task->id} performed successfully"); + $managed++; } catch (ZFE_Tasks_Performer_Exception $e) { $task->setErrors($e->getMessage()); - $task->save(); + $this->log("{$task->id} performed with error: {$e->getMessage()}"); } - } return $managed; } /** - * Запланировать задачу для данной записи + * Запланировать задачу для данной записи. * - * @param Doctrine_Record $record + * @param Doctrine_Record $record * @param ZFE_Tasks_Performer $performer - * @param DateTime|null $sheduleDateTime + * @param DateTime|null $scheduleDateTime * * @return null|Tasks */ public function plan( Doctrine_Record $record, ZFE_Tasks_Performer $performer, - DateTime $sheduleDateTime = null + DateTime $scheduleDateTime = null ) { $task = $this->findOnePlanned($record, $performer->getCode()); if ($task === null) { @@ -247,8 +252,8 @@ public function plan( $task->saveAsRoot(); } - if ($sheduleDateTime) { - $task->setScheduledAt($sheduleDateTime); + if ($scheduleDateTime) { + $task->setScheduledAt($scheduleDateTime); $task->save(); } @@ -258,36 +263,37 @@ public function plan( /** * Запланировать повторное выполнение задачи. * - * Запланировать повторное выполение успешно выполненной задачи - * возможно только с параметром $force + * Запланировать повторное выполнение успешно выполненной задачи + * возможно только с параметром $force. * - * @param Tasks $task - * @param bool $force - * @return Tasks + * @param ZFE_Model_Default_Tasks $task + * @param bool $force * * @throws ZFE_Tasks_Exception + * + * @return Tasks */ - public function revision(Tasks $task, $force = false) + public function revision(ZFE_Model_Default_Tasks $task, $force = false) { if (!empty($task->getErrors()) || $force) { - $this->finish($task); - $taskRevision = new Tasks; + $taskRevision = new Tasks; /** @var ZFE_Model_Default_Tasks $task */ $taskRevision->saveAsChildOf($task); return $taskRevision; } - throw new ZFE_Tasks_Exception("Задача была выполнена успешно, доработка невозможна"); + throw new ZFE_Tasks_Exception('Задача была выполнена успешно, доработка невозможна'); } /** - * Сохранить задачу как выполненную + * Сохранить задачу как выполненную. * - * @param Tasks $task - * @return Tasks + * @param ZFE_Model_Default_Tasks $task + * + * @return ZFE_Model_Default_Tasks */ - public function finish(Tasks $task) + public function finish(ZFE_Model_Default_Tasks $task) { $task->setDoneAt(new Doctrine_Expression('NOW()')); $task->setState(static::STATE_DONE); diff --git a/library/ZFE/Tasks/Performer.php b/library/ZFE/Tasks/Performer.php index 023a2de..8bbe81e 100644 --- a/library/ZFE/Tasks/Performer.php +++ b/library/ZFE/Tasks/Performer.php @@ -1,22 +1,34 @@ LazyPerson + * Application_Performer_LazyPerson -> LazyPerson. + * * @return string */ final public function getCode() @@ -27,7 +39,7 @@ final public function getCode() } /** - * Выполнить необходимые действия по задаче для указанной по id записи в БД + * Выполнить необходимые действия по задаче для указанной по id записи в БД. * * @param int $relatedItemId Идентификатор записи БД * @throw ZFE_Tasks_Performer_Exception diff --git a/library/ZFE/Tasks/Performer/ErrorStub.php b/library/ZFE/Tasks/Performer/ErrorStub.php index a2cc2fc..515db4a 100644 --- a/library/ZFE/Tasks/Performer/ErrorStub.php +++ b/library/ZFE/Tasks/Performer/ErrorStub.php @@ -1,5 +1,12 @@ setScheme($components['scheme']); } - if ( ! empty($components['login'])) { + if (!empty($components['login'])) { $uri->setLogin($components['login']); } - if ( ! empty($components['pass'])) { + if (!empty($components['pass'])) { $uri->setPassword($components['pass']); } - if ( ! empty($components['host'])) { + if (!empty($components['host'])) { $uri->setHost($components['host']); } - if ( ! empty($components['port'])) { + if (!empty($components['port'])) { $uri->setPort($components['port']); } - if ( ! empty($components['path'])) { + if (!empty($components['path'])) { $uri->setPath($components['path']); } - if ( ! empty($components['query'])) { + if (!empty($components['query'])) { $uri->setQuery($uri->parseQuery($components['query'])); } - if ( ! empty($components['fragment'])) { + if (!empty($components['fragment'])) { $uri->setFragment($components['fragment']); } @@ -160,7 +160,7 @@ public static function parseUri(string $uri) * Указать схему. * * @param string|null $scheme - * + * * @return static|$this */ public function setScheme(?string $scheme) @@ -183,7 +183,7 @@ public function getScheme() * Указать логин. * * @param string|null $login - * + * * @return static|$this */ public function setLogin(?string $login) @@ -206,7 +206,7 @@ public function getLogin() * Указать пароль. * * @param string|null $password - * + * * @return static|$this */ public function setPassword(?string $password) @@ -229,7 +229,7 @@ public function getPassword() * Указать хост. * * @param string|null $host - * + * * @return static|$this */ public function setHost(?string $host) @@ -252,7 +252,7 @@ public function getHost() * Указать порт. * * @param int|null $port - * + * * @return static|$this */ public function setPort(?int $port) @@ -275,7 +275,7 @@ public function getPort() * Указать путь. * * @param string|null $path - * + * * @return static|$this */ public function setPath(?string $path) @@ -298,7 +298,7 @@ public function getPath() * Указать запрос. * * @param string|array $query - * + * * @return static|$this */ public function setQuery($query) @@ -319,7 +319,7 @@ public function setQuery($query) * * @param string $key * @param mixed $value - * + * * @return static|$this */ public function setQueryPart(string $key, $value) @@ -332,7 +332,7 @@ public function setQueryPart(string $key, $value) * Удалить параметр запроса. * * @param string $key - * + * * @return static|$this */ public function removeQueryPart(string $key) @@ -345,7 +345,7 @@ public function removeQueryPart(string $key) * Разобрать запрос на составляющие. * * @param string $string - * + * * @return array */ public static function parseQuery(string $string) @@ -389,7 +389,7 @@ public function getQueryParts() * Указать фрагмент. * * @param string|null $fragment - * + * * @return static|$this */ public function setFragment(?string $fragment) @@ -417,37 +417,37 @@ public function getUri() { $uri = ''; - if ( ! empty($this->_scheme)) { + if (!empty($this->_scheme)) { $uri .= $this->_scheme . '://'; } - if ( ! empty($this->_login)) { + if (!empty($this->_login)) { $uri .= $this->_login; - if ( ! empty($this->_password)) { + if (!empty($this->_password)) { $uri .= ':' . $this->_password; } $uri .= '@'; } - if ( ! empty($this->_host)) { + if (!empty($this->_host)) { $uri .= $this->_host; - if ( ! empty($this->_port)) { + if (!empty($this->_port)) { $uri .= ':' . $this->_port; } } - if ( ! empty($this->_path)) { + if (!empty($this->_path)) { $uri .= $this->_path; } - if ( ! empty($this->_query)) { + if (!empty($this->_query)) { $uri .= '?' . $this->getQuery(); } - if ( ! empty($this->_fragment)) { + if (!empty($this->_fragment)) { $uri .= '#' . $this->_fragment; } @@ -480,7 +480,7 @@ public function getParts(bool $showEmpty = false) 'fragment' => $this->_fragment, ]; - if ( ! $showEmpty) { + if (!$showEmpty) { return array_diff($parts, ['', null, []]); } diff --git a/library/ZFE/Uri/Route.php b/library/ZFE/Uri/Route.php index a4df5ed..c0b7576 100644 --- a/library/ZFE/Uri/Route.php +++ b/library/ZFE/Uri/Route.php @@ -73,7 +73,7 @@ public function __construct() * Указать модуль. * * @param string $module - * + * * @return static|$this */ public function setModule(?string $module) @@ -102,7 +102,7 @@ public function getModule(bool $useDefault = false) * Указать контроллер. * * @param string $controller - * + * * @return static|$this */ public function setController(?string $controller) @@ -131,7 +131,7 @@ public function getController(bool $useDefault = false) * Указать действие. * * @param string $action - * + * * @return static|$this */ public function setAction(?string $action) @@ -160,7 +160,7 @@ public function getAction(bool $useDefault = false) * Установить параметры. * * @param array $params - * + * * @return static|$this */ public function setParams(array $params) @@ -174,12 +174,12 @@ public function setParams(array $params) * * @param string $key * @param mixed $value - * + * * @return static|$this */ public function setParam(string $key, $value) { - if (in_array($value, [null, ''], true)) { + if (in_array($value, [null, ''])) { unset($this->_params[$key]); } else { $this->_params[$key] = $value; @@ -203,7 +203,7 @@ public function removeParam(string $key) * Получить параметр. * * @param string $key - * + * * @return mixed */ public function getParam(string $key) @@ -235,7 +235,7 @@ public function getParams() /** * Удалить все параметры. - * + * * @return static|$this */ public function clearParams() @@ -270,7 +270,7 @@ public static function fromString(string $string) } $query = $uri->getQueryParts(); - if ( ! empty($query)) { + if (!empty($query)) { foreach ($query as $key => $value) { $uri->setParam($key, $value); } @@ -314,7 +314,7 @@ public function getUri() /** * Упростить параметры. - * + * * @return static|$this */ public function simplifyParams() @@ -327,7 +327,7 @@ public function simplifyParams() * Упростить массив рекурсивно. * * @param array $array - * + * * @return array */ private static function _simplifyParamsRecursive(array $array) @@ -335,7 +335,7 @@ private static function _simplifyParamsRecursive(array $array) foreach ($array as $key => $value) { if (is_array($value)) { foreach (self::_simplifyParamsRecursive($value) as $v_key => $v_value) { - if ( ! in_array($v_value, [null, ''])) { + if (!in_array($v_value, [null, ''])) { $array[$key . '_' . $v_key] = $v_value; } } @@ -359,7 +359,7 @@ public function getParts(bool $showEmpty = false) 'params' => $this->getParams(), ]; - if ( ! $showEmpty) { + if (!$showEmpty) { return array_diff($parts, ['', null, []]); } diff --git a/library/ZFE/Validate/Color.php b/library/ZFE/Validate/Color.php index a9fce7b..63b4cd9 100644 --- a/library/ZFE/Validate/Color.php +++ b/library/ZFE/Validate/Color.php @@ -71,15 +71,15 @@ class ZFE_Validate_Color extends Zend_Validate_Abstract */ public function isValid($value) { - if ( ! is_string($value)) { + if (!is_string($value)) { $this->_error(self::INVALID); return false; } $this->_setValue($value); - if ( ! in_array(mb_strtolower($value), $this->_colors, true)) { + if (!in_array(mb_strtolower($value), $this->_colors)) { $len = mb_strlen($value); - if ('#' !== $value[0] || ! (4 === $len || 7 === $len) || ! ctype_xdigit(mb_substr($value, 1))) { + if ('#' !== $value[0] || !(4 === $len || 7 === $len) || !ctype_xdigit(mb_substr($value, 1))) { $this->_error(self::NOT_COLOR); return false; } diff --git a/library/ZFE/Validate/Date/Abstract.php b/library/ZFE/Validate/Date/Abstract.php index 7a29945..2b102c7 100644 --- a/library/ZFE/Validate/Date/Abstract.php +++ b/library/ZFE/Validate/Date/Abstract.php @@ -135,7 +135,7 @@ public function getDate() public function setDate($date) { require_once 'Zend/Date.php'; - if ( ! $date instanceof Zend_Date) { + if (!$date instanceof Zend_Date) { if (Zend_Date::isDate($date, $this->_format, $this->_locale)) { $date = new Zend_Date($date, $this->_format, $this->_locale); } @@ -231,7 +231,7 @@ public function getOrEqual() */ protected function _setValue($value) { - if ( ! $value instanceof Zend_Date) { + if (!$value instanceof Zend_Date) { // Before we convert our value to Zend_Date, let's make sure it's valid. require_once 'Zend/Validate/Date.php'; $validator = new Zend_Validate_Date($this->_format, $this->_locale); @@ -262,7 +262,7 @@ protected function _parseDate($context = null) // If our $date is a string and exists in our context array, then this means // the user passed in a field name as the date to parse. Let's get the value // from the field and convert it to a Zend_Date - if ( ! $this->_date instanceof Zend_Date) { + if (!$this->_date instanceof Zend_Date) { if (is_array($context) && key_exists($this->_date, $context)) { // Get the field value from the context array $date = $context[$this->_date]; diff --git a/library/ZFE/Validate/Date/GreaterThan.php b/library/ZFE/Validate/Date/GreaterThan.php index ad8af0f..f616d72 100644 --- a/library/ZFE/Validate/Date/GreaterThan.php +++ b/library/ZFE/Validate/Date/GreaterThan.php @@ -44,17 +44,17 @@ public function __construct($date, $format = null, $locale = null, $orEqual = fa */ public function isValid($value, $context = null) { - if ( ! $this->_setValue($value)) { + if (!$this->_setValue($value)) { return false; } - if ( ! $this->_parseDate($context)) { + if (!$this->_parseDate($context)) { return false; } $compare = $this->_value->compare($this->_date); $compare = ($this->_orEqual) ? ($compare >= 0) : ($compare > 0); - if ( ! $compare) { + if (!$compare) { $this->_error(self::NOT_GREATER); return false; } diff --git a/library/ZFE/Validate/Date/LessThan.php b/library/ZFE/Validate/Date/LessThan.php index 0f8054c..784d44c 100644 --- a/library/ZFE/Validate/Date/LessThan.php +++ b/library/ZFE/Validate/Date/LessThan.php @@ -44,17 +44,17 @@ public function __construct($date, $format = null, $locale = null, $orEqual = fa */ public function isValid($value, $context = null) { - if ( ! $this->_setValue($value)) { + if (!$this->_setValue($value)) { return false; } - if ( ! $this->_parseDate($context)) { + if (!$this->_parseDate($context)) { return false; } $compare = $this->_value->compare($this->_date); $compare = ($this->_orEqual) ? ($compare <= 0) : ($compare < 0); - if ( ! $compare) { + if (!$compare) { $this->_error(self::NOT_LESS); return false; } diff --git a/library/ZFE/Validate/Db/Abstract.php b/library/ZFE/Validate/Db/Abstract.php index 662fa8a..87e46aa 100644 --- a/library/ZFE/Validate/Db/Abstract.php +++ b/library/ZFE/Validate/Db/Abstract.php @@ -57,12 +57,12 @@ public function __construct($options) $options = func_get_args(); $temp['model'] = array_shift($options); $temp['field'] = array_shift($options); - if ( ! empty($options)) { + if (!empty($options)) { $temp['where'] = array_shift($options); } $options = $temp; - } elseif ( ! is_array($options)) { + } elseif (!is_array($options)) { throw new Zend_Validate_Exception('Не допустимый параметр!'); } @@ -154,7 +154,7 @@ public function setWhere($where) { if (is_string($where)) { $where = [$where]; - } elseif ( ! is_array($where) && null !== $where) { + } elseif (!is_array($where) && null !== $where) { throw new Zend_Validate_Exception('Не верный формат дополнительных условий'); } diff --git a/library/ZFE/Validate/GreaterThan.php b/library/ZFE/Validate/GreaterThan.php index c95df29..e84aceb 100644 --- a/library/ZFE/Validate/GreaterThan.php +++ b/library/ZFE/Validate/GreaterThan.php @@ -65,22 +65,22 @@ public function __construct($options) { if ($options instanceof Zend_Config) { $options = $options->toArray(); - } elseif ( ! is_array($options)) { + } elseif (!is_array($options)) { $options = func_get_args(); $temp['min'] = array_shift($options); - if ( ! empty($options)) { + if (!empty($options)) { $temp['inclusive'] = array_shift($options); } $options = $temp; } - if ( ! key_exists('min', $options)) { + if (!key_exists('min', $options)) { require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception("Missing option 'min'"); } - if ( ! key_exists('inclusive', $options)) { + if (!key_exists('inclusive', $options)) { $options['inclusive'] = false; } diff --git a/library/ZFE/Validate/LessThan.php b/library/ZFE/Validate/LessThan.php index dc97c57..44d03e6 100644 --- a/library/ZFE/Validate/LessThan.php +++ b/library/ZFE/Validate/LessThan.php @@ -64,22 +64,22 @@ public function __construct($options) { if ($options instanceof Zend_Config) { $options = $options->toArray(); - } elseif ( ! is_array($options)) { + } elseif (!is_array($options)) { $options = func_get_args(); $temp['max'] = array_shift($options); - if ( ! empty($options)) { + if (!empty($options)) { $temp['inclusive'] = array_shift($options); } $options = $temp; } - if ( ! key_exists('max', $options)) { + if (!key_exists('max', $options)) { require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception("Missing option 'max'"); } - if ( ! key_exists('inclusive', $options)) { + if (!key_exists('inclusive', $options)) { $options['inclusive'] = true; } diff --git a/library/ZFE/Validate/Url.php b/library/ZFE/Validate/Url.php index 57ffde2..23c2e94 100644 --- a/library/ZFE/Validate/Url.php +++ b/library/ZFE/Validate/Url.php @@ -65,7 +65,7 @@ public function isValid($value) // resource path . '(?:/\S*)?' . '$_iuS'; - if ( ! preg_match($pattern, $value)) { + if (!preg_match($pattern, $value)) { $this->_setValue((string) $value); $this->_error(self::INVALID); return false; diff --git a/library/ZFE/View/Helper/AbstractPartial.php b/library/ZFE/View/Helper/AbstractPartial.php index 81d4dbd..033be76 100644 --- a/library/ZFE/View/Helper/AbstractPartial.php +++ b/library/ZFE/View/Helper/AbstractPartial.php @@ -60,7 +60,7 @@ public function abstractPartial($name = null, $module = null, $model = null, $co $model = $module; } - if ( ! empty($model)) { + if (!empty($model)) { if (is_array($model)) { $view->assign($model); } elseif (is_object($model)) { diff --git a/library/ZFE/View/Helper/Alerts.php b/library/ZFE/View/Helper/Alerts.php index e6b64b8..8a07248 100644 --- a/library/ZFE/View/Helper/Alerts.php +++ b/library/ZFE/View/Helper/Alerts.php @@ -20,14 +20,14 @@ public function alerts() $session = new Zend_Session_Namespace('Notices'); - if ( ! isset($session->events) || empty($session->events)) { + if (!isset($session->events) || empty($session->events)) { return ''; } foreach ($session->events as $event) { $alerts[] = $this->_makeAlert( $event['message'], - isset($event['options']['type']) && ! empty($event['options']['type']) ? $event['options']['type'] : null + isset($event['options']['type']) && !empty($event['options']['type']) ? $event['options']['type'] : null ); } $session->events = null; diff --git a/library/ZFE/View/Helper/AutoFormat.php b/library/ZFE/View/Helper/AutoFormat.php index 4b7ebef..2073400 100644 --- a/library/ZFE/View/Helper/AutoFormat.php +++ b/library/ZFE/View/Helper/AutoFormat.php @@ -76,7 +76,7 @@ public function formatByTable(ZFE_Model_Table $table, $columnName, $value) { $modelName = $table->getClassnameToReturn(); - if (in_array($columnName, $modelName::$booleanFields, true)) { + if (in_array($columnName, $modelName::$booleanFields)) { return $value ? 'да' : 'нет'; } diff --git a/library/ZFE/View/Helper/ControlTabs.php b/library/ZFE/View/Helper/ControlTabs.php index 812d96f..3308639 100644 --- a/library/ZFE/View/Helper/ControlTabs.php +++ b/library/ZFE/View/Helper/ControlTabs.php @@ -104,7 +104,7 @@ public function setItem(ZFE_Model_AbstractRecord $item) */ public function addTab(string $name, array $tab, bool $replace = false) { - if ( ! $replace && key_exists($name, $this->_tabs)) { + if (!$replace && key_exists($name, $this->_tabs)) { throw new ZFE_View_Helper_Exception("Вкладка с названием '${name}' уже зарегистрирована."); } @@ -126,7 +126,7 @@ public function addTab(string $name, array $tab, bool $replace = false) */ public function modifyTab(string $name, array $settings, bool $skipMissing = false) { - if ( ! key_exists($name, $this->_tabs)) { + if (!key_exists($name, $this->_tabs)) { if ($skipMissing) { return $this; } @@ -138,7 +138,7 @@ public function modifyTab(string $name, array $settings, bool $skipMissing = fal } /** - * Удалить вкладку по коду вкладки + * Удалить вкладку по коду вкладки. * * @param string $name * @@ -165,7 +165,7 @@ public function setResource(string $resource) public function __toString() { - if ( ! ($this->_item instanceof ZFE_Model_AbstractRecord)) { + if (!($this->_item instanceof ZFE_Model_AbstractRecord)) { trigger_error('Невозможно отобразить вкладки: не передана запись $item.', E_USER_WARNING); return ''; } @@ -195,7 +195,7 @@ public function __toString() foreach ($this->_tabs as $tab) { $resource = $tab['resource'] ?? $this->_resource ?? $request->getControllerName(); $privilege = $tab['privilege'] ?? $tab['action']; - if ( ! $this->view->isAllowedMe($resource, $privilege)) { + if (!$this->view->isAllowedMe($resource, $privilege)) { continue; } @@ -214,7 +214,7 @@ public function __toString() } $isActive = $request->getActionName() === $tab['action']; - if ($isActive && ! empty($tab['params'])) { + if ($isActive && !empty($tab['params'])) { foreach ($tab['params'] as $param => $value) { if ($request->getParam($param) !== $value) { $isActive = false; @@ -223,7 +223,7 @@ public function __toString() } } - $isDisabled = ($onlyRegistered && ! $this->_item->exists()) + $isDisabled = ($onlyRegistered && !$this->_item->exists()) || ($onlyValid && $this->_item->isDeleted()); $class = []; diff --git a/library/ZFE/View/Helper/CrazyButtons.php b/library/ZFE/View/Helper/CrazyButtons.php index c2ffaaa..45af0b2 100644 --- a/library/ZFE/View/Helper/CrazyButtons.php +++ b/library/ZFE/View/Helper/CrazyButtons.php @@ -93,7 +93,7 @@ public function one(array $button, $class = 'btn btn-default') { $label = $button['label']; - if ( ! empty($button['ico'])) { + if (!empty($button['ico'])) { $ico = $this->view->tag('span', ['class' => $button['ico']]); } else { $ico = ''; diff --git a/library/ZFE/View/Helper/DateForHuman.php b/library/ZFE/View/Helper/DateForHuman.php index 8080a8c..5e07cab 100644 --- a/library/ZFE/View/Helper/DateForHuman.php +++ b/library/ZFE/View/Helper/DateForHuman.php @@ -33,7 +33,7 @@ class ZFE_View_Helper_DateForHuman extends Zend_View_Helper_Abstract */ public function dateForHuman($date) { - if ( ! $date || ! $timestamp = strtotime($date)) { + if (!$date || !$timestamp = strtotime($date)) { return ''; } diff --git a/library/ZFE/View/Helper/DateTime.php b/library/ZFE/View/Helper/DateTime.php index 32e83c5..c228021 100644 --- a/library/ZFE/View/Helper/DateTime.php +++ b/library/ZFE/View/Helper/DateTime.php @@ -26,12 +26,12 @@ class ZFE_View_Helper_DateTime extends Zend_View_Helper_Abstract */ public function dateTime($dateTime, $time = true) { - if (in_array($dateTime, ['0000-00-00', '0000-00-00 00:00:00'], true)) { + if (in_array($dateTime, ['0000-00-00', '0000-00-00 00:00:00'])) { return ''; } $timestamp = strtotime($dateTime); - if ( ! $timestamp) { + if (!$timestamp) { return ''; } diff --git a/library/ZFE/View/Helper/DateTimeCompact.php b/library/ZFE/View/Helper/DateTimeCompact.php index 3156a92..d042ea3 100644 --- a/library/ZFE/View/Helper/DateTimeCompact.php +++ b/library/ZFE/View/Helper/DateTimeCompact.php @@ -18,7 +18,7 @@ class ZFE_View_Helper_DateTimeCompact extends Zend_View_Helper_Abstract */ public function dateTimeCompact($dateTime) { - if ( ! $dateTime || ! $timestamp = strtotime($dateTime)) { + if (!$dateTime || !$timestamp = strtotime($dateTime)) { return ''; } diff --git a/library/ZFE/View/Helper/Fieldset.php b/library/ZFE/View/Helper/Fieldset.php index 53cdbf5..c34d1d9 100644 --- a/library/ZFE/View/Helper/Fieldset.php +++ b/library/ZFE/View/Helper/Fieldset.php @@ -27,7 +27,7 @@ public function fieldset($name, $content, $attribs = null) $legend = ''; if (isset($attribs['legend'])) { $legendString = trim($attribs['legend']); - if ( ! empty($legendString)) { + if (!empty($legendString)) { $legend = (empty($attribs['legend_class']) ? '', $output); $output = preg_replace('/<\/pre>$/', '