Skip to content

Commit

Permalink
Merge pull request #228 from mmoll/phpstan
Browse files Browse the repository at this point in the history
Apply suggested PHPStan changes
  • Loading branch information
jorgelzpz committed Nov 16, 2017
2 parents aa8247b + 88a2484 commit 4b544ed
Show file tree
Hide file tree
Showing 35 changed files with 131 additions and 81 deletions.
12 changes: 6 additions & 6 deletions web/src/CalDAV/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@

class Client
{
/** @type AgenDAV\Http\Client HTTP client used */
/** @type \AgenDAV\Http\Client HTTP client used */

protected $http_client;

/** @type AgenDAV\XML\Toolkit XML toolkit */
/** @type \AgenDAV\XML\Toolkit XML toolkit */
protected $xml_toolkit;

/** @type AgenDAV\Event\Parser Event parser */
/** @type \AgenDAV\Event\Parser Event parser */
protected $event_parser;


Expand Down Expand Up @@ -197,7 +197,7 @@ public function getCalendarByUrl($url)
/**
* Creates a calendar collection
*
* @param AgenDAV\CalDAV\Resource\Calendar $calendar Calendar that we want to create
* @param \AgenDAV\CalDAV\Resource\Calendar $calendar Calendar that we want to create
* @return void
*/
public function createCalendar(Calendar $calendar)
Expand Down Expand Up @@ -287,7 +287,7 @@ public function fetchObjectByUid(Calendar $calendar, $uid)
/**
* Puts an calendar object on the CalDAV server, inside its parent collection
*
* @param AgenDAV\CalDAV\Resource\CalendarObject $calendar_object
* @param \AgenDAV\CalDAV\Resource\CalendarObject $calendar_object
* @return \GuzzleHttp\Psr7\Response
*/
public function uploadCalendarObject(CalendarObject $calendar_object)
Expand Down Expand Up @@ -388,7 +388,7 @@ public function report($url, $body, $depth = 1)
* Converts a pre-parsed REPORT response to an array of CalendarObject
*
* @param array Data returned by report()
* @param AgenDAV\CalDAV\Resource\Calendar $calendar Calendar these objects come from
* @param \AgenDAV\CalDAV\Resource\Calendar $calendar Calendar these objects come from
* @return array of CalendarObject
*/
protected function buildObjectCollection(array $raw_data, Calendar $calendar)
Expand Down
2 changes: 1 addition & 1 deletion web/src/CalDAV/Resource/CalendarObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class CalendarObject
/**
* Contained event
*
* @var string
* @var \AgenDAV\Event
*/
protected $event;

Expand Down
2 changes: 1 addition & 1 deletion web/src/CalDAV/Share/ACL.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class ACL
/**
* Creates a new ACL
*
* @param AgenDAV\CalDAV\Share\Permissions $permissions
* @param \AgenDAV\CalDAV\Share\Permissions $permissions
*/
public function __construct(Permissions $permissions)
{
Expand Down
2 changes: 1 addition & 1 deletion web/src/CalendarFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class CalendarFinder
protected $current_principal;

/**
* @param Symfony\Component\HttpFoundation\Session\Session $session
* @param \Symfony\Component\HttpFoundation\Session\Session $session
* @param \AgenDAV\CalDAV\Client $client
*/
public function __construct(Session $session, Client $client)
Expand Down
2 changes: 1 addition & 1 deletion web/src/Controller/Calendars/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Create extends JSONController
/**
* Validates user input
*
* @param Symfony\Component\HttpFoundation\ParameterBag $input
* @param \Symfony\Component\HttpFoundation\ParameterBag $input
* @return bool
*/
protected function validateInput(ParameterBag $input)
Expand Down
2 changes: 1 addition & 1 deletion web/src/Controller/Calendars/Delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Delete extends JSONController
/**
* Validates user input
*
* @param Symfony\Component\HttpFoundation\ParameterBag $input
* @param \Symfony\Component\HttpFoundation\ParameterBag $input
* @return bool
*/
protected function validateInput(ParameterBag $input)
Expand Down
4 changes: 2 additions & 2 deletions web/src/Controller/Calendars/Save.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Save extends JSONController
/**
* Validates user input
*
* @param Symfony\Component\HttpFoundation\ParameterBag $input
* @param \Symfony\Component\HttpFoundation\ParameterBag $input
* @return bool
*/
protected function validateInput(ParameterBag $input)
Expand Down Expand Up @@ -138,7 +138,7 @@ protected function updateCalDAV($calendar)
/**
* Saves calendar name and color into the Share object
*
* @param AgenDAV\Data\Share $share
* @param \AgenDAV\Data\Share $share
* @param ParameterBag $input
* @return void
*/
Expand Down
2 changes: 1 addition & 1 deletion web/src/Controller/Event/Alter.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ abstract class Alter extends JSONController
/**
* Validates user input
*
* @param Symfony\Component\HttpFoundation\ParameterBag $input
* @param \Symfony\Component\HttpFoundation\ParameterBag $input
* @return bool
*/
protected function validateInput(ParameterBag $input)
Expand Down
2 changes: 1 addition & 1 deletion web/src/Controller/Event/Delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Delete extends JSONController
/**
* Validates user input
*
* @param Symfony\Component\HttpFoundation\ParameterBag $input
* @param \Symfony\Component\HttpFoundation\ParameterBag $input
* @return bool
*/
protected function validateInput(ParameterBag $input)
Expand Down
3 changes: 2 additions & 1 deletion web/src/Controller/Event/Drop.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Drop extends Alter
* @param \AgenDAV\EventInstance $instance
* @param \DateTimeZone $timezone
* @param int $minutes
* @param Symfony\Component\HttpFoundation\ParameterBag $input
* @param \Symfony\Component\HttpFoundation\ParameterBag $input
*/
protected function modifyInstance(
EventInstance $instance,
Expand Down Expand Up @@ -96,6 +96,7 @@ protected function modifyInstance(
*
* @param string $was_allday Possible values: 'true' or 'false'
* @param string $now_allday Possible values: 'true' or 'false'
*
* @return int One of the constants from this class
*/
protected function describeMovement($was_allday, $now_allday)
Expand Down
5 changes: 3 additions & 2 deletions web/src/Controller/Event/GetBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,11 @@ protected function buildFullCalendarEvent(Calendar $calendar, CalendarObject $ob
/**
* Serialize a list of FullCalendar events using Fractal
*
* @param \AgenDAV\Event\FullCalendarEven $event FullCalendar event
* @param \AgenDAV\Event\FullCalendarEvent $event FullCalendar event
* @param \DateTimeZone $timezone Time zone the user has
* @param \Silex\Application $app
* @return array
*
* @return JsonResponse
*/
protected function serializeEvent(FullCalendarEvent $event, \DateTimeZone $timezone, Application $app)
{
Expand Down
7 changes: 4 additions & 3 deletions web/src/Controller/Event/Listing.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function __construct()
/**
* Validates user input
*
* @param Symfony\Component\HttpFoundation\ParameterBag $input
* @param \Symfony\Component\HttpFoundation\ParameterBag $input
* @return bool
*/
protected function validateInput(ParameterBag $input)
Expand Down Expand Up @@ -112,7 +112,7 @@ protected function execute(ParameterBag $input, Application $app)
*/
protected function getTimeFilterDatestring(\DateTimeImmutable $datetime)
{
$datetime_utc = $datetime->setTimeZone($this->utc);
$datetime_utc = $datetime->setTimezone($this->utc);

return $datetime_utc->format('Ymd\THis\Z');
}
Expand Down Expand Up @@ -146,7 +146,8 @@ protected function buildFullCalendarEvents(
* @param array $events FullCalendar events
* @param \DateTimeZone $timezone Time zone the user has
* @param \Silex\Application $app
* @return array
*
* @return JsonResponse
*/
protected function serializeFullCalendarEvents(array $events, \DateTimeZone $timezone, Application $app)
{
Expand Down
4 changes: 2 additions & 2 deletions web/src/Controller/Event/Save.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Save extends JSONController
/**
* Validates user input
*
* @param Symfony\Component\HttpFoundation\ParameterBag $input
* @param \Symfony\Component\HttpFoundation\ParameterBag $input
* @return bool
*/
protected function validateInput(ParameterBag $input)
Expand Down Expand Up @@ -89,7 +89,7 @@ public function execute(ParameterBag $input, Application $app)
* Decides whether this request tries to create a new event or update
* an existing one
*
* @param Symfony\Component\HttpFoundation\ParameterBag $input
* @param \Symfony\Component\HttpFoundation\ParameterBag $input
* @return bool
*/
protected function isModification(ParameterBag $input)
Expand Down
3 changes: 2 additions & 1 deletion web/src/Controller/JSONController.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ protected function validateInput(ParameterBag $input)
*
* @param \Symfony\Component\HttpFoundation\ParameterBag $input
* @param \Silex\Application $app
* @return array
*
* @return JsonResponse
*/
abstract protected function execute(ParameterBag $input, Application $app);

Expand Down
2 changes: 1 addition & 1 deletion web/src/Controller/Preferences.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function saveAction(Request $request, Application $app)
if (!$input->has('language') || !$input->has('timezone') || !$input->has('default_calendar')
|| !$input->has('date_format') || !$input->has('time_format') || !$input->has('weekstart')
|| !$input->has('show_week_nb')) {
$app->abort('400', $app['translator']->trans('messages.error_empty_fields'));
$app->abort(400, $app['translator']->trans('messages.error_empty_fields'));
}

$username = $app['session']->get('username');
Expand Down
3 changes: 2 additions & 1 deletion web/src/Csrf.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ public static function check(Request $request, Application $app)
/**
* Returns current CSRF token
*
* @param Silex\Application $app
* @param \Silex\Application $app
*
* @return \Symfony\Component\Security\Csrf\CsrfToken
*/
public static function getCurrentToken(Application $app)
Expand Down
6 changes: 3 additions & 3 deletions web/src/DB/Migrations/Version20140812133707.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ protected function createSharesTable(Schema $schema)
{
$shares_table = $schema->createTable('shares');
$sid = $shares_table->addColumn('sid', 'integer', ['unsigned' => true]);
$sid->setAutoIncrement(true);
$sid->setAutoincrement(true);
$shares_table->addColumn('owner', 'string', ['length' => 255]);
$shares_table->addColumn('calendar', 'string', ['length' => 255]);
$shares_table->addColumn('with', 'string', ['length' => 255]);
Expand All @@ -46,8 +46,8 @@ public function createSessionsTable(Schema $schema)
{
$sessions = $schema->createTable('sessions');
$sessions->addColumn('sess_id', 'string');
$sessions->addColumn('sess_data', 'text')->setNotNull(true);
$sessions->addColumn('sess_time', 'integer')->setNotNull(true)->setUnsigned(true);
$sessions->addColumn('sess_data', 'text')->setNotnull(true);
$sessions->addColumn('sess_time', 'integer')->setNotnull(true)->setUnsigned(true);
$sessions->setPrimaryKey(array('sess_id'));
}

Expand Down
2 changes: 1 addition & 1 deletion web/src/DB/Migrations/Version20150804202842.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function up(Schema $schema)
$this->write('Creating table principals');

$principals = $schema->createTable('principals');
$principals->addColumn('path', 'string', ['length' => 255])->setNotNull(true);
$principals->addColumn('path', 'string', ['length' => 255])->setNotnull(true);
$principals->addColumn('display_name', 'string', ['length' => 255]);
$principals->addColumn('email', 'string', ['length' => 255]);

Expand Down
2 changes: 1 addition & 1 deletion web/src/DB/Migrations/Version20151028190444.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Version20151028190444 extends AbstractMigration
public function up(Schema $schema)
{
$principals = $schema->createTable('principals');
$principals->addColumn('url', 'string', ['length' => 255])->setNotNull(true);
$principals->addColumn('url', 'string', ['length' => 255])->setNotnull(true);
$principals->addColumn('displayname', 'string', ['length' => 255]);
$principals->addColumn('email', 'string', ['length' => 255]);

Expand Down
24 changes: 21 additions & 3 deletions web/src/Data/Preferences.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
* along with AgenDAV. If not, see <http://www.gnu.org/licenses/>.
*/


use Doctrine\ORM\Mapping\Column;
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\Id;
use Doctrine\ORM\Mapping\Table;
/**
* Holds user preferences
*/
Expand All @@ -32,7 +35,10 @@
*/
class Preferences
{
/** @Id @Column(type="string") */
/**
* @Id
* @Column(type="string")
*/
private $username;

/** @Column(type="json_array") */
Expand All @@ -48,8 +54,18 @@ public function __set($name, $value) {
$this->options[$name] = $value;
}


/**
* @param $name
*
* @return bool
*/
public function __isset($name) {
return array_key_exists($name, $this->options);
}

public function __get($name) {
if (array_key_exists($name, $this->options)) {
if ($this->__isset($name)) {
return $this->options[$name];
} else {
return null;
Expand All @@ -61,6 +77,7 @@ public function __get($name) {
*
* @param string $name Preference name
* @param mixed $default_value Default value if preference is not set
*
* @return mixed Preference value, or default_value if it is not set
*/
public function get($name, $default_value = null)
Expand Down Expand Up @@ -95,6 +112,7 @@ public function setAll($options) {
* has a value, it will not get overwritten
*
* @param array $defaults
*
* @return void
*/
public function addDefaults(array $defaults)
Expand Down
10 changes: 9 additions & 1 deletion web/src/Data/Principal.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,21 @@
* along with AgenDAV. If not, see <http://www.gnu.org/licenses/>.
*/

use Doctrine\ORM\Mapping\Column;
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\Id;
use Doctrine\ORM\Mapping\Table;

/**
* @Entity
* @Table(name="principals")
*/
class Principal
{
/** @Id @Column(type="string") */
/**
* @Id
* @Column(type="string")
*/
private $url;

/** @Column(type="string") */
Expand Down

0 comments on commit 4b544ed

Please sign in to comment.