Skip to content

Commit

Permalink
Deprecated FileResource::changeDetector()
Browse files Browse the repository at this point in the history
  • Loading branch information
vudaltsov committed Mar 9, 2024
1 parent dfe9374 commit e3bc2d8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 0.3.0
## 0.3.1

- Implemented `getType()`, `getReturnType()`, `getTentativeReturnType()`, `hasTentativeReturnType()`, `hasReturnType()`.
- Deprecated `FileResource::changeDetector()`.
3 changes: 3 additions & 0 deletions FileResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,13 @@ public function contents(): string
}

/**
* @deprecated will be removed in 0.4.0
* @throws FileNotReadable
*/
public function changeDetector(): ChangeDetector
{
trigger_deprecation('typhoon/reflection', '0.3.1', 'Method %s() is deprecated and will be removed on 0.4.0.', __METHOD__);

return $this->changeDetector ??= ChangeDetector::fromFileContents($this->file, $this->contents());
}

Expand Down
3 changes: 2 additions & 1 deletion PhpParserReflector/ContextualPhpParserReflector.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use PHPStan\PhpDocParser\Ast\Type\UnionTypeNode;
use Typhoon\Reflection\FileResource;
use Typhoon\Reflection\Metadata\AttributeMetadata;
use Typhoon\Reflection\Metadata\ChangeDetector;
use Typhoon\Reflection\Metadata\ClassConstantMetadata;
use Typhoon\Reflection\Metadata\ClassMetadata;
use Typhoon\Reflection\Metadata\InheritedName;
Expand Down Expand Up @@ -82,7 +83,7 @@ trait: $trait,
return new ClassMetadata(
name: $name,
modifiers: ClassReflections::modifiers($node),
changeDetector: $this->file->changeDetector(),
changeDetector: ChangeDetector::fromFileContents($this->file->file, $this->file->contents()),
internal: $this->file->isInternal(),
extension: $this->file->extension,
file: $this->file->isInternal() ? false : $this->file->file,
Expand Down

0 comments on commit e3bc2d8

Please sign in to comment.