Skip to content
This repository was archived by the owner on Aug 25, 2025. It is now read-only.

Commit 0311747

Browse files
committed
Code fixes for 4.0 compatibiltiy
1 parent 69caa8e commit 0311747

File tree

7 files changed

+9
-9
lines changed

7 files changed

+9
-9
lines changed

examples/dorm/CodegenDorm.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ public function generate(): void {
5757
);
5858

5959
$rc = new \ReflectionClass(\get_class($this->schema));
60-
$path = $rc->getFileName();
61-
$pos = \strrpos($path, '/');
60+
$path = $rc->getFileName() as string;
61+
$pos = \strrpos((string) $path, '/');
6262
$dir = \substr($path, 0, $pos + 1);
6363
$gen_from = 'codegen.php '.$this->getSchemaName().'Schema';
6464

examples/dorm/CodegenMutator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function generate(): void {
5555
->addMethods($this->getSetters());
5656

5757
$rc = new \ReflectionClass(\get_class($this->schema));
58-
$path = $rc->getFileName();
58+
$path = $rc->getFileName() as string;
5959
$pos = \strrpos($path, '/');
6060
$dir = \substr($path, 0, $pos + 1);
6161
$gen_from = 'codegen.php '.$rc->getShortName();

src/CodegenFile.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ private function loadExistingFiles(): ?string {
444444
foreach ($file_names as $file_name) {
445445
if (\file_exists($file_name)) {
446446
$content = Filesystem::readFile($file_name);
447-
if ($content) {
447+
if ($content !== '') {
448448
$root_dir = $this->config->getRootDir();
449449
$relative_path = Str\starts_with($file_name, $root_dir)
450450
? Str\slice($file_name, Str\length($root_dir) + 1)

src/HackfmtFormatter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ public function format(
5454
private function getFormattedOptions(): string {
5555
$options = vec[
5656
'--indent-width',
57-
$this->config->getSpacesPerIndentation(),
57+
(string) $this->config->getSpacesPerIndentation(),
5858
'--line-width',
59-
$this->config->getMaxLineLength(),
59+
(string) $this->config->getMaxLineLength(),
6060
];
6161

6262
if ($this->config->shouldUseTabs()) {

src/PartiallyGeneratedCode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ private function iterateCodeSections(
189189
"The manual section ".$current_id." was not closed at the end of code",
190190
);
191191
}
192-
if ($code) {
192+
if ($code !== '') {
193193
yield tuple(null, \implode("\n", $chunk));
194194
}
195195
}

src/_Private/strip_hh_prefix.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function strip_hh_prefix(
4747
for ($i = 0; $i < $len; ++$i) {
4848
$prev = $c;
4949
$c = $str[$i];
50-
if ($in_literal) {
50+
if ($in_literal !== '') {
5151
if ($c === '\\') {
5252
$out .= $c;
5353
++$i;

tests/CodegenExpectedFile.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ final class CodegenExpectedFile {
3838
*/
3939
public static function getPath(string $class_name): string {
4040
$ref = new \ReflectionClass($class_name);
41-
$source_file = $ref->getFileName();
41+
$source_file = (string) $ref->getFileName();
4242
// Get classname without namespace
4343
$class_name = $ref->getShortName();
4444
return \dirname($source_file).'/'.$class_name.self::EXTENSION;

0 commit comments

Comments
 (0)