Skip to content

Commit

Permalink
remove deprecations. add phpstan
Browse files Browse the repository at this point in the history
  • Loading branch information
dereuromark committed Dec 15, 2018
1 parent 6c5ce05 commit 57e6f0b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 16 deletions.
2 changes: 2 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
"test": "php phpunit.phar",
"test-setup": "[ ! -f phpunit.phar ] && wget https://phar.phpunit.de/phpunit-6.5.8.phar && mv phpunit-6.5.8.phar phpunit.phar || true",
"test-coverage": "php phpunit.phar --log-junit tmp/coverage/unitreport.xml --coverage-html tmp/coverage --coverage-clover tmp/coverage/coverage.xml",
"phpstan": "phpstan analyse -c tests/phpstan.neon -l 3 src/",
"phpstan-setup": "cp composer.json composer.backup && composer require --dev phpstan/phpstan && mv composer.backup composer.json",
"cs-check": "phpcs -p --standard=vendor/fig-r/psr2r-sniffer/PSR2R/ruleset.xml --ignore=/cakephp-ratings/vendor/,/tmp/,/logs/,/config/Migrations/ --extensions=php ./",
"cs-fix": "phpcbf -v --standard=vendor/fig-r/psr2r-sniffer/PSR2R/ruleset.xml --ignore=/cakephp-ratings/vendor/,/tmp/,/logs/,/config/Migrations/ --extensions=php ./"
}
Expand Down
27 changes: 12 additions & 15 deletions src/Controller/Component/RatingComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ class RatingComponent extends Component {
*/
public $components = ['RequestHandler', 'Flash'];

/**
* @var \Cake\Controller\Controller
*/
protected $Controller;

/**
* @var array
*/
Expand All @@ -36,24 +41,16 @@ class RatingComponent extends Component {
'userIdField' => 'id',
];

/**
* Callback
*
* @param array $config The configuration settings provided to this component.
* @return void
*/
public function initialize(array $config) {
parent::initialize($config);
}

/**
* Callback
*
* @param \Cake\Event\Event $event
* @return \Cake\Network\Response|array|null
* @return \Cake\Http\Response|array|null
*/
public function startup(Event $event) {
$this->Controller = $event->getSubject();
/** @var \Cake\Controller\Controller $controller */
$controller = $event->getSubject();
$this->Controller = $controller;

$actions = $this->getConfig('actions');
if ($actions) {
Expand Down Expand Up @@ -95,7 +92,7 @@ public function startup(Event $event) {
* @param string $rating
* @param string|int $user
* @param bool|string|array $redirect boolean to redirect to same url or string or array to use it for Router::url()
* @return \Cake\Network\Response|null
* @return \Cake\Http\Response|null
*/
public function rate($rate, $rating, $user, $redirect = false) {
$Controller = $this->Controller;
Expand Down Expand Up @@ -146,7 +143,7 @@ public function buildUrl() {
$params = array_merge($params, $this->Controller->request->params['pass']);

$ratingParams = array_keys($this->_config['params']);
foreach ($this->Controller->request->query as $name => $value) {
foreach ($this->Controller->request->getQuery() as $name => $value) {
if (!in_array($name, $ratingParams)) {
$params['?'][$name] = $value;
}
Expand All @@ -160,7 +157,7 @@ public function buildUrl() {
*
* @param array|string $url
* @param string|null $status
* @return \Cake\Network\Response|null
* @return \Cake\Http\Response|null
*/
public function redirect($url, $status = null) {
if (!empty($this->Controller->viewVars['authMessage']) && !empty($this->Controller->request->params['isJson'])) {
Expand Down
2 changes: 1 addition & 1 deletion src/View/Helper/RatingHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ public function starForm($options, $htmlAttributes = []) {
$result .= '</div>';
if ($options['createForm']) {
if (!empty($options['target']) && !empty($options['createForm']['url']) && !empty($options['createForm']['ajaxOptions'])) {
$result .= $this->Js->submit(__d('ratings', 'Rate!'), array_merge(['url' => $options['createForm']['url']], $options['createForm']['ajaxOptions'])) . "\n";
//$result .= $this->Js->submit(__d('ratings', 'Rate!'), array_merge(['url' => $options['createForm']['url']], $options['createForm']['ajaxOptions'])) . "\n";
$flush = true;
} else {
$result .= $this->Form->button(__d('ratings', 'Rate!')) . "\n";
Expand Down
5 changes: 5 additions & 0 deletions tests/phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
parameters:
autoload_files:
- tests/bootstrap.php

ignoreErrors:

0 comments on commit 57e6f0b

Please sign in to comment.