diff --git a/app/router/Route.php b/app/router/Route.php index 7f42f31..4f2a623 100644 --- a/app/router/Route.php +++ b/app/router/Route.php @@ -27,6 +27,7 @@ class Route /** * @param array $request + * @return bool */ public function match($request) { diff --git a/classes/Format.class.php b/classes/Format.class.php index fbefc25..f5c6b06 100644 --- a/classes/Format.class.php +++ b/classes/Format.class.php @@ -229,4 +229,3 @@ class Format * Оффсет с учетом летнего/зимнего времени */ Format::setTimezoneOffset(date('Z') - ((date('I') ? 60*60 : 0 ))); -?> \ No newline at end of file diff --git a/classes/User.class.php b/classes/User.class.php index c5b9229..06ff07f 100644 --- a/classes/User.class.php +++ b/classes/User.class.php @@ -116,4 +116,3 @@ class User return $model->getById($id); } } -?> \ No newline at end of file diff --git a/exception/ErrorHandler.php b/exception/ErrorHandler.php index 954f8dc..058f9f6 100644 --- a/exception/ErrorHandler.php +++ b/exception/ErrorHandler.php @@ -73,6 +73,7 @@ class ErrorHandler /** * @param Exception $exception + * @return string */ static public function showDebug($exception) { diff --git a/form/Form.php b/form/Form.php index c867b0d..ea4d233 100644 --- a/form/Form.php +++ b/form/Form.php @@ -13,21 +13,31 @@ abstract class Form { const SUCCESS = 'success'; - const ERROR = 'error'; - + + const ERROR = 'error'; + + /** + * @var FormField[] + */ protected $fields = array(); - protected $messages = array(self::SUCCESS => 'Form data valid', - self::ERROR => 'Form data invalid'); - + + /** + * @var array + */ + protected $messages = array( + self::SUCCESS => 'Form data valid', + self::ERROR => 'Form data invalid'); + protected $valid = true; - + public function __construct() { $this->init(); } - + /** * @param string $name + * @param bool|string $message * @return FormField */ protected function addField($name, $message = false) @@ -35,13 +45,13 @@ abstract class Form $this->fields[$name] = new FormField($message); return $this->fields[$name]; } - + public function isValid($data) { if (!is_array($data)) { throw new InitializationException(__CLASS__ . '::' . __METHOD__ . ' expects an array'); } - + foreach ($this->fields as $field_name => $field) { if (isset($data[$field_name])) { $this->valid &= $field->isValid($data[$field_name], $data); @@ -54,7 +64,7 @@ abstract class Form } return $this->valid; } - + public function getMessages() { $messages = array(); @@ -65,7 +75,7 @@ abstract class Form } return $messages; } - + public function getValue($key) { if (isset($this->fields[$key])) { @@ -73,7 +83,10 @@ abstract class Form } return false; } - + + /** + * @return array + */ public function getValues() { $values = array(); @@ -84,7 +97,10 @@ abstract class Form } return $values; } - + + /** + * @return array + */ public function getSourceValues() { $values = array(); @@ -93,35 +109,49 @@ abstract class Form } return $values; } - + + /** + * @return string + */ public function getMessageType() { return ($this->valid) ? self::SUCCESS : self::ERROR; } - + + /** + * @return string + */ public function getMessage() { return $this->messages[$this->getMessageType()]; } - + + /** + * @param string $message + * @return Form + */ public function setSuccessMessage($message) { $this->messages[self::SUCCESS] = (string) $message; return $this; } - + + /** + * @param string $message + * @return Form + */ public function setErrorMessage($message) { $this->messages[self::ERROR] = (string) $message; return $this; } - + protected function fillHelperData() { $data['messages'] = $this->getMessages(); $data['values'] = $this->getSourceValues(); Session::set(get_class($this), $data); } - + abstract protected function init(); } \ No newline at end of file diff --git a/form/FormField.php b/form/FormField.php index 0e93d03..2e8a345 100644 --- a/form/FormField.php +++ b/form/FormField.php @@ -1,7 +1,7 @@ - * @link http://netmonsters.ru + * @link http://netmonsters.ru * @package Majestic * @subpackage form * @since 2010-04-25 @@ -11,51 +11,93 @@ class FormField { - + /** + * @var iValidator[] + */ protected $validators = array(); + + /** + * @var iFilter[] + */ protected $filters = array(); - + /** * Used instead message of validator if defined. - * + * * @var string */ protected $default_message = false; + + /** + * @var string + */ protected $message = false; + + /** + * @var mixed + */ protected $value; - + /* Flags */ + /** + * @var bool + */ protected $required = true; + + /** + * @var bool + */ protected $ignored = false; - - + + + /** + * @param bool|string $default_message + */ public function __construct($default_message = false) { $this->default_message = $default_message; } - + + /** + * @param bool $flag + * @return FormField + */ public function setRequired($flag) { $this->required = (bool) $flag; return $this; } - + + /** + * @return bool + */ public function isRequired() { return $this->required; } - + + /** + * @param bool $flag + * @return FormField + */ public function setIgnored($flag) { $this->ignored = (bool) $flag; return $this; } - + + /** + * @return bool + */ public function isIgnored() { return $this->ignored; } - + + /** + * @param string[]|iValidator[] $validators + * @return FormField + */ public function addValidators($validators) { foreach ($validators as $validator) { @@ -63,7 +105,12 @@ class FormField } return $this; } - + + /** + * @param string|iValidator $validator + * @return FormField + * @throws InitializationException + */ public function addValidator($validator) { if ($validator instanceof iValidator) { @@ -77,7 +124,7 @@ class FormField $this->validators[$name] = $validator; return $this; } - + public function addFilters($filters) { foreach ($filters as $filter) { @@ -85,10 +132,10 @@ class FormField } return $this; } - + public function addFilter($filter) { - if ($filter instanceof iFilter) { + if ($filter instanceof iFilter) { $name = get_class($filter); } elseif (is_string($filter)) { $name = $filter . 'Filter'; @@ -99,7 +146,7 @@ class FormField $this->filters[$name] = $filter; return $this; } - + public function getValue() { $value = $this->value; @@ -110,10 +157,10 @@ class FormField } return $value; } - + /** * $value & $key for array_walk_recursive - * + * * @param mixed $value * @param mixed $key */ @@ -123,24 +170,24 @@ class FormField $value = $filter->filter($value); } } - + public function getSourceValue() { return $this->value; } - + public function isValid($value, $context = null) { $this->value = $value; // filtered value here $value = $this->getValue(); - + $valid = true; - + if ((($value === '') || ($value === null)) && !$this->isRequired()) { return $valid; } - + foreach ($this->validators as $validator) { if (is_array($value)) { foreach ($value as $val) { @@ -158,14 +205,14 @@ class FormField } elseif ($validator->isValid($value, $context)) { continue; } - + $valid = false; $this->message = ($this->default_message) ? $this->default_message : $validator->getMessage(); break; } return $valid; } - + public function getMessage() { return $this->message; diff --git a/i18n/I18N.php b/i18n/I18N.php index 1867436..2dd043a 100644 --- a/i18n/I18N.php +++ b/i18n/I18N.php @@ -20,10 +20,11 @@ class I18N static protected $lang = ''; static protected $locale = ''; - - + + /** - * @param mixed $lang default language set + * @throws InitializationException + * @internal mixed $lang default language set */ static public function init() { diff --git a/model/MongoStatement.php b/model/MongoStatement.php index 221e49c..91dd585 100644 --- a/model/MongoStatement.php +++ b/model/MongoStatement.php @@ -131,6 +131,7 @@ class MongoStatement extends DbStatement /** * @param MongoDbCommand $request + * @throws GeneralException * @return bool */ protected function driverExecute($request)