1010use wcf \data \page \Page ;
1111use wcf \system \application \ApplicationHandler ;
1212use wcf \system \application \IApplication ;
13+ use wcf \system \benchmark \Benchmark ;
1314use wcf \system \box \BoxHandler ;
14- use wcf \system \cache \builder \CoreObjectCacheBuilder ;
1515use wcf \system \cache \builder \PackageUpdateCacheBuilder ;
16+ use wcf \system \cache \eager \CoreObjectCache ;
1617use wcf \system \database \MySQLDatabase ;
1718use wcf \system \event \EventHandler ;
1819use wcf \system \exception \ErrorException ;
1920use wcf \system \exception \IPrintableException ;
20- use wcf \system \exception \ParentClassException ;
2121use wcf \system \exception \SystemException ;
2222use wcf \system \language \LanguageFactory ;
2323use wcf \system \package \command \RebuildBootstrapper ;
3131use wcf \system \template \EmailTemplateEngine ;
3232use wcf \system \template \TemplateEngine ;
3333use wcf \system \user \storage \UserStorageHandler ;
34+ use wcf \system \user \UserProfileHandler ;
3435use wcf \util \DirectoryUtil ;
3536use wcf \util \FileUtil ;
3637use wcf \util \StringUtil ;
7980\mb_language ('uni ' );
8081
8182// define current woltlab suite version
82- \define ('WCF_VERSION ' , '6.1.11 ' );
83+ \define ('WCF_VERSION ' , '6.2.0 dev 1 ' );
8384
8485// define current unix timestamp
8586\define ('TIME_NOW ' , \time ());
9899 * @author Marcel Werk
99100 * @copyright 2001-2019 WoltLab GmbH
100101 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
102+ *
103+ * @method static Benchmark getBenchmark()
104+ * @method static UserProfileHandler getUserProfileHandler()
101105 */
102106class WCF
103107{
@@ -121,7 +125,7 @@ class WCF
121125
122126 /**
123127 * list of autoload directories
124- * @var array
128+ * @var array<string, string>
125129 */
126130 protected static $ autoloadDirectories = [
127131 'wcf ' => WCF_DIR . 'lib/ ' ,
@@ -135,9 +139,10 @@ class WCF
135139
136140 /**
137141 * list of cached core objects
138- * @var string[]
142+ *
143+ * @var array<string, class-string<SingletonFactory>>
139144 */
140- protected static $ coreObjectCache = [] ;
145+ protected static array $ coreObjectCache ;
141146
142147 /**
143148 * database object
@@ -175,7 +180,7 @@ class WCF
175180 */
176181 protected static $ zendOpcacheEnabled ;
177182
178- public const BOOTSTRAP_LOADER = \WCF_DIR . '/ lib/bootstrap.php ' ;
183+ public const BOOTSTRAP_LOADER = \WCF_DIR . 'lib/bootstrap.php ' ;
179184
180185 /**
181186 * Calls all init functions of the WCF class.
@@ -229,11 +234,14 @@ final protected function runBootstrappers(): void
229234 *
230235 * You *must* not create output in here under normal circumstances, as it might get eaten
231236 * when gzip is enabled.
237+ *
238+ * @return void
232239 */
233240 public static function destruct ()
234241 {
235242 try {
236243 // database has to be initialized
244+ // @phpstan-ignore function.alreadyNarrowedType
237245 if (!\is_object (self ::$ dbObj )) {
238246 return ;
239247 }
@@ -253,6 +261,7 @@ public static function destruct()
253261 }
254262
255263 // update session
264+ // @phpstan-ignore function.alreadyNarrowedType
256265 if (\is_object (self ::getSession ())) {
257266 self ::getSession ()->update ();
258267 }
@@ -318,7 +327,7 @@ final public static function getTPL()
318327 /**
319328 * Calls the show method on the given exception.
320329 */
321- final public static function handleException (\Throwable $ e )
330+ final public static function handleException (\Throwable $ e ): never
322331 {
323332 // backwards compatibility
324333 if ($ e instanceof IPrintableException) {
@@ -338,6 +347,8 @@ final public static function handleException(\Throwable $e)
338347 @\header ('HTTP/1.1 500 Internal Server Error ' );
339348 try {
340349 \wcf \functions \exception \printThrowable ($ e );
350+
351+ exit ;
341352 } catch (\Throwable $ e2 ) {
342353 echo "<pre>An Exception was thrown while handling an Exception: \n\n" ;
343354 echo \preg_replace ('/Database->__construct\(.*\)/ ' , 'Database->__construct(...) ' , $ e2 );
@@ -358,11 +369,11 @@ final public static function handleException(\Throwable $e)
358369 * @param int $line
359370 * @throws ErrorException
360371 */
361- final public static function handleError ($ severity , $ message , $ file , $ line ): void
372+ final public static function handleError ($ severity , $ message , $ file , $ line ): bool
362373 {
363374 // this is necessary for the shut-up operator
364375 if (!(\error_reporting () & $ severity )) {
365- return ;
376+ return true ;
366377 }
367378
368379 throw new ErrorException ($ message , 0 , $ severity , $ file , $ line );
@@ -412,6 +423,7 @@ protected function loadOptions(): void
412423 if (!\is_writable ($ filename )) {
413424 FileUtil::makeWritable ($ filename );
414425
426+ // @phpstan-ignore booleanNot.alwaysTrue
415427 if (!\is_writable ($ filename )) {
416428 throw new SystemException ("The option file ' " . $ filename . "' is not writable. " );
417429 }
@@ -500,6 +512,9 @@ protected function defineLegacyOptions(): void
500512
501513 // The option for the SFS action has been converted into a general option with version 6.1.
502514 \define ('BLACKLIST_SFS_ACTION ' , 'disable ' );
515+
516+ // The option to show an article counter in the message sidebar was removed with version 6.2.
517+ \define ('MESSAGE_SIDEBAR_ENABLE_ARTICLES ' , 0 );
503518 }
504519
505520 /**
@@ -639,6 +654,7 @@ protected function loadApplication(Application $application, bool $isDependentAp
639654 $ packageDir = FileUtil::getRealPath (WCF_DIR . $ relativePath );
640655 self ::$ autoloadDirectories [$ abbreviation ] = $ packageDir . 'lib/ ' ;
641656
657+ // @phpstan-ignore if.alwaysFalse
642658 if (\class_exists ($ className )) {
643659 // the class can now be found, update the `packageDir` value
644660 (new PackageEditor ($ package ))->update (['packageDir ' => $ relativePath ]);
@@ -739,7 +755,7 @@ protected function initCoreObjects(): void
739755 return ;
740756 }
741757
742- self ::$ coreObjectCache = CoreObjectCacheBuilder:: getInstance ()-> getData ();
758+ self ::$ coreObjectCache = ( new CoreObjectCache ())-> getCache ();
743759 }
744760
745761 /**
@@ -825,7 +841,7 @@ final public static function setLanguage(int $languageID): void
825841 final public static function autoload (string $ className ): void
826842 {
827843 $ className = \strtr ($ className , '\\' , '/ ' );
828- if (($ slashPos = \strpos ($ className , '/ ' )) !== null ) {
844+ if (($ slashPos = \strpos ($ className , '/ ' )) !== false ) {
829845 $ applicationPrefix = \substr ($ className , 0 , $ slashPos );
830846 if (isset (self ::$ autoloadDirectories [$ applicationPrefix ])) {
831847 $ classPath = self ::$ autoloadDirectories [$ applicationPrefix ] . \substr ($ className , $ slashPos + 1 ) . '.class.php ' ;
@@ -849,7 +865,7 @@ final public static function autoloadDebug(string $className): void
849865 // logic cannot be moved into a shared function, because it
850866 // measurably reduced autoloader performance.
851867 $ className = \strtr ($ className , '\\' , '/ ' );
852- if (($ slashPos = \strpos ($ className , '/ ' )) !== null ) {
868+ if (($ slashPos = \strpos ($ className , '/ ' )) !== false ) {
853869 $ applicationPrefix = \substr ($ className , 0 , $ slashPos );
854870 if (isset (self ::$ autoloadDirectories [$ applicationPrefix ])) {
855871 $ classPath = self ::$ autoloadDirectories [$ applicationPrefix ] . \substr ($ className , $ slashPos + 1 ) . '.class.php ' ;
@@ -872,7 +888,8 @@ final public static function autoloadDebug(string $className): void
872888 }
873889
874890 /**
875- * @inheritDoc
891+ * @param mixed[] $arguments
892+ * @return ?object
876893 */
877894 final public function __call (string $ name , array $ arguments )
878895 {
@@ -887,9 +904,9 @@ final public function __call(string $name, array $arguments)
887904 /**
888905 * Returns dynamically loaded core objects.
889906 *
890- * @param array $arguments
891- * @return object
892- * @throws SystemException
907+ * @param mixed[] $arguments
908+ * @return ? object
909+ * @throws SystemException
893910 */
894911 final public static function __callStatic (string $ name , array $ arguments )
895912 {
@@ -905,20 +922,18 @@ final public static function __callStatic(string $name, array $arguments)
905922 }
906923
907924 if (\class_exists ($ objectName )) {
908- if (!\is_subclass_of ($ objectName , SingletonFactory::class)) {
909- throw new ParentClassException ($ objectName , SingletonFactory::class);
910- }
911-
912925 self ::$ coreObject [$ className ] = \call_user_func ([$ objectName , 'getInstance ' ]);
913926
914927 return self ::$ coreObject [$ className ];
915928 }
929+
930+ return null ;
916931 }
917932
918933 /**
919934 * Searches for cached core object definition.
920935 *
921- * @return string|null
936+ * @return class- string<SingletonFactory> |null
922937 */
923938 final protected static function getCoreObject (string $ className )
924939 {
@@ -987,6 +1002,7 @@ public static function getActivePath(): string
9871002 }
9881003
9891004 /**
1005+ * @param string $fragment
9901006 * @deprecated 5.5 - Put a '#' followed by the fragment as the anchor's href. Make sure to |rawurlencode any variables that may contain special characters.
9911007 */
9921008 public function getAnchor ($ fragment ): string
0 commit comments