From 804729e655ec362262a690960e4c45c008ba4c7d Mon Sep 17 00:00:00 2001 From: Simon Leary Date: Fri, 7 Nov 2025 13:28:15 -0500 Subject: [PATCH 1/4] phpstan CI --- .github/workflows/phpstan.yml | 20 +++++++++++++ composer.json | 3 +- composer.lock | 55 ++++++++++++++++++++++++++++++++++- 3 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/phpstan.yml diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml new file mode 100644 index 00000000..380a0ca4 --- /dev/null +++ b/.github/workflows/phpstan.yml @@ -0,0 +1,20 @@ +name: pre-commit + +on: + pull_request: + push: + branches: [main] + +jobs: + pre-commit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + submodules: true + - uses: shivammathur/setup-php@v2 + with: + php-version: "8.3" + tools: composer + - run: composer install --dev + - run: ./vendor/bin/phpstan --memory-limit=-1 analyse ./resources/ diff --git a/composer.json b/composer.json index 4636af51..4df2fee9 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,8 @@ "require-dev": { "phpunit/phpunit": ">=12", "robiningelbrecht/phpunit-coverage-tools": "<2", - "squizlabs/php_codesniffer": "*" + "squizlabs/php_codesniffer": "*", + "phpstan/phpstan": "^2.1" }, "config": { "platform": { diff --git a/composer.lock b/composer.lock index 74733f60..5287047d 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "fa7299619e6198f9ef10dca9d729d04e", + "content-hash": "c754a39c23ea5a178af79ad73f1cf138", "packages": [ { "name": "paragonie/constant_time_encoding", @@ -605,6 +605,59 @@ }, "time": "2022-02-21T01:04:05+00:00" }, + { + "name": "phpstan/phpstan", + "version": "2.1.31", + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/ead89849d879fe203ce9292c6ef5e7e76f867b96", + "reference": "ead89849d879fe203ce9292c6ef5e7e76f867b96", + "shasum": "" + }, + "require": { + "php": "^7.4|^8.0" + }, + "conflict": { + "phpstan/phpstan-shim": "*" + }, + "bin": [ + "phpstan", + "phpstan.phar" + ], + "type": "library", + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan - PHP Static Analysis Tool", + "keywords": [ + "dev", + "static analysis" + ], + "support": { + "docs": "https://phpstan.org/user-guide/getting-started", + "forum": "https://github.com/phpstan/phpstan/discussions", + "issues": "https://github.com/phpstan/phpstan/issues", + "security": "https://github.com/phpstan/phpstan/security/policy", + "source": "https://github.com/phpstan/phpstan-src" + }, + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://github.com/phpstan", + "type": "github" + } + ], + "time": "2025-10-10T14:14:11+00:00" + }, { "name": "phpunit/php-code-coverage", "version": "12.4.0", From 7b678c2b6a45e0152940e00640c0c93d918a4867 Mon Sep 17 00:00:00 2001 From: Simon Leary Date: Fri, 7 Nov 2025 13:32:06 -0500 Subject: [PATCH 2/4] fix phpstan errors --- resources/lib/UnityLDAP.php | 8 ++++---- resources/lib/UnityOrg.php | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/resources/lib/UnityLDAP.php b/resources/lib/UnityLDAP.php index 940f75a5..32641c7b 100644 --- a/resources/lib/UnityLDAP.php +++ b/resources/lib/UnityLDAP.php @@ -464,7 +464,7 @@ public function getUserEntry($uid) { $uid = ldap_escape($uid, "", LDAP_ESCAPE_DN); return $this->getEntry( - unityLDAP::RDN . "=$uid," . CONFIG["ldap"]["user_ou"], + UnityLDAP::RDN . "=$uid," . CONFIG["ldap"]["user_ou"], ); } @@ -472,7 +472,7 @@ public function getGroupEntry($gid) { $gid = ldap_escape($gid, "", LDAP_ESCAPE_DN); return $this->getEntry( - unityLDAP::RDN . "=$gid," . CONFIG["ldap"]["group_ou"], + UnityLDAP::RDN . "=$gid," . CONFIG["ldap"]["group_ou"], ); } @@ -480,7 +480,7 @@ public function getPIGroupEntry($gid) { $gid = ldap_escape($gid, "", LDAP_ESCAPE_DN); return $this->getEntry( - unityLDAP::RDN . "=$gid," . CONFIG["ldap"]["pigroup_ou"], + UnityLDAP::RDN . "=$gid," . CONFIG["ldap"]["pigroup_ou"], ); } @@ -488,7 +488,7 @@ public function getOrgGroupEntry($gid) { $gid = ldap_escape($gid, "", LDAP_ESCAPE_DN); return $this->getEntry( - unityLDAP::RDN . "=$gid," . CONFIG["ldap"]["orggroup_ou"], + UnityLDAP::RDN . "=$gid," . CONFIG["ldap"]["orggroup_ou"], ); } } diff --git a/resources/lib/UnityOrg.php b/resources/lib/UnityOrg.php index 5753e73b..677cbd26 100644 --- a/resources/lib/UnityOrg.php +++ b/resources/lib/UnityOrg.php @@ -50,7 +50,7 @@ public function inOrg($user, $ignorecache = false) public function getOrgMembers($ignorecache = false) { - $members = $this->getGroupMemberUIDs($ignorecache); + $members = $this->getOrgMemberUIDs($ignorecache); $out = []; foreach ($members as $member) { $user_obj = new UnityUser( From 11b3ede346d4a24df820f1d8845b758a5a42a961 Mon Sep 17 00:00:00 2001 From: Simon Leary Date: Fri, 7 Nov 2025 13:32:54 -0500 Subject: [PATCH 3/4] rename --- .github/workflows/phpstan.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index 380a0ca4..d5140a97 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -1,4 +1,4 @@ -name: pre-commit +name: phpstan on: pull_request: From f9423ae19cf71cc3efd96536c90e32df44e09307 Mon Sep 17 00:00:00 2001 From: Simon Leary Date: Fri, 7 Nov 2025 13:33:52 -0500 Subject: [PATCH 4/4] update phpopenldaper --- resources/lib/phpopenldaper | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/lib/phpopenldaper b/resources/lib/phpopenldaper index 6eaf386b..abd76194 160000 --- a/resources/lib/phpopenldaper +++ b/resources/lib/phpopenldaper @@ -1 +1 @@ -Subproject commit 6eaf386b214506dd18f9ad6510579c3ba6d3c1a2 +Subproject commit abd7619407f885a156af980140a7d97a5e64cc41