Skip to content

Commit

Permalink
Merge pull request #1160 from Intermesh/feature/1159-phpstan
Browse files Browse the repository at this point in the history
  • Loading branch information
mschering authored Jun 28, 2024
2 parents 7680b27 + 71e427d commit b7f390f
Show file tree
Hide file tree
Showing 12 changed files with 118 additions and 14 deletions.
32 changes: 32 additions & 0 deletions tests/phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
parameters:

level: 3

parallel:
processTimeout: 100.00
fileExtensions:
- php

paths:
- %currentWorkingDirectory%/go

scanDirectories:
- %currentWorkingDirectory%/api
- %currentWorkingDirectory%/controller
- %currentWorkingDirectory%/go
- %currentWorkingDirectory%/modules

excludePaths:
analyse:
- */vendor/*

reportUnmatchedIgnoredErrors: false
treatPhpDocTypesAsCertain: false
ignoreErrors:
- identifier: missingType.iterableValue
- identifier: missingType.generics
- '#Class .* referenced with incorrect case: .*#'
- '#Variable .* in empty\(\) always exists and is always falsy.#'
- '#Variable .* in empty\(\) always exists and is not falsy.#'
- '#Variable .* in isset\(\) always exists and is always null.#'
- '#Unsafe usage of new static\(\).#'
6 changes: 5 additions & 1 deletion www/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,18 @@
}
],
"require-dev": {
"phpunit/phpunit": "*"
"phpunit/phpunit": "*",
"phpstan/phpstan": "^1.11"
},
"autoload": {
"psr-4": {
"go\\core\\": "go/core/",
"go\\modules\\": "go/modules/"
}
},
"scripts": {
"go:analyse": "./vendor/phpstan/phpstan/phpstan analyse -c ../tests/phpstan.neon --memory-limit=1G;"
},
"config": {
"optimize-autoloader": true,
"platform": {
Expand Down
60 changes: 59 additions & 1 deletion www/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion www/go/base/db/ActiveRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public function modelTypeId(){

/**
* For compatibility with new framework
* @return type
* @return \go\core\orm\EntityType
*/
public static function entityType() {
return \go\core\orm\EntityType::findByClassName(static::class);
Expand Down
2 changes: 1 addition & 1 deletion www/go/base/fs/Folder.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public static function tempFolder($sub=''){
*
* @param boolean $getHidden
* @param boolean|string $sort 'mtime','ctime' or 'name'
* @return File or Folder
* @return false|File[]|Folder[]
*/
public function ls($getHidden=false, $sort=false) {
if (!$dir = opendir($this->path))
Expand Down
3 changes: 1 addition & 2 deletions www/go/base/wbxml/Decoder.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<?php
//chdir(\GO::config()->root_path.'go/vendor/XML_WBXML/WBXML/');
require_once(\GO::config()->root_path.'go/vendor/XML_WBXML/WBXML/Decoder.php');

namespace GO\Base\Wbxml;

require_once(\GO::config()->root_path.'go/vendor/XML_WBXML/WBXML/Decoder.php');

class Decoder extends XML_WBXML_Decoder{

Expand Down
2 changes: 1 addition & 1 deletion www/go/base/wbxml/Encoder.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
require_once(\GO::config()->root_path.'go/vendor/XML_WBXML/WBXML/Encoder.php');

namespace GO\Base\Wbxml;

require_once(\GO::config()->root_path.'go/vendor/XML_WBXML/WBXML/Encoder.php');

class Encoder extends XML_WBXML_Encoder{

Expand Down
3 changes: 3 additions & 0 deletions www/go/core/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,9 @@ public function getUserId(): ?int
return null;
}

/**
* @return \go\core\model\Settings
*/
public function getSettings()
{
return Settings::get();
Expand Down
2 changes: 1 addition & 1 deletion www/go/core/data/convert/Spreadsheet.php
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ public final function getHeaders() {
*
* @param string $entityCls
* @param bool $forMapping
* @return string[]
* @return string[][]
* @throws Exception
*/
protected function internalGetHeaders(bool $forMapping = false) {
Expand Down
4 changes: 2 additions & 2 deletions www/go/core/fs/Blob.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class Blob extends orm\Entity {
/**
* Modified at
*
* @var DateTime
* @var ?DateTime
*/
public $modifiedAt;

Expand All @@ -86,7 +86,7 @@ class Blob extends orm\Entity {
/**
* Blob can be deleted after this date
*
* @var DateTime
* @var ?DateTime
*/
public $staleAt;

Expand Down
8 changes: 4 additions & 4 deletions www/go/core/jmap/EntityController.php
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ private function destroyEntities(array $destroy, ArrayObject $result) {
* Takes the request arguments, validates them and fills it with defaults.
*
* @param array $params
* @return array
* @return ArrayObject
* @throws InvalidArguments
*/
protected function paramsGetUpdates(array $params): ArrayObject
Expand Down Expand Up @@ -956,7 +956,7 @@ protected function paramsImport($params) : ArrayObject {
* Default handler for Foo/import method
*
* @param array $params
* @return array
* @return ArrayObject
* @throws Exception
*/
protected function defaultImport(array $params): ArrayObject
Expand Down Expand Up @@ -1005,7 +1005,7 @@ protected function defaultExportColumns($params): ArrayObject
* Default handler for Foo/importCSVMapping method
*
* @param array $params
* @return array
* @return ArrayObject
* @throws Exception
*/
protected function defaultImportCSVMapping(array $params): ArrayObject
Expand Down Expand Up @@ -1079,7 +1079,7 @@ private function findConverter(string $extension): AbstractConverter
* Foo/export().
*
* @param array $params Identical to Foo/get. Additionally you MUST pass a 'extension'. It will find the converter class using the Entity::converter() method.
* @return array
* @return ArrayObject
* @throws InvalidArguments
* @throws Exception
* @see AbstractConverter
Expand Down
8 changes: 8 additions & 0 deletions www/modules/files/model/Folder.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@
* @property boolean $apply_state Apply the configured state of the column model to everybody.
* @property \GO\Base\Fs\Folder $fsFolder
* @property int $acl_write
*
* @property GO\Files\Model\Folder $parent
* @property GO\Base\Model\User $quotaUser
* @property GO\Files\Model\Folder[]|\GO\Base\Db\ActiveStatement $folders
* @property GO\Files\Model\File[]|\GO\Base\Db\ActiveStatement $files
* @property GO\Files\Model\FolderNotification[] $notifyUsers
* @property GO\Files\Model\FolderPreference[] $preferences
* @property GO\Files\Model\SharedRootFolder[] $sharedRootFolders
*/
class Folder extends \GO\Base\Db\ActiveRecord {

Expand Down

0 comments on commit b7f390f

Please sign in to comment.