mirror of
https://github.com/standardebooks/web.git
synced 2025-07-06 06:40:33 -04:00
PHP 8.3 (part of Ubuntu 24.04) outputs a deprecated warning for properties that were not in the class definition. Error below. There were a few of these missing from the `Ebook`, `GitCommit`, `CollectionMembership`, `EbookSource`, and `Contributor` classes. Adding them doesn't change any functionality, but it does make it clearer what properties a class has. Some of these properties are never set for `Ebook` instances created from the filesystem, i.e., `Created` and `Updated`, and some of them need to be manually set to make `Ebook` instances from the filesystem and the database match, e.g., `GitCommitId`, `CollectionEbookId`, `EbookSourceId`, and `ContributorId`. Making the `Ebook` instances from the filesystem and the database match each other makes it easier to spot bugs in the future. Previous errors with PHP 8.3: ``` PHP Deprecated: Creation of dynamic property Ebook::$Created is deprecated in /standardebooks.org/web/lib/Traits/Accessor.php on line 42 PHP Deprecated: Creation of dynamic property Ebook::$Updated is deprecated in /standardebooks.org/web/lib/Traits/Accessor.php on line 42 PHP Deprecated: Creation of dynamic property GitCommit::$GitCommitId is deprecated in /standardebooks.org/web/lib/DbConnection.php on line 286 PHP Deprecated: Creation of dynamic property GitCommit::$EbookId is deprecated in /standardebooks.org/web/lib/DbConnection.php on line 286 PHP Deprecated: Creation of dynamic property GitCommit::$GitCommitId is deprecated in /standardebooks.org/web/lib/DbConnection.php on line 286 PHP Deprecated: Creation of dynamic property GitCommit::$EbookId is deprecated in /standardebooks.org/web/lib/DbConnection.php on line 286 PHP Deprecated: Creation of dynamic property GitCommit::$GitCommitId is deprecated in /standardebooks.org/web/lib/DbConnection.php on line 286 PHP Deprecated: Creation of dynamic property GitCommit::$EbookId is deprecated in /standardebooks.org/web/lib/DbConnection.php on line 286 PHP Deprecated: Creation of dynamic property GitCommit::$GitCommitId is deprecated in /standardebooks.org/web/lib/DbConnection.php on line 286 PHP Deprecated: Creation of dynamic property GitCommit::$EbookId is deprecated in /standardebooks.org/web/lib/DbConnection.php on line 286 PHP Deprecated: Creation of dynamic property GitCommit::$GitCommitId is deprecated in /standardebooks.org/web/lib/DbConnection.php on line 286 PHP Deprecated: Creation of dynamic property GitCommit::$EbookId is deprecated in /standardebooks.org/web/lib/DbConnection.php on line 286 PHP Deprecated: Creation of dynamic property CollectionMembership::$CollectionEbookId is deprecated in /standardebooks.org/web/lib/Traits/Accessor.php on line 42 PHP Deprecated: Creation of dynamic property CollectionMembership::$EbookId is deprecated in /standardebooks.org/web/lib/Traits/Accessor.php on line 42 PHP Deprecated: Creation of dynamic property CollectionMembership::$CollectionId is deprecated in /standardebooks.org/web/lib/Traits/Accessor.php on line 42 PHP Deprecated: Creation of dynamic property EbookSource::$EbookSourceId is deprecated in /standardebooks.org/web/lib/DbConnection.php on line 286 PHP Deprecated: Creation of dynamic property EbookSource::$EbookId is deprecated in /standardebooks.org/web/lib/DbConnection.php on line 286 PHP Deprecated: Creation of dynamic property EbookSource::$EbookSourceId is deprecated in /standardebooks.org/web/lib/DbConnection.php on line 286 PHP Deprecated: Creation of dynamic property EbookSource::$EbookId is deprecated in /standardebooks.org/web/lib/DbConnection.php on line 286 PHP Deprecated: Creation of dynamic property Contributor::$ContributorId is deprecated in /standardebooks.org/web/lib/DbConnection.php on line 286 PHP Deprecated: Creation of dynamic property Contributor::$EbookId is deprecated in /standardebooks.org/web/lib/DbConnection.php on line 286 PHP Deprecated: Creation of dynamic property Contributor::$SortOrder is deprecated in /standardebooks.org/web/lib/DbConnection.php on line 286 ```
26 lines
663 B
PHP
26 lines
663 B
PHP
<?
|
|
use Safe\DateTimeImmutable;
|
|
|
|
class GitCommit{
|
|
public ?int $GitCommitId = null;
|
|
public ?int $EbookId = null;
|
|
public DateTimeImmutable $Created;
|
|
public string $Message;
|
|
public string $Hash;
|
|
|
|
/**
|
|
* @throws Exceptions\InvalidGitCommitException
|
|
*/
|
|
public static function FromLog(string $unixTimestamp, string $hash, string $message): GitCommit{
|
|
$instance = new GitCommit();
|
|
try{
|
|
$instance->Created = new DateTimeImmutable('@' . $unixTimestamp);
|
|
}
|
|
catch(\Exception){
|
|
throw new Exceptions\InvalidGitCommitException('Invalid timestamp for Git commit.');
|
|
}
|
|
$instance->Message = $message;
|
|
$instance->Hash = $hash;
|
|
return $instance;
|
|
}
|
|
}
|