Skip to content

Commit

Permalink
Merge pull request #18 from YuriiDorosh/fixes/hot_fixes
Browse files Browse the repository at this point in the history
Fixes/hot fixes
  • Loading branch information
YuriiDorosh authored Mar 9, 2024
2 parents 6f11b45 + 5378bd3 commit 5a77767
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 27 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/code-format-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,5 @@ jobs:
- name: Run PHP_CodeSniffer
run: php ./vendor/bin/phpcs --standard=./configs/phpcs.xml ./app

- name: Update Psalm Configuration for GitHub Actions
run: |
sed -i 's|../psalm/stubs.php|/home/runner/work/CodeIgniter4-template/CodeIgniter4-template/psalm/stubs.php|' ./configs/psalm.xml
- name: Run Psalm
run: php ./vendor/bin/psalm --config=./configs/psalm.xml
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,10 @@ check_format_from_composer:
composer run check_format

psalm:
vendor/bin/psalm --config=./configs/psalm.xml
vendor/bin/psalm --config=./configs/psalm.xml

psalm_clear_cache:
vendor/bin/psalm --clear-cache --config=./configs/psalm.xml

psalm_forced_start:
make -B psalm
2 changes: 1 addition & 1 deletion configs/psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
</projectFiles>

<stubs>
<file name="../psalm/stubs.php" />
<file name="../psalm/psalm.php" />
</stubs>
</psalm>
34 changes: 13 additions & 21 deletions psalm/psalm.php
Original file line number Diff line number Diff line change
@@ -1,28 +1,20 @@
<?php

/**
* Stub file for Psalm to recognize CodeIgniter framework functions and classes.
* Stub file for Psalm to recognize CodeIgniter framework functions and classes, including the global view function.
*/

namespace Psalm\Internal\Codebase;
// Remove the namespace declaration to declare the `view` function in the global namespace.
// Remove the namespace Psalm\Internal\Codebase;

class InternalCodebase
{
/**
* Initializes framework functions for Psalm to recognize.
*/
public function initFunctions(): void
{
// Fully qualify the namespace when checking for the function's existence
if (!function_exists(__NAMESPACE__ . '\\view')) {
/**
* Declare the stub function within the current namespace.
* @psalm-suppress UndefinedFunction
*/
function view(string $view, array $options = []): string
{
return '';
}
}
}
/**
* A stub for the global `view` function provided by CodeIgniter.
*
* @param string $view Name of the view file to load.
* @param array $options Data to pass to the view.
* @return string Rendered view content as a string.
*/
function view(string $view, array $options = []): string {
// Mock implementation for Psalm's benefit.
return '';
}

0 comments on commit 5a77767

Please sign in to comment.