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

SplFile{Info,Object} stub fixes #1651

Closed
wants to merge 3 commits into from
Closed
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
38 changes: 32 additions & 6 deletions SPL/SPL_c1.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public function getPerms(): int|false {}
* @link https://php.net/manual/en/splfileinfo.getinode.php
* @return int|false The inode number for the filesystem object on success, or <b>FALSE</b> on failure.
* @since 5.1.2
* @throws \RunTimeException on error.
*/
#[TentativeType]
public function getInode(): int|false {}
Expand All @@ -93,6 +94,7 @@ public function getInode(): int|false {}
* @link https://php.net/manual/en/splfileinfo.getsize.php
* @return int|false The filesize in bytes on success, or <b>FALSE</b> on failure.
* @since 5.1.2
* @throws \RunTimeException on error.
*/
#[TentativeType]
public function getSize(): int|false {}
Expand All @@ -102,6 +104,7 @@ public function getSize(): int|false {}
* @link https://php.net/manual/en/splfileinfo.getowner.php
* @return int|false The owner id in numerical format on success, or <b>FALSE</b> on failure.
* @since 5.1.2
* @throws \RunTimeException on error.
*/
#[TentativeType]
public function getOwner(): int|false {}
Expand All @@ -111,6 +114,7 @@ public function getOwner(): int|false {}
* @link https://php.net/manual/en/splfileinfo.getgroup.php
* @return int|false The group id in numerical format on success, or <b>FALSE</b> on failure.
* @since 5.1.2
* @throws \RunTimeException on error.
*/
#[TentativeType]
public function getGroup(): int|false {}
Expand All @@ -120,6 +124,7 @@ public function getGroup(): int|false {}
* @link https://php.net/manual/en/splfileinfo.getatime.php
* @return int|false The time the file was last accessed on success, or <b>FALSE</b> on failure.
* @since 5.1.2
* @throws \RunTimeException on error.
*/
#[TentativeType]
public function getATime(): int|false {}
Expand All @@ -138,6 +143,7 @@ public function getMTime(): int|false {}
* @link https://php.net/manual/en/splfileinfo.getctime.php
* @return int|false The last change time, in a Unix timestamp on success, or <b>FALSE</b> on failure.
* @since 5.1.2
* @throws \RunTimeException on error.
*/
#[TentativeType]
public function getCTime(): int|false {}
Expand All @@ -149,6 +155,7 @@ public function getCTime(): int|false {}
* May be one of file, link,
* or dir
* @since 5.1.2
* @throws \RunTimeException on error.
*/
#[TentativeType]
public function getType(): string|false {}
Expand Down Expand Up @@ -212,6 +219,7 @@ public function isLink(): bool {}
* @link https://php.net/manual/en/splfileinfo.getlinktarget.php
* @return string|false The target of the filesystem link on success, or <b>FALSE</b> on failure.
* @since 5.2.2
* @throws \RunTimeException on error.
*/
#[TentativeType]
public function getLinkTarget(): string|false {}
Expand All @@ -227,23 +235,29 @@ public function getRealPath(): string|false {}

/**
* Gets an SplFileInfo object for the file
*
* @template T of SplFileInfo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of template in the stub have names, like

  • TValue
  • TDefault
  • TKey
  • TPriority
  • ...

Maybe there is something better to do here than T.

* @link https://php.net/manual/en/splfileinfo.getfileinfo.php
* @param string $class [optional] <p>
* @param class-string<T> $class [optional] <p>
* Name of an <b>SplFileInfo</b> derived class to use.
* </p>
* @return SplFileInfo An <b>SplFileInfo</b> object created for the file.
* @return T An <b>SplFileInfo</b> object created for the file.
* @since 5.1.2
*/
#[TentativeType]
public function getFileInfo(#[LanguageLevelTypeAware(['8.0' => 'string|null'], default: '')] $class = null): SplFileInfo {}

/**
* Gets an SplFileInfo object for the path
*
* @template T of SplFileInfo
* @link https://php.net/manual/en/splfileinfo.getpathinfo.php
* @param string $class [optional] <p>
*
* @param class-string<T> $class [optional] <p>
* Name of an <b>SplFileInfo</b> derived class to use.
* </p>
* @return SplFileInfo|null A <b>SplFileInfo</b> object for the parent path of the file on success, or <b>NULL</b> on failure.
*
* @return T|null A <b>SplFileInfo</b> object for the parent path of the file on success, or <b>NULL</b> on failure.
* @since 5.1.2
*/
#[TentativeType]
Expand All @@ -263,6 +277,7 @@ public function getPathInfo(#[LanguageLevelTypeAware(['8.0' => 'string|null'], d
* </p>
* @return SplFileObject The opened file as an <b>SplFileObject</b> object.
* @since 5.1.2
* @throws \RuntimeException If the file cannot be opened (e.g. insufficient access rights).
*/
#[TentativeType]
public function openFile(
Expand All @@ -273,8 +288,10 @@ public function openFile(

/**
* Sets the class name used with <b>SplFileInfo::openFile</b>
*
* @template T of SplFileObject
* @link https://php.net/manual/en/splfileinfo.setfileclass.php
* @param string $class [optional] <p>
* @param class-string<T> $class [optional] <p>
* The class name to use when openFile() is called.
* </p>
* @return void
Expand All @@ -285,10 +302,12 @@ public function setFileClass(#[LanguageLevelTypeAware(['8.0' => 'string'], defau

/**
* Sets the class used with getFileInfo and getPathInfo
* @template T of SplFileInfo*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @template T of SplFileInfo*
* @template T of SplFileInfo

no ?

I never saw a syntax with *

* @link https://php.net/manual/en/splfileinfo.setinfoclass.php
* @param string $class [optional] <p>
* @param class-string<T> $class [optional] <p>
* The class name to use.
* </p>
*
* @return void
* @since 5.1.2
*/
Expand Down Expand Up @@ -645,6 +664,8 @@ public function __construct(
* Rewind the file to the first line
* @link https://php.net/manual/en/splfileobject.rewind.php
* @return void
*
* @throws RuntimeException If cannot be rewound
*/
#[TentativeType]
public function rewind(): void {}
Expand All @@ -669,6 +690,8 @@ public function valid(): bool {}
* Gets line from file
* @link https://php.net/manual/en/splfileobject.fgets.php
* @return string a string containing the next line from the file.
*
* @throws RuntimeException If the file cannot be read
*/
#[TentativeType]
public function fgets(): string {}
Expand Down Expand Up @@ -970,6 +993,8 @@ public function getFlags(): int {}
* The maximum length of a line.
* </p>
* @return void
*
* @throws DomainException When <i>maxLength</i> is less than zero.
*/
#[TentativeType]
public function setMaxLineLen(#[LanguageLevelTypeAware(['8.0' => 'int'], default: '')] $maxLength): void {}
Expand Down Expand Up @@ -1009,6 +1034,7 @@ public function getChildren() {}
* The zero-based line number to seek to.
* </p>
* @return void
* @throws LogicException If the <i>line</i> is negative
*/
#[TentativeType]
public function seek(#[LanguageLevelTypeAware(['8.0' => 'int'], default: '')] $line): void {}
Expand Down