diff --git a/.github/workflows/php-lint.yml b/.github/workflows/php-lint.yml new file mode 100644 index 0000000..8ce95d7 --- /dev/null +++ b/.github/workflows/php-lint.yml @@ -0,0 +1,20 @@ +name: PHP Lint + +on: + push: + paths: + - '**/*.php' + - '.github/workflows/php-lint.yml' + pull_request: + paths: + - '**/*.php' + - '.github/workflows/php-lint.yml' + +jobs: + phplint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Run php -l on all files + run: | + find . -name '*.php' -print0 | xargs -0 -n 1 php -l diff --git a/MicrofyClass.php b/MicrofyClass.php index f5e980f..986db93 100644 --- a/MicrofyClass.php +++ b/MicrofyClass.php @@ -107,6 +107,7 @@ public static function dbPdo($host, $dbname, $user, $pass, $charset = 'utf8mb4', return new PDO($dsn, $user, $pass, $options); } catch (PDOException $e) { self::dd("PDO Connection failed: " . $e->getMessage()); + return null; } } diff --git a/README.md b/README.md index 4f4c748..a5b9312 100644 --- a/README.md +++ b/README.md @@ -136,6 +136,14 @@ Microfy::c('Step A'); ``` More [Examples](https://itnb.com/MicrofyClass/) +## ✅ Lint Check + +Run PHP's built-in linter across all project files: + +```bash +./scripts/lint.sh +``` + --- diff --git a/scripts/lint.sh b/scripts/lint.sh new file mode 100755 index 0000000..ab30d70 --- /dev/null +++ b/scripts/lint.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Lint all PHP files in the repository +find . -name '*.php' -print0 | xargs -0 -n 1 php -l