Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unexpected warning in ClassCache::get() in some cases #67

Merged
merged 5 commits into from
Jan 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions .github/workflows/bc.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
on:
- pull_request
- push
pull_request:
push:

name: backwards compatibility

jobs:
roave_bc_check:
name: Roave BC Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: fetch tags
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Roave BC Check
uses: docker://nyholm/roave-bc-check-ga
uses: yiisoft/actions/.github/workflows/bc.yml@master
with:
os: >-
['ubuntu-latest']
php: >-
['8.0']
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## 1.0.5 under development

- no changes in this release.
- Bug #67: Fix unexpected warning in `ClassCache::get()` in some cases (@vjik)

## 1.0.4 August 16, 2022

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"phpunit/phpunit": "^9.5",
"roave/infection-static-analysis-plugin": "^1.16",
"spatie/phpunit-watcher": "^1.23",
"vimeo/psalm": "^4.18"
"vimeo/psalm": "^4.30|^5.4"
},
"autoload": {
"psr-4": {
Expand Down
47 changes: 29 additions & 18 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,20 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" colors="true" verbose="true" bootstrap="vendor/autoload.php" failOnRisky="true" failOnWarning="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory>./</directory>
</include>
<exclude>
<directory>./tests</directory>
<directory>./vendor</directory>
</exclude>
</coverage>
<php>
<ini name="error_reporting" value="-1"/>
</php>
<testsuites>
<testsuite name="Yii proxy tests">
<directory>./tests</directory>
</testsuite>
</testsuites>

<phpunit
bootstrap="vendor/autoload.php"
colors="true"
verbose="true"
failOnRisky="true"
failOnWarning="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="false"
stopOnFailure="false"
executionOrder="random"
resolveDependencies="true"
>
<php>
<ini name="error_reporting" value="-1"/>
</php>

<testsuites>
<testsuite name="Yii Proxy tests">
<directory>./tests</directory>
</testsuite>
</testsuites>

<coverage>
<include>
<directory>./src</directory>
</include>
</coverage>
</phpunit>
9 changes: 5 additions & 4 deletions src/ClassCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,14 @@ public function set(string $className, string $baseProxyClassName, string $class
*/
public function get(string $className, string $baseProxyClassName): ?string
{
try {
$content = file_get_contents($this->getClassPath($className, $baseProxyClassName));
} catch (Exception) {
$classPath = $this->getClassPath($className, $baseProxyClassName);
if (!file_exists($classPath)) {
return null;
}

return $content;
$content = file_get_contents($classPath);

return $content === false ? null : $content;
}

/**
Expand Down
1 change: 0 additions & 1 deletion src/ClassConfigFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ private function getMethodConfig(ReflectionClass $class, ReflectionMethod $metho
*/
private function getMethodModifiers(ReflectionClass $class, ReflectionMethod $method): array
{
/** @psalm-var list<string> $modifiers Can be removed after release https://github.com/vimeo/psalm/pull/8405 */
$modifiers = Reflection::getModifierNames($method->getModifiers());
if (!$class->isInterface()) {
return $modifiers;
Expand Down