Skip to content

Commit

Permalink
Verify stub aliases in CI (php#13682)
Browse files Browse the repository at this point in the history
In the same time, let's not verify implementation aliases since they may now legitimately differ from their aliased function/method counterparts (think about the ext/dom refactoring where e.g. many return type declarations have changed). Additionally, unnecessary `@no-verify` tags are cleaned up.
  • Loading branch information
kocsismate authored Mar 13, 2024
1 parent cc0260e commit 577db99
Show file tree
Hide file tree
Showing 14 changed files with 16 additions and 33 deletions.
5 changes: 2 additions & 3 deletions .github/actions/verify-generated-files/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ runs:
steps:
- shell: bash
run: |
set -x
set -ex
[[ "$OSTYPE" == "darwin"* ]] && export PATH="$(brew --prefix)/opt/bison/bin:$PATH"
scripts/dev/credits
scripts/dev/genfiles
Zend/zend_vm_gen.php
ext/tokenizer/tokenizer_data_gen.php
build/gen_stub.php -f
build/gen_stub.php --generate-optimizer-info
build/gen_stub.php -f --generate-optimizer-info --verify
git add . -N && git diff --exit-code
2 changes: 1 addition & 1 deletion build/gen_stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -5922,7 +5922,7 @@ function initPhpParser() {
$errors = [];

foreach ($funcMap as $aliasFunc) {
if (!$aliasFunc->alias) {
if (!$aliasFunc->alias || $aliasFunc->aliasType !== "alias") {
continue;
}

Expand Down
3 changes: 0 additions & 3 deletions ext/bz2/bz2.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,18 @@ function bzread($bz, int $length = 1024): string|false {}
/**
* @param resource $bz
* @implementation-alias fwrite
* @no-verify Uses different parameter name
*/
function bzwrite($bz, string $data, ?int $length = null): int|false {}

/**
* @param resource $bz
* @implementation-alias fflush
* @no-verify Uses different parameter name
*/
function bzflush($bz): bool {}

/**
* @param resource $bz
* @implementation-alias fclose
* @no-verify Uses different parameter name
*/
function bzclose($bz): bool {}

Expand Down
2 changes: 1 addition & 1 deletion ext/bz2/bz2_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions ext/mysqli/mysqli.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,6 @@ public function character_set_name(): string {}
/**
* @return true
* @alias mysqli_close
* @no-verify
*/
public function close() {} // TODO make return type void

Expand Down Expand Up @@ -989,7 +988,6 @@ public function set_opt(int $option, $value): bool {}
/**
* @return true
* @alias mysqli_ssl_set
* @no-verify
*/
public function ssl_set(
?string $key,
Expand Down Expand Up @@ -1242,7 +1240,6 @@ public function bind_result(mixed &...$vars): bool {}
/**
* @return true
* @alias mysqli_stmt_close
* @no-verify
*/
public function close() {} // TODO make return type void

Expand Down
2 changes: 1 addition & 1 deletion ext/mysqli/mysqli_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 1 addition & 6 deletions ext/phar/phar_object.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,7 @@ final public static function webPhar(

class PharData extends RecursiveDirectoryIterator implements Countable, ArrayAccess
{
/**
* @implementation-alias Phar::__construct
* @no-verify PharData constructor accepts extra $format argument
*/
/** @implementation-alias Phar::__construct */
public function __construct(string $filename, int $flags = FilesystemIterator::SKIP_DOTS|FilesystemIterator::UNIX_PATHS, ?string $alias = null, int $format = 0) {}

/** @implementation-alias Phar::__destruct */
Expand Down Expand Up @@ -299,14 +296,12 @@ public function decompressFiles() {} // TODO make return type void
/**
* @tentative-return-type
* @implementation-alias Phar::compress
* @no-verify
*/
public function compress(int $compression, ?string $extension = null): ?PharData {}

/**
* @tentative-return-type
* @implementation-alias Phar::decompress
* @no-verify
*/
public function decompress(?string $extension = null): ?PharData {}

Expand Down
2 changes: 1 addition & 1 deletion ext/phar/phar_object_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions ext/reflection/php_reflection.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -800,10 +800,7 @@ public function __construct(object|string $class, string $constant) {}

public function getEnum(): ReflectionEnum {}

/**
* @implementation-alias ReflectionClassConstant::getValue
* @no-verify
*/
/** @implementation-alias ReflectionClassConstant::getValue */
public function getValue(): UnitEnum {}
}

Expand Down
2 changes: 1 addition & 1 deletion ext/reflection/php_reflection_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions ext/spl/spl_observer.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,13 @@ public function offsetGet($object): mixed {}
* @param object $object
* @tentative-return-type
* @implementation-alias SplObjectStorage::attach
* @no-verify Cannot specify arg type because ArrayAccess does not
*/
public function offsetSet($object, mixed $info = null): void {}

/**
* @param object $object
* @tentative-return-type
* @implementation-alias SplObjectStorage::detach
* @no-verify Cannot specify arg type because ArrayAccess does not
*/
public function offsetUnset($object): void {}

Expand Down
2 changes: 1 addition & 1 deletion ext/spl/spl_observer_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions ext/sqlite3/sqlite3.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,13 +272,13 @@ class SQLite3
public const int RECURSIVE = UNKNOWN;
#endif

/**
* @implementation-alias SQLite3::open
* @no-verify SQLite3::open should really be static
*/
/** @implementation-alias SQLite3::open */
public function __construct(string $filename, int $flags = SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE, string $encryptionKey = "") {}

/** @tentative-return-type */
/**
* @tentative-return-type
* @todo SQLite3::open should really be static
*/
public function open(string $filename, int $flags = SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE, string $encryptionKey = ""): void {}

/** @return bool */
Expand Down
2 changes: 1 addition & 1 deletion ext/sqlite3/sqlite3_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 577db99

Please sign in to comment.