Skip to content

Commit

Permalink
Merge pull request #269 from totti95/fix/php81Compatibility
Browse files Browse the repository at this point in the history
Fix php 8.1 compatibility ReadOnly and add toArray method annotation
  • Loading branch information
homersimpsons authored Mar 17, 2022
2 parents 2847c66 + 8922eef commit 8da64b2
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/InnerResultIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public function count()
if ($this->fetchStarted && $this->tdbmService->getConnection()->getDatabasePlatform() instanceof MySqlPlatform) {
// Optimisation: we don't need a separate "count" SQL request in MySQL.
assert($this->statement instanceof Statement);
$this->count = $this->statement->rowCount();
$this->count = (int)$this->statement->rowCount();
return $this->count;
}
return $this->getRowCountViaSqlQuery();
Expand Down
2 changes: 1 addition & 1 deletion src/Utils/AbstractBeanPropertyDescriptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace TheCodingMachine\TDBM\Utils;

use Doctrine\DBAL\Schema\Table;
use TheCodingMachine\TDBM\Utils\Annotation\ReadOnly;
use TheCodingMachine\TDBM\Utils\Annotation\ReadOnlyColumn;
use Laminas\Code\Generator\DocBlock\Tag\ParamTag;
use Laminas\Code\Generator\MethodGenerator;

Expand Down
2 changes: 1 addition & 1 deletion src/Utils/Annotation/AnnotationParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static function buildWithDefaultAnnotations(array $additionalAnnotations)
'ProtectedGetter' => ProtectedGetter::class,
'ProtectedSetter' => ProtectedSetter::class,
'ProtectedOneToMany' => ProtectedOneToMany::class,
'ReadOnly' => ReadOnly::class,
'ReadOnly' => ReadOnlyColumn::class,
'JsonKey' => JsonKey::class,
'JsonIgnore' => JsonIgnore::class,
'JsonInclude' => JsonInclude::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
*
* @Annotation
*/
final class ReadOnly
final class ReadOnlyColumn
{
}
2 changes: 1 addition & 1 deletion src/Utils/BeanDescriptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -1198,7 +1198,7 @@ public function generateResultIteratorPhpCode(): ?FileGenerator
$class->setDocBlock((new DocBlockGenerator(
"The $baseClassName class will iterate over results of $beanClassWithoutNameSpace class.",
null,
[new Tag\MethodTag('getIterator', ['\\' . $beanClassName . '[]'])]
[new Tag\MethodTag('getIterator', ['\\' . $beanClassName . '[]']), new Tag\MethodTag('toArray', ['\\' . $beanClassName . '[]'])]
))->setWordWrap(false));

$file = $this->codeGeneratorListener->onBaseResultIteratorGenerated($file, $this, $this->configuration);
Expand Down
2 changes: 1 addition & 1 deletion src/Utils/ObjectBeanPropertyDescriptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ private function isSetterProtected(): bool

public function isReadOnly(): bool
{
return $this->findAnnotation(Annotation\ReadOnly::class) !== null;
return $this->findAnnotation(Annotation\ReadOnlyColumn::class) !== null;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Utils/ScalarBeanPropertyDescriptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ private function isSetterProtected(): bool

public function isReadOnly(): bool
{
return $this->findAnnotation(Annotation\ReadOnly::class) !== null;
return $this->findAnnotation(Annotation\ReadOnlyColumn::class) !== null;
}

private function findAnnotation(string $type): ?object
Expand Down

0 comments on commit 8da64b2

Please sign in to comment.