From 5193b4266c7cebafbab91bac04eda22bd8edb0fa Mon Sep 17 00:00:00 2001 From: Floorb <132411956+Neetpone@users.noreply.github.com> Date: Fri, 24 Feb 2023 06:26:40 -0500 Subject: [PATCH] misc cleanup, update vendor stuff, fix captcha --- admin/ajax_pastes.php | 53 - admin/common.php | 2 +- admin/configuration.php | 2 +- admin/index.php | 2 +- composer.lock | 429 ++++--- includes/Helpers/AbilityHelper.php | 2 +- includes/Helpers/SessionHelper.php | 2 +- includes/Models/Badge.php | 13 + includes/Models/User.php | 6 +- includes/captcha.php | 6 +- includes/common.php | 17 +- includes/functions.php | 10 +- js/main.js | 22 +- public/assets/bundle/archive.js | 22 +- public/assets/bundle/archive.min.js | 2 +- public/assets/bundle/archive.min.js.map | 2 +- public/assets/bundle/generic.js | 22 +- public/assets/bundle/generic.min.js | 2 +- public/assets/bundle/generic.min.js.map | 2 +- public/assets/bundle/user_profile.js | 22 +- public/assets/bundle/user_profile.min.js | 2 +- public/assets/bundle/user_profile.min.js.map | 2 +- public/captcha.php | 4 + public/index.php | 2 +- public/login.php | 4 +- public/paste.php | 3 +- theme/bulma/common.php | 5 +- theme/bulma/login.php | 16 +- theme/bulma/main.php | 5 +- theme/bulma/user_profile.php | 6 +- theme/bulma/view.php | 19 +- vendor/autoload.php | 18 + vendor/bin/carbon | 5 +- vendor/brick/math/CHANGELOG.md | 445 +++++++ vendor/brick/math/LICENSE | 20 + vendor/brick/math/composer.json | 34 + vendor/brick/math/src/BigDecimal.php | 786 ++++++++++++ vendor/brick/math/src/BigInteger.php | 1079 +++++++++++++++++ vendor/brick/math/src/BigNumber.php | 512 ++++++++ vendor/brick/math/src/BigRational.php | 445 +++++++ .../src/Exception/DivisionByZeroException.php | 35 + .../Exception/IntegerOverflowException.php | 23 + .../math/src/Exception/MathException.php | 12 + .../src/Exception/NegativeNumberException.php | 12 + .../src/Exception/NumberFormatException.php | 33 + .../Exception/RoundingNecessaryException.php | 19 + vendor/brick/math/src/Internal/Calculator.php | 676 +++++++++++ .../Internal/Calculator/BcMathCalculator.php | 75 ++ .../src/Internal/Calculator/GmpCalculator.php | 108 ++ .../Internal/Calculator/NativeCalculator.php | 581 +++++++++ vendor/brick/math/src/RoundingMode.php | 107 ++ vendor/composer/ClassLoader.php | 41 +- vendor/composer/InstalledVersions.php | 16 +- vendor/composer/autoload_classmap.php | 2 +- vendor/composer/autoload_files.php | 7 +- vendor/composer/autoload_namespaces.php | 2 +- vendor/composer/autoload_psr4.php | 5 +- vendor/composer/autoload_real.php | 56 +- vendor/composer/autoload_static.php | 17 +- vendor/composer/installed.json | 471 ++++--- vendor/composer/installed.php | 148 ++- vendor/composer/platform_check.php | 4 +- vendor/doctrine/inflector/composer.json | 17 +- .../Inflector/Rules/English/Inflectible.php | 16 +- .../Inflector/Rules/English/Uninflected.php | 14 +- .../Inflector/Rules/French/Inflectible.php | 12 +- .../Inflector/Rules/French/Uninflected.php | 12 +- .../Rules/NorwegianBokmal/Inflectible.php | 12 +- .../Rules/NorwegianBokmal/Uninflected.php | 12 +- .../Rules/Portuguese/Inflectible.php | 12 +- .../Rules/Portuguese/Uninflected.php | 12 +- .../Inflector/Rules/Spanish/Inflectible.php | 12 +- .../Inflector/Rules/Spanish/Uninflected.php | 12 +- .../Inflector/Rules/Turkish/Inflectible.php | 12 +- .../Inflector/Rules/Turkish/Uninflected.php | 12 +- vendor/doctrine/inflector/phpstan.neon.dist | 13 - vendor/doctrine/inflector/psalm.xml | 15 - vendor/illuminate/collections/Arr.php | 121 +- vendor/illuminate/collections/Collection.php | 139 ++- vendor/illuminate/collections/Enumerable.php | 40 +- .../illuminate/collections/LazyCollection.php | 97 +- .../collections/Traits/EnumeratesValues.php | 148 +-- vendor/illuminate/collections/helpers.php | 3 +- .../conditionable/HigherOrderWhenProxy.php | 55 +- .../conditionable/Traits/Conditionable.php | 24 +- vendor/illuminate/container/Container.php | 46 +- .../container/ContextualBindingBuilder.php | 4 +- .../contracts/Broadcasting/ShouldBeUnique.php | 8 + .../illuminate/contracts/Cache/Repository.php | 26 +- .../contracts/Console/Isolatable.php | 8 + .../Console/PromptsForMissingInput.php | 8 + .../contracts/Cookie/QueueingFactory.php | 2 +- .../contracts/Database/Eloquent/Castable.php | 3 +- .../Database/Eloquent/CastsAttributes.php | 8 +- .../contracts/Database/ModelIdentifier.php | 20 + .../contracts/Foundation/Application.php | 2 +- .../illuminate/contracts/Mail/Attachable.php | 13 + vendor/illuminate/contracts/Mail/Mailable.php | 2 +- vendor/illuminate/contracts/Mail/Mailer.php | 4 +- .../contracts/Pagination/Paginator.php | 4 +- vendor/illuminate/contracts/Queue/Monitor.php | 2 +- .../contracts/Routing/ResponseFactory.php | 4 +- .../contracts/Validation/InvokableRule.php | 16 + .../View/ViewCompilationException.php | 10 + .../database/Concerns/BuildsQueries.php | 42 +- .../database/Concerns/CompilesJsonPaths.php | 64 + .../database/Concerns/ManagesTransactions.php | 34 +- .../database/Concerns/ParsesSearchPath.php | 10 +- vendor/illuminate/database/Connection.php | 167 ++- .../database/ConnectionResolver.php | 4 +- .../database/Connectors/ConnectionFactory.php | 6 +- .../database/Connectors/PostgresConnector.php | 5 + .../database/Connectors/SQLiteConnector.php | 6 +- .../Connectors/SqlServerConnector.php | 30 +- .../Console/DatabaseInspectionCommand.php | 246 ++++ .../illuminate/database/Console/DbCommand.php | 8 + .../database/Console/DumpCommand.php | 12 +- .../Console/Factories/FactoryMakeCommand.php | 12 +- .../Console/Migrations/FreshCommand.php | 8 +- .../Console/Migrations/InstallCommand.php | 2 +- .../Console/Migrations/MigrateCommand.php | 144 ++- .../Console/Migrations/MigrateMakeCommand.php | 23 +- .../Console/Migrations/ResetCommand.php | 2 +- .../Console/Migrations/StatusCommand.php | 35 +- .../database/Console/MonitorCommand.php | 151 +++ .../database/Console/PruneCommand.php | 65 +- .../database/Console/Seeds/SeedCommand.php | 8 +- .../Console/Seeds/SeederMakeCommand.php | 18 +- .../database/Console/Seeds/stubs/seeder.stub | 2 +- .../database/Console/ShowCommand.php | 189 +++ .../database/Console/TableCommand.php | 246 ++++ .../database/Console/WipeCommand.php | 10 +- .../illuminate/database/DatabaseManager.php | 28 +- .../database/DatabaseTransactionsManager.php | 53 +- .../illuminate/database/DeadlockException.php | 10 + .../database/DetectsLostConnections.php | 4 + .../BroadcastableModelEventOccurred.php | 7 + .../illuminate/database/Eloquent/Builder.php | 234 +++- .../database/Eloquent/Casts/ArrayObject.php | 5 + .../database/Eloquent/Casts/AsArrayObject.php | 10 +- .../database/Eloquent/Casts/AsCollection.php | 10 +- .../Eloquent/Casts/AsEncryptedArrayObject.php | 2 +- .../Eloquent/Casts/AsEncryptedCollection.php | 2 +- .../Eloquent/Casts/AsEnumArrayObject.php | 84 ++ .../Eloquent/Casts/AsEnumCollection.php | 80 ++ .../database/Eloquent/Casts/AsStringable.php | 2 +- .../database/Eloquent/Casts/Attribute.php | 19 + .../database/Eloquent/Collection.php | 174 +-- .../Eloquent/Concerns/GuardsAttributes.php | 20 +- .../Eloquent/Concerns/HasAttributes.php | 241 +++- .../database/Eloquent/Concerns/HasEvents.php | 26 +- .../Eloquent/Concerns/HasRelationships.php | 63 +- .../Eloquent/Concerns/HasTimestamps.php | 72 +- .../database/Eloquent/Concerns/HasUlids.php | 96 ++ .../database/Eloquent/Concerns/HasUuids.php | 96 ++ .../Eloquent/Concerns/HidesAttributes.php | 20 +- .../Concerns/QueriesRelationships.php | 141 ++- .../Factories/BelongsToManyRelationship.php | 19 +- .../Factories/BelongsToRelationship.php | 19 +- .../Eloquent/Factories/CrossJoinSequence.php | 2 +- .../database/Eloquent/Factories/Factory.php | 165 ++- .../Eloquent/Factories/Relationship.php | 13 + .../database/Eloquent/Factories/Sequence.php | 2 +- .../Eloquent/MissingAttributeException.php | 23 + vendor/illuminate/database/Eloquent/Model.php | 287 ++++- .../PendingHasThroughRelationship.php | 90 ++ .../Eloquent/Relations/BelongsToMany.php | 77 +- .../Concerns/InteractsWithDictionary.php | 5 +- .../Concerns/InteractsWithPivotTable.php | 14 +- .../Eloquent/Relations/HasManyThrough.php | 33 +- .../Eloquent/Relations/HasOneOrMany.php | 48 + .../database/Eloquent/Relations/MorphMany.php | 13 + .../database/Eloquent/Relations/Relation.php | 6 +- .../database/Eloquent/SoftDeletes.php | 41 +- .../database/Eloquent/SoftDeletingScope.php | 19 +- .../database/Events/ConnectionEstablished.php | 8 + .../database/Events/DatabaseBusy.php | 32 + .../database/Events/TransactionCommitting.php | 8 + .../database/LostConnectionException.php | 10 + .../DatabaseMigrationRepository.php | 2 +- .../database/Migrations/Migrator.php | 107 +- .../MultipleColumnsSelectedException.php | 10 + vendor/illuminate/database/Query/Builder.php | 292 ++++- .../database/Query/Grammars/Grammar.php | 109 +- .../database/Query/Grammars/MySqlGrammar.php | 64 +- .../Query/Grammars/PostgresGrammar.php | 72 +- .../database/Query/Grammars/SQLiteGrammar.php | 27 + .../Query/Grammars/SqlServerGrammar.php | 52 +- .../illuminate/database/Query/IndexHint.php | 33 + .../SQLiteDatabaseDoesNotExistException.php | 28 + .../illuminate/database/Schema/Blueprint.php | 128 +- vendor/illuminate/database/Schema/Builder.php | 81 +- .../database/Schema/ColumnDefinition.php | 2 +- .../Schema/ForeignIdColumnDefinition.php | 2 +- .../database/Schema/ForeignKeyDefinition.php | 10 + .../database/Schema/Grammars/ChangeColumn.php | 7 +- .../database/Schema/Grammars/Grammar.php | 38 +- .../database/Schema/Grammars/MySqlGrammar.php | 42 +- .../Schema/Grammars/PostgresGrammar.php | 84 +- .../Schema/Grammars/SQLiteGrammar.php | 64 +- .../Schema/Grammars/SqlServerGrammar.php | 39 + .../database/Schema/IndexDefinition.php | 16 + .../database/Schema/MySqlBuilder.php | 4 +- .../database/Schema/MySqlSchemaState.php | 4 +- .../database/Schema/PostgresBuilder.php | 26 +- .../database/Schema/PostgresSchemaState.php | 23 +- .../database/Schema/SQLiteBuilder.php | 24 + .../database/Schema/SchemaState.php | 2 +- .../database/Schema/SqlServerBuilder.php | 24 + .../database/Schema/SqliteSchemaState.php | 6 + vendor/illuminate/database/Seeder.php | 23 +- .../database/SqlServerConnection.php | 2 +- vendor/illuminate/database/composer.json | 8 +- vendor/illuminate/support/Benchmark.php | 50 + vendor/illuminate/support/Carbon.php | 3 + vendor/illuminate/support/Composer.php | 24 +- .../support/ConfigurationUrlParser.php | 4 +- vendor/illuminate/support/DateFactory.php | 144 +-- vendor/illuminate/support/Env.php | 4 +- .../support/Exceptions/MathException.php | 10 + vendor/illuminate/support/Facades/App.php | 145 ++- vendor/illuminate/support/Facades/Artisan.php | 18 +- vendor/illuminate/support/Facades/Auth.php | 71 +- vendor/illuminate/support/Facades/Blade.php | 40 +- .../illuminate/support/Facades/Broadcast.php | 29 +- vendor/illuminate/support/Facades/Bus.php | 63 +- vendor/illuminate/support/Facades/Cache.php | 63 +- vendor/illuminate/support/Facades/Config.php | 15 +- vendor/illuminate/support/Facades/Cookie.php | 18 +- vendor/illuminate/support/Facades/Crypt.php | 6 +- vendor/illuminate/support/Facades/DB.php | 124 +- vendor/illuminate/support/Facades/Date.php | 72 +- vendor/illuminate/support/Facades/Event.php | 38 +- vendor/illuminate/support/Facades/Facade.php | 1 + vendor/illuminate/support/Facades/File.php | 75 +- vendor/illuminate/support/Facades/Gate.php | 39 +- vendor/illuminate/support/Facades/Hash.php | 14 +- vendor/illuminate/support/Facades/Http.php | 117 +- vendor/illuminate/support/Facades/Lang.php | 28 +- vendor/illuminate/support/Facades/Log.php | 34 +- vendor/illuminate/support/Facades/Mail.php | 66 +- .../support/Facades/Notification.php | 38 +- .../support/Facades/ParallelTesting.php | 10 +- .../illuminate/support/Facades/Password.php | 9 +- vendor/illuminate/support/Facades/Queue.php | 56 +- .../support/Facades/RateLimiter.php | 18 +- .../illuminate/support/Facades/Redirect.php | 26 +- vendor/illuminate/support/Facades/Redis.php | 26 +- vendor/illuminate/support/Facades/Request.php | 244 ++-- .../illuminate/support/Facades/Response.php | 32 +- vendor/illuminate/support/Facades/Route.php | 107 +- vendor/illuminate/support/Facades/Schema.php | 39 +- vendor/illuminate/support/Facades/Session.php | 77 +- vendor/illuminate/support/Facades/Storage.php | 90 +- vendor/illuminate/support/Facades/URL.php | 54 +- .../illuminate/support/Facades/Validator.php | 17 +- vendor/illuminate/support/Facades/View.php | 83 +- vendor/illuminate/support/Facades/Vite.php | 41 + vendor/illuminate/support/Fluent.php | 2 +- vendor/illuminate/support/Js.php | 5 + vendor/illuminate/support/Lottery.php | 271 +++++ vendor/illuminate/support/MessageBag.php | 6 +- vendor/illuminate/support/Pluralizer.php | 80 +- vendor/illuminate/support/Str.php | 400 ++++-- vendor/illuminate/support/Stringable.php | 227 +++- .../support/Testing/Fakes/BatchFake.php | 163 +++ .../Testing/Fakes/BatchRepositoryFake.php | 33 +- .../support/Testing/Fakes/BusFake.php | 168 ++- .../support/Testing/Fakes/EventFake.php | 82 +- .../support/Testing/Fakes/MailFake.php | 51 +- .../Testing/Fakes/NotificationFake.php | 44 +- .../Testing/Fakes/PendingBatchFake.php | 10 + .../support/Testing/Fakes/QueueFake.php | 133 +- vendor/illuminate/support/Timebox.php | 72 ++ vendor/illuminate/support/ValidatedInput.php | 34 +- vendor/illuminate/support/composer.json | 8 +- vendor/illuminate/support/helpers.php | 13 +- vendor/nesbot/carbon/.phpstorm.meta.php | 10 + vendor/nesbot/carbon/composer.json | 86 +- .../MessageFormatterMapperStrongType.php | 28 + .../MessageFormatterMapperWeakType.php | 36 + .../Carbon/PHPStan/AbstractMacroBuiltin.php | 36 + .../Carbon/PHPStan/AbstractMacroStatic.php | 45 + .../lazy/Carbon/PHPStan/MacroStrongType.php | 6 +- .../lazy/Carbon/PHPStan/MacroWeakType.php | 6 +- vendor/nesbot/carbon/readme.md | 12 +- .../carbon/src/Carbon/AbstractTranslator.php | 27 +- vendor/nesbot/carbon/src/Carbon/Carbon.php | 4 +- .../carbon/src/Carbon/CarbonImmutable.php | 958 +++++++-------- .../carbon/src/Carbon/CarbonInterface.php | 82 +- .../carbon/src/Carbon/CarbonInterval.php | 218 ++-- .../nesbot/carbon/src/Carbon/CarbonPeriod.php | 414 +++++-- .../src/Carbon/CarbonPeriodImmutable.php | 33 + .../carbon/src/Carbon/CarbonTimeZone.php | 42 +- .../Exceptions/BadComparisonUnitException.php | 25 +- .../BadFluentConstructorException.php | 25 +- .../Exceptions/BadFluentSetterException.php | 29 +- .../Exceptions/BadMethodCallException.php | 1 + .../Exceptions/EndLessPeriodException.php | 19 + .../src/Carbon/Exceptions/Exception.php | 1 + .../Carbon/Exceptions/ImmutableException.php | 24 +- .../Exceptions/InvalidArgumentException.php | 1 + .../Exceptions/InvalidCastException.php | 13 +- .../Exceptions/InvalidDateException.php | 6 +- .../Exceptions/InvalidFormatException.php | 13 +- .../Exceptions/InvalidIntervalException.php | 13 +- .../Exceptions/InvalidPeriodDateException.php | 13 +- .../InvalidPeriodParameterException.php | 13 +- .../Exceptions/InvalidTimeZoneException.php | 13 +- .../Exceptions/InvalidTypeException.php | 13 +- .../Exceptions/NotACarbonClassException.php | 31 +- .../Carbon/Exceptions/NotAPeriodException.php | 13 +- .../Exceptions/NotLocaleAwareException.php | 6 +- .../Carbon/Exceptions/OutOfRangeException.php | 6 +- .../Carbon/Exceptions/ParseErrorException.php | 61 +- .../Carbon/Exceptions/RuntimeException.php | 1 + .../src/Carbon/Exceptions/UnitException.php | 13 +- .../Exceptions/UnitNotConfiguredException.php | 25 +- .../Exceptions/UnknownGetterException.php | 29 +- .../Exceptions/UnknownMethodException.php | 25 +- .../Exceptions/UnknownSetterException.php | 29 +- .../Exceptions/UnknownUnitException.php | 25 +- .../Exceptions/UnreachableException.php | 13 +- vendor/nesbot/carbon/src/Carbon/Factory.php | 6 +- .../carbon/src/Carbon/FactoryImmutable.php | 6 +- .../nesbot/carbon/src/Carbon/Lang/ar_AE.php | 2 + .../nesbot/carbon/src/Carbon/Lang/ar_BH.php | 2 + .../nesbot/carbon/src/Carbon/Lang/ar_EG.php | 2 + .../nesbot/carbon/src/Carbon/Lang/ar_IQ.php | 2 + .../nesbot/carbon/src/Carbon/Lang/ar_JO.php | 2 + .../nesbot/carbon/src/Carbon/Lang/ar_KW.php | 2 + .../nesbot/carbon/src/Carbon/Lang/ar_LB.php | 2 + .../nesbot/carbon/src/Carbon/Lang/ar_OM.php | 2 + .../nesbot/carbon/src/Carbon/Lang/ar_PS.php | 5 + .../nesbot/carbon/src/Carbon/Lang/ar_QA.php | 2 + .../nesbot/carbon/src/Carbon/Lang/ar_SA.php | 2 + .../nesbot/carbon/src/Carbon/Lang/ar_SD.php | 2 + .../nesbot/carbon/src/Carbon/Lang/ar_SY.php | 2 + .../nesbot/carbon/src/Carbon/Lang/ar_YE.php | 2 + vendor/nesbot/carbon/src/Carbon/Lang/be.php | 7 +- .../carbon/src/Carbon/Lang/ca_ES_Valencia.php | 10 + vendor/nesbot/carbon/src/Carbon/Lang/ckb.php | 89 ++ vendor/nesbot/carbon/src/Carbon/Lang/cs.php | 3 +- vendor/nesbot/carbon/src/Carbon/Lang/cy.php | 2 +- vendor/nesbot/carbon/src/Carbon/Lang/da.php | 7 +- vendor/nesbot/carbon/src/Carbon/Lang/de.php | 9 + vendor/nesbot/carbon/src/Carbon/Lang/en.php | 2 +- vendor/nesbot/carbon/src/Carbon/Lang/es.php | 10 + vendor/nesbot/carbon/src/Carbon/Lang/fi.php | 2 + vendor/nesbot/carbon/src/Carbon/Lang/fr.php | 11 +- vendor/nesbot/carbon/src/Carbon/Lang/it.php | 11 +- vendor/nesbot/carbon/src/Carbon/Lang/ku.php | 42 +- vendor/nesbot/carbon/src/Carbon/Lang/lv.php | 3 +- vendor/nesbot/carbon/src/Carbon/Lang/mn.php | 62 +- vendor/nesbot/carbon/src/Carbon/Lang/oc.php | 2 +- vendor/nesbot/carbon/src/Carbon/Lang/pl.php | 2 +- vendor/nesbot/carbon/src/Carbon/Lang/pt.php | 9 + vendor/nesbot/carbon/src/Carbon/Lang/sh.php | 2 +- vendor/nesbot/carbon/src/Carbon/Lang/sk.php | 10 +- vendor/nesbot/carbon/src/Carbon/Lang/sl.php | 4 +- .../nesbot/carbon/src/Carbon/Lang/sr_Cyrl.php | 22 +- .../carbon/src/Carbon/Lang/sr_Cyrl_BA.php | 10 + .../carbon/src/Carbon/Lang/sr_Cyrl_ME.php | 31 +- .../carbon/src/Carbon/Lang/sr_Cyrl_XK.php | 10 + .../carbon/src/Carbon/Lang/sr_Latn_BA.php | 10 + .../carbon/src/Carbon/Lang/sr_Latn_ME.php | 10 + .../carbon/src/Carbon/Lang/sr_Latn_XK.php | 10 + vendor/nesbot/carbon/src/Carbon/Lang/ss.php | 2 +- vendor/nesbot/carbon/src/Carbon/Lang/sv.php | 2 +- vendor/nesbot/carbon/src/Carbon/Lang/uk.php | 1 + .../src/Carbon/Laravel/ServiceProvider.php | 52 +- .../MessageFormatterMapper.php | 42 + .../src/Carbon/PHPStan/AbstractMacro.php | 96 +- .../carbon/src/Carbon/PHPStan/Macro.php | 7 + .../src/Carbon/PHPStan/MacroExtension.php | 18 +- .../src/Carbon/PHPStan/MacroScanner.php | 28 +- .../carbon/src/Carbon/Traits/Comparison.php | 97 +- .../carbon/src/Carbon/Traits/Converter.php | 64 +- .../carbon/src/Carbon/Traits/Creator.php | 56 +- .../nesbot/carbon/src/Carbon/Traits/Date.php | 92 +- .../carbon/src/Carbon/Traits/Difference.php | 31 +- .../carbon/src/Carbon/Traits/Localization.php | 36 +- .../src/Carbon/Traits/MagicParameter.php | 33 + .../nesbot/carbon/src/Carbon/Traits/Mixin.php | 16 +- .../carbon/src/Carbon/Traits/Modifiers.php | 6 +- .../carbon/src/Carbon/Traits/Options.php | 2 +- .../carbon/src/Carbon/Traits/Rounding.php | 23 +- .../src/Carbon/Traits/Serialization.php | 100 +- .../nesbot/carbon/src/Carbon/Traits/Test.php | 26 +- .../carbon/src/Carbon/Traits/Timestamp.php | 6 +- .../src/Carbon/Traits/ToStringFormat.php | 56 + .../nesbot/carbon/src/Carbon/Traits/Units.php | 14 +- vendor/symfony/console/Application.php | 147 ++- vendor/symfony/console/CHANGELOG.md | 19 + .../console/CI/GithubActionReporter.php | 2 +- vendor/symfony/console/Color.php | 49 +- vendor/symfony/console/Command/Command.php | 81 +- .../console/Command/CompleteCommand.php | 47 +- .../console/Command/DumpCompletionCommand.php | 55 +- .../symfony/console/Command/HelpCommand.php | 33 +- .../symfony/console/Command/LazyCommand.php | 25 +- .../symfony/console/Command/ListCommand.php | 31 +- .../symfony/console/Command/LockableTrait.php | 3 +- .../CommandLoader/ContainerCommandLoader.php | 11 +- .../CommandLoader/FactoryCommandLoader.php | 9 - .../console/Completion/CompletionInput.php | 9 +- .../Output/BashCompletionOutput.php | 3 + .../Output/FishCompletionOutput.php | 33 + .../Completion/Output/ZshCompletionOutput.php | 36 + .../symfony/console/Completion/Suggestion.php | 16 +- vendor/symfony/console/Cursor.php | 8 +- .../AddConsoleCommandPass.php | 6 +- .../Descriptor/ApplicationDescription.php | 4 +- .../symfony/console/Descriptor/Descriptor.php | 30 +- .../console/Descriptor/JsonDescriptor.php | 15 - .../console/Descriptor/MarkdownDescriptor.php | 21 - .../console/Descriptor/TextDescriptor.php | 18 - .../console/Descriptor/XmlDescriptor.php | 15 - .../console/Event/ConsoleErrorEvent.php | 1 - vendor/symfony/console/Event/ConsoleEvent.php | 4 +- .../console/EventListener/ErrorListener.php | 4 +- .../Exception/InvalidOptionException.php | 2 +- .../console/Formatter/NullOutputFormatter.php | 22 +- .../Formatter/NullOutputFormatterStyle.php | 25 +- .../console/Formatter/OutputFormatter.php | 27 +- .../Formatter/OutputFormatterStyle.php | 26 +- .../OutputFormatterStyleInterface.php | 4 +- .../Formatter/OutputFormatterStyleStack.php | 8 +- .../WrappableOutputFormatterInterface.php | 2 + .../console/Helper/DebugFormatterHelper.php | 3 - .../console/Helper/DescriptorHelper.php | 3 - vendor/symfony/console/Helper/Dumper.php | 29 +- .../console/Helper/FormatterHelper.php | 3 - vendor/symfony/console/Helper/Helper.php | 17 +- .../console/Helper/HelperInterface.php | 2 +- vendor/symfony/console/Helper/HelperSet.php | 6 +- .../console/Helper/InputAwareHelper.php | 3 - .../symfony/console/Helper/OutputWrapper.php | 76 ++ .../symfony/console/Helper/ProcessHelper.php | 3 - vendor/symfony/console/Helper/ProgressBar.php | 48 +- .../console/Helper/ProgressIndicator.php | 27 +- .../symfony/console/Helper/QuestionHelper.php | 12 +- .../console/Helper/SymfonyQuestionHelper.php | 6 - vendor/symfony/console/Helper/Table.php | 214 +++- vendor/symfony/console/Input/ArgvInput.php | 14 +- vendor/symfony/console/Input/ArrayInput.php | 14 +- vendor/symfony/console/Input/Input.php | 42 - .../symfony/console/Input/InputArgument.php | 35 +- .../symfony/console/Input/InputDefinition.php | 4 +- .../symfony/console/Input/InputInterface.php | 3 + vendor/symfony/console/Input/InputOption.php | 36 +- vendor/symfony/console/Input/StringInput.php | 3 + vendor/symfony/console/LICENSE | 2 +- .../symfony/console/Logger/ConsoleLogger.php | 11 +- .../symfony/console/Output/AnsiColorMode.php | 124 ++ .../symfony/console/Output/BufferedOutput.php | 3 - .../symfony/console/Output/ConsoleOutput.php | 17 +- .../console/Output/ConsoleSectionOutput.php | 113 +- vendor/symfony/console/Output/NullOutput.php | 38 +- vendor/symfony/console/Output/Output.php | 38 +- .../console/Output/OutputInterface.php | 8 +- .../symfony/console/Output/StreamOutput.php | 7 +- .../console/Output/TrimmedBufferOutput.php | 3 - vendor/symfony/console/Question/Question.php | 14 +- vendor/symfony/console/README.md | 16 - .../symfony/console/Resources/completion.bash | 9 +- .../symfony/console/Resources/completion.fish | 29 + .../symfony/console/Resources/completion.zsh | 80 ++ .../console/SignalRegistry/SignalRegistry.php | 12 +- vendor/symfony/console/Style/OutputStyle.php | 41 +- vendor/symfony/console/Style/SymfonyStyle.php | 104 +- vendor/symfony/console/Terminal.php | 71 +- .../console/Tester/ApplicationTester.php | 44 +- .../symfony/console/Tester/CommandTester.php | 2 +- .../Tester/Constraint/CommandIsSuccessful.php | 12 - vendor/symfony/console/Tester/TesterTrait.php | 6 +- vendor/symfony/console/composer.json | 3 +- .../deprecation-contracts/CHANGELOG.md | 5 + vendor/symfony/deprecation-contracts/LICENSE | 19 + .../symfony/deprecation-contracts/README.md | 26 + .../deprecation-contracts/composer.json | 35 + .../deprecation-contracts/function.php | 27 + vendor/symfony/polyfill-ctype/README.md | 2 +- vendor/symfony/polyfill-ctype/composer.json | 2 +- .../polyfill-intl-grapheme/Grapheme.php | 2 +- .../symfony/polyfill-intl-grapheme/README.md | 2 +- .../polyfill-intl-grapheme/composer.json | 2 +- .../polyfill-intl-normalizer/Normalizer.php | 2 +- .../polyfill-intl-normalizer/README.md | 2 +- .../polyfill-intl-normalizer/composer.json | 2 +- vendor/symfony/polyfill-mbstring/Mbstring.php | 63 +- vendor/symfony/polyfill-mbstring/README.md | 2 +- .../symfony/polyfill-mbstring/composer.json | 2 +- vendor/symfony/polyfill-php80/README.md | 7 +- .../Resources/stubs/Attribute.php | 9 + .../Resources/stubs/PhpToken.php | 11 +- .../Resources/stubs/Stringable.php | 9 + .../Resources/stubs/UnhandledMatchError.php | 9 + .../Resources/stubs/ValueError.php | 9 + vendor/symfony/polyfill-php80/composer.json | 2 +- vendor/symfony/service-contracts/.gitignore | 3 - .../Attribute/SubscribedService.php | 20 +- vendor/symfony/service-contracts/LICENSE | 2 +- .../service-contracts/ServiceLocatorTrait.php | 9 - .../ServiceProviderInterface.php | 9 + .../ServiceSubscriberInterface.php | 13 +- .../ServiceSubscriberTrait.php | 32 +- .../symfony/service-contracts/composer.json | 9 +- vendor/symfony/string/AbstractString.php | 18 +- .../symfony/string/AbstractUnicodeString.php | 39 +- vendor/symfony/string/ByteString.php | 23 +- vendor/symfony/string/CHANGELOG.md | 5 + vendor/symfony/string/CodePointString.php | 2 +- .../string/Inflector/EnglishInflector.php | 10 +- .../string/Inflector/FrenchInflector.php | 10 +- vendor/symfony/string/LICENSE | 2 +- vendor/symfony/string/LazyString.php | 10 +- .../Resources/data/wcswidth_table_wide.php | 48 +- .../Resources/data/wcswidth_table_zero.php | 46 +- vendor/symfony/string/Resources/functions.php | 2 +- .../symfony/string/Slugger/AsciiSlugger.php | 51 +- vendor/symfony/string/UnicodeString.php | 4 +- vendor/symfony/string/composer.json | 3 +- .../symfony/translation-contracts/.gitignore | 3 - vendor/symfony/translation-contracts/LICENSE | 2 +- .../Test/TranslatorTest.php | 4 +- .../translation-contracts/TranslatorTrait.php | 212 ++-- .../translation-contracts/composer.json | 9 +- vendor/symfony/translation/CHANGELOG.md | 13 + .../Catalogue/AbstractOperation.php | 27 +- .../translation/Catalogue/MergeOperation.php | 15 +- .../translation/Catalogue/TargetOperation.php | 15 +- .../CatalogueMetadataAwareInterface.php | 44 + .../Command/TranslationPullCommand.php | 21 +- .../Command/TranslationPushCommand.php | 17 +- .../translation/Command/XliffLintCommand.php | 27 +- .../TranslationDataCollector.php | 14 +- .../translation/DataCollectorTranslator.php | 23 +- .../DependencyInjection/TranslatorPass.php | 15 + .../translation/Dumper/CsvFileDumper.php | 6 - .../symfony/translation/Dumper/FileDumper.php | 3 - .../translation/Dumper/IcuResFileDumper.php | 13 +- .../translation/Dumper/IniFileDumper.php | 6 - .../translation/Dumper/JsonFileDumper.php | 6 - .../translation/Dumper/MoFileDumper.php | 10 +- .../translation/Dumper/PhpFileDumper.php | 6 - .../translation/Dumper/PoFileDumper.php | 6 - .../translation/Dumper/QtFileDumper.php | 6 - .../translation/Dumper/XliffFileDumper.php | 32 +- .../translation/Dumper/YamlFileDumper.php | 6 - .../Exception/ProviderException.php | 2 +- .../translation/Extractor/ChainExtractor.php | 6 - .../translation/Extractor/PhpAstExtractor.php | 78 ++ .../translation/Extractor/PhpExtractor.php | 13 +- .../Extractor/PhpStringTokenParser.php | 5 + .../Extractor/Visitor/AbstractVisitor.php | 124 ++ .../Extractor/Visitor/ConstraintVisitor.php | 114 ++ .../Extractor/Visitor/TransMethodVisitor.php | 65 + .../Visitor/TranslatableMessageVisitor.php | 65 + .../translation/Formatter/IntlFormatter.php | 5 +- .../Formatter/MessageFormatter.php | 10 +- vendor/symfony/translation/LICENSE | 2 +- .../translation/Loader/ArrayLoader.php | 3 - .../translation/Loader/CsvFileLoader.php | 5 +- .../symfony/translation/Loader/FileLoader.php | 7 +- .../translation/Loader/IcuDatFileLoader.php | 5 +- .../translation/Loader/IcuResFileLoader.php | 5 +- .../translation/Loader/IniFileLoader.php | 3 - .../translation/Loader/JsonFileLoader.php | 25 +- .../translation/Loader/MoFileLoader.php | 2 - .../translation/Loader/PhpFileLoader.php | 11 +- .../translation/Loader/PoFileLoader.php | 12 +- .../translation/Loader/QtFileLoader.php | 3 - .../translation/Loader/XliffFileLoader.php | 9 +- .../translation/Loader/YamlFileLoader.php | 3 - vendor/symfony/translation/LocaleSwitcher.php | 75 ++ .../symfony/translation/LoggingTranslator.php | 23 +- .../symfony/translation/MessageCatalogue.php | 124 +- .../translation/MetadataAwareInterface.php | 2 +- .../Provider/FilteringProvider.php | 5 +- .../PseudoLocalizationTranslator.php | 7 +- vendor/symfony/translation/README.md | 8 +- .../translation/Reader/TranslationReader.php | 3 - .../Resources/bin/translation-status.php | 4 + .../translation/Resources/data/parents.json | 3 + ...ct.xsd => xliff-core-1.2-transitional.xsd} | 84 +- .../Test/ProviderFactoryTestCase.php | 16 +- .../translation/Test/ProviderTestCase.php | 16 +- vendor/symfony/translation/Translator.php | 38 +- vendor/symfony/translation/TranslatorBag.php | 11 +- .../symfony/translation/Util/XliffUtils.php | 2 +- vendor/symfony/translation/composer.json | 5 +- 592 files changed, 19688 insertions(+), 5691 deletions(-) delete mode 100644 admin/ajax_pastes.php create mode 100644 includes/Models/Badge.php create mode 100644 vendor/brick/math/CHANGELOG.md create mode 100644 vendor/brick/math/LICENSE create mode 100644 vendor/brick/math/composer.json create mode 100644 vendor/brick/math/src/BigDecimal.php create mode 100644 vendor/brick/math/src/BigInteger.php create mode 100644 vendor/brick/math/src/BigNumber.php create mode 100644 vendor/brick/math/src/BigRational.php create mode 100644 vendor/brick/math/src/Exception/DivisionByZeroException.php create mode 100644 vendor/brick/math/src/Exception/IntegerOverflowException.php create mode 100644 vendor/brick/math/src/Exception/MathException.php create mode 100644 vendor/brick/math/src/Exception/NegativeNumberException.php create mode 100644 vendor/brick/math/src/Exception/NumberFormatException.php create mode 100644 vendor/brick/math/src/Exception/RoundingNecessaryException.php create mode 100644 vendor/brick/math/src/Internal/Calculator.php create mode 100644 vendor/brick/math/src/Internal/Calculator/BcMathCalculator.php create mode 100644 vendor/brick/math/src/Internal/Calculator/GmpCalculator.php create mode 100644 vendor/brick/math/src/Internal/Calculator/NativeCalculator.php create mode 100644 vendor/brick/math/src/RoundingMode.php delete mode 100644 vendor/doctrine/inflector/phpstan.neon.dist delete mode 100644 vendor/doctrine/inflector/psalm.xml create mode 100644 vendor/illuminate/contracts/Broadcasting/ShouldBeUnique.php create mode 100644 vendor/illuminate/contracts/Console/Isolatable.php create mode 100644 vendor/illuminate/contracts/Console/PromptsForMissingInput.php create mode 100644 vendor/illuminate/contracts/Mail/Attachable.php create mode 100644 vendor/illuminate/contracts/Validation/InvokableRule.php create mode 100644 vendor/illuminate/contracts/View/ViewCompilationException.php create mode 100644 vendor/illuminate/database/Concerns/CompilesJsonPaths.php create mode 100644 vendor/illuminate/database/Console/DatabaseInspectionCommand.php create mode 100644 vendor/illuminate/database/Console/MonitorCommand.php create mode 100644 vendor/illuminate/database/Console/ShowCommand.php create mode 100644 vendor/illuminate/database/Console/TableCommand.php create mode 100644 vendor/illuminate/database/DeadlockException.php create mode 100644 vendor/illuminate/database/Eloquent/Casts/AsEnumArrayObject.php create mode 100644 vendor/illuminate/database/Eloquent/Casts/AsEnumCollection.php create mode 100644 vendor/illuminate/database/Eloquent/Concerns/HasUlids.php create mode 100644 vendor/illuminate/database/Eloquent/Concerns/HasUuids.php create mode 100755 vendor/illuminate/database/Eloquent/MissingAttributeException.php create mode 100644 vendor/illuminate/database/Eloquent/PendingHasThroughRelationship.php create mode 100644 vendor/illuminate/database/Events/ConnectionEstablished.php create mode 100644 vendor/illuminate/database/Events/DatabaseBusy.php create mode 100644 vendor/illuminate/database/Events/TransactionCommitting.php create mode 100644 vendor/illuminate/database/LostConnectionException.php create mode 100644 vendor/illuminate/database/MultipleColumnsSelectedException.php create mode 100755 vendor/illuminate/database/Query/IndexHint.php create mode 100644 vendor/illuminate/database/SQLiteDatabaseDoesNotExistException.php create mode 100644 vendor/illuminate/database/Schema/IndexDefinition.php create mode 100644 vendor/illuminate/support/Benchmark.php create mode 100644 vendor/illuminate/support/Exceptions/MathException.php create mode 100644 vendor/illuminate/support/Facades/Vite.php create mode 100644 vendor/illuminate/support/Lottery.php create mode 100644 vendor/illuminate/support/Testing/Fakes/BatchFake.php create mode 100644 vendor/illuminate/support/Timebox.php create mode 100644 vendor/nesbot/carbon/.phpstorm.meta.php create mode 100644 vendor/nesbot/carbon/lazy/Carbon/MessageFormatter/MessageFormatterMapperStrongType.php create mode 100644 vendor/nesbot/carbon/lazy/Carbon/MessageFormatter/MessageFormatterMapperWeakType.php create mode 100644 vendor/nesbot/carbon/lazy/Carbon/PHPStan/AbstractMacroBuiltin.php create mode 100644 vendor/nesbot/carbon/lazy/Carbon/PHPStan/AbstractMacroStatic.php create mode 100644 vendor/nesbot/carbon/src/Carbon/CarbonPeriodImmutable.php create mode 100644 vendor/nesbot/carbon/src/Carbon/Exceptions/EndLessPeriodException.php create mode 100644 vendor/nesbot/carbon/src/Carbon/Lang/ckb.php create mode 100644 vendor/nesbot/carbon/src/Carbon/MessageFormatter/MessageFormatterMapper.php create mode 100644 vendor/nesbot/carbon/src/Carbon/Traits/MagicParameter.php create mode 100644 vendor/nesbot/carbon/src/Carbon/Traits/ToStringFormat.php create mode 100644 vendor/symfony/console/Completion/Output/FishCompletionOutput.php create mode 100644 vendor/symfony/console/Completion/Output/ZshCompletionOutput.php create mode 100644 vendor/symfony/console/Helper/OutputWrapper.php create mode 100644 vendor/symfony/console/Output/AnsiColorMode.php create mode 100644 vendor/symfony/console/Resources/completion.fish create mode 100644 vendor/symfony/console/Resources/completion.zsh create mode 100644 vendor/symfony/deprecation-contracts/CHANGELOG.md create mode 100644 vendor/symfony/deprecation-contracts/LICENSE create mode 100644 vendor/symfony/deprecation-contracts/README.md create mode 100644 vendor/symfony/deprecation-contracts/composer.json create mode 100644 vendor/symfony/deprecation-contracts/function.php delete mode 100644 vendor/symfony/service-contracts/.gitignore delete mode 100644 vendor/symfony/translation-contracts/.gitignore create mode 100644 vendor/symfony/translation/CatalogueMetadataAwareInterface.php create mode 100644 vendor/symfony/translation/Extractor/PhpAstExtractor.php create mode 100644 vendor/symfony/translation/Extractor/Visitor/AbstractVisitor.php create mode 100644 vendor/symfony/translation/Extractor/Visitor/ConstraintVisitor.php create mode 100644 vendor/symfony/translation/Extractor/Visitor/TransMethodVisitor.php create mode 100644 vendor/symfony/translation/Extractor/Visitor/TranslatableMessageVisitor.php create mode 100644 vendor/symfony/translation/LocaleSwitcher.php rename vendor/symfony/translation/Resources/schemas/{xliff-core-1.2-strict.xsd => xliff-core-1.2-transitional.xsd} (96%) diff --git a/admin/ajax_pastes.php b/admin/ajax_pastes.php deleted file mode 100644 index 1de5207..0000000 --- a/admin/ajax_pastes.php +++ /dev/null @@ -1,53 +0,0 @@ - 'id', 'dt' => 0), - array('db' => 'member', 'dt' => 1), - array('db' => 'ip', 'dt' => 2), - array('db' => 'visible', 'dt' => 3) -); - -$columns2 = array( - array('db' => 'id', 'dt' => 0), - array('db' => 'member', 'dt' => 1), - array('db' => 'ip', 'dt' => 2), - array('db' => 'visible', 'dt' => 3), - array('db' => 'details', 'dt' => 4), - array('db' => 'view', 'dt' => 5), - array('db' => 'delete', 'dt' => 6) -); - - -// SQL server connection information -$sql_details = array( - 'user' => $db_user, - 'pass' => $db_pass, - 'db' => $db_schema, - 'host' => $db_host -); - - -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * If you just want to use the basic configuration for DataTables with PHP - * server-side, there is no need to edit below this line. - */ - -require('ssp.pastes.php'); - -echo json_encode( - SSP::simple($_GET, $sql_details, $table, $primaryKey, $columns, $columns2) -); diff --git a/admin/common.php b/admin/common.php index 9b08540..11c12ef 100644 --- a/admin/common.php +++ b/admin/common.php @@ -8,7 +8,7 @@ require_once('../includes/common.php'); use PonePaste\Models\AdminLog; use PonePaste\Models\User; -function updateAdminHistory(User $admin, int $action) { +function updateAdminHistory(User $admin, int $action) : void { $log = new AdminLog([ 'user_id' => $admin->id, 'action' => $action, diff --git a/admin/configuration.php b/admin/configuration.php index 1885aea..2b0d8e0 100644 --- a/admin/configuration.php +++ b/admin/configuration.php @@ -7,7 +7,7 @@ require_once('common.php'); const CONFIG_FILE_PATH = '../config/site.php'; -function updateConfiguration(string $path, array $new_config) { +function updateConfiguration(string $path, array $new_config) : void { $fp = fopen($path, 'w'); $new_config_text = var_export($new_config, true); diff --git a/admin/index.php b/admin/index.php index 5a4284f..426f726 100644 --- a/admin/index.php +++ b/admin/index.php @@ -5,7 +5,7 @@ require_once(__DIR__ . '/../includes/common.php'); use PonePaste\Models\User; use PonePaste\Models\AdminLog; -function updateAdminHistory(User $admin, int $action) { +function updateAdminHistory(User $admin, int $action) : void { $log = new AdminLog([ 'user_id' => $admin->id, 'action' => $action, diff --git a/composer.lock b/composer.lock index 7199b85..0d7d67f 100644 --- a/composer.lock +++ b/composer.lock @@ -7,29 +7,84 @@ "content-hash": "bc050acf9c5c5997281c5c3a6f33c811", "packages": [ { - "name": "doctrine/inflector", - "version": "2.0.4", + "name": "brick/math", + "version": "0.11.0", "source": { "type": "git", - "url": "https://github.com/doctrine/inflector.git", - "reference": "8b7ff3e4b7de6b2c84da85637b59fd2880ecaa89" + "url": "https://github.com/brick/math.git", + "reference": "0ad82ce168c82ba30d1c01ec86116ab52f589478" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/inflector/zipball/8b7ff3e4b7de6b2c84da85637b59fd2880ecaa89", - "reference": "8b7ff3e4b7de6b2c84da85637b59fd2880ecaa89", + "url": "https://api.github.com/repos/brick/math/zipball/0ad82ce168c82ba30d1c01ec86116ab52f589478", + "reference": "0ad82ce168c82ba30d1c01ec86116ab52f589478", + "shasum": "" + }, + "require": { + "php": "^8.0" + }, + "require-dev": { + "php-coveralls/php-coveralls": "^2.2", + "phpunit/phpunit": "^9.0", + "vimeo/psalm": "5.0.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Brick\\Math\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Arbitrary-precision arithmetic library", + "keywords": [ + "Arbitrary-precision", + "BigInteger", + "BigRational", + "arithmetic", + "bigdecimal", + "bignum", + "brick", + "math" + ], + "support": { + "issues": "https://github.com/brick/math/issues", + "source": "https://github.com/brick/math/tree/0.11.0" + }, + "funding": [ + { + "url": "https://github.com/BenMorel", + "type": "github" + } + ], + "time": "2023-01-15T23:15:59+00:00" + }, + { + "name": "doctrine/inflector", + "version": "2.0.6", + "source": { + "type": "git", + "url": "https://github.com/doctrine/inflector.git", + "reference": "d9d313a36c872fd6ee06d9a6cbcf713eaa40f024" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/inflector/zipball/d9d313a36c872fd6ee06d9a6cbcf713eaa40f024", + "reference": "d9d313a36c872fd6ee06d9a6cbcf713eaa40f024", "shasum": "" }, "require": { "php": "^7.2 || ^8.0" }, "require-dev": { - "doctrine/coding-standard": "^8.2", - "phpstan/phpstan": "^0.12", - "phpstan/phpstan-phpunit": "^0.12", - "phpstan/phpstan-strict-rules": "^0.12", - "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0", - "vimeo/psalm": "^4.10" + "doctrine/coding-standard": "^10", + "phpstan/phpstan": "^1.8", + "phpstan/phpstan-phpunit": "^1.1", + "phpstan/phpstan-strict-rules": "^1.3", + "phpunit/phpunit": "^8.5 || ^9.5", + "vimeo/psalm": "^4.25" }, "type": "library", "autoload": { @@ -79,7 +134,7 @@ ], "support": { "issues": "https://github.com/doctrine/inflector/issues", - "source": "https://github.com/doctrine/inflector/tree/2.0.4" + "source": "https://github.com/doctrine/inflector/tree/2.0.6" }, "funding": [ { @@ -95,7 +150,7 @@ "type": "tidelift" } ], - "time": "2021-10-22T20:16:43+00:00" + "time": "2022-10-20T09:10:12+00:00" }, { "name": "erusev/parsedown", @@ -149,16 +204,16 @@ }, { "name": "illuminate/collections", - "version": "v9.4.1", + "version": "v9.52.4", "source": { "type": "git", "url": "https://github.com/illuminate/collections.git", - "reference": "22c4bb17f4e6c6fb470b5957e8232b1b5baf76b0" + "reference": "0168d0e44ea0c4fe5451fe08cde7049b9e9f9741" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/collections/zipball/22c4bb17f4e6c6fb470b5957e8232b1b5baf76b0", - "reference": "22c4bb17f4e6c6fb470b5957e8232b1b5baf76b0", + "url": "https://api.github.com/repos/illuminate/collections/zipball/0168d0e44ea0c4fe5451fe08cde7049b9e9f9741", + "reference": "0168d0e44ea0c4fe5451fe08cde7049b9e9f9741", "shasum": "" }, "require": { @@ -200,20 +255,20 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2022-03-07T15:02:25+00:00" + "time": "2023-02-22T11:32:27+00:00" }, { "name": "illuminate/conditionable", - "version": "v9.4.1", + "version": "v9.52.4", "source": { "type": "git", "url": "https://github.com/illuminate/conditionable.git", - "reference": "56b4ba1166c264064bf63896f498a2bee320d16a" + "reference": "bea24daa0fa84b7e7b0d5b84f62c71b7e2dc3364" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/conditionable/zipball/56b4ba1166c264064bf63896f498a2bee320d16a", - "reference": "56b4ba1166c264064bf63896f498a2bee320d16a", + "url": "https://api.github.com/repos/illuminate/conditionable/zipball/bea24daa0fa84b7e7b0d5b84f62c71b7e2dc3364", + "reference": "bea24daa0fa84b7e7b0d5b84f62c71b7e2dc3364", "shasum": "" }, "require": { @@ -246,20 +301,20 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2022-02-28T16:37:46+00:00" + "time": "2023-02-01T21:42:32+00:00" }, { "name": "illuminate/container", - "version": "v9.4.1", + "version": "v9.52.4", "source": { "type": "git", "url": "https://github.com/illuminate/container.git", - "reference": "66f9049b19fb34e74134c6eeff92a442cee068e5" + "reference": "1641dda2d0750b68bb1264a3b37ff3973f2e6265" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/container/zipball/66f9049b19fb34e74134c6eeff92a442cee068e5", - "reference": "66f9049b19fb34e74134c6eeff92a442cee068e5", + "url": "https://api.github.com/repos/illuminate/container/zipball/1641dda2d0750b68bb1264a3b37ff3973f2e6265", + "reference": "1641dda2d0750b68bb1264a3b37ff3973f2e6265", "shasum": "" }, "require": { @@ -297,20 +352,20 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2022-03-03T14:08:19+00:00" + "time": "2023-01-24T16:54:18+00:00" }, { "name": "illuminate/contracts", - "version": "v9.4.1", + "version": "v9.52.4", "source": { "type": "git", "url": "https://github.com/illuminate/contracts.git", - "reference": "ce68106c575410c71f92ac1c91c5d95c561033bc" + "reference": "44f65d723b13823baa02ff69751a5948bde60c22" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/contracts/zipball/ce68106c575410c71f92ac1c91c5d95c561033bc", - "reference": "ce68106c575410c71f92ac1c91c5d95c561033bc", + "url": "https://api.github.com/repos/illuminate/contracts/zipball/44f65d723b13823baa02ff69751a5948bde60c22", + "reference": "44f65d723b13823baa02ff69751a5948bde60c22", "shasum": "" }, "require": { @@ -345,35 +400,37 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2022-03-04T18:18:32+00:00" + "time": "2023-02-08T14:36:30+00:00" }, { "name": "illuminate/database", - "version": "v9.4.1", + "version": "v9.52.4", "source": { "type": "git", "url": "https://github.com/illuminate/database.git", - "reference": "0fffd6ba91eb58330cbf7331c77ea38c2a16b5d9" + "reference": "fc7e9cf5d4c7c4c0a2800c0d345cc9985fb1b040" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/database/zipball/0fffd6ba91eb58330cbf7331c77ea38c2a16b5d9", - "reference": "0fffd6ba91eb58330cbf7331c77ea38c2a16b5d9", + "url": "https://api.github.com/repos/illuminate/database/zipball/fc7e9cf5d4c7c4c0a2800c0d345cc9985fb1b040", + "reference": "fc7e9cf5d4c7c4c0a2800c0d345cc9985fb1b040", "shasum": "" }, "require": { - "ext-json": "*", + "brick/math": "^0.9.3|^0.10.2|^0.11", + "ext-pdo": "*", "illuminate/collections": "^9.0", "illuminate/container": "^9.0", "illuminate/contracts": "^9.0", "illuminate/macroable": "^9.0", "illuminate/support": "^9.0", "php": "^8.0.2", - "symfony/console": "^6.0" + "symfony/console": "^6.0.9" }, "suggest": { "doctrine/dbal": "Required to rename columns and drop SQLite columns (^2.13.3|^3.1.4).", - "fakerphp/faker": "Required to use the eloquent factory builder (^1.9.1).", + "ext-filter": "Required to use the Postgres database driver.", + "fakerphp/faker": "Required to use the eloquent factory builder (^1.21).", "illuminate/console": "Required to use the database commands (^9.0).", "illuminate/events": "Required to use the observers with Eloquent (^9.0).", "illuminate/filesystem": "Required to use the migrations (^9.0).", @@ -413,20 +470,20 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2022-03-07T01:28:38+00:00" + "time": "2023-02-12T20:16:50+00:00" }, { "name": "illuminate/macroable", - "version": "v9.4.1", + "version": "v9.52.4", "source": { "type": "git", "url": "https://github.com/illuminate/macroable.git", - "reference": "25a2c6dac2b7541ecbadef952702e84ae15f5354" + "reference": "e3bfaf6401742a9c6abca61b9b10e998e5b6449a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/macroable/zipball/25a2c6dac2b7541ecbadef952702e84ae15f5354", - "reference": "25a2c6dac2b7541ecbadef952702e84ae15f5354", + "url": "https://api.github.com/repos/illuminate/macroable/zipball/e3bfaf6401742a9c6abca61b9b10e998e5b6449a", + "reference": "e3bfaf6401742a9c6abca61b9b10e998e5b6449a", "shasum": "" }, "require": { @@ -459,31 +516,32 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2022-02-01T14:44:21+00:00" + "time": "2022-08-09T13:29:29+00:00" }, { "name": "illuminate/support", - "version": "v9.4.1", + "version": "v9.52.4", "source": { "type": "git", "url": "https://github.com/illuminate/support.git", - "reference": "568ed7a21a75e0bd9ca641b6c4a626872ee26d6f" + "reference": "63dcb4523ccdfc01cdf5be17791f07cc20982a1e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/support/zipball/568ed7a21a75e0bd9ca641b6c4a626872ee26d6f", - "reference": "568ed7a21a75e0bd9ca641b6c4a626872ee26d6f", + "url": "https://api.github.com/repos/illuminate/support/zipball/63dcb4523ccdfc01cdf5be17791f07cc20982a1e", + "reference": "63dcb4523ccdfc01cdf5be17791f07cc20982a1e", "shasum": "" }, "require": { "doctrine/inflector": "^2.0", - "ext-json": "*", + "ext-ctype": "*", + "ext-filter": "*", "ext-mbstring": "*", "illuminate/collections": "^9.0", "illuminate/conditionable": "^9.0", "illuminate/contracts": "^9.0", "illuminate/macroable": "^9.0", - "nesbot/carbon": "^2.53.1", + "nesbot/carbon": "^2.62.1", "php": "^8.0.2", "voku/portable-ascii": "^2.0" }, @@ -493,8 +551,9 @@ "suggest": { "illuminate/filesystem": "Required to use the composer class (^9.0).", "league/commonmark": "Required to use Str::markdown() and Stringable::markdown() (^2.0.2).", - "ramsey/uuid": "Required to use Str::uuid() (^4.2.2).", + "ramsey/uuid": "Required to use Str::uuid() (^4.7).", "symfony/process": "Required to use the composer class (^6.0).", + "symfony/uid": "Required to use Str::ulid() (^6.0).", "symfony/var-dumper": "Required to use the dd function (^6.0).", "vlucas/phpdotenv": "Required to use the Env class and env helper (^5.4.1)." }, @@ -528,20 +587,20 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2022-03-08T14:39:38+00:00" + "time": "2023-02-13T16:54:43+00:00" }, { "name": "nesbot/carbon", - "version": "2.57.0", + "version": "2.66.0", "source": { "type": "git", "url": "https://github.com/briannesbitt/Carbon.git", - "reference": "4a54375c21eea4811dbd1149fe6b246517554e78" + "reference": "496712849902241f04902033b0441b269effe001" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/4a54375c21eea4811dbd1149fe6b246517554e78", - "reference": "4a54375c21eea4811dbd1149fe6b246517554e78", + "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/496712849902241f04902033b0441b269effe001", + "reference": "496712849902241f04902033b0441b269effe001", "shasum": "" }, "require": { @@ -552,14 +611,16 @@ "symfony/translation": "^3.4 || ^4.0 || ^5.0 || ^6.0" }, "require-dev": { - "doctrine/dbal": "^2.0 || ^3.0", + "doctrine/dbal": "^2.0 || ^3.1.4", "doctrine/orm": "^2.7", "friendsofphp/php-cs-fixer": "^3.0", "kylekatarnls/multi-tester": "^2.0", + "ondrejmirtes/better-reflection": "*", "phpmd/phpmd": "^2.9", "phpstan/extension-installer": "^1.0", - "phpstan/phpstan": "^0.12.54 || ^1.0", - "phpunit/phpunit": "^7.5.20 || ^8.5.14", + "phpstan/phpstan": "^0.12.99 || ^1.7.14", + "phpunit/php-file-iterator": "^2.0.5 || ^3.0.6", + "phpunit/phpunit": "^7.5.20 || ^8.5.26 || ^9.5.20", "squizlabs/php_codesniffer": "^3.4" }, "bin": [ @@ -616,15 +677,19 @@ }, "funding": [ { - "url": "https://opencollective.com/Carbon", - "type": "open_collective" + "url": "https://github.com/sponsors/kylekatarnls", + "type": "github" }, { - "url": "https://tidelift.com/funding/github/packagist/nesbot/carbon", + "url": "https://opencollective.com/Carbon#sponsor", + "type": "opencollective" + }, + { + "url": "https://tidelift.com/subscription/pkg/packagist-nesbot-carbon?utm_source=packagist-nesbot-carbon&utm_medium=referral&utm_campaign=readme", "type": "tidelift" } ], - "time": "2022-02-13T18:13:33+00:00" + "time": "2023-01-29T18:53:47+00:00" }, { "name": "psr/container", @@ -810,20 +875,21 @@ }, { "name": "symfony/console", - "version": "v6.0.5", + "version": "v6.2.5", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "3bebf4108b9e07492a2a4057d207aa5a77d146b1" + "reference": "3e294254f2191762c1d137aed4b94e966965e985" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/3bebf4108b9e07492a2a4057d207aa5a77d146b1", - "reference": "3bebf4108b9e07492a2a4057d207aa5a77d146b1", + "url": "https://api.github.com/repos/symfony/console/zipball/3e294254f2191762c1d137aed4b94e966965e985", + "reference": "3e294254f2191762c1d137aed4b94e966965e985", "shasum": "" }, "require": { - "php": ">=8.0.2", + "php": ">=8.1", + "symfony/deprecation-contracts": "^2.1|^3", "symfony/polyfill-mbstring": "~1.0", "symfony/service-contracts": "^1.1|^2|^3", "symfony/string": "^5.4|^6.0" @@ -885,7 +951,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v6.0.5" + "source": "https://github.com/symfony/console/tree/v6.2.5" }, "funding": [ { @@ -901,20 +967,87 @@ "type": "tidelift" } ], - "time": "2022-02-25T10:48:52+00:00" + "time": "2023-01-01T08:38:09+00:00" }, { - "name": "symfony/polyfill-ctype", - "version": "v1.25.0", + "name": "symfony/deprecation-contracts", + "version": "v3.2.0", "source": { "type": "git", - "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "30885182c981ab175d4d034db0f6f469898070ab" + "url": "https://github.com/symfony/deprecation-contracts.git", + "reference": "1ee04c65529dea5d8744774d474e7cbd2f1206d3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/30885182c981ab175d4d034db0f6f469898070ab", - "reference": "30885182c981ab175d4d034db0f6f469898070ab", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/1ee04c65529dea5d8744774d474e7cbd2f1206d3", + "reference": "1ee04c65529dea5d8744774d474e7cbd2f1206d3", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.3-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "files": [ + "function.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "A generic function and convention to trigger deprecation notices", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.2.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2022-11-25T10:21:52+00:00" + }, + { + "name": "symfony/polyfill-ctype", + "version": "v1.27.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "5bbc823adecdae860bb64756d639ecfec17b050a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/5bbc823adecdae860bb64756d639ecfec17b050a", + "reference": "5bbc823adecdae860bb64756d639ecfec17b050a", "shasum": "" }, "require": { @@ -929,7 +1062,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.23-dev" + "dev-main": "1.27-dev" }, "thanks": { "name": "symfony/polyfill", @@ -967,7 +1100,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.25.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.27.0" }, "funding": [ { @@ -983,20 +1116,20 @@ "type": "tidelift" } ], - "time": "2021-10-20T20:35:02+00:00" + "time": "2022-11-03T14:55:06+00:00" }, { "name": "symfony/polyfill-intl-grapheme", - "version": "v1.25.0", + "version": "v1.27.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-grapheme.git", - "reference": "81b86b50cf841a64252b439e738e97f4a34e2783" + "reference": "511a08c03c1960e08a883f4cffcacd219b758354" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/81b86b50cf841a64252b439e738e97f4a34e2783", - "reference": "81b86b50cf841a64252b439e738e97f4a34e2783", + "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/511a08c03c1960e08a883f4cffcacd219b758354", + "reference": "511a08c03c1960e08a883f4cffcacd219b758354", "shasum": "" }, "require": { @@ -1008,7 +1141,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.23-dev" + "dev-main": "1.27-dev" }, "thanks": { "name": "symfony/polyfill", @@ -1048,7 +1181,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.25.0" + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.27.0" }, "funding": [ { @@ -1064,20 +1197,20 @@ "type": "tidelift" } ], - "time": "2021-11-23T21:10:46+00:00" + "time": "2022-11-03T14:55:06+00:00" }, { "name": "symfony/polyfill-intl-normalizer", - "version": "v1.25.0", + "version": "v1.27.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-normalizer.git", - "reference": "8590a5f561694770bdcd3f9b5c69dde6945028e8" + "reference": "19bd1e4fcd5b91116f14d8533c57831ed00571b6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/8590a5f561694770bdcd3f9b5c69dde6945028e8", - "reference": "8590a5f561694770bdcd3f9b5c69dde6945028e8", + "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/19bd1e4fcd5b91116f14d8533c57831ed00571b6", + "reference": "19bd1e4fcd5b91116f14d8533c57831ed00571b6", "shasum": "" }, "require": { @@ -1089,7 +1222,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.23-dev" + "dev-main": "1.27-dev" }, "thanks": { "name": "symfony/polyfill", @@ -1132,7 +1265,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.25.0" + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.27.0" }, "funding": [ { @@ -1148,20 +1281,20 @@ "type": "tidelift" } ], - "time": "2021-02-19T12:13:01+00:00" + "time": "2022-11-03T14:55:06+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.25.0", + "version": "v1.27.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "0abb51d2f102e00a4eefcf46ba7fec406d245825" + "reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/0abb51d2f102e00a4eefcf46ba7fec406d245825", - "reference": "0abb51d2f102e00a4eefcf46ba7fec406d245825", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/8ad114f6b39e2c98a8b0e3bd907732c207c2b534", + "reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534", "shasum": "" }, "require": { @@ -1176,7 +1309,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.23-dev" + "dev-main": "1.27-dev" }, "thanks": { "name": "symfony/polyfill", @@ -1215,7 +1348,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.25.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.27.0" }, "funding": [ { @@ -1231,20 +1364,20 @@ "type": "tidelift" } ], - "time": "2021-11-30T18:21:41+00:00" + "time": "2022-11-03T14:55:06+00:00" }, { "name": "symfony/polyfill-php80", - "version": "v1.25.0", + "version": "v1.27.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "4407588e0d3f1f52efb65fbe92babe41f37fe50c" + "reference": "7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/4407588e0d3f1f52efb65fbe92babe41f37fe50c", - "reference": "4407588e0d3f1f52efb65fbe92babe41f37fe50c", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936", + "reference": "7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936", "shasum": "" }, "require": { @@ -1253,7 +1386,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.23-dev" + "dev-main": "1.27-dev" }, "thanks": { "name": "symfony/polyfill", @@ -1298,7 +1431,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.25.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.27.0" }, "funding": [ { @@ -1314,24 +1447,24 @@ "type": "tidelift" } ], - "time": "2022-03-04T08:16:47+00:00" + "time": "2022-11-03T14:55:06+00:00" }, { "name": "symfony/service-contracts", - "version": "v3.0.0", + "version": "v3.2.0", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "36715ebf9fb9db73db0cb24263c79077c6fe8603" + "reference": "aac98028c69df04ee77eb69b96b86ee51fbf4b75" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/36715ebf9fb9db73db0cb24263c79077c6fe8603", - "reference": "36715ebf9fb9db73db0cb24263c79077c6fe8603", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/aac98028c69df04ee77eb69b96b86ee51fbf4b75", + "reference": "aac98028c69df04ee77eb69b96b86ee51fbf4b75", "shasum": "" }, "require": { - "php": ">=8.0.2", + "php": ">=8.1", "psr/container": "^2.0" }, "conflict": { @@ -1343,7 +1476,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "3.0-dev" + "dev-main": "3.3-dev" }, "thanks": { "name": "symfony/contracts", @@ -1353,7 +1486,10 @@ "autoload": { "psr-4": { "Symfony\\Contracts\\Service\\": "" - } + }, + "exclude-from-classmap": [ + "/Test/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -1380,7 +1516,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/service-contracts/tree/v3.0.0" + "source": "https://github.com/symfony/service-contracts/tree/v3.2.0" }, "funding": [ { @@ -1396,24 +1532,24 @@ "type": "tidelift" } ], - "time": "2021-11-04T17:53:12+00:00" + "time": "2022-11-25T10:21:52+00:00" }, { "name": "symfony/string", - "version": "v6.0.3", + "version": "v6.2.5", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "522144f0c4c004c80d56fa47e40e17028e2eefc2" + "reference": "b2dac0fa27b1ac0f9c0c0b23b43977f12308d0b0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/522144f0c4c004c80d56fa47e40e17028e2eefc2", - "reference": "522144f0c4c004c80d56fa47e40e17028e2eefc2", + "url": "https://api.github.com/repos/symfony/string/zipball/b2dac0fa27b1ac0f9c0c0b23b43977f12308d0b0", + "reference": "b2dac0fa27b1ac0f9c0c0b23b43977f12308d0b0", "shasum": "" }, "require": { - "php": ">=8.0.2", + "php": ">=8.1", "symfony/polyfill-ctype": "~1.8", "symfony/polyfill-intl-grapheme": "~1.0", "symfony/polyfill-intl-normalizer": "~1.0", @@ -1425,6 +1561,7 @@ "require-dev": { "symfony/error-handler": "^5.4|^6.0", "symfony/http-client": "^5.4|^6.0", + "symfony/intl": "^6.2", "symfony/translation-contracts": "^2.0|^3.0", "symfony/var-exporter": "^5.4|^6.0" }, @@ -1465,7 +1602,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v6.0.3" + "source": "https://github.com/symfony/string/tree/v6.2.5" }, "funding": [ { @@ -1481,24 +1618,24 @@ "type": "tidelift" } ], - "time": "2022-01-02T09:55:41+00:00" + "time": "2023-01-01T08:38:09+00:00" }, { "name": "symfony/translation", - "version": "v6.0.6", + "version": "v6.2.5", "source": { "type": "git", "url": "https://github.com/symfony/translation.git", - "reference": "f6639cb9b5e0c57fe31e3263b900a77eedb0c908" + "reference": "60556925a703cfbc1581cde3b3f35b0bb0ea904c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation/zipball/f6639cb9b5e0c57fe31e3263b900a77eedb0c908", - "reference": "f6639cb9b5e0c57fe31e3263b900a77eedb0c908", + "url": "https://api.github.com/repos/symfony/translation/zipball/60556925a703cfbc1581cde3b3f35b0bb0ea904c", + "reference": "60556925a703cfbc1581cde3b3f35b0bb0ea904c", "shasum": "" }, "require": { - "php": ">=8.0.2", + "php": ">=8.1", "symfony/polyfill-mbstring": "~1.0", "symfony/translation-contracts": "^2.3|^3.0" }, @@ -1514,6 +1651,7 @@ "symfony/translation-implementation": "2.3|3.0" }, "require-dev": { + "nikic/php-parser": "^4.13", "psr/log": "^1|^2|^3", "symfony/config": "^5.4|^6.0", "symfony/console": "^5.4|^6.0", @@ -1523,10 +1661,12 @@ "symfony/http-kernel": "^5.4|^6.0", "symfony/intl": "^5.4|^6.0", "symfony/polyfill-intl-icu": "^1.21", + "symfony/routing": "^5.4|^6.0", "symfony/service-contracts": "^1.1.2|^2|^3", "symfony/yaml": "^5.4|^6.0" }, "suggest": { + "nikic/php-parser": "To use PhpAstExtractor", "psr/log-implementation": "To use logging capability in translator", "symfony/config": "", "symfony/yaml": "" @@ -1560,7 +1700,7 @@ "description": "Provides tools to internationalize your application", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/translation/tree/v6.0.6" + "source": "https://github.com/symfony/translation/tree/v6.2.5" }, "funding": [ { @@ -1576,24 +1716,24 @@ "type": "tidelift" } ], - "time": "2022-03-02T12:58:14+00:00" + "time": "2023-01-05T07:00:27+00:00" }, { "name": "symfony/translation-contracts", - "version": "v3.0.0", + "version": "v3.2.0", "source": { "type": "git", "url": "https://github.com/symfony/translation-contracts.git", - "reference": "1b6ea5a7442af5a12dba3dbd6d71034b5b234e77" + "reference": "68cce71402305a015f8c1589bfada1280dc64fe7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation-contracts/zipball/1b6ea5a7442af5a12dba3dbd6d71034b5b234e77", - "reference": "1b6ea5a7442af5a12dba3dbd6d71034b5b234e77", + "url": "https://api.github.com/repos/symfony/translation-contracts/zipball/68cce71402305a015f8c1589bfada1280dc64fe7", + "reference": "68cce71402305a015f8c1589bfada1280dc64fe7", "shasum": "" }, "require": { - "php": ">=8.0.2" + "php": ">=8.1" }, "suggest": { "symfony/translation-implementation": "" @@ -1601,7 +1741,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "3.0-dev" + "dev-main": "3.3-dev" }, "thanks": { "name": "symfony/contracts", @@ -1611,7 +1751,10 @@ "autoload": { "psr-4": { "Symfony\\Contracts\\Translation\\": "" - } + }, + "exclude-from-classmap": [ + "/Test/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -1638,7 +1781,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/translation-contracts/tree/v3.0.0" + "source": "https://github.com/symfony/translation-contracts/tree/v3.2.0" }, "funding": [ { @@ -1654,7 +1797,7 @@ "type": "tidelift" } ], - "time": "2021-09-07T12:43:40+00:00" + "time": "2022-11-25T10:21:52+00:00" }, { "name": "voku/portable-ascii", @@ -1745,5 +1888,5 @@ "ext-redis": "*" }, "platform-dev": [], - "plugin-api-version": "2.2.0" + "plugin-api-version": "2.3.0" } diff --git a/includes/Helpers/AbilityHelper.php b/includes/Helpers/AbilityHelper.php index 83d2595..97caf25 100644 --- a/includes/Helpers/AbilityHelper.php +++ b/includes/Helpers/AbilityHelper.php @@ -32,4 +32,4 @@ class AbilityHelper { return false; } -} \ No newline at end of file +} diff --git a/includes/Helpers/SessionHelper.php b/includes/Helpers/SessionHelper.php index a13970f..b1b3e99 100644 --- a/includes/Helpers/SessionHelper.php +++ b/includes/Helpers/SessionHelper.php @@ -25,7 +25,7 @@ class SessionHelper { return null; } - public static function destroySession() { + public static function destroySession() : void { $token = $_COOKIE[SessionHelper::REMEMBER_TOKEN_COOKIE]; UserSession::where('token', $token)->delete(); diff --git a/includes/Models/Badge.php b/includes/Models/Badge.php new file mode 100644 index 0000000..0491d7e --- /dev/null +++ b/includes/Models/Badge.php @@ -0,0 +1,13 @@ +hasMany(Paste::class) ->whereRaw("((expiry IS NULL) OR ((expiry != 'SELF') AND (expiry > NOW())))"); } + + public function badges() { + return $this->hasMany(Badge::class); + } } diff --git a/includes/captcha.php b/includes/captcha.php index c44ccfa..5b35dbc 100644 --- a/includes/captcha.php +++ b/includes/captcha.php @@ -1,5 +1,5 @@ setex('captcha/' . md5($token), 600, $code); diff --git a/includes/common.php b/includes/common.php index 353e3cd..3656d39 100644 --- a/includes/common.php +++ b/includes/common.php @@ -6,6 +6,7 @@ require_once(__DIR__ . '/../vendor/autoload.php'); require_once(__DIR__ . '/config.php'); require_once(__DIR__ . '/functions.php'); require_once(__DIR__ . '/passwords.php'); +require_once(__DIR__ . '/captcha.php'); use Illuminate\Database\Capsule\Manager as Capsule; use PonePaste\Helpers\SessionHelper; @@ -18,10 +19,10 @@ use PonePaste\Helpers\AbilityHelper; /* View functions */ function javascriptIncludeTag(string $name) : string { if (PP_DEBUG) { - return ""; + return ""; } - return ""; + return ""; } function urlForPage($page = '') : string { @@ -76,7 +77,7 @@ function optionsForSelect(array $displays, array $values, string $currentSelecti /** * @throws Exception if the flash level is invalid */ -function flash(string $level, string $message) { +function flash(string $level, string $message) : void { if (!isset($_SESSION['flashes'])) { $_SESSION['flashes'] = [ 'success' => [], @@ -93,15 +94,15 @@ function flash(string $level, string $message) { } -function flashError(string $message) { +function flashError(string $message) : void { flash('error', $message); } -function flashWarning(string $message) { +function flashWarning(string $message) : void { flash('warning', $message); } -function flashSuccess(string $message) { +function flashSuccess(string $message) : void { flash('success', $message); } @@ -117,8 +118,8 @@ function getFlashes() { return $flashes; } -function outputFlashes($flashes) { - function __outputFlash($level, $flash) { +function outputFlashes($flashes) : void { + function __outputFlash($level, $flash) : void { echo '
' . pp_html_escape($flash) . diff --git a/includes/functions.php b/includes/functions.php index 4919f37..6c2d848 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -56,7 +56,7 @@ function tagsToHtmlUser(string | array | Collection $tags, $profile_username) : return $output; } -function linkify($value, $protocols = array('http', 'mail'), array $attributes = array()) { +function linkify($value, $protocols = array('http', 'mail'), array $attributes = array()) : array|string|null { // Link attributes $attr = ''; foreach ($attributes as $key => $val) { @@ -90,7 +90,7 @@ function linkify($value, $protocols = array('http', 'mail'), array $attributes = }, $value); } -function formatBytes($size, $precision = 2) { +function formatBytes($size, $precision = 2) : string { $base = log($size, 1024); $suffixes = ['B', 'KB', 'MB', 'GB', 'TB']; @@ -118,7 +118,7 @@ function friendlyDateDifference(DateTime $lesser, DateTime $greater) : string { foreach ($parts as $part => $value) { if ($value !== 0) { $pluralizer = ($value === 1 ? '' : 's'); - $friendly .= "${value} ${part}${pluralizer} "; + $friendly .= "{$value} {$part}{$pluralizer} "; } } @@ -148,7 +148,7 @@ function truncate(string $input, int $maxWords, int $maxChars) : string { return $result . ($input == $result ? '' : '[...]'); } -function embedView($paste_id, $p_title, $content, $title) { +function embedView($paste_id, $p_title, $content, $title) : bool { $stats = false; if ($content) { // Build the output @@ -216,7 +216,7 @@ function embedView($paste_id, $p_title, $content, $title) { return $stats; } -function addToSitemap(Paste $paste, $priority, $changefreq) { +function addToSitemap(Paste $paste, $priority, $changefreq) : void { $c_date = date('Y-m-d'); $site_data = file_get_contents("sitemap.xml"); $site_data = str_replace("", "", $site_data); diff --git a/js/main.js b/js/main.js index 5b5ba9a..b90a407 100644 --- a/js/main.js +++ b/js/main.js @@ -80,6 +80,7 @@ const globalSetup = () => { main.id = ''; } + // CAPTCHA refresh const captchaContainer = $('.captcha_container'); if (captchaContainer) { @@ -88,14 +89,27 @@ const globalSetup = () => { if (refreshElement && imageElement) { refreshElement.addEventListener('click', () => { - imageElement.src = imageElement.src.split('?')[0] + '?rand=' + Math.random(); + let src = imageElement.src; + + if (src.indexOf('&refresh') !== -1) { + // yeah, it's kinda cancerous. fuck off. + src = src.split('&rand=')[0]; + } else { + src += '&refresh'; + } + + imageElement.src = src + '&rand=' + Math.random(); }); } } - Array.prototype.forEach.call($('.js-hidden'), (elem) => { - toggleEl(elem); - }); + const hiddenElements = $$('.js-hidden'); + + if (hiddenElements) { + Array.prototype.forEach.call(hiddenElements, (elem) => { + toggleEl(elem); + }); + } } export { globalSetup }; \ No newline at end of file diff --git a/public/assets/bundle/archive.js b/public/assets/bundle/archive.js index a27acd1..e10b9d1 100644 --- a/public/assets/bundle/archive.js +++ b/public/assets/bundle/archive.js @@ -488,6 +488,7 @@ const globalSetup = () => { main.id = ''; } + // CAPTCHA refresh const captchaContainer = $('.captcha_container'); if (captchaContainer) { @@ -496,14 +497,27 @@ const globalSetup = () => { if (refreshElement && imageElement) { refreshElement.addEventListener('click', () => { - imageElement.src = imageElement.src.split('?')[0] + '?rand=' + Math.random(); + let src = imageElement.src; + + if (src.indexOf('&refresh') !== -1) { + // yeah, it's kinda cancerous. fuck off. + src = src.split('&rand=')[0]; + } else { + src += '&refresh'; + } + + imageElement.src = src + '&rand=' + Math.random(); }); } } - Array.prototype.forEach.call($('.js-hidden'), (elem) => { - toggleEl(elem); - }); + const hiddenElements = $$('.js-hidden'); + + if (hiddenElements) { + Array.prototype.forEach.call(hiddenElements, (elem) => { + toggleEl(elem); + }); + } }; whenReady(() => { diff --git a/public/assets/bundle/archive.min.js b/public/assets/bundle/archive.min.js index ca012d0..0ff2c44 100644 --- a/public/assets/bundle/archive.min.js +++ b/public/assets/bundle/archive.min.js @@ -1,2 +1,2 @@ -function t(t){return function(t){if(Array.isArray(t))return n(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||a(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function e(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=a(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var i=0,r=function(){};return{s:r,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,o=!0,l=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return o=t.done,t},e:function(t){l=!0,s=t},f:function(){try{o||null==n.return||n.return()}finally{if(l)throw s}}}}function a(t,e){if(t){if("string"==typeof t)return n(t,e);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?n(t,e):void 0}}function n(t,e){(null==e||e>t.length)&&(e=t.length);for(var a=0,n=new Array(e);a/g,">").replace(/"/g,""").replace(/'/g,"'")},p=function(){function t(e){i(this,t),this.element=e}return s(t,[{key:"attach",value:function(t){this.element.addEventListener("click",(function(e){e.target&&e.target.classList.contains("paginator__button")&&t(+e.target.dataset.page)}))}},{key:"update",value:function(t,e,a){d(this.element);var n=Math.floor(t/e);if(0!==n){var i=a-2<0?0:a-2,r=a+2>n?n:a+2,s=Math.abs(0-a)>2,o=Math.abs(n-a)>2,l=0===a?"disabled":"";this.element.appendChild(c(''))),s&&(this.element.appendChild(c('"))),this.element.appendChild(c('')));for(var u=i;u<=r;u++){var h=u===a?"paginator__button--selected":"";this.element.appendChild(c('")))}o&&(this.element.appendChild(c('')),this.element.appendChild(c('"))));var p=a===n?"disabled":"";this.element.appendChild(c('')))}}}]),t}(),f=function(){function a(t,e){i(this,a),this.element=t,this.container=t.parentElement,this.options=e,this.ajaxCallback=e.ajaxCallback,this.data=[],this.unfilteredData=[],this.totalRecords=-1,this.perPage=20,this.currentPage=0,this.paginator=new p(this.container.querySelector(".paginator")),this.filterCallback=e.filterCallback,this.sortField=null,this.sortDir=!0}return s(a,[{key:"attach",value:function(){var t=this;this.filterField=this.container.querySelector("input.search"),this.filterField&&this.filterCallback&&(this.filterField.addEventListener("keyup",(function(e){e.target&&t._updateFilter(e.target.value)})),this.options.preFilter&&(this.filterField.value=this.options.preFilter)),this.perPageField=this.container.querySelector("select[name=per_page]"),this.perPageField&&this.perPageField.addEventListener("change",(function(e){t.perPage=Number(e.target.value),t._updatePage(0)}));var e=this.element.querySelector("tr.paginator__sort");e&&e.addEventListener("click",(function(e){var a=e.target;if(a.dataset.sortField){if(t.sortField){var n=t.element.querySelector("th[data-sort-field=".concat(t.sortField,"]"));n.classList.remove("paginator__sort--down"),n.classList.remove("paginator__sort--up")}t._updateSort(a.dataset.sortField,!t.sortDir),a.classList.add(t.sortDir?"paginator__sort--up":"paginator__sort--down")}})),this.paginator.attach(this._updatePage.bind(this)),this._loadEntries()}},{key:"_loadEntries",value:function(){var t=this;new Promise(this.ajaxCallback).then((function(e){t.element.classList.remove("hidden"),t.unfilteredData=e.data,t._updateFilter(t.options.preFilter)}))}},{key:"_updateEntries",value:function(t){this.data=t,this.totalRecords=this.data.length;var e=this.element.querySelector("tbody");d(e);for(var a=this.perPage*this.currentPage,n=a+this.perPage>this.totalRecords?this.totalRecords:a+this.perPage,i=a;in[e]?i=1:t[e]1&&void 0!==arguments[1]?arguments[1]:{};i(this,t),this.element=e,this.tags=[],this.options=a,this.maxTags=a.maxTags||10,this.inputNode=null,this.containerNode=null}return s(t,[{key:"attach",value:function(){if(this.element.style.display="none",this.containerNode=c('
'),this.inputNode=c(''),this.containerNode.appendChild(this.inputNode),this.element.parentNode.insertBefore(this.containerNode,this.element.nextSibling),this.element.value){var t,a=e(this.element.value.split(","));try{for(a.s();!(t=a.n()).done;){var n=t.value;this.addTag(n)}}catch(t){a.e(t)}finally{a.f()}}this.containerNode.addEventListener("keydown",this._handleInputKeyUp.bind(this)),this.containerNode.addEventListener("click",this._handleContainerClick.bind(this))}},{key:"detach",value:function(){this.tags.clear(),this.containerNode.remove(),this.element.style.display="inline-block"}},{key:"updateHiddenInputValue",value:function(){this.element.value=this.tags.join(",")}},{key:"deleteTagNode",value:function(t){this.tags.splice(this.tags.indexOf(t.dataset.value.toLowerCase()),1),t.remove(),this.tags.length'+h(t)+''),this.inputNode),this.tags.length>=this.maxTags&&(this.inputNode.disabled=!0))}},{key:"_handleInputKeyUp",value:function(t){var e=this.inputNode.value;"Backspace"===t.key&&""===e?this.inputNode.previousSibling&&(this.deleteTagNode(this.inputNode.previousSibling),this.updateHiddenInputValue()):","===t.key&&(this.addTag(e),this.inputNode.value="",this.updateHiddenInputValue(),t.preventDefault())}},{key:"_handleContainerClick",value:function(t){t.target&&t.target.classList.contains("delete")&&(this.deleteTagNode(t.target.closest(".tag")),this.updateHiddenInputValue())}}]),t}(),m=function(){var t,e;Array.prototype.forEach.call((t=".js-tag-input",document.querySelectorAll(t)||[]),(function(t){new v(t).attach()})),(e=l('[data-target~="#signin"],[data-target~="#signup"]'))&&(e.href="javascript:void(0)",e.addEventListener("click",(function(){l(".modal").classList.add("is-active")})),l(".modal-button-close").addEventListener("click",(function(){l(".modal").classList.remove("is-active")})));var a=l(".panel-tools .embed-tool");a&&a.addEventListener("click",(function(t){t.target&&t.target.closest(".panel-tools")&&u(t.target.closest(".panel-tools").querySelector(".panel-embed"))}));var n=l(".expand-tool");n&&n.addEventListener("click",(function(t){if(t.target&&t.target.closest(".panel")){var e=t.target.closest(".panel");e.classList.contains("panel-fullsize")?e.classList.remove("panel-fullsize"):e.classList.add("panel-fullsize")}})),(document.querySelectorAll(".notification .delete")||[]).forEach((function(t){var e=t.parentNode;t.addEventListener("click",(function(){e.parentNode.removeChild(e)}))}));var i=Array.prototype.slice.call(document.querySelectorAll(".navbar-burger"),0);i.length>0&&i.forEach((function(t){t.addEventListener("click",(function(){var e=t.dataset.target,a=document.getElementById(e);t.classList.toggle("is-active"),a.classList.toggle("is-active")}))}));var r=l(".preloader"),s=l("main");r&&s&&(r.remove(),s.id="");var o=l(".captcha_container");if(o){var c=o.querySelector("a"),d=o.querySelector("img");c&&d&&c.addEventListener("click",(function(){d.src=d.src.split("?")[0]+"?rand="+Math.random()}))}Array.prototype.forEach.call(l(".js-hidden"),(function(t){u(t)}))};o=function(){m();var t=new URLSearchParams(window.location.search).get("q");new f(document.getElementById("archive"),{ajaxCallback:function(t){fetch("/api/ajax_pastes.php").then((function(t){return t.json()})).then(t)},rowCallback:function(t){return'\n ').concat(h(t.title),'\n ').concat(h(t.author),"\n ").concat(t.tags.map((function(t){var e;return e=-1!==t.name.indexOf("nsfw")?"is-danger":-1!==t.name.indexOf("safe")?"is-success":-1!==t.name.indexOf("/")?"is-primary":"is-info",'\n ').concat(h(t.name),"\n ")})).join(""),"\n ")},filterCallback:g,preFilter:t}).attach()},"loading"!==document.readyState?o():document.addEventListener("DOMContentLoaded",o); +function t(t){return function(t){if(Array.isArray(t))return n(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||a(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function e(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=a(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var i=0,r=function(){};return{s:r,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,o=!0,l=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return o=t.done,t},e:function(t){l=!0,s=t},f:function(){try{o||null==n.return||n.return()}finally{if(l)throw s}}}}function a(t,e){if(t){if("string"==typeof t)return n(t,e);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?n(t,e):void 0}}function n(t,e){(null==e||e>t.length)&&(e=t.length);for(var a=0,n=new Array(e);a/g,">").replace(/"/g,""").replace(/'/g,"'")},f=function(){function t(e){i(this,t),this.element=e}return s(t,[{key:"attach",value:function(t){this.element.addEventListener("click",(function(e){e.target&&e.target.classList.contains("paginator__button")&&t(+e.target.dataset.page)}))}},{key:"update",value:function(t,e,a){u(this.element);var n=Math.floor(t/e);if(0!==n){var i=a-2<0?0:a-2,r=a+2>n?n:a+2,s=Math.abs(0-a)>2,o=Math.abs(n-a)>2,l=0===a?"disabled":"";this.element.appendChild(d(''))),s&&(this.element.appendChild(d('"))),this.element.appendChild(d('')));for(var c=i;c<=r;c++){var h=c===a?"paginator__button--selected":"";this.element.appendChild(d('")))}o&&(this.element.appendChild(d('')),this.element.appendChild(d('"))));var p=a===n?"disabled":"";this.element.appendChild(d('')))}}}]),t}(),g=function(){function a(t,e){i(this,a),this.element=t,this.container=t.parentElement,this.options=e,this.ajaxCallback=e.ajaxCallback,this.data=[],this.unfilteredData=[],this.totalRecords=-1,this.perPage=20,this.currentPage=0,this.paginator=new f(this.container.querySelector(".paginator")),this.filterCallback=e.filterCallback,this.sortField=null,this.sortDir=!0}return s(a,[{key:"attach",value:function(){var t=this;this.filterField=this.container.querySelector("input.search"),this.filterField&&this.filterCallback&&(this.filterField.addEventListener("keyup",(function(e){e.target&&t._updateFilter(e.target.value)})),this.options.preFilter&&(this.filterField.value=this.options.preFilter)),this.perPageField=this.container.querySelector("select[name=per_page]"),this.perPageField&&this.perPageField.addEventListener("change",(function(e){t.perPage=Number(e.target.value),t._updatePage(0)}));var e=this.element.querySelector("tr.paginator__sort");e&&e.addEventListener("click",(function(e){var a=e.target;if(a.dataset.sortField){if(t.sortField){var n=t.element.querySelector("th[data-sort-field=".concat(t.sortField,"]"));n.classList.remove("paginator__sort--down"),n.classList.remove("paginator__sort--up")}t._updateSort(a.dataset.sortField,!t.sortDir),a.classList.add(t.sortDir?"paginator__sort--up":"paginator__sort--down")}})),this.paginator.attach(this._updatePage.bind(this)),this._loadEntries()}},{key:"_loadEntries",value:function(){var t=this;new Promise(this.ajaxCallback).then((function(e){t.element.classList.remove("hidden"),t.unfilteredData=e.data,t._updateFilter(t.options.preFilter)}))}},{key:"_updateEntries",value:function(t){this.data=t,this.totalRecords=this.data.length;var e=this.element.querySelector("tbody");u(e);for(var a=this.perPage*this.currentPage,n=a+this.perPage>this.totalRecords?this.totalRecords:a+this.perPage,i=a;in[e]?i=1:t[e]1&&void 0!==arguments[1]?arguments[1]:{};i(this,t),this.element=e,this.tags=[],this.options=a,this.maxTags=a.maxTags||10,this.inputNode=null,this.containerNode=null}return s(t,[{key:"attach",value:function(){if(this.element.style.display="none",this.containerNode=d('
'),this.inputNode=d(''),this.containerNode.appendChild(this.inputNode),this.element.parentNode.insertBefore(this.containerNode,this.element.nextSibling),this.element.value){var t,a=e(this.element.value.split(","));try{for(a.s();!(t=a.n()).done;){var n=t.value;this.addTag(n)}}catch(t){a.e(t)}finally{a.f()}}this.containerNode.addEventListener("keydown",this._handleInputKeyUp.bind(this)),this.containerNode.addEventListener("click",this._handleContainerClick.bind(this))}},{key:"detach",value:function(){this.tags.clear(),this.containerNode.remove(),this.element.style.display="inline-block"}},{key:"updateHiddenInputValue",value:function(){this.element.value=this.tags.join(",")}},{key:"deleteTagNode",value:function(t){this.tags.splice(this.tags.indexOf(t.dataset.value.toLowerCase()),1),t.remove(),this.tags.length'+p(t)+''),this.inputNode),this.tags.length>=this.maxTags&&(this.inputNode.disabled=!0))}},{key:"_handleInputKeyUp",value:function(t){var e=this.inputNode.value;"Backspace"===t.key&&""===e?this.inputNode.previousSibling&&(this.deleteTagNode(this.inputNode.previousSibling),this.updateHiddenInputValue()):","===t.key&&(this.addTag(e),this.inputNode.value="",this.updateHiddenInputValue(),t.preventDefault())}},{key:"_handleContainerClick",value:function(t){t.target&&t.target.classList.contains("delete")&&(this.deleteTagNode(t.target.closest(".tag")),this.updateHiddenInputValue())}}]),t}(),y=function(){var t;Array.prototype.forEach.call(c(".js-tag-input"),(function(t){new m(t).attach()})),(t=l('[data-target~="#signin"],[data-target~="#signup"]'))&&(t.href="javascript:void(0)",t.addEventListener("click",(function(){l(".modal").classList.add("is-active")})),l(".modal-button-close").addEventListener("click",(function(){l(".modal").classList.remove("is-active")})));var e=l(".panel-tools .embed-tool");e&&e.addEventListener("click",(function(t){t.target&&t.target.closest(".panel-tools")&&h(t.target.closest(".panel-tools").querySelector(".panel-embed"))}));var a=l(".expand-tool");a&&a.addEventListener("click",(function(t){if(t.target&&t.target.closest(".panel")){var e=t.target.closest(".panel");e.classList.contains("panel-fullsize")?e.classList.remove("panel-fullsize"):e.classList.add("panel-fullsize")}})),(document.querySelectorAll(".notification .delete")||[]).forEach((function(t){var e=t.parentNode;t.addEventListener("click",(function(){e.parentNode.removeChild(e)}))}));var n=Array.prototype.slice.call(document.querySelectorAll(".navbar-burger"),0);n.length>0&&n.forEach((function(t){t.addEventListener("click",(function(){var e=t.dataset.target,a=document.getElementById(e);t.classList.toggle("is-active"),a.classList.toggle("is-active")}))}));var i=l(".preloader"),r=l("main");i&&r&&(i.remove(),r.id="");var s=l(".captcha_container");if(s){var o=s.querySelector("a"),d=s.querySelector("img");o&&d&&o.addEventListener("click",(function(){var t=d.src;-1!==t.indexOf("&refresh")?t=t.split("&rand=")[0]:t+="&refresh",d.src=t+"&rand="+Math.random()}))}var u=c(".js-hidden");u&&Array.prototype.forEach.call(u,(function(t){h(t)}))};o=function(){y();var t=new URLSearchParams(window.location.search).get("q");new g(document.getElementById("archive"),{ajaxCallback:function(t){fetch("/api/ajax_pastes.php").then((function(t){return t.json()})).then(t)},rowCallback:function(t){return'\n ').concat(p(t.title),'\n ').concat(p(t.author),"\n ").concat(t.tags.map((function(t){var e;return e=-1!==t.name.indexOf("nsfw")?"is-danger":-1!==t.name.indexOf("safe")?"is-success":-1!==t.name.indexOf("/")?"is-primary":"is-info",'\n ').concat(p(t.name),"\n ")})).join(""),"\n ")},filterCallback:v,preFilter:t}).attach()},"loading"!==document.readyState?o():document.addEventListener("DOMContentLoaded",o); //# sourceMappingURL=archive.min.js.map diff --git a/public/assets/bundle/archive.min.js.map b/public/assets/bundle/archive.min.js.map index 65bfa62..39f8873 100644 --- a/public/assets/bundle/archive.min.js.map +++ b/public/assets/bundle/archive.min.js.map @@ -1 +1 @@ -{"version":3,"file":"archive.min.js","sources":["../../../js/dom.js","../../../js/data_tables.js","../../../js/tag_input.js","../../../js/main.js","../../../js/archive.js","../../../js/utils.js"],"sourcesContent":["const $ = function(selector) {\n return document.querySelector(selector);\n};\n\nconst $$ = function(selector) {\n return document.querySelectorAll(selector) || [];\n};\n\nconst makeEl = function(html) {\n const template = document.createElement('template');\n\n template.innerHTML = html.trim();\n\n return template.content.firstChild;\n};\n\nconst clearEl = function(el) {\n while (el.firstChild) {\n el.removeChild(el.firstChild);\n }\n};\n\nconst toggleEl = function(el) {\n if (el.classList.contains('is-hidden')) {\n el.classList.remove('is-hidden');\n } else {\n el.classList.add('is-hidden');\n }\n};\n\nconst escape = function(unsafe) {\n return unsafe\n .replace(/&/g, \"&\")\n .replace(//g, \">\")\n .replace(/\"/g, \""\")\n .replace(/'/g, \"'\");\n}\n\nconst whenReady = function(funcp) {\n if (document.readyState !== 'loading') {\n funcp();\n } else {\n document.addEventListener('DOMContentLoaded', funcp);\n }\n}\n\nexport { whenReady, $, $$, makeEl, clearEl, toggleEl, escape };","import { makeEl, clearEl } from \"./dom\";\n\nclass SimplePaginator {\n constructor(element) {\n this.element = element;\n }\n\n attach(pageCallback) {\n this.element.addEventListener('click', evt => {\n if (evt.target && evt.target.classList.contains('paginator__button')) {\n pageCallback(+evt.target.dataset.page);\n }\n });\n }\n\n update(totalRecords, perPage, currentPage) {\n clearEl(this.element);\n\n /* First and last page in existence */\n const firstPage = 0;\n const lastPage = Math.floor(totalRecords / perPage); // ish?\n const numPagesToShow = 2;\n\n if (lastPage === firstPage) {\n return;\n }\n\n /* First and last page the main paginator will show */\n const firstPageShow = (currentPage - numPagesToShow) < firstPage ? firstPage : (currentPage - numPagesToShow);\n const lastPageShow = (currentPage + numPagesToShow) > lastPage ? lastPage : (currentPage + numPagesToShow);\n\n /* Whether to show the first and last pages in existence at the ends of the paginator */\n const showFirstPage = (Math.abs(firstPage - currentPage)) > (numPagesToShow);\n const showLastPage = (Math.abs(lastPage - currentPage)) > (numPagesToShow);\n\n\n const prevButtonDisabled = currentPage === firstPage ? 'disabled' : ''\n\n /* Previous button */\n this.element.appendChild(makeEl(\n ``\n ));\n\n /* First page button */\n if (showFirstPage) {\n this.element.appendChild(makeEl(\n ``\n ));\n this.element.appendChild(makeEl(``));\n }\n\n /* \"window\" buttons */\n for (let i = firstPageShow; i <= lastPageShow; i++) {\n const selected = (i === currentPage ? 'paginator__button--selected' : '');\n this.element.appendChild(makeEl(\n ``\n ));\n }\n\n /* Last page button */\n if (showLastPage) {\n this.element.appendChild(makeEl(``));\n this.element.appendChild(makeEl(\n ``\n ));\n }\n\n const nextButtonDisabled = currentPage === lastPage ? 'disabled' : ''\n /* Next button */\n this.element.appendChild(makeEl(\n ``\n ));\n }\n}\n\nclass DataTable {\n constructor(element, options) {\n this.element = element;\n this.container = element.parentElement;\n this.options = options;\n\n this.ajaxCallback = options.ajaxCallback;\n this.data = [];\n this.unfilteredData = [];\n\n this.totalRecords = -1;\n this.perPage = 20;\n this.currentPage = 0;\n\n this.paginator = new SimplePaginator(this.container.querySelector('.paginator'));\n\n this.filterCallback = options.filterCallback;\n this.sortField = null;\n this.sortDir = true;\n }\n\n attach() {\n this.filterField = this.container.querySelector('input.search');\n if (this.filterField && this.filterCallback) {\n this.filterField.addEventListener('keyup', evt => {\n if (evt.target) {\n this._updateFilter(evt.target.value);\n }\n });\n\n if (this.options.preFilter) {\n this.filterField.value = this.options.preFilter;\n }\n }\n\n this.perPageField = this.container.querySelector('select[name=per_page]');\n\n if (this.perPageField) {\n this.perPageField.addEventListener('change', evt => {\n this.perPage = Number(evt.target.value);\n this._updatePage(0);\n });\n }\n\n const header = this.element.querySelector('tr.paginator__sort');\n\n if (header) {\n header.addEventListener('click', evt => {\n const target = evt.target;\n\n if (!target.dataset.sortField) {\n return;\n }\n\n if (this.sortField) {\n const elem = this.element.querySelector(`th[data-sort-field=${this.sortField}]`)\n elem.classList.remove('paginator__sort--down');\n elem.classList.remove('paginator__sort--up');\n }\n\n this._updateSort(target.dataset.sortField, !this.sortDir);\n\n target.classList.add(this.sortDir ? 'paginator__sort--up' : 'paginator__sort--down');\n });\n }\n\n this.paginator.attach(this._updatePage.bind(this));\n this._loadEntries();\n }\n\n /* Load the requested data from the server, and when done, update the DOM. */\n _loadEntries() {\n new Promise(this.ajaxCallback)\n .then(data => {\n this.element.classList.remove('hidden');\n this.unfilteredData = data.data;\n this._updateFilter(this.options.preFilter);\n });\n }\n\n /* Update the DOM to reflect the current state of the data we have loaded */\n _updateEntries(data) {\n this.data = data;\n this.totalRecords = this.data.length;\n\n const bodyElement = this.element.querySelector('tbody');\n clearEl(bodyElement);\n\n const firstIndex = (this.perPage * this.currentPage);\n const lastIndex = (firstIndex + this.perPage) > this.totalRecords ? this.totalRecords : (firstIndex + this.perPage);\n\n\n for (let i = firstIndex; i < lastIndex; i++) {\n const rowElem = makeEl(this.options.rowCallback(this.data[i]));\n rowElem.classList.add(i % 2 === 0 ? 'odd' : 'even');\n\n bodyElement.appendChild(rowElem);\n }\n\n this.paginator.update(this.totalRecords, this.perPage, this.currentPage);\n }\n\n _updatePage(n) {\n this.currentPage = n;\n this.paginator.update(this.totalRecords, this.perPage, this.currentPage);\n this._updateEntries(this.data);\n }\n\n _updateFilter(query) {\n /* clearing the query */\n if (query === null || query === '') {\n this._updateEntries(this.unfilteredData);\n return;\n }\n\n let data = [];\n for (const datum of this.unfilteredData) {\n if (this.filterCallback(datum, query)) {\n data.push(datum);\n }\n }\n\n this._updatePage(0)\n this._updateEntries(data);\n }\n\n _updateSort(field, direction) {\n this.sortField = field;\n this.sortDir = direction;\n\n let newEntries = [...this.data].sort((a, b) => {\n let sorter = 0;\n\n if (a[field] > b[field]) {\n sorter = 1;\n } else if (a[field] < b[field]) {\n sorter = -1;\n }\n\n if (!direction) {\n sorter = -sorter;\n }\n\n return sorter;\n });\n\n this._updatePage(0);\n this._updateEntries(newEntries);\n }\n}\n\nconst dumbFilterCallback = (datum, query) => {\n if (!query) {\n return true;\n }\n\n if (datum.title.indexOf(query) !== -1) {\n return true;\n }\n\n /* this is inefficient */\n for (const tag of datum.tags) {\n if (tag.name.toLowerCase() === query.toLowerCase()) {\n return true;\n }\n }\n\n return false;\n};\n\nexport { DataTable, dumbFilterCallback };\n","import { makeEl, escape } from \"./dom\";\n\nclass TagsInput {\n constructor(element, options = {}) {\n this.element = element;\n this.tags = [];\n this.options = options\n\n this.maxTags = options.maxTags || 10;\n this.inputNode = null;\n this.containerNode = null;\n }\n\n attach() {\n this.element.style.display = 'none';\n\n this.containerNode = makeEl('
');\n this.inputNode = makeEl('');\n this.containerNode.appendChild(this.inputNode);\n\n this.element.parentNode.insertBefore(this.containerNode, this.element.nextSibling);\n\n /* Load existing tags from input */\n if (this.element.value) {\n for (const tag of this.element.value.split(',')) {\n this.addTag(tag);\n }\n }\n\n /* Handle addition and removal of tags via key-presses */\n this.containerNode.addEventListener('keydown', this._handleInputKeyUp.bind(this));\n\n /* Handle deletions by clicking the delete button */\n this.containerNode.addEventListener('click', this._handleContainerClick.bind(this));\n }\n\n detach() {\n this.tags.clear();\n this.containerNode.remove();\n this.element.style.display = 'inline-block';\n }\n\n updateHiddenInputValue() {\n this.element.value = this.tags.join(',');\n }\n\n deleteTagNode(node) {\n this.tags.splice(this.tags.indexOf(node.dataset.value.toLowerCase()), 1);\n node.remove();\n\n /* Below the limit? Make sure the input is enabled. */\n if (this.tags.length < this.maxTags) {\n this.inputNode.disabled = false;\n }\n }\n\n addTag(tagValue) {\n tagValue = tagValue.trim();\n\n /* Tag value is probably not empty and we don't already have the same tag. */\n if (tagValue !== '' && this.tags.indexOf(tagValue.toLowerCase()) === -1) {\n this.tags.push(tagValue.toLowerCase());\n\n this.inputNode.parentNode.insertBefore(\n makeEl('' + escape(tagValue) + ''),\n this.inputNode\n );\n\n /* Too many tags, disable the input for now. */\n if (this.tags.length >= this.maxTags) {\n this.inputNode.disabled = true;\n }\n }\n }\n\n _handleInputKeyUp(evt) {\n let tagValue = this.inputNode.value;\n\n if (evt.key === 'Backspace' && tagValue === '') {\n // Remove the child\n if (this.inputNode.previousSibling) {\n this.deleteTagNode(this.inputNode.previousSibling);\n\n this.updateHiddenInputValue();\n }\n } else if (evt.key === ',') {\n this.addTag(tagValue);\n\n this.inputNode.value = ''\n this.updateHiddenInputValue();\n\n evt.preventDefault();\n }\n }\n\n _handleContainerClick(evt) {\n if (evt.target && evt.target.classList.contains('delete')) {\n this.deleteTagNode(evt.target.closest('.tag'));\n this.updateHiddenInputValue();\n }\n }\n}\n\nexport { TagsInput };\n","import { $, $$, toggleEl } from './dom';\nimport { TagsInput } from \"./tag_input\";\n\nconst setupSignupModal = () => {\n const signupButton = $('[data-target~=\"#signin\"],[data-target~=\"#signup\"]');\n\n if (signupButton) {\n signupButton.href = 'javascript:void(0)';\n\n signupButton.addEventListener('click', () => {\n $('.modal').classList.add('is-active');\n });\n\n $('.modal-button-close').addEventListener('click', () => {\n $('.modal').classList.remove('is-active');\n });\n }\n}\n\nconst globalSetup = () => {\n Array.prototype.forEach.call($$('.js-tag-input'), (el) => {\n new TagsInput(el).attach();\n });\n\n setupSignupModal();\n\n const embedButton = $('.panel-tools .embed-tool');\n\n if (embedButton){\n embedButton.addEventListener('click', (evt) => {\n if (evt.target && evt.target.closest('.panel-tools')) {\n toggleEl(evt.target.closest('.panel-tools').querySelector('.panel-embed'));\n }\n });\n }\n\n const expandButton = $('.expand-tool');\n\n if (expandButton) {\n expandButton.addEventListener('click', (evt) => {\n if (evt.target && evt.target.closest('.panel')) {\n const panel = evt.target.closest('.panel');\n\n if (panel.classList.contains('panel-fullsize')) {\n panel.classList.remove('panel-fullsize');\n } else {\n panel.classList.add('panel-fullsize');\n }\n }\n });\n }\n\n // Notifications\n (document.querySelectorAll('.notification .delete') || []).forEach(($delete) => {\n const $notification = $delete.parentNode;\n\n $delete.addEventListener('click', () => {\n $notification.parentNode.removeChild($notification);\n });\n });\n\n // Hamburger menu\n const $navbarBurgers = Array.prototype.slice.call(document.querySelectorAll('.navbar-burger'), 0);\n if ($navbarBurgers.length > 0) {\n $navbarBurgers.forEach(el => {\n el.addEventListener('click', () => {\n const target = el.dataset.target;\n const $target = document.getElementById(target);\n el.classList.toggle('is-active');\n $target.classList.toggle('is-active');\n });\n });\n }\n\n const preloader = $('.preloader');\n const main = $('main');\n\n if (preloader && main) {\n preloader.remove();\n main.id = '';\n }\n\n const captchaContainer = $('.captcha_container');\n\n if (captchaContainer) {\n const refreshElement = captchaContainer.querySelector('a');\n const imageElement = captchaContainer.querySelector('img');\n\n if (refreshElement && imageElement) {\n refreshElement.addEventListener('click', () => {\n imageElement.src = imageElement.src.split('?')[0] + '?rand=' + Math.random();\n });\n }\n }\n\n Array.prototype.forEach.call($('.js-hidden'), (elem) => {\n toggleEl(elem);\n });\n}\n\nexport { globalSetup };","import { escape, whenReady } from './dom';\nimport { DataTable, dumbFilterCallback } from './data_tables';\nimport { tagsToHtml } from \"./utils\";\nimport { globalSetup } from './main';\n\nwhenReady(() => {\n globalSetup();\n\n const urlParams = new URLSearchParams(window.location.search);\n const myParam = urlParams.get('q');\n const apiUrl = /* myParam !== null ? '/api/ajax_pastes.php?q=' + myParam : */ '/api/ajax_pastes.php';\n\n const table = new DataTable(document.getElementById('archive'), {\n ajaxCallback: (resolve) => {\n fetch(apiUrl)\n .then(r => r.json())\n .then(resolve);\n },\n rowCallback: (rowData) => {\n return `\n ${escape(rowData.title)}\n ${escape(rowData.author)}\n ${tagsToHtml(rowData.tags)}\n `;\n },\n filterCallback: dumbFilterCallback,\n preFilter: myParam\n });\n table.attach();\n});","import { escape } from \"./dom\";\n\nconst tagsToHtml = (tags) => {\n\n return tags.map(tagData => {\n let tagColorClass;\n if (tagData.name.indexOf('nsfw') !== -1) {\n tagColorClass = 'is-danger';\n } else if (tagData.name.indexOf('safe') !== -1) {\n tagColorClass = 'is-success';\n } else if (tagData.name.indexOf('/') !== -1) {\n tagColorClass = 'is-primary';\n } else {\n tagColorClass = 'is-info';\n }\n\n return `\n ${escape(tagData.name)}\n `;\n }).join('');\n};\n\nexport { tagsToHtml };\n"],"names":["funcp","$","selector","document","querySelector","makeEl","html","template","createElement","innerHTML","trim","content","firstChild","clearEl","el","removeChild","toggleEl","classList","contains","remove","add","escape","unsafe","replace","SimplePaginator","element","pageCallback","addEventListener","evt","target","dataset","page","totalRecords","perPage","currentPage","this","lastPage","Math","floor","firstPageShow","lastPageShow","showFirstPage","abs","showLastPage","prevButtonDisabled","appendChild","i","selected","nextButtonDisabled","DataTable","options","container","parentElement","ajaxCallback","data","unfilteredData","paginator","filterCallback","sortField","sortDir","filterField","_this","_updateFilter","value","preFilter","perPageField","Number","_updatePage","header","elem","_updateSort","attach","bind","_loadEntries","Promise","then","_this2","length","bodyElement","firstIndex","lastIndex","rowElem","rowCallback","update","n","_updateEntries","query","datum","push","field","direction","newEntries","_toConsumableArray","sort","a","b","sorter","dumbFilterCallback","title","indexOf","tags","name","toLowerCase","TagsInput","maxTags","inputNode","containerNode","style","display","parentNode","insertBefore","nextSibling","split","tag","addTag","_handleInputKeyUp","_handleContainerClick","clear","join","node","splice","disabled","tagValue","key","previousSibling","deleteTagNode","updateHiddenInputValue","preventDefault","closest","globalSetup","signupButton","Array","prototype","forEach","call","querySelectorAll","href","embedButton","expandButton","panel","$delete","$notification","$navbarBurgers","slice","$target","getElementById","toggle","preloader","main","id","captchaContainer","refreshElement","imageElement","src","random","myParam","URLSearchParams","window","location","search","get","resolve","fetch","r","json","rowData","author","map","tagData","tagColorClass","slug","readyState"],"mappings":"krDAAA,IAuC2BA,EAvCrBC,EAAI,SAASC,UACRC,SAASC,cAAcF,IAO5BG,EAAS,SAASC,OACdC,EAAWJ,SAASK,cAAc,mBAExCD,EAASE,UAAYH,EAAKI,OAEnBH,EAASI,QAAQC,YAGtBC,EAAU,SAASC,QACdA,EAAGF,YACNE,EAAGC,YAAYD,EAAGF,aAIpBI,EAAW,SAASF,GAClBA,EAAGG,UAAUC,SAAS,aACtBJ,EAAGG,UAAUE,OAAO,aAEpBL,EAAGG,UAAUG,IAAI,cAInBC,EAAS,SAASC,UACbA,EACFC,QAAQ,KAAM,SACdA,QAAQ,KAAM,QACdA,QAAQ,KAAM,QACdA,QAAQ,KAAM,UACdA,QAAQ,KAAM,WClCjBC,wBACUC,kBACHA,QAAUA,kCAGnB,SAAOC,QACED,QAAQE,iBAAiB,SAAS,SAAAC,GAC/BA,EAAIC,QAAUD,EAAIC,OAAOZ,UAAUC,SAAS,sBAC5CQ,GAAcE,EAAIC,OAAOC,QAAQC,+BAK7C,SAAOC,EAAcC,EAASC,GAC1BrB,EAAQsB,KAAKV,aAIPW,EAAWC,KAAKC,MAAMN,EAAeC,MADzB,IAIdG,OAKEG,EAAiBL,EAPA,EAFL,EAAA,EAS8DA,EAPzD,EAQjBM,EAAgBN,EARC,EAQ+BE,EAAWA,EAAYF,EARtD,EAWjBO,EAAiBJ,KAAKK,IAbV,EAa0BR,GAXrB,EAYjBS,EAAgBN,KAAKK,IAAIN,EAAWF,GAZnB,EAejBU,EAjBY,IAiBSV,EAA4B,WAAa,QAG/DT,QAAQoB,YAAYxC,uDACyBuC,yBAAiCV,EAAc,2BAI7FO,SACKhB,QAAQoB,YAAYxC,yDA1BX,eAAA,sBA6BToB,QAAQoB,YAAYxC,2CAIxB,IAAIyC,EAAIP,EAAeO,GAAKN,EAAcM,IAAK,KAC1CC,EAAYD,IAAMZ,EAAc,8BAAgC,QACjET,QAAQoB,YAAYxC,6CACe0C,0BAAwBD,eAAMA,iBAKtEH,SACKlB,QAAQoB,YAAYxC,2CACpBoB,QAAQoB,YAAYxC,yDAC2B+B,eAAaA,sBAI/DY,EAAqBd,IAAgBE,EAAW,WAAa,QAE9DX,QAAQoB,YAAYxC,mDACqB2C,yBAAiCd,EAAc,iCAK/Fe,wBACUxB,EAASyB,kBACZzB,QAAUA,OACV0B,UAAY1B,EAAQ2B,mBACpBF,QAAUA,OAEVG,aAAeH,EAAQG,kBACvBC,KAAO,QACPC,eAAiB,QAEjBvB,cAAgB,OAChBC,QAAU,QACVC,YAAc,OAEdsB,UAAY,IAAIhC,EAAgBW,KAAKgB,UAAU/C,cAAc,oBAE7DqD,eAAiBP,EAAQO,oBACzBC,UAAY,UACZC,SAAU,kCAGnB,2BACSC,YAAczB,KAAKgB,UAAU/C,cAAc,gBAC5C+B,KAAKyB,aAAezB,KAAKsB,sBACpBG,YAAYjC,iBAAiB,SAAS,SAAAC,GACpCA,EAAIC,QACJgC,EAAKC,cAAclC,EAAIC,OAAOkC,UAIjC5B,KAAKe,QAAQc,iBACRJ,YAAYG,MAAQ5B,KAAKe,QAAQc,iBAIzCC,aAAe9B,KAAKgB,UAAU/C,cAAc,yBAE7C+B,KAAK8B,mBACAA,aAAatC,iBAAiB,UAAU,SAAAC,GAC1CiC,EAAK5B,QAAUiC,OAAOtC,EAAIC,OAAOkC,OACjCF,EAAKM,YAAY,UAIlBC,EAASjC,KAAKV,QAAQrB,cAAc,sBAEtCgE,GACAA,EAAOzC,iBAAiB,SAAS,SAAAC,OACvBC,EAASD,EAAIC,UAEdA,EAAOC,QAAQ4B,cAIhBG,EAAKH,UAAW,KACVW,EAAOR,EAAKpC,QAAQrB,2CAAoCyD,EAAKH,gBACnEW,EAAKpD,UAAUE,OAAO,yBACtBkD,EAAKpD,UAAUE,OAAO,uBAG1B0C,EAAKS,YAAYzC,EAAOC,QAAQ4B,WAAYG,EAAKF,SAEjD9B,EAAOZ,UAAUG,IAAIyC,EAAKF,QAAU,sBAAwB,kCAI/DH,UAAUe,OAAOpC,KAAKgC,YAAYK,KAAKrC,YACvCsC,2CAIT,0BACQC,QAAQvC,KAAKkB,cACZsB,MAAK,SAAArB,GACFsB,EAAKnD,QAAQR,UAAUE,OAAO,UAC9ByD,EAAKrB,eAAiBD,EAAKA,KAC3BsB,EAAKd,cAAcc,EAAK1B,QAAQc,4CAK5C,SAAeV,QACNA,KAAOA,OACPtB,aAAeG,KAAKmB,KAAKuB,WAExBC,EAAc3C,KAAKV,QAAQrB,cAAc,SAC/CS,EAAQiE,WAEFC,EAAc5C,KAAKF,QAAUE,KAAKD,YAClC8C,EAAaD,EAAa5C,KAAKF,QAAWE,KAAKH,aAAeG,KAAKH,aAAgB+C,EAAa5C,KAAKF,QAGlGa,EAAIiC,EAAYjC,EAAIkC,EAAWlC,IAAK,KACnCmC,EAAU5E,EAAO8B,KAAKe,QAAQgC,YAAY/C,KAAKmB,KAAKR,KAC1DmC,EAAQhE,UAAUG,IAAI0B,EAAI,GAAM,EAAI,MAAQ,QAE5CgC,EAAYjC,YAAYoC,QAGvBzB,UAAU2B,OAAOhD,KAAKH,aAAcG,KAAKF,QAASE,KAAKD,wCAGhE,SAAYkD,QACHlD,YAAckD,OACd5B,UAAU2B,OAAOhD,KAAKH,aAAcG,KAAKF,QAASE,KAAKD,kBACvDmD,eAAelD,KAAKmB,mCAG7B,SAAcgC,MAEI,OAAVA,GAA4B,KAAVA,SAKlBhC,EAAO,OACSnB,KAAKoB,+CAAgB,KAA9BgC,UACHpD,KAAKsB,eAAe8B,EAAOD,IAC3BhC,EAAKkC,KAAKD,uCAIbpB,YAAY,QACZkB,eAAe/B,aAZX+B,eAAelD,KAAKoB,2CAejC,SAAYkC,EAAOC,QACVhC,UAAY+B,OACZ9B,QAAU+B,MAEXC,EAAaC,EAAIzD,KAAKmB,MAAMuC,MAAK,SAACC,EAAGC,OACjCC,EAAS,SAETF,EAAEL,GAASM,EAAEN,GACbO,EAAS,EACFF,EAAEL,GAASM,EAAEN,KACpBO,GAAU,GAGTN,IACDM,GAAUA,GAGPA,UAGN7B,YAAY,QACZkB,eAAeM,YAItBM,EAAqB,SAACV,EAAOD,OAC1BA,SACM,MAGyB,IAAhCC,EAAMW,MAAMC,QAAQb,UACb,YAIOC,EAAMa,qCAAM,YAClBC,KAAKC,gBAAkBhB,EAAMgB,qBAC1B,wCAIR,GChPLC,wBACU9E,OAASyB,yDAAU,kBACtBzB,QAAUA,OACV2E,KAAO,QACPlD,QAAUA,OAEVsD,QAAUtD,EAAQsD,SAAW,QAC7BC,UAAY,UACZC,cAAgB,qCAGzB,mBACSjF,QAAQkF,MAAMC,QAAU,YAExBF,cAAgBrG,EAAO,uCACvBoG,UAAYpG,EAAO,mFACnBqG,cAAc7D,YAAYV,KAAKsE,gBAE/BhF,QAAQoF,WAAWC,aAAa3E,KAAKuE,cAAevE,KAAKV,QAAQsF,aAGlE5E,KAAKV,QAAQsC,MAAO,WACF5B,KAAKV,QAAQsC,MAAMiD,MAAM,qCAAM,KAAtCC,eACFC,OAAOD,wCAKfP,cAAc/E,iBAAiB,UAAWQ,KAAKgF,kBAAkB3C,KAAKrC,YAGtEuE,cAAc/E,iBAAiB,QAASQ,KAAKiF,sBAAsB5C,KAAKrC,6BAGjF,gBACSiE,KAAKiB,aACLX,cAAcvF,cACdM,QAAQkF,MAAMC,QAAU,qDAGjC,gBACSnF,QAAQsC,MAAQ5B,KAAKiE,KAAKkB,KAAK,kCAGxC,SAAcC,QACLnB,KAAKoB,OAAOrF,KAAKiE,KAAKD,QAAQoB,EAAKzF,QAAQiC,MAAMuC,eAAgB,GACtEiB,EAAKpG,SAGDgB,KAAKiE,KAAKvB,OAAS1C,KAAKqE,eACnBC,UAAUgB,UAAW,yBAIlC,SAAOC,GAIc,MAHjBA,EAAWA,EAAShH,UAGkD,IAA/CyB,KAAKiE,KAAKD,QAAQuB,EAASpB,sBACzCF,KAAKZ,KAAKkC,EAASpB,oBAEnBG,UAAUI,WAAWC,aACtBzG,EAAO,yCAA2CgB,EAAOqG,GAAY,KAAOrG,EAAOqG,GAAY,2CAC/FvF,KAAKsE,WAILtE,KAAKiE,KAAKvB,QAAU1C,KAAKqE,eACpBC,UAAUgB,UAAW,qCAKtC,SAAkB7F,OACV8F,EAAWvF,KAAKsE,UAAU1C,MAEd,cAAZnC,EAAI+F,KAAoC,KAAbD,EAEvBvF,KAAKsE,UAAUmB,uBACVC,cAAc1F,KAAKsE,UAAUmB,sBAE7BE,0BAEU,MAAZlG,EAAI+F,WACNT,OAAOQ,QAEPjB,UAAU1C,MAAQ,QAClB+D,yBAELlG,EAAImG,uDAIZ,SAAsBnG,GACdA,EAAIC,QAAUD,EAAIC,OAAOZ,UAAUC,SAAS,iBACvC2G,cAAcjG,EAAIC,OAAOmG,QAAQ,cACjCF,mCC/EXG,EAAc,WHfT,IAAS/H,EGAVgI,EAgBNC,MAAMC,UAAUC,QAAQC,MHhBRpI,EGgBgB,gBHfzBC,SAASoI,iBAAiBrI,IAAa,KGeI,SAACY,OAC3CyF,EAAUzF,GAAIyD,aAjBhB2D,EAAejI,EAAE,wDAGnBiI,EAAaM,KAAO,qBAEpBN,EAAavG,iBAAiB,SAAS,WACnC1B,EAAE,UAAUgB,UAAUG,IAAI,gBAG9BnB,EAAE,uBAAuB0B,iBAAiB,SAAS,WAC/C1B,EAAE,UAAUgB,UAAUE,OAAO,qBAY/BsH,EAAcxI,EAAE,4BAElBwI,GACAA,EAAY9G,iBAAiB,SAAS,SAACC,GAC/BA,EAAIC,QAAUD,EAAIC,OAAOmG,QAAQ,iBACjChH,EAASY,EAAIC,OAAOmG,QAAQ,gBAAgB5H,cAAc,wBAKhEsI,EAAezI,EAAE,gBAEnByI,GACAA,EAAa/G,iBAAiB,SAAS,SAACC,MAChCA,EAAIC,QAAUD,EAAIC,OAAOmG,QAAQ,UAAW,KACtCW,EAAQ/G,EAAIC,OAAOmG,QAAQ,UAE7BW,EAAM1H,UAAUC,SAAS,kBACzByH,EAAM1H,UAAUE,OAAO,kBAEvBwH,EAAM1H,UAAUG,IAAI,uBAOnCjB,SAASoI,iBAAiB,0BAA4B,IAAIF,SAAQ,SAACO,OAC1DC,EAAgBD,EAAQ/B,WAE9B+B,EAAQjH,iBAAiB,SAAS,WAC9BkH,EAAchC,WAAW9F,YAAY8H,aAKvCC,EAAiBX,MAAMC,UAAUW,MAAMT,KAAKnI,SAASoI,iBAAiB,kBAAmB,GAC3FO,EAAejE,OAAS,GACxBiE,EAAeT,SAAQ,SAAAvH,GACnBA,EAAGa,iBAAiB,SAAS,eACnBE,EAASf,EAAGgB,QAAQD,OACpBmH,EAAU7I,SAAS8I,eAAepH,GACxCf,EAAGG,UAAUiI,OAAO,aACpBF,EAAQ/H,UAAUiI,OAAO,uBAK/BC,EAAYlJ,EAAE,cACdmJ,EAAOnJ,EAAE,QAEXkJ,GAAaC,IACbD,EAAUhI,SACViI,EAAKC,GAAK,QAGRC,EAAmBrJ,EAAE,yBAEvBqJ,EAAkB,KACZC,EAAiBD,EAAiBlJ,cAAc,KAChDoJ,EAAeF,EAAiBlJ,cAAc,OAEhDmJ,GAAkBC,GAClBD,EAAe5H,iBAAiB,SAAS,WACrC6H,EAAaC,IAAMD,EAAaC,IAAIzC,MAAM,KAAK,GAAK,SAAW3E,KAAKqH,YAKhFvB,MAAMC,UAAUC,QAAQC,KAAKrI,EAAE,eAAe,SAACoE,GAC3CrD,EAASqD,OHzDUrE,EIlCjB,WACNiI,QAGM0B,EADY,IAAIC,gBAAgBC,OAAOC,SAASC,QAC5BC,IAAI,KAGhB,IAAI/G,EAAU9C,SAAS8I,eAAe,WAAY,CAC5D5F,aAAc,SAAC4G,GACXC,8BACKvF,MAAK,SAAAwF,UAAKA,EAAEC,UACZzF,KAAKsF,IAEd/E,YAAa,SAACmF,+DAEkBA,EAAQhB,gBAAOhI,EAAOgJ,EAAQnE,wEACzB7E,EAAOgJ,EAAQC,qBAAYjJ,EAAOgJ,EAAQC,0DAC9CD,EAAQjE,KClBjCmE,KAAI,SAAAC,OACRC,SAEAA,GADkC,IAAlCD,EAAQnE,KAAKF,QAAQ,QACL,aACyB,IAAlCqE,EAAQnE,KAAKF,QAAQ,QACZ,cACsB,IAA/BqE,EAAQnE,KAAKF,QAAQ,KACZ,aAEA,wCAGUqE,EAAQE,iEACCD,eAAkBpJ,EAAOmJ,EAAQnE,kDAEzEiB,KAAK,yCDMJ7D,eAAgBwC,EAChBjC,UAAW2F,IAETpF,UJYsB,YAAxBpE,SAASwK,WACT3K,IAEAG,SAASwB,iBAAiB,mBAAoB3B"} \ No newline at end of file +{"version":3,"file":"archive.min.js","sources":["../../../js/dom.js","../../../js/data_tables.js","../../../js/tag_input.js","../../../js/main.js","../../../js/archive.js","../../../js/utils.js"],"sourcesContent":["const $ = function(selector) {\n return document.querySelector(selector);\n};\n\nconst $$ = function(selector) {\n return document.querySelectorAll(selector) || [];\n};\n\nconst makeEl = function(html) {\n const template = document.createElement('template');\n\n template.innerHTML = html.trim();\n\n return template.content.firstChild;\n};\n\nconst clearEl = function(el) {\n while (el.firstChild) {\n el.removeChild(el.firstChild);\n }\n};\n\nconst toggleEl = function(el) {\n if (el.classList.contains('is-hidden')) {\n el.classList.remove('is-hidden');\n } else {\n el.classList.add('is-hidden');\n }\n};\n\nconst escape = function(unsafe) {\n return unsafe\n .replace(/&/g, \"&\")\n .replace(//g, \">\")\n .replace(/\"/g, \""\")\n .replace(/'/g, \"'\");\n}\n\nconst whenReady = function(funcp) {\n if (document.readyState !== 'loading') {\n funcp();\n } else {\n document.addEventListener('DOMContentLoaded', funcp);\n }\n}\n\nexport { whenReady, $, $$, makeEl, clearEl, toggleEl, escape };","import { makeEl, clearEl } from \"./dom\";\n\nclass SimplePaginator {\n constructor(element) {\n this.element = element;\n }\n\n attach(pageCallback) {\n this.element.addEventListener('click', evt => {\n if (evt.target && evt.target.classList.contains('paginator__button')) {\n pageCallback(+evt.target.dataset.page);\n }\n });\n }\n\n update(totalRecords, perPage, currentPage) {\n clearEl(this.element);\n\n /* First and last page in existence */\n const firstPage = 0;\n const lastPage = Math.floor(totalRecords / perPage); // ish?\n const numPagesToShow = 2;\n\n if (lastPage === firstPage) {\n return;\n }\n\n /* First and last page the main paginator will show */\n const firstPageShow = (currentPage - numPagesToShow) < firstPage ? firstPage : (currentPage - numPagesToShow);\n const lastPageShow = (currentPage + numPagesToShow) > lastPage ? lastPage : (currentPage + numPagesToShow);\n\n /* Whether to show the first and last pages in existence at the ends of the paginator */\n const showFirstPage = (Math.abs(firstPage - currentPage)) > (numPagesToShow);\n const showLastPage = (Math.abs(lastPage - currentPage)) > (numPagesToShow);\n\n\n const prevButtonDisabled = currentPage === firstPage ? 'disabled' : ''\n\n /* Previous button */\n this.element.appendChild(makeEl(\n ``\n ));\n\n /* First page button */\n if (showFirstPage) {\n this.element.appendChild(makeEl(\n ``\n ));\n this.element.appendChild(makeEl(``));\n }\n\n /* \"window\" buttons */\n for (let i = firstPageShow; i <= lastPageShow; i++) {\n const selected = (i === currentPage ? 'paginator__button--selected' : '');\n this.element.appendChild(makeEl(\n ``\n ));\n }\n\n /* Last page button */\n if (showLastPage) {\n this.element.appendChild(makeEl(``));\n this.element.appendChild(makeEl(\n ``\n ));\n }\n\n const nextButtonDisabled = currentPage === lastPage ? 'disabled' : ''\n /* Next button */\n this.element.appendChild(makeEl(\n ``\n ));\n }\n}\n\nclass DataTable {\n constructor(element, options) {\n this.element = element;\n this.container = element.parentElement;\n this.options = options;\n\n this.ajaxCallback = options.ajaxCallback;\n this.data = [];\n this.unfilteredData = [];\n\n this.totalRecords = -1;\n this.perPage = 20;\n this.currentPage = 0;\n\n this.paginator = new SimplePaginator(this.container.querySelector('.paginator'));\n\n this.filterCallback = options.filterCallback;\n this.sortField = null;\n this.sortDir = true;\n }\n\n attach() {\n this.filterField = this.container.querySelector('input.search');\n if (this.filterField && this.filterCallback) {\n this.filterField.addEventListener('keyup', evt => {\n if (evt.target) {\n this._updateFilter(evt.target.value);\n }\n });\n\n if (this.options.preFilter) {\n this.filterField.value = this.options.preFilter;\n }\n }\n\n this.perPageField = this.container.querySelector('select[name=per_page]');\n\n if (this.perPageField) {\n this.perPageField.addEventListener('change', evt => {\n this.perPage = Number(evt.target.value);\n this._updatePage(0);\n });\n }\n\n const header = this.element.querySelector('tr.paginator__sort');\n\n if (header) {\n header.addEventListener('click', evt => {\n const target = evt.target;\n\n if (!target.dataset.sortField) {\n return;\n }\n\n if (this.sortField) {\n const elem = this.element.querySelector(`th[data-sort-field=${this.sortField}]`)\n elem.classList.remove('paginator__sort--down');\n elem.classList.remove('paginator__sort--up');\n }\n\n this._updateSort(target.dataset.sortField, !this.sortDir);\n\n target.classList.add(this.sortDir ? 'paginator__sort--up' : 'paginator__sort--down');\n });\n }\n\n this.paginator.attach(this._updatePage.bind(this));\n this._loadEntries();\n }\n\n /* Load the requested data from the server, and when done, update the DOM. */\n _loadEntries() {\n new Promise(this.ajaxCallback)\n .then(data => {\n this.element.classList.remove('hidden');\n this.unfilteredData = data.data;\n this._updateFilter(this.options.preFilter);\n });\n }\n\n /* Update the DOM to reflect the current state of the data we have loaded */\n _updateEntries(data) {\n this.data = data;\n this.totalRecords = this.data.length;\n\n const bodyElement = this.element.querySelector('tbody');\n clearEl(bodyElement);\n\n const firstIndex = (this.perPage * this.currentPage);\n const lastIndex = (firstIndex + this.perPage) > this.totalRecords ? this.totalRecords : (firstIndex + this.perPage);\n\n\n for (let i = firstIndex; i < lastIndex; i++) {\n const rowElem = makeEl(this.options.rowCallback(this.data[i]));\n rowElem.classList.add(i % 2 === 0 ? 'odd' : 'even');\n\n bodyElement.appendChild(rowElem);\n }\n\n this.paginator.update(this.totalRecords, this.perPage, this.currentPage);\n }\n\n _updatePage(n) {\n this.currentPage = n;\n this.paginator.update(this.totalRecords, this.perPage, this.currentPage);\n this._updateEntries(this.data);\n }\n\n _updateFilter(query) {\n /* clearing the query */\n if (query === null || query === '') {\n this._updateEntries(this.unfilteredData);\n return;\n }\n\n let data = [];\n for (const datum of this.unfilteredData) {\n if (this.filterCallback(datum, query)) {\n data.push(datum);\n }\n }\n\n this._updatePage(0)\n this._updateEntries(data);\n }\n\n _updateSort(field, direction) {\n this.sortField = field;\n this.sortDir = direction;\n\n let newEntries = [...this.data].sort((a, b) => {\n let sorter = 0;\n\n if (a[field] > b[field]) {\n sorter = 1;\n } else if (a[field] < b[field]) {\n sorter = -1;\n }\n\n if (!direction) {\n sorter = -sorter;\n }\n\n return sorter;\n });\n\n this._updatePage(0);\n this._updateEntries(newEntries);\n }\n}\n\nconst dumbFilterCallback = (datum, query) => {\n if (!query) {\n return true;\n }\n\n if (datum.title.indexOf(query) !== -1) {\n return true;\n }\n\n /* this is inefficient */\n for (const tag of datum.tags) {\n if (tag.name.toLowerCase() === query.toLowerCase()) {\n return true;\n }\n }\n\n return false;\n};\n\nexport { DataTable, dumbFilterCallback };\n","import { makeEl, escape } from \"./dom\";\n\nclass TagsInput {\n constructor(element, options = {}) {\n this.element = element;\n this.tags = [];\n this.options = options\n\n this.maxTags = options.maxTags || 10;\n this.inputNode = null;\n this.containerNode = null;\n }\n\n attach() {\n this.element.style.display = 'none';\n\n this.containerNode = makeEl('
');\n this.inputNode = makeEl('');\n this.containerNode.appendChild(this.inputNode);\n\n this.element.parentNode.insertBefore(this.containerNode, this.element.nextSibling);\n\n /* Load existing tags from input */\n if (this.element.value) {\n for (const tag of this.element.value.split(',')) {\n this.addTag(tag);\n }\n }\n\n /* Handle addition and removal of tags via key-presses */\n this.containerNode.addEventListener('keydown', this._handleInputKeyUp.bind(this));\n\n /* Handle deletions by clicking the delete button */\n this.containerNode.addEventListener('click', this._handleContainerClick.bind(this));\n }\n\n detach() {\n this.tags.clear();\n this.containerNode.remove();\n this.element.style.display = 'inline-block';\n }\n\n updateHiddenInputValue() {\n this.element.value = this.tags.join(',');\n }\n\n deleteTagNode(node) {\n this.tags.splice(this.tags.indexOf(node.dataset.value.toLowerCase()), 1);\n node.remove();\n\n /* Below the limit? Make sure the input is enabled. */\n if (this.tags.length < this.maxTags) {\n this.inputNode.disabled = false;\n }\n }\n\n addTag(tagValue) {\n tagValue = tagValue.trim();\n\n /* Tag value is probably not empty and we don't already have the same tag. */\n if (tagValue !== '' && this.tags.indexOf(tagValue.toLowerCase()) === -1) {\n this.tags.push(tagValue.toLowerCase());\n\n this.inputNode.parentNode.insertBefore(\n makeEl('' + escape(tagValue) + ''),\n this.inputNode\n );\n\n /* Too many tags, disable the input for now. */\n if (this.tags.length >= this.maxTags) {\n this.inputNode.disabled = true;\n }\n }\n }\n\n _handleInputKeyUp(evt) {\n let tagValue = this.inputNode.value;\n\n if (evt.key === 'Backspace' && tagValue === '') {\n // Remove the child\n if (this.inputNode.previousSibling) {\n this.deleteTagNode(this.inputNode.previousSibling);\n\n this.updateHiddenInputValue();\n }\n } else if (evt.key === ',') {\n this.addTag(tagValue);\n\n this.inputNode.value = ''\n this.updateHiddenInputValue();\n\n evt.preventDefault();\n }\n }\n\n _handleContainerClick(evt) {\n if (evt.target && evt.target.classList.contains('delete')) {\n this.deleteTagNode(evt.target.closest('.tag'));\n this.updateHiddenInputValue();\n }\n }\n}\n\nexport { TagsInput };\n","import { $, $$, toggleEl } from './dom';\nimport { TagsInput } from \"./tag_input\";\n\nconst setupSignupModal = () => {\n const signupButton = $('[data-target~=\"#signin\"],[data-target~=\"#signup\"]');\n\n if (signupButton) {\n signupButton.href = 'javascript:void(0)';\n\n signupButton.addEventListener('click', () => {\n $('.modal').classList.add('is-active');\n });\n\n $('.modal-button-close').addEventListener('click', () => {\n $('.modal').classList.remove('is-active');\n });\n }\n}\n\nconst globalSetup = () => {\n Array.prototype.forEach.call($$('.js-tag-input'), (el) => {\n new TagsInput(el).attach();\n });\n\n setupSignupModal();\n\n const embedButton = $('.panel-tools .embed-tool');\n\n if (embedButton){\n embedButton.addEventListener('click', (evt) => {\n if (evt.target && evt.target.closest('.panel-tools')) {\n toggleEl(evt.target.closest('.panel-tools').querySelector('.panel-embed'));\n }\n });\n }\n\n const expandButton = $('.expand-tool');\n\n if (expandButton) {\n expandButton.addEventListener('click', (evt) => {\n if (evt.target && evt.target.closest('.panel')) {\n const panel = evt.target.closest('.panel');\n\n if (panel.classList.contains('panel-fullsize')) {\n panel.classList.remove('panel-fullsize');\n } else {\n panel.classList.add('panel-fullsize');\n }\n }\n });\n }\n\n // Notifications\n (document.querySelectorAll('.notification .delete') || []).forEach(($delete) => {\n const $notification = $delete.parentNode;\n\n $delete.addEventListener('click', () => {\n $notification.parentNode.removeChild($notification);\n });\n });\n\n // Hamburger menu\n const $navbarBurgers = Array.prototype.slice.call(document.querySelectorAll('.navbar-burger'), 0);\n if ($navbarBurgers.length > 0) {\n $navbarBurgers.forEach(el => {\n el.addEventListener('click', () => {\n const target = el.dataset.target;\n const $target = document.getElementById(target);\n el.classList.toggle('is-active');\n $target.classList.toggle('is-active');\n });\n });\n }\n\n const preloader = $('.preloader');\n const main = $('main');\n\n if (preloader && main) {\n preloader.remove();\n main.id = '';\n }\n\n // CAPTCHA refresh\n const captchaContainer = $('.captcha_container');\n\n if (captchaContainer) {\n const refreshElement = captchaContainer.querySelector('a');\n const imageElement = captchaContainer.querySelector('img');\n\n if (refreshElement && imageElement) {\n refreshElement.addEventListener('click', () => {\n let src = imageElement.src;\n\n if (src.indexOf('&refresh') !== -1) {\n // yeah, it's kinda cancerous. fuck off.\n src = src.split('&rand=')[0];\n } else {\n src += '&refresh';\n }\n\n imageElement.src = src + '&rand=' + Math.random();\n });\n }\n }\n\n const hiddenElements = $$('.js-hidden');\n\n if (hiddenElements) {\n Array.prototype.forEach.call(hiddenElements, (elem) => {\n toggleEl(elem);\n });\n }\n}\n\nexport { globalSetup };","import { escape, whenReady } from './dom';\nimport { DataTable, dumbFilterCallback } from './data_tables';\nimport { tagsToHtml } from \"./utils\";\nimport { globalSetup } from './main';\n\nwhenReady(() => {\n globalSetup();\n\n const urlParams = new URLSearchParams(window.location.search);\n const myParam = urlParams.get('q');\n const apiUrl = /* myParam !== null ? '/api/ajax_pastes.php?q=' + myParam : */ '/api/ajax_pastes.php';\n\n const table = new DataTable(document.getElementById('archive'), {\n ajaxCallback: (resolve) => {\n fetch(apiUrl)\n .then(r => r.json())\n .then(resolve);\n },\n rowCallback: (rowData) => {\n return `\n ${escape(rowData.title)}\n ${escape(rowData.author)}\n ${tagsToHtml(rowData.tags)}\n `;\n },\n filterCallback: dumbFilterCallback,\n preFilter: myParam\n });\n table.attach();\n});","import { escape } from \"./dom\";\n\nconst tagsToHtml = (tags) => {\n\n return tags.map(tagData => {\n let tagColorClass;\n if (tagData.name.indexOf('nsfw') !== -1) {\n tagColorClass = 'is-danger';\n } else if (tagData.name.indexOf('safe') !== -1) {\n tagColorClass = 'is-success';\n } else if (tagData.name.indexOf('/') !== -1) {\n tagColorClass = 'is-primary';\n } else {\n tagColorClass = 'is-info';\n }\n\n return `\n ${escape(tagData.name)}\n `;\n }).join('');\n};\n\nexport { tagsToHtml };\n"],"names":["funcp","$","selector","document","querySelector","$$","querySelectorAll","makeEl","html","template","createElement","innerHTML","trim","content","firstChild","clearEl","el","removeChild","toggleEl","classList","contains","remove","add","escape","unsafe","replace","SimplePaginator","element","pageCallback","addEventListener","evt","target","dataset","page","totalRecords","perPage","currentPage","this","lastPage","Math","floor","firstPageShow","lastPageShow","showFirstPage","abs","showLastPage","prevButtonDisabled","appendChild","i","selected","nextButtonDisabled","DataTable","options","container","parentElement","ajaxCallback","data","unfilteredData","paginator","filterCallback","sortField","sortDir","filterField","_this","_updateFilter","value","preFilter","perPageField","Number","_updatePage","header","elem","_updateSort","attach","bind","_loadEntries","Promise","then","_this2","length","bodyElement","firstIndex","lastIndex","rowElem","rowCallback","update","n","_updateEntries","query","datum","push","field","direction","newEntries","_toConsumableArray","sort","a","b","sorter","dumbFilterCallback","title","indexOf","tags","name","toLowerCase","TagsInput","maxTags","inputNode","containerNode","style","display","parentNode","insertBefore","nextSibling","split","tag","addTag","_handleInputKeyUp","_handleContainerClick","clear","join","node","splice","disabled","tagValue","key","previousSibling","deleteTagNode","updateHiddenInputValue","preventDefault","closest","globalSetup","signupButton","Array","prototype","forEach","call","href","embedButton","expandButton","panel","$delete","$notification","$navbarBurgers","slice","$target","getElementById","toggle","preloader","main","id","captchaContainer","refreshElement","imageElement","src","random","hiddenElements","myParam","URLSearchParams","window","location","search","get","resolve","fetch","r","json","rowData","author","map","tagData","tagColorClass","slug","readyState"],"mappings":"krDAAA,IAuC2BA,EAvCrBC,EAAI,SAASC,UACRC,SAASC,cAAcF,IAG5BG,EAAK,SAASH,UACTC,SAASG,iBAAiBJ,IAAa,IAG5CK,EAAS,SAASC,OACdC,EAAWN,SAASO,cAAc,mBAExCD,EAASE,UAAYH,EAAKI,OAEnBH,EAASI,QAAQC,YAGtBC,EAAU,SAASC,QACdA,EAAGF,YACNE,EAAGC,YAAYD,EAAGF,aAIpBI,EAAW,SAASF,GAClBA,EAAGG,UAAUC,SAAS,aACtBJ,EAAGG,UAAUE,OAAO,aAEpBL,EAAGG,UAAUG,IAAI,cAInBC,EAAS,SAASC,UACbA,EACFC,QAAQ,KAAM,SACdA,QAAQ,KAAM,QACdA,QAAQ,KAAM,QACdA,QAAQ,KAAM,UACdA,QAAQ,KAAM,WClCjBC,wBACUC,kBACHA,QAAUA,kCAGnB,SAAOC,QACED,QAAQE,iBAAiB,SAAS,SAAAC,GAC/BA,EAAIC,QAAUD,EAAIC,OAAOZ,UAAUC,SAAS,sBAC5CQ,GAAcE,EAAIC,OAAOC,QAAQC,+BAK7C,SAAOC,EAAcC,EAASC,GAC1BrB,EAAQsB,KAAKV,aAIPW,EAAWC,KAAKC,MAAMN,EAAeC,MADzB,IAIdG,OAKEG,EAAiBL,EAPA,EAFL,EAAA,EAS8DA,EAPzD,EAQjBM,EAAgBN,EARC,EAQ+BE,EAAWA,EAAYF,EARtD,EAWjBO,EAAiBJ,KAAKK,IAbV,EAa0BR,GAXrB,EAYjBS,EAAgBN,KAAKK,IAAIN,EAAWF,GAZnB,EAejBU,EAjBY,IAiBSV,EAA4B,WAAa,QAG/DT,QAAQoB,YAAYxC,uDACyBuC,yBAAiCV,EAAc,2BAI7FO,SACKhB,QAAQoB,YAAYxC,yDA1BX,eAAA,sBA6BToB,QAAQoB,YAAYxC,2CAIxB,IAAIyC,EAAIP,EAAeO,GAAKN,EAAcM,IAAK,KAC1CC,EAAYD,IAAMZ,EAAc,8BAAgC,QACjET,QAAQoB,YAAYxC,6CACe0C,0BAAwBD,eAAMA,iBAKtEH,SACKlB,QAAQoB,YAAYxC,2CACpBoB,QAAQoB,YAAYxC,yDAC2B+B,eAAaA,sBAI/DY,EAAqBd,IAAgBE,EAAW,WAAa,QAE9DX,QAAQoB,YAAYxC,mDACqB2C,yBAAiCd,EAAc,iCAK/Fe,wBACUxB,EAASyB,kBACZzB,QAAUA,OACV0B,UAAY1B,EAAQ2B,mBACpBF,QAAUA,OAEVG,aAAeH,EAAQG,kBACvBC,KAAO,QACPC,eAAiB,QAEjBvB,cAAgB,OAChBC,QAAU,QACVC,YAAc,OAEdsB,UAAY,IAAIhC,EAAgBW,KAAKgB,UAAUjD,cAAc,oBAE7DuD,eAAiBP,EAAQO,oBACzBC,UAAY,UACZC,SAAU,kCAGnB,2BACSC,YAAczB,KAAKgB,UAAUjD,cAAc,gBAC5CiC,KAAKyB,aAAezB,KAAKsB,sBACpBG,YAAYjC,iBAAiB,SAAS,SAAAC,GACpCA,EAAIC,QACJgC,EAAKC,cAAclC,EAAIC,OAAOkC,UAIjC5B,KAAKe,QAAQc,iBACRJ,YAAYG,MAAQ5B,KAAKe,QAAQc,iBAIzCC,aAAe9B,KAAKgB,UAAUjD,cAAc,yBAE7CiC,KAAK8B,mBACAA,aAAatC,iBAAiB,UAAU,SAAAC,GAC1CiC,EAAK5B,QAAUiC,OAAOtC,EAAIC,OAAOkC,OACjCF,EAAKM,YAAY,UAIlBC,EAASjC,KAAKV,QAAQvB,cAAc,sBAEtCkE,GACAA,EAAOzC,iBAAiB,SAAS,SAAAC,OACvBC,EAASD,EAAIC,UAEdA,EAAOC,QAAQ4B,cAIhBG,EAAKH,UAAW,KACVW,EAAOR,EAAKpC,QAAQvB,2CAAoC2D,EAAKH,gBACnEW,EAAKpD,UAAUE,OAAO,yBACtBkD,EAAKpD,UAAUE,OAAO,uBAG1B0C,EAAKS,YAAYzC,EAAOC,QAAQ4B,WAAYG,EAAKF,SAEjD9B,EAAOZ,UAAUG,IAAIyC,EAAKF,QAAU,sBAAwB,kCAI/DH,UAAUe,OAAOpC,KAAKgC,YAAYK,KAAKrC,YACvCsC,2CAIT,0BACQC,QAAQvC,KAAKkB,cACZsB,MAAK,SAAArB,GACFsB,EAAKnD,QAAQR,UAAUE,OAAO,UAC9ByD,EAAKrB,eAAiBD,EAAKA,KAC3BsB,EAAKd,cAAcc,EAAK1B,QAAQc,4CAK5C,SAAeV,QACNA,KAAOA,OACPtB,aAAeG,KAAKmB,KAAKuB,WAExBC,EAAc3C,KAAKV,QAAQvB,cAAc,SAC/CW,EAAQiE,WAEFC,EAAc5C,KAAKF,QAAUE,KAAKD,YAClC8C,EAAaD,EAAa5C,KAAKF,QAAWE,KAAKH,aAAeG,KAAKH,aAAgB+C,EAAa5C,KAAKF,QAGlGa,EAAIiC,EAAYjC,EAAIkC,EAAWlC,IAAK,KACnCmC,EAAU5E,EAAO8B,KAAKe,QAAQgC,YAAY/C,KAAKmB,KAAKR,KAC1DmC,EAAQhE,UAAUG,IAAI0B,EAAI,GAAM,EAAI,MAAQ,QAE5CgC,EAAYjC,YAAYoC,QAGvBzB,UAAU2B,OAAOhD,KAAKH,aAAcG,KAAKF,QAASE,KAAKD,wCAGhE,SAAYkD,QACHlD,YAAckD,OACd5B,UAAU2B,OAAOhD,KAAKH,aAAcG,KAAKF,QAASE,KAAKD,kBACvDmD,eAAelD,KAAKmB,mCAG7B,SAAcgC,MAEI,OAAVA,GAA4B,KAAVA,SAKlBhC,EAAO,OACSnB,KAAKoB,+CAAgB,KAA9BgC,UACHpD,KAAKsB,eAAe8B,EAAOD,IAC3BhC,EAAKkC,KAAKD,uCAIbpB,YAAY,QACZkB,eAAe/B,aAZX+B,eAAelD,KAAKoB,2CAejC,SAAYkC,EAAOC,QACVhC,UAAY+B,OACZ9B,QAAU+B,MAEXC,EAAaC,EAAIzD,KAAKmB,MAAMuC,MAAK,SAACC,EAAGC,OACjCC,EAAS,SAETF,EAAEL,GAASM,EAAEN,GACbO,EAAS,EACFF,EAAEL,GAASM,EAAEN,KACpBO,GAAU,GAGTN,IACDM,GAAUA,GAGPA,UAGN7B,YAAY,QACZkB,eAAeM,YAItBM,EAAqB,SAACV,EAAOD,OAC1BA,SACM,MAGyB,IAAhCC,EAAMW,MAAMC,QAAQb,UACb,YAIOC,EAAMa,qCAAM,YAClBC,KAAKC,gBAAkBhB,EAAMgB,qBAC1B,wCAIR,GChPLC,wBACU9E,OAASyB,yDAAU,kBACtBzB,QAAUA,OACV2E,KAAO,QACPlD,QAAUA,OAEVsD,QAAUtD,EAAQsD,SAAW,QAC7BC,UAAY,UACZC,cAAgB,qCAGzB,mBACSjF,QAAQkF,MAAMC,QAAU,YAExBF,cAAgBrG,EAAO,uCACvBoG,UAAYpG,EAAO,mFACnBqG,cAAc7D,YAAYV,KAAKsE,gBAE/BhF,QAAQoF,WAAWC,aAAa3E,KAAKuE,cAAevE,KAAKV,QAAQsF,aAGlE5E,KAAKV,QAAQsC,MAAO,WACF5B,KAAKV,QAAQsC,MAAMiD,MAAM,qCAAM,KAAtCC,eACFC,OAAOD,wCAKfP,cAAc/E,iBAAiB,UAAWQ,KAAKgF,kBAAkB3C,KAAKrC,YAGtEuE,cAAc/E,iBAAiB,QAASQ,KAAKiF,sBAAsB5C,KAAKrC,6BAGjF,gBACSiE,KAAKiB,aACLX,cAAcvF,cACdM,QAAQkF,MAAMC,QAAU,qDAGjC,gBACSnF,QAAQsC,MAAQ5B,KAAKiE,KAAKkB,KAAK,kCAGxC,SAAcC,QACLnB,KAAKoB,OAAOrF,KAAKiE,KAAKD,QAAQoB,EAAKzF,QAAQiC,MAAMuC,eAAgB,GACtEiB,EAAKpG,SAGDgB,KAAKiE,KAAKvB,OAAS1C,KAAKqE,eACnBC,UAAUgB,UAAW,yBAIlC,SAAOC,GAIc,MAHjBA,EAAWA,EAAShH,UAGkD,IAA/CyB,KAAKiE,KAAKD,QAAQuB,EAASpB,sBACzCF,KAAKZ,KAAKkC,EAASpB,oBAEnBG,UAAUI,WAAWC,aACtBzG,EAAO,yCAA2CgB,EAAOqG,GAAY,KAAOrG,EAAOqG,GAAY,2CAC/FvF,KAAKsE,WAILtE,KAAKiE,KAAKvB,QAAU1C,KAAKqE,eACpBC,UAAUgB,UAAW,qCAKtC,SAAkB7F,OACV8F,EAAWvF,KAAKsE,UAAU1C,MAEd,cAAZnC,EAAI+F,KAAoC,KAAbD,EAEvBvF,KAAKsE,UAAUmB,uBACVC,cAAc1F,KAAKsE,UAAUmB,sBAE7BE,0BAEU,MAAZlG,EAAI+F,WACNT,OAAOQ,QAEPjB,UAAU1C,MAAQ,QAClB+D,yBAELlG,EAAImG,uDAIZ,SAAsBnG,GACdA,EAAIC,QAAUD,EAAIC,OAAOZ,UAAUC,SAAS,iBACvC2G,cAAcjG,EAAIC,OAAOmG,QAAQ,cACjCF,mCC/EXG,EAAc,WAhBK,IACfC,EAgBNC,MAAMC,UAAUC,QAAQC,KAAKnI,EAAG,kBAAkB,SAACW,OAC3CyF,EAAUzF,GAAIyD,aAjBhB2D,EAAenI,EAAE,wDAGnBmI,EAAaK,KAAO,qBAEpBL,EAAavG,iBAAiB,SAAS,WACnC5B,EAAE,UAAUkB,UAAUG,IAAI,gBAG9BrB,EAAE,uBAAuB4B,iBAAiB,SAAS,WAC/C5B,EAAE,UAAUkB,UAAUE,OAAO,qBAY/BqH,EAAczI,EAAE,4BAElByI,GACAA,EAAY7G,iBAAiB,SAAS,SAACC,GAC/BA,EAAIC,QAAUD,EAAIC,OAAOmG,QAAQ,iBACjChH,EAASY,EAAIC,OAAOmG,QAAQ,gBAAgB9H,cAAc,wBAKhEuI,EAAe1I,EAAE,gBAEnB0I,GACAA,EAAa9G,iBAAiB,SAAS,SAACC,MAChCA,EAAIC,QAAUD,EAAIC,OAAOmG,QAAQ,UAAW,KACtCU,EAAQ9G,EAAIC,OAAOmG,QAAQ,UAE7BU,EAAMzH,UAAUC,SAAS,kBACzBwH,EAAMzH,UAAUE,OAAO,kBAEvBuH,EAAMzH,UAAUG,IAAI,uBAOnCnB,SAASG,iBAAiB,0BAA4B,IAAIiI,SAAQ,SAACM,OAC1DC,EAAgBD,EAAQ9B,WAE9B8B,EAAQhH,iBAAiB,SAAS,WAC9BiH,EAAc/B,WAAW9F,YAAY6H,aAKvCC,EAAiBV,MAAMC,UAAUU,MAAMR,KAAKrI,SAASG,iBAAiB,kBAAmB,GAC3FyI,EAAehE,OAAS,GACxBgE,EAAeR,SAAQ,SAAAvH,GACnBA,EAAGa,iBAAiB,SAAS,eACnBE,EAASf,EAAGgB,QAAQD,OACpBkH,EAAU9I,SAAS+I,eAAenH,GACxCf,EAAGG,UAAUgI,OAAO,aACpBF,EAAQ9H,UAAUgI,OAAO,uBAK/BC,EAAYnJ,EAAE,cACdoJ,EAAOpJ,EAAE,QAEXmJ,GAAaC,IACbD,EAAU/H,SACVgI,EAAKC,GAAK,QAIRC,EAAmBtJ,EAAE,yBAEvBsJ,EAAkB,KACZC,EAAiBD,EAAiBnJ,cAAc,KAChDqJ,EAAeF,EAAiBnJ,cAAc,OAEhDoJ,GAAkBC,GAClBD,EAAe3H,iBAAiB,SAAS,eACjC6H,EAAMD,EAAaC,KAEU,IAA7BA,EAAIrD,QAAQ,YAEZqD,EAAMA,EAAIxC,MAAM,UAAU,GAE1BwC,GAAO,WAGXD,EAAaC,IAAMA,EAAM,SAAWnH,KAAKoH,gBAK/CC,EAAiBvJ,EAAG,cAEtBuJ,GACAvB,MAAMC,UAAUC,QAAQC,KAAKoB,GAAgB,SAACrF,GAC1CrD,EAASqD,OHtEMvE,EIlCjB,WACNmI,QAGM0B,EADY,IAAIC,gBAAgBC,OAAOC,SAASC,QAC5BC,IAAI,KAGhB,IAAI/G,EAAUhD,SAAS+I,eAAe,WAAY,CAC5D3F,aAAc,SAAC4G,GACXC,8BACKvF,MAAK,SAAAwF,UAAKA,EAAEC,UACZzF,KAAKsF,IAEd/E,YAAa,SAACmF,+DAEkBA,EAAQjB,gBAAO/H,EAAOgJ,EAAQnE,wEACzB7E,EAAOgJ,EAAQC,qBAAYjJ,EAAOgJ,EAAQC,0DAC9CD,EAAQjE,KClBjCmE,KAAI,SAAAC,OACRC,SAEAA,GADkC,IAAlCD,EAAQnE,KAAKF,QAAQ,QACL,aACyB,IAAlCqE,EAAQnE,KAAKF,QAAQ,QACZ,cACsB,IAA/BqE,EAAQnE,KAAKF,QAAQ,KACZ,aAEA,wCAGUqE,EAAQE,iEACCD,eAAkBpJ,EAAOmJ,EAAQnE,kDAEzEiB,KAAK,yCDMJ7D,eAAgBwC,EAChBjC,UAAW2F,IAETpF,UJYsB,YAAxBtE,SAAS0K,WACT7K,IAEAG,SAAS0B,iBAAiB,mBAAoB7B"} \ No newline at end of file diff --git a/public/assets/bundle/generic.js b/public/assets/bundle/generic.js index 787d3d1..0faeba8 100644 --- a/public/assets/bundle/generic.js +++ b/public/assets/bundle/generic.js @@ -219,6 +219,7 @@ const globalSetup = () => { main.id = ''; } + // CAPTCHA refresh const captchaContainer = $('.captcha_container'); if (captchaContainer) { @@ -227,14 +228,27 @@ const globalSetup = () => { if (refreshElement && imageElement) { refreshElement.addEventListener('click', () => { - imageElement.src = imageElement.src.split('?')[0] + '?rand=' + Math.random(); + let src = imageElement.src; + + if (src.indexOf('&refresh') !== -1) { + // yeah, it's kinda cancerous. fuck off. + src = src.split('&rand=')[0]; + } else { + src += '&refresh'; + } + + imageElement.src = src + '&rand=' + Math.random(); }); } } - Array.prototype.forEach.call($('.js-hidden'), (elem) => { - toggleEl(elem); - }); + const hiddenElements = $$('.js-hidden'); + + if (hiddenElements) { + Array.prototype.forEach.call(hiddenElements, (elem) => { + toggleEl(elem); + }); + } }; whenReady(globalSetup); diff --git a/public/assets/bundle/generic.min.js b/public/assets/bundle/generic.min.js index d40b6c4..ed5c8ee 100644 --- a/public/assets/bundle/generic.min.js +++ b/public/assets/bundle/generic.min.js @@ -1,2 +1,2 @@ -function e(e,n){var a="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!a){if(Array.isArray(e)||(a=function(e,n){if(!e)return;if("string"==typeof e)return t(e,n);var a=Object.prototype.toString.call(e).slice(8,-1);"Object"===a&&e.constructor&&(a=e.constructor.name);if("Map"===a||"Set"===a)return Array.from(e);if("Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return t(e,n)}(e))||n&&e&&"number"==typeof e.length){a&&(e=a);var i=0,r=function(){};return{s:r,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,l=!1;return{s:function(){a=a.call(e)},n:function(){var e=a.next();return s=e.done,e},e:function(e){l=!0,o=e},f:function(){try{s||null==a.return||a.return()}finally{if(l)throw o}}}}function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,a=new Array(t);n/g,">").replace(/"/g,""").replace(/'/g,"'")},c=function(){function t(e){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};n(this,t),this.element=e,this.tags=[],this.options=a,this.maxTags=a.maxTags||10,this.inputNode=null,this.containerNode=null}var i,r,s;return i=t,(r=[{key:"attach",value:function(){if(this.element.style.display="none",this.containerNode=o('
'),this.inputNode=o(''),this.containerNode.appendChild(this.inputNode),this.element.parentNode.insertBefore(this.containerNode,this.element.nextSibling),this.element.value){var t,n=e(this.element.value.split(","));try{for(n.s();!(t=n.n()).done;){var a=t.value;this.addTag(a)}}catch(e){n.e(e)}finally{n.f()}}this.containerNode.addEventListener("keydown",this._handleInputKeyUp.bind(this)),this.containerNode.addEventListener("click",this._handleContainerClick.bind(this))}},{key:"detach",value:function(){this.tags.clear(),this.containerNode.remove(),this.element.style.display="inline-block"}},{key:"updateHiddenInputValue",value:function(){this.element.value=this.tags.join(",")}},{key:"deleteTagNode",value:function(e){this.tags.splice(this.tags.indexOf(e.dataset.value.toLowerCase()),1),e.remove(),this.tags.length'+l(e)+''),this.inputNode),this.tags.length>=this.maxTags&&(this.inputNode.disabled=!0))}},{key:"_handleInputKeyUp",value:function(e){var t=this.inputNode.value;"Backspace"===e.key&&""===t?this.inputNode.previousSibling&&(this.deleteTagNode(this.inputNode.previousSibling),this.updateHiddenInputValue()):","===e.key&&(this.addTag(t),this.inputNode.value="",this.updateHiddenInputValue(),e.preventDefault())}},{key:"_handleContainerClick",value:function(e){e.target&&e.target.classList.contains("delete")&&(this.deleteTagNode(e.target.closest(".tag")),this.updateHiddenInputValue())}}])&&a(i.prototype,r),s&&a(i,s),t}();i=function(){var e,t;Array.prototype.forEach.call((e=".js-tag-input",document.querySelectorAll(e)||[]),(function(e){new c(e).attach()})),(t=r('[data-target~="#signin"],[data-target~="#signup"]'))&&(t.href="javascript:void(0)",t.addEventListener("click",(function(){r(".modal").classList.add("is-active")})),r(".modal-button-close").addEventListener("click",(function(){r(".modal").classList.remove("is-active")})));var n=r(".panel-tools .embed-tool");n&&n.addEventListener("click",(function(e){e.target&&e.target.closest(".panel-tools")&&s(e.target.closest(".panel-tools").querySelector(".panel-embed"))}));var a=r(".expand-tool");a&&a.addEventListener("click",(function(e){if(e.target&&e.target.closest(".panel")){var t=e.target.closest(".panel");t.classList.contains("panel-fullsize")?t.classList.remove("panel-fullsize"):t.classList.add("panel-fullsize")}})),(document.querySelectorAll(".notification .delete")||[]).forEach((function(e){var t=e.parentNode;e.addEventListener("click",(function(){t.parentNode.removeChild(t)}))}));var i=Array.prototype.slice.call(document.querySelectorAll(".navbar-burger"),0);i.length>0&&i.forEach((function(e){e.addEventListener("click",(function(){var t=e.dataset.target,n=document.getElementById(t);e.classList.toggle("is-active"),n.classList.toggle("is-active")}))}));var o=r(".preloader"),l=r("main");o&&l&&(o.remove(),l.id="");var d=r(".captcha_container");if(d){var u=d.querySelector("a"),h=d.querySelector("img");u&&h&&u.addEventListener("click",(function(){h.src=h.src.split("?")[0]+"?rand="+Math.random()}))}Array.prototype.forEach.call(r(".js-hidden"),(function(e){s(e)}))},"loading"!==document.readyState?i():document.addEventListener("DOMContentLoaded",i); +function e(e,n){var a="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!a){if(Array.isArray(e)||(a=function(e,n){if(!e)return;if("string"==typeof e)return t(e,n);var a=Object.prototype.toString.call(e).slice(8,-1);"Object"===a&&e.constructor&&(a=e.constructor.name);if("Map"===a||"Set"===a)return Array.from(e);if("Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return t(e,n)}(e))||n&&e&&"number"==typeof e.length){a&&(e=a);var i=0,r=function(){};return{s:r,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,l=!1;return{s:function(){a=a.call(e)},n:function(){var e=a.next();return s=e.done,e},e:function(e){l=!0,o=e},f:function(){try{s||null==a.return||a.return()}finally{if(l)throw o}}}}function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,a=new Array(t);n/g,">").replace(/"/g,""").replace(/'/g,"'")},d=function(){function t(e){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};n(this,t),this.element=e,this.tags=[],this.options=a,this.maxTags=a.maxTags||10,this.inputNode=null,this.containerNode=null}var i,r,o;return i=t,(r=[{key:"attach",value:function(){if(this.element.style.display="none",this.containerNode=s('
'),this.inputNode=s(''),this.containerNode.appendChild(this.inputNode),this.element.parentNode.insertBefore(this.containerNode,this.element.nextSibling),this.element.value){var t,n=e(this.element.value.split(","));try{for(n.s();!(t=n.n()).done;){var a=t.value;this.addTag(a)}}catch(e){n.e(e)}finally{n.f()}}this.containerNode.addEventListener("keydown",this._handleInputKeyUp.bind(this)),this.containerNode.addEventListener("click",this._handleContainerClick.bind(this))}},{key:"detach",value:function(){this.tags.clear(),this.containerNode.remove(),this.element.style.display="inline-block"}},{key:"updateHiddenInputValue",value:function(){this.element.value=this.tags.join(",")}},{key:"deleteTagNode",value:function(e){this.tags.splice(this.tags.indexOf(e.dataset.value.toLowerCase()),1),e.remove(),this.tags.length'+c(e)+''),this.inputNode),this.tags.length>=this.maxTags&&(this.inputNode.disabled=!0))}},{key:"_handleInputKeyUp",value:function(e){var t=this.inputNode.value;"Backspace"===e.key&&""===t?this.inputNode.previousSibling&&(this.deleteTagNode(this.inputNode.previousSibling),this.updateHiddenInputValue()):","===e.key&&(this.addTag(t),this.inputNode.value="",this.updateHiddenInputValue(),e.preventDefault())}},{key:"_handleContainerClick",value:function(e){e.target&&e.target.classList.contains("delete")&&(this.deleteTagNode(e.target.closest(".tag")),this.updateHiddenInputValue())}}])&&a(i.prototype,r),o&&a(i,o),t}();i=function(){var e;Array.prototype.forEach.call(o(".js-tag-input"),(function(e){new d(e).attach()})),(e=r('[data-target~="#signin"],[data-target~="#signup"]'))&&(e.href="javascript:void(0)",e.addEventListener("click",(function(){r(".modal").classList.add("is-active")})),r(".modal-button-close").addEventListener("click",(function(){r(".modal").classList.remove("is-active")})));var t=r(".panel-tools .embed-tool");t&&t.addEventListener("click",(function(e){e.target&&e.target.closest(".panel-tools")&&l(e.target.closest(".panel-tools").querySelector(".panel-embed"))}));var n=r(".expand-tool");n&&n.addEventListener("click",(function(e){if(e.target&&e.target.closest(".panel")){var t=e.target.closest(".panel");t.classList.contains("panel-fullsize")?t.classList.remove("panel-fullsize"):t.classList.add("panel-fullsize")}})),(document.querySelectorAll(".notification .delete")||[]).forEach((function(e){var t=e.parentNode;e.addEventListener("click",(function(){t.parentNode.removeChild(t)}))}));var a=Array.prototype.slice.call(document.querySelectorAll(".navbar-burger"),0);a.length>0&&a.forEach((function(e){e.addEventListener("click",(function(){var t=e.dataset.target,n=document.getElementById(t);e.classList.toggle("is-active"),n.classList.toggle("is-active")}))}));var i=r(".preloader"),s=r("main");i&&s&&(i.remove(),s.id="");var c=r(".captcha_container");if(c){var u=c.querySelector("a"),h=c.querySelector("img");u&&h&&u.addEventListener("click",(function(){var e=h.src;-1!==e.indexOf("&refresh")?e=e.split("&rand=")[0]:e+="&refresh",h.src=e+"&rand="+Math.random()}))}var p=o(".js-hidden");p&&Array.prototype.forEach.call(p,(function(e){l(e)}))},"loading"!==document.readyState?i():document.addEventListener("DOMContentLoaded",i); //# sourceMappingURL=generic.min.js.map diff --git a/public/assets/bundle/generic.min.js.map b/public/assets/bundle/generic.min.js.map index 7e400e1..3be1295 100644 --- a/public/assets/bundle/generic.min.js.map +++ b/public/assets/bundle/generic.min.js.map @@ -1 +1 @@ -{"version":3,"file":"generic.min.js","sources":["../../../js/dom.js","../../../js/tag_input.js","../../../js/main.js"],"sourcesContent":["const $ = function(selector) {\n return document.querySelector(selector);\n};\n\nconst $$ = function(selector) {\n return document.querySelectorAll(selector) || [];\n};\n\nconst makeEl = function(html) {\n const template = document.createElement('template');\n\n template.innerHTML = html.trim();\n\n return template.content.firstChild;\n};\n\nconst clearEl = function(el) {\n while (el.firstChild) {\n el.removeChild(el.firstChild);\n }\n};\n\nconst toggleEl = function(el) {\n if (el.classList.contains('is-hidden')) {\n el.classList.remove('is-hidden');\n } else {\n el.classList.add('is-hidden');\n }\n};\n\nconst escape = function(unsafe) {\n return unsafe\n .replace(/&/g, \"&\")\n .replace(//g, \">\")\n .replace(/\"/g, \""\")\n .replace(/'/g, \"'\");\n}\n\nconst whenReady = function(funcp) {\n if (document.readyState !== 'loading') {\n funcp();\n } else {\n document.addEventListener('DOMContentLoaded', funcp);\n }\n}\n\nexport { whenReady, $, $$, makeEl, clearEl, toggleEl, escape };","import { makeEl, escape } from \"./dom\";\n\nclass TagsInput {\n constructor(element, options = {}) {\n this.element = element;\n this.tags = [];\n this.options = options\n\n this.maxTags = options.maxTags || 10;\n this.inputNode = null;\n this.containerNode = null;\n }\n\n attach() {\n this.element.style.display = 'none';\n\n this.containerNode = makeEl('
');\n this.inputNode = makeEl('');\n this.containerNode.appendChild(this.inputNode);\n\n this.element.parentNode.insertBefore(this.containerNode, this.element.nextSibling);\n\n /* Load existing tags from input */\n if (this.element.value) {\n for (const tag of this.element.value.split(',')) {\n this.addTag(tag);\n }\n }\n\n /* Handle addition and removal of tags via key-presses */\n this.containerNode.addEventListener('keydown', this._handleInputKeyUp.bind(this));\n\n /* Handle deletions by clicking the delete button */\n this.containerNode.addEventListener('click', this._handleContainerClick.bind(this));\n }\n\n detach() {\n this.tags.clear();\n this.containerNode.remove();\n this.element.style.display = 'inline-block';\n }\n\n updateHiddenInputValue() {\n this.element.value = this.tags.join(',');\n }\n\n deleteTagNode(node) {\n this.tags.splice(this.tags.indexOf(node.dataset.value.toLowerCase()), 1);\n node.remove();\n\n /* Below the limit? Make sure the input is enabled. */\n if (this.tags.length < this.maxTags) {\n this.inputNode.disabled = false;\n }\n }\n\n addTag(tagValue) {\n tagValue = tagValue.trim();\n\n /* Tag value is probably not empty and we don't already have the same tag. */\n if (tagValue !== '' && this.tags.indexOf(tagValue.toLowerCase()) === -1) {\n this.tags.push(tagValue.toLowerCase());\n\n this.inputNode.parentNode.insertBefore(\n makeEl('' + escape(tagValue) + ''),\n this.inputNode\n );\n\n /* Too many tags, disable the input for now. */\n if (this.tags.length >= this.maxTags) {\n this.inputNode.disabled = true;\n }\n }\n }\n\n _handleInputKeyUp(evt) {\n let tagValue = this.inputNode.value;\n\n if (evt.key === 'Backspace' && tagValue === '') {\n // Remove the child\n if (this.inputNode.previousSibling) {\n this.deleteTagNode(this.inputNode.previousSibling);\n\n this.updateHiddenInputValue();\n }\n } else if (evt.key === ',') {\n this.addTag(tagValue);\n\n this.inputNode.value = ''\n this.updateHiddenInputValue();\n\n evt.preventDefault();\n }\n }\n\n _handleContainerClick(evt) {\n if (evt.target && evt.target.classList.contains('delete')) {\n this.deleteTagNode(evt.target.closest('.tag'));\n this.updateHiddenInputValue();\n }\n }\n}\n\nexport { TagsInput };\n","import { $, $$, toggleEl } from './dom';\nimport { TagsInput } from \"./tag_input\";\n\nconst setupSignupModal = () => {\n const signupButton = $('[data-target~=\"#signin\"],[data-target~=\"#signup\"]');\n\n if (signupButton) {\n signupButton.href = 'javascript:void(0)';\n\n signupButton.addEventListener('click', () => {\n $('.modal').classList.add('is-active');\n });\n\n $('.modal-button-close').addEventListener('click', () => {\n $('.modal').classList.remove('is-active');\n });\n }\n}\n\nconst globalSetup = () => {\n Array.prototype.forEach.call($$('.js-tag-input'), (el) => {\n new TagsInput(el).attach();\n });\n\n setupSignupModal();\n\n const embedButton = $('.panel-tools .embed-tool');\n\n if (embedButton){\n embedButton.addEventListener('click', (evt) => {\n if (evt.target && evt.target.closest('.panel-tools')) {\n toggleEl(evt.target.closest('.panel-tools').querySelector('.panel-embed'));\n }\n });\n }\n\n const expandButton = $('.expand-tool');\n\n if (expandButton) {\n expandButton.addEventListener('click', (evt) => {\n if (evt.target && evt.target.closest('.panel')) {\n const panel = evt.target.closest('.panel');\n\n if (panel.classList.contains('panel-fullsize')) {\n panel.classList.remove('panel-fullsize');\n } else {\n panel.classList.add('panel-fullsize');\n }\n }\n });\n }\n\n // Notifications\n (document.querySelectorAll('.notification .delete') || []).forEach(($delete) => {\n const $notification = $delete.parentNode;\n\n $delete.addEventListener('click', () => {\n $notification.parentNode.removeChild($notification);\n });\n });\n\n // Hamburger menu\n const $navbarBurgers = Array.prototype.slice.call(document.querySelectorAll('.navbar-burger'), 0);\n if ($navbarBurgers.length > 0) {\n $navbarBurgers.forEach(el => {\n el.addEventListener('click', () => {\n const target = el.dataset.target;\n const $target = document.getElementById(target);\n el.classList.toggle('is-active');\n $target.classList.toggle('is-active');\n });\n });\n }\n\n const preloader = $('.preloader');\n const main = $('main');\n\n if (preloader && main) {\n preloader.remove();\n main.id = '';\n }\n\n const captchaContainer = $('.captcha_container');\n\n if (captchaContainer) {\n const refreshElement = captchaContainer.querySelector('a');\n const imageElement = captchaContainer.querySelector('img');\n\n if (refreshElement && imageElement) {\n refreshElement.addEventListener('click', () => {\n imageElement.src = imageElement.src.split('?')[0] + '?rand=' + Math.random();\n });\n }\n }\n\n Array.prototype.forEach.call($('.js-hidden'), (elem) => {\n toggleEl(elem);\n });\n}\n\nexport { globalSetup };"],"names":["funcp","$","selector","document","querySelector","makeEl","html","template","createElement","innerHTML","trim","content","firstChild","toggleEl","el","classList","contains","remove","add","escape","unsafe","replace","TagsInput","element","options","tags","maxTags","inputNode","containerNode","style","display","appendChild","this","parentNode","insertBefore","nextSibling","value","split","tag","addTag","addEventListener","_handleInputKeyUp","bind","_handleContainerClick","clear","join","node","splice","indexOf","dataset","toLowerCase","length","disabled","tagValue","push","evt","key","previousSibling","deleteTagNode","updateHiddenInputValue","preventDefault","target","closest","signupButton","Array","prototype","forEach","call","querySelectorAll","attach","href","embedButton","expandButton","panel","$delete","$notification","removeChild","$navbarBurgers","slice","$target","getElementById","toggle","preloader","main","id","captchaContainer","refreshElement","imageElement","src","Math","random","elem","readyState"],"mappings":"wxCAAA,IAuC2BA,EAvCrBC,EAAI,SAASC,UACRC,SAASC,cAAcF,IAO5BG,EAAS,SAASC,OACdC,EAAWJ,SAASK,cAAc,mBAExCD,EAASE,UAAYH,EAAKI,OAEnBH,EAASI,QAAQC,YAStBC,EAAW,SAASC,GAClBA,EAAGC,UAAUC,SAAS,aACtBF,EAAGC,UAAUE,OAAO,aAEpBH,EAAGC,UAAUG,IAAI,cAInBC,EAAS,SAASC,UACbA,EACFC,QAAQ,KAAM,SACdA,QAAQ,KAAM,QACdA,QAAQ,KAAM,QACdA,QAAQ,KAAM,UACdA,QAAQ,KAAM,WClCjBC,wBACUC,OAASC,yDAAU,kBACtBD,QAAUA,OACVE,KAAO,QACPD,QAAUA,OAEVE,QAAUF,EAAQE,SAAW,QAC7BC,UAAY,UACZC,cAAgB,kDAGzB,mBACSL,QAAQM,MAAMC,QAAU,YAExBF,cAAgBvB,EAAO,uCACvBsB,UAAYtB,EAAO,mFACnBuB,cAAcG,YAAYC,KAAKL,gBAE/BJ,QAAQU,WAAWC,aAAaF,KAAKJ,cAAeI,KAAKT,QAAQY,aAGlEH,KAAKT,QAAQa,MAAO,WACFJ,KAAKT,QAAQa,MAAMC,MAAM,qCAAM,KAAtCC,eACFC,OAAOD,wCAKfV,cAAcY,iBAAiB,UAAWR,KAAKS,kBAAkBC,KAAKV,YAGtEJ,cAAcY,iBAAiB,QAASR,KAAKW,sBAAsBD,KAAKV,6BAGjF,gBACSP,KAAKmB,aACLhB,cAAcX,cACdM,QAAQM,MAAMC,QAAU,qDAGjC,gBACSP,QAAQa,MAAQJ,KAAKP,KAAKoB,KAAK,kCAGxC,SAAcC,QACLrB,KAAKsB,OAAOf,KAAKP,KAAKuB,QAAQF,EAAKG,QAAQb,MAAMc,eAAgB,GACtEJ,EAAK7B,SAGDe,KAAKP,KAAK0B,OAASnB,KAAKN,eACnBC,UAAUyB,UAAW,yBAIlC,SAAOC,GAIc,MAHjBA,EAAWA,EAAS3C,UAGkD,IAA/CsB,KAAKP,KAAKuB,QAAQK,EAASH,sBACzCzB,KAAK6B,KAAKD,EAASH,oBAEnBvB,UAAUM,WAAWC,aACtB7B,EAAO,yCAA2Cc,EAAOkC,GAAY,KAAOlC,EAAOkC,GAAY,2CAC/FrB,KAAKL,WAILK,KAAKP,KAAK0B,QAAUnB,KAAKN,eACpBC,UAAUyB,UAAW,qCAKtC,SAAkBG,OACVF,EAAWrB,KAAKL,UAAUS,MAEd,cAAZmB,EAAIC,KAAoC,KAAbH,EAEvBrB,KAAKL,UAAU8B,uBACVC,cAAc1B,KAAKL,UAAU8B,sBAE7BE,0BAEU,MAAZJ,EAAIC,WACNjB,OAAOc,QAEP1B,UAAUS,MAAQ,QAClBuB,yBAELJ,EAAIK,uDAIZ,SAAsBL,GACdA,EAAIM,QAAUN,EAAIM,OAAO9C,UAAUC,SAAS,iBACvC0C,cAAcH,EAAIM,OAAOC,QAAQ,cACjCH,+DD3DU3D,EEpBP,WFfT,IAASE,EEAV6D,EAgBNC,MAAMC,UAAUC,QAAQC,MFhBRjE,EEgBgB,gBFfzBC,SAASiE,iBAAiBlE,IAAa,KEeI,SAACY,OAC3CQ,EAAUR,GAAIuD,aAjBhBN,EAAe9D,EAAE,wDAGnB8D,EAAaO,KAAO,qBAEpBP,EAAavB,iBAAiB,SAAS,WACnCvC,EAAE,UAAUc,UAAUG,IAAI,gBAG9BjB,EAAE,uBAAuBuC,iBAAiB,SAAS,WAC/CvC,EAAE,UAAUc,UAAUE,OAAO,qBAY/BsD,EAActE,EAAE,4BAElBsE,GACAA,EAAY/B,iBAAiB,SAAS,SAACe,GAC/BA,EAAIM,QAAUN,EAAIM,OAAOC,QAAQ,iBACjCjD,EAAS0C,EAAIM,OAAOC,QAAQ,gBAAgB1D,cAAc,wBAKhEoE,EAAevE,EAAE,gBAEnBuE,GACAA,EAAahC,iBAAiB,SAAS,SAACe,MAChCA,EAAIM,QAAUN,EAAIM,OAAOC,QAAQ,UAAW,KACtCW,EAAQlB,EAAIM,OAAOC,QAAQ,UAE7BW,EAAM1D,UAAUC,SAAS,kBACzByD,EAAM1D,UAAUE,OAAO,kBAEvBwD,EAAM1D,UAAUG,IAAI,uBAOnCf,SAASiE,iBAAiB,0BAA4B,IAAIF,SAAQ,SAACQ,OAC1DC,EAAgBD,EAAQzC,WAE9ByC,EAAQlC,iBAAiB,SAAS,WAC9BmC,EAAc1C,WAAW2C,YAAYD,aAKvCE,EAAiBb,MAAMC,UAAUa,MAAMX,KAAKhE,SAASiE,iBAAiB,kBAAmB,GAC3FS,EAAe1B,OAAS,GACxB0B,EAAeX,SAAQ,SAAApD,GACnBA,EAAG0B,iBAAiB,SAAS,eACnBqB,EAAS/C,EAAGmC,QAAQY,OACpBkB,EAAU5E,SAAS6E,eAAenB,GACxC/C,EAAGC,UAAUkE,OAAO,aACpBF,EAAQhE,UAAUkE,OAAO,uBAK/BC,EAAYjF,EAAE,cACdkF,EAAOlF,EAAE,QAEXiF,GAAaC,IACbD,EAAUjE,SACVkE,EAAKC,GAAK,QAGRC,EAAmBpF,EAAE,yBAEvBoF,EAAkB,KACZC,EAAiBD,EAAiBjF,cAAc,KAChDmF,EAAeF,EAAiBjF,cAAc,OAEhDkF,GAAkBC,GAClBD,EAAe9C,iBAAiB,SAAS,WACrC+C,EAAaC,IAAMD,EAAaC,IAAInD,MAAM,KAAK,GAAK,SAAWoD,KAAKC,YAKhF1B,MAAMC,UAAUC,QAAQC,KAAKlE,EAAE,eAAe,SAAC0F,GAC3C9E,EAAS8E,OFxDe,YAAxBxF,SAASyF,WACT5F,IAEAG,SAASqC,iBAAiB,mBAAoBxC"} \ No newline at end of file +{"version":3,"file":"generic.min.js","sources":["../../../js/dom.js","../../../js/tag_input.js","../../../js/main.js"],"sourcesContent":["const $ = function(selector) {\n return document.querySelector(selector);\n};\n\nconst $$ = function(selector) {\n return document.querySelectorAll(selector) || [];\n};\n\nconst makeEl = function(html) {\n const template = document.createElement('template');\n\n template.innerHTML = html.trim();\n\n return template.content.firstChild;\n};\n\nconst clearEl = function(el) {\n while (el.firstChild) {\n el.removeChild(el.firstChild);\n }\n};\n\nconst toggleEl = function(el) {\n if (el.classList.contains('is-hidden')) {\n el.classList.remove('is-hidden');\n } else {\n el.classList.add('is-hidden');\n }\n};\n\nconst escape = function(unsafe) {\n return unsafe\n .replace(/&/g, \"&\")\n .replace(//g, \">\")\n .replace(/\"/g, \""\")\n .replace(/'/g, \"'\");\n}\n\nconst whenReady = function(funcp) {\n if (document.readyState !== 'loading') {\n funcp();\n } else {\n document.addEventListener('DOMContentLoaded', funcp);\n }\n}\n\nexport { whenReady, $, $$, makeEl, clearEl, toggleEl, escape };","import { makeEl, escape } from \"./dom\";\n\nclass TagsInput {\n constructor(element, options = {}) {\n this.element = element;\n this.tags = [];\n this.options = options\n\n this.maxTags = options.maxTags || 10;\n this.inputNode = null;\n this.containerNode = null;\n }\n\n attach() {\n this.element.style.display = 'none';\n\n this.containerNode = makeEl('
');\n this.inputNode = makeEl('');\n this.containerNode.appendChild(this.inputNode);\n\n this.element.parentNode.insertBefore(this.containerNode, this.element.nextSibling);\n\n /* Load existing tags from input */\n if (this.element.value) {\n for (const tag of this.element.value.split(',')) {\n this.addTag(tag);\n }\n }\n\n /* Handle addition and removal of tags via key-presses */\n this.containerNode.addEventListener('keydown', this._handleInputKeyUp.bind(this));\n\n /* Handle deletions by clicking the delete button */\n this.containerNode.addEventListener('click', this._handleContainerClick.bind(this));\n }\n\n detach() {\n this.tags.clear();\n this.containerNode.remove();\n this.element.style.display = 'inline-block';\n }\n\n updateHiddenInputValue() {\n this.element.value = this.tags.join(',');\n }\n\n deleteTagNode(node) {\n this.tags.splice(this.tags.indexOf(node.dataset.value.toLowerCase()), 1);\n node.remove();\n\n /* Below the limit? Make sure the input is enabled. */\n if (this.tags.length < this.maxTags) {\n this.inputNode.disabled = false;\n }\n }\n\n addTag(tagValue) {\n tagValue = tagValue.trim();\n\n /* Tag value is probably not empty and we don't already have the same tag. */\n if (tagValue !== '' && this.tags.indexOf(tagValue.toLowerCase()) === -1) {\n this.tags.push(tagValue.toLowerCase());\n\n this.inputNode.parentNode.insertBefore(\n makeEl('' + escape(tagValue) + ''),\n this.inputNode\n );\n\n /* Too many tags, disable the input for now. */\n if (this.tags.length >= this.maxTags) {\n this.inputNode.disabled = true;\n }\n }\n }\n\n _handleInputKeyUp(evt) {\n let tagValue = this.inputNode.value;\n\n if (evt.key === 'Backspace' && tagValue === '') {\n // Remove the child\n if (this.inputNode.previousSibling) {\n this.deleteTagNode(this.inputNode.previousSibling);\n\n this.updateHiddenInputValue();\n }\n } else if (evt.key === ',') {\n this.addTag(tagValue);\n\n this.inputNode.value = ''\n this.updateHiddenInputValue();\n\n evt.preventDefault();\n }\n }\n\n _handleContainerClick(evt) {\n if (evt.target && evt.target.classList.contains('delete')) {\n this.deleteTagNode(evt.target.closest('.tag'));\n this.updateHiddenInputValue();\n }\n }\n}\n\nexport { TagsInput };\n","import { $, $$, toggleEl } from './dom';\nimport { TagsInput } from \"./tag_input\";\n\nconst setupSignupModal = () => {\n const signupButton = $('[data-target~=\"#signin\"],[data-target~=\"#signup\"]');\n\n if (signupButton) {\n signupButton.href = 'javascript:void(0)';\n\n signupButton.addEventListener('click', () => {\n $('.modal').classList.add('is-active');\n });\n\n $('.modal-button-close').addEventListener('click', () => {\n $('.modal').classList.remove('is-active');\n });\n }\n}\n\nconst globalSetup = () => {\n Array.prototype.forEach.call($$('.js-tag-input'), (el) => {\n new TagsInput(el).attach();\n });\n\n setupSignupModal();\n\n const embedButton = $('.panel-tools .embed-tool');\n\n if (embedButton){\n embedButton.addEventListener('click', (evt) => {\n if (evt.target && evt.target.closest('.panel-tools')) {\n toggleEl(evt.target.closest('.panel-tools').querySelector('.panel-embed'));\n }\n });\n }\n\n const expandButton = $('.expand-tool');\n\n if (expandButton) {\n expandButton.addEventListener('click', (evt) => {\n if (evt.target && evt.target.closest('.panel')) {\n const panel = evt.target.closest('.panel');\n\n if (panel.classList.contains('panel-fullsize')) {\n panel.classList.remove('panel-fullsize');\n } else {\n panel.classList.add('panel-fullsize');\n }\n }\n });\n }\n\n // Notifications\n (document.querySelectorAll('.notification .delete') || []).forEach(($delete) => {\n const $notification = $delete.parentNode;\n\n $delete.addEventListener('click', () => {\n $notification.parentNode.removeChild($notification);\n });\n });\n\n // Hamburger menu\n const $navbarBurgers = Array.prototype.slice.call(document.querySelectorAll('.navbar-burger'), 0);\n if ($navbarBurgers.length > 0) {\n $navbarBurgers.forEach(el => {\n el.addEventListener('click', () => {\n const target = el.dataset.target;\n const $target = document.getElementById(target);\n el.classList.toggle('is-active');\n $target.classList.toggle('is-active');\n });\n });\n }\n\n const preloader = $('.preloader');\n const main = $('main');\n\n if (preloader && main) {\n preloader.remove();\n main.id = '';\n }\n\n // CAPTCHA refresh\n const captchaContainer = $('.captcha_container');\n\n if (captchaContainer) {\n const refreshElement = captchaContainer.querySelector('a');\n const imageElement = captchaContainer.querySelector('img');\n\n if (refreshElement && imageElement) {\n refreshElement.addEventListener('click', () => {\n let src = imageElement.src;\n\n if (src.indexOf('&refresh') !== -1) {\n // yeah, it's kinda cancerous. fuck off.\n src = src.split('&rand=')[0];\n } else {\n src += '&refresh';\n }\n\n imageElement.src = src + '&rand=' + Math.random();\n });\n }\n }\n\n const hiddenElements = $$('.js-hidden');\n\n if (hiddenElements) {\n Array.prototype.forEach.call(hiddenElements, (elem) => {\n toggleEl(elem);\n });\n }\n}\n\nexport { globalSetup };"],"names":["funcp","$","selector","document","querySelector","$$","querySelectorAll","makeEl","html","template","createElement","innerHTML","trim","content","firstChild","toggleEl","el","classList","contains","remove","add","escape","unsafe","replace","TagsInput","element","options","tags","maxTags","inputNode","containerNode","style","display","appendChild","this","parentNode","insertBefore","nextSibling","value","split","tag","addTag","addEventListener","_handleInputKeyUp","bind","_handleContainerClick","clear","join","node","splice","indexOf","dataset","toLowerCase","length","disabled","tagValue","push","evt","key","previousSibling","deleteTagNode","updateHiddenInputValue","preventDefault","target","closest","signupButton","Array","prototype","forEach","call","attach","href","embedButton","expandButton","panel","$delete","$notification","removeChild","$navbarBurgers","slice","$target","getElementById","toggle","preloader","main","id","captchaContainer","refreshElement","imageElement","src","Math","random","hiddenElements","elem","readyState"],"mappings":"wxCAAA,IAuC2BA,EAvCrBC,EAAI,SAASC,UACRC,SAASC,cAAcF,IAG5BG,EAAK,SAASH,UACTC,SAASG,iBAAiBJ,IAAa,IAG5CK,EAAS,SAASC,OACdC,EAAWN,SAASO,cAAc,mBAExCD,EAASE,UAAYH,EAAKI,OAEnBH,EAASI,QAAQC,YAStBC,EAAW,SAASC,GAClBA,EAAGC,UAAUC,SAAS,aACtBF,EAAGC,UAAUE,OAAO,aAEpBH,EAAGC,UAAUG,IAAI,cAInBC,EAAS,SAASC,UACbA,EACFC,QAAQ,KAAM,SACdA,QAAQ,KAAM,QACdA,QAAQ,KAAM,QACdA,QAAQ,KAAM,UACdA,QAAQ,KAAM,WClCjBC,wBACUC,OAASC,yDAAU,kBACtBD,QAAUA,OACVE,KAAO,QACPD,QAAUA,OAEVE,QAAUF,EAAQE,SAAW,QAC7BC,UAAY,UACZC,cAAgB,kDAGzB,mBACSL,QAAQM,MAAMC,QAAU,YAExBF,cAAgBvB,EAAO,uCACvBsB,UAAYtB,EAAO,mFACnBuB,cAAcG,YAAYC,KAAKL,gBAE/BJ,QAAQU,WAAWC,aAAaF,KAAKJ,cAAeI,KAAKT,QAAQY,aAGlEH,KAAKT,QAAQa,MAAO,WACFJ,KAAKT,QAAQa,MAAMC,MAAM,qCAAM,KAAtCC,eACFC,OAAOD,wCAKfV,cAAcY,iBAAiB,UAAWR,KAAKS,kBAAkBC,KAAKV,YAGtEJ,cAAcY,iBAAiB,QAASR,KAAKW,sBAAsBD,KAAKV,6BAGjF,gBACSP,KAAKmB,aACLhB,cAAcX,cACdM,QAAQM,MAAMC,QAAU,qDAGjC,gBACSP,QAAQa,MAAQJ,KAAKP,KAAKoB,KAAK,kCAGxC,SAAcC,QACLrB,KAAKsB,OAAOf,KAAKP,KAAKuB,QAAQF,EAAKG,QAAQb,MAAMc,eAAgB,GACtEJ,EAAK7B,SAGDe,KAAKP,KAAK0B,OAASnB,KAAKN,eACnBC,UAAUyB,UAAW,yBAIlC,SAAOC,GAIc,MAHjBA,EAAWA,EAAS3C,UAGkD,IAA/CsB,KAAKP,KAAKuB,QAAQK,EAASH,sBACzCzB,KAAK6B,KAAKD,EAASH,oBAEnBvB,UAAUM,WAAWC,aACtB7B,EAAO,yCAA2Cc,EAAOkC,GAAY,KAAOlC,EAAOkC,GAAY,2CAC/FrB,KAAKL,WAILK,KAAKP,KAAK0B,QAAUnB,KAAKN,eACpBC,UAAUyB,UAAW,qCAKtC,SAAkBG,OACVF,EAAWrB,KAAKL,UAAUS,MAEd,cAAZmB,EAAIC,KAAoC,KAAbH,EAEvBrB,KAAKL,UAAU8B,uBACVC,cAAc1B,KAAKL,UAAU8B,sBAE7BE,0BAEU,MAAZJ,EAAIC,WACNjB,OAAOc,QAEP1B,UAAUS,MAAQ,QAClBuB,yBAELJ,EAAIK,uDAIZ,SAAsBL,GACdA,EAAIM,QAAUN,EAAIM,OAAO9C,UAAUC,SAAS,iBACvC0C,cAAcH,EAAIM,OAAOC,QAAQ,cACjCH,+DD3DU7D,EEpBP,WAhBK,IACfiE,EAgBNC,MAAMC,UAAUC,QAAQC,KAAKhE,EAAG,kBAAkB,SAACW,OAC3CQ,EAAUR,GAAIsD,aAjBhBL,EAAehE,EAAE,wDAGnBgE,EAAaM,KAAO,qBAEpBN,EAAavB,iBAAiB,SAAS,WACnCzC,EAAE,UAAUgB,UAAUG,IAAI,gBAG9BnB,EAAE,uBAAuByC,iBAAiB,SAAS,WAC/CzC,EAAE,UAAUgB,UAAUE,OAAO,qBAY/BqD,EAAcvE,EAAE,4BAElBuE,GACAA,EAAY9B,iBAAiB,SAAS,SAACe,GAC/BA,EAAIM,QAAUN,EAAIM,OAAOC,QAAQ,iBACjCjD,EAAS0C,EAAIM,OAAOC,QAAQ,gBAAgB5D,cAAc,wBAKhEqE,EAAexE,EAAE,gBAEnBwE,GACAA,EAAa/B,iBAAiB,SAAS,SAACe,MAChCA,EAAIM,QAAUN,EAAIM,OAAOC,QAAQ,UAAW,KACtCU,EAAQjB,EAAIM,OAAOC,QAAQ,UAE7BU,EAAMzD,UAAUC,SAAS,kBACzBwD,EAAMzD,UAAUE,OAAO,kBAEvBuD,EAAMzD,UAAUG,IAAI,uBAOnCjB,SAASG,iBAAiB,0BAA4B,IAAI8D,SAAQ,SAACO,OAC1DC,EAAgBD,EAAQxC,WAE9BwC,EAAQjC,iBAAiB,SAAS,WAC9BkC,EAAczC,WAAW0C,YAAYD,aAKvCE,EAAiBZ,MAAMC,UAAUY,MAAMV,KAAKlE,SAASG,iBAAiB,kBAAmB,GAC3FwE,EAAezB,OAAS,GACxByB,EAAeV,SAAQ,SAAApD,GACnBA,EAAG0B,iBAAiB,SAAS,eACnBqB,EAAS/C,EAAGmC,QAAQY,OACpBiB,EAAU7E,SAAS8E,eAAelB,GACxC/C,EAAGC,UAAUiE,OAAO,aACpBF,EAAQ/D,UAAUiE,OAAO,uBAK/BC,EAAYlF,EAAE,cACdmF,EAAOnF,EAAE,QAEXkF,GAAaC,IACbD,EAAUhE,SACViE,EAAKC,GAAK,QAIRC,EAAmBrF,EAAE,yBAEvBqF,EAAkB,KACZC,EAAiBD,EAAiBlF,cAAc,KAChDoF,EAAeF,EAAiBlF,cAAc,OAEhDmF,GAAkBC,GAClBD,EAAe7C,iBAAiB,SAAS,eACjC+C,EAAMD,EAAaC,KAEU,IAA7BA,EAAIvC,QAAQ,YAEZuC,EAAMA,EAAIlD,MAAM,UAAU,GAE1BkD,GAAO,WAGXD,EAAaC,IAAMA,EAAM,SAAWC,KAAKC,gBAK/CC,EAAiBvF,EAAG,cAEtBuF,GACA1B,MAAMC,UAAUC,QAAQC,KAAKuB,GAAgB,SAACC,GAC1C9E,EAAS8E,OFrEW,YAAxB1F,SAAS2F,WACT9F,IAEAG,SAASuC,iBAAiB,mBAAoB1C"} \ No newline at end of file diff --git a/public/assets/bundle/user_profile.js b/public/assets/bundle/user_profile.js index 1582d2a..4321ac7 100644 --- a/public/assets/bundle/user_profile.js +++ b/public/assets/bundle/user_profile.js @@ -488,6 +488,7 @@ const globalSetup = () => { main.id = ''; } + // CAPTCHA refresh const captchaContainer = $('.captcha_container'); if (captchaContainer) { @@ -496,14 +497,27 @@ const globalSetup = () => { if (refreshElement && imageElement) { refreshElement.addEventListener('click', () => { - imageElement.src = imageElement.src.split('?')[0] + '?rand=' + Math.random(); + let src = imageElement.src; + + if (src.indexOf('&refresh') !== -1) { + // yeah, it's kinda cancerous. fuck off. + src = src.split('&rand=')[0]; + } else { + src += '&refresh'; + } + + imageElement.src = src + '&rand=' + Math.random(); }); } } - Array.prototype.forEach.call($('.js-hidden'), (elem) => { - toggleEl(elem); - }); + const hiddenElements = $$('.js-hidden'); + + if (hiddenElements) { + Array.prototype.forEach.call(hiddenElements, (elem) => { + toggleEl(elem); + }); + } }; const getUserInfo = () => { diff --git a/public/assets/bundle/user_profile.min.js b/public/assets/bundle/user_profile.min.js index 02dc0a5..04bad95 100644 --- a/public/assets/bundle/user_profile.min.js +++ b/public/assets/bundle/user_profile.min.js @@ -1,2 +1,2 @@ -function t(t){return function(t){if(Array.isArray(t))return n(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||a(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function e(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=a(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var i=0,r=function(){};return{s:r,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,o=!0,l=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return o=t.done,t},e:function(t){l=!0,s=t},f:function(){try{o||null==n.return||n.return()}finally{if(l)throw s}}}}function a(t,e){if(t){if("string"==typeof t)return n(t,e);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?n(t,e):void 0}}function n(t,e){(null==e||e>t.length)&&(e=t.length);for(var a=0,n=new Array(e);a/g,">").replace(/"/g,""").replace(/'/g,"'")},p=function(){function t(e){i(this,t),this.element=e}return s(t,[{key:"attach",value:function(t){this.element.addEventListener("click",(function(e){e.target&&e.target.classList.contains("paginator__button")&&t(+e.target.dataset.page)}))}},{key:"update",value:function(t,e,a){d(this.element);var n=Math.floor(t/e);if(0!==n){var i=a-2<0?0:a-2,r=a+2>n?n:a+2,s=Math.abs(0-a)>2,o=Math.abs(n-a)>2,l=0===a?"disabled":"";this.element.appendChild(c(''))),s&&(this.element.appendChild(c('"))),this.element.appendChild(c('')));for(var u=i;u<=r;u++){var h=u===a?"paginator__button--selected":"";this.element.appendChild(c('")))}o&&(this.element.appendChild(c('')),this.element.appendChild(c('"))));var p=a===n?"disabled":"";this.element.appendChild(c('')))}}}]),t}(),f=function(){function a(t,e){i(this,a),this.element=t,this.container=t.parentElement,this.options=e,this.ajaxCallback=e.ajaxCallback,this.data=[],this.unfilteredData=[],this.totalRecords=-1,this.perPage=20,this.currentPage=0,this.paginator=new p(this.container.querySelector(".paginator")),this.filterCallback=e.filterCallback,this.sortField=null,this.sortDir=!0}return s(a,[{key:"attach",value:function(){var t=this;this.filterField=this.container.querySelector("input.search"),this.filterField&&this.filterCallback&&(this.filterField.addEventListener("keyup",(function(e){e.target&&t._updateFilter(e.target.value)})),this.options.preFilter&&(this.filterField.value=this.options.preFilter)),this.perPageField=this.container.querySelector("select[name=per_page]"),this.perPageField&&this.perPageField.addEventListener("change",(function(e){t.perPage=Number(e.target.value),t._updatePage(0)}));var e=this.element.querySelector("tr.paginator__sort");e&&e.addEventListener("click",(function(e){var a=e.target;if(a.dataset.sortField){if(t.sortField){var n=t.element.querySelector("th[data-sort-field=".concat(t.sortField,"]"));n.classList.remove("paginator__sort--down"),n.classList.remove("paginator__sort--up")}t._updateSort(a.dataset.sortField,!t.sortDir),a.classList.add(t.sortDir?"paginator__sort--up":"paginator__sort--down")}})),this.paginator.attach(this._updatePage.bind(this)),this._loadEntries()}},{key:"_loadEntries",value:function(){var t=this;new Promise(this.ajaxCallback).then((function(e){t.element.classList.remove("hidden"),t.unfilteredData=e.data,t._updateFilter(t.options.preFilter)}))}},{key:"_updateEntries",value:function(t){this.data=t,this.totalRecords=this.data.length;var e=this.element.querySelector("tbody");d(e);for(var a=this.perPage*this.currentPage,n=a+this.perPage>this.totalRecords?this.totalRecords:a+this.perPage,i=a;in[e]?i=1:t[e]\n ').concat(h(t.name),"\n ")})).join("")},m=function(){function t(e){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};i(this,t),this.element=e,this.tags=[],this.options=a,this.maxTags=a.maxTags||10,this.inputNode=null,this.containerNode=null}return s(t,[{key:"attach",value:function(){if(this.element.style.display="none",this.containerNode=c('
'),this.inputNode=c(''),this.containerNode.appendChild(this.inputNode),this.element.parentNode.insertBefore(this.containerNode,this.element.nextSibling),this.element.value){var t,a=e(this.element.value.split(","));try{for(a.s();!(t=a.n()).done;){var n=t.value;this.addTag(n)}}catch(t){a.e(t)}finally{a.f()}}this.containerNode.addEventListener("keydown",this._handleInputKeyUp.bind(this)),this.containerNode.addEventListener("click",this._handleContainerClick.bind(this))}},{key:"detach",value:function(){this.tags.clear(),this.containerNode.remove(),this.element.style.display="inline-block"}},{key:"updateHiddenInputValue",value:function(){this.element.value=this.tags.join(",")}},{key:"deleteTagNode",value:function(t){this.tags.splice(this.tags.indexOf(t.dataset.value.toLowerCase()),1),t.remove(),this.tags.length'+h(t)+''),this.inputNode),this.tags.length>=this.maxTags&&(this.inputNode.disabled=!0))}},{key:"_handleInputKeyUp",value:function(t){var e=this.inputNode.value;"Backspace"===t.key&&""===e?this.inputNode.previousSibling&&(this.deleteTagNode(this.inputNode.previousSibling),this.updateHiddenInputValue()):","===t.key&&(this.addTag(e),this.inputNode.value="",this.updateHiddenInputValue(),t.preventDefault())}},{key:"_handleContainerClick",value:function(t){t.target&&t.target.classList.contains("delete")&&(this.deleteTagNode(t.target.closest(".tag")),this.updateHiddenInputValue())}}]),t}(),y=function(){var t,e;Array.prototype.forEach.call((t=".js-tag-input",document.querySelectorAll(t)||[]),(function(t){new m(t).attach()})),(e=l('[data-target~="#signin"],[data-target~="#signup"]'))&&(e.href="javascript:void(0)",e.addEventListener("click",(function(){l(".modal").classList.add("is-active")})),l(".modal-button-close").addEventListener("click",(function(){l(".modal").classList.remove("is-active")})));var a=l(".panel-tools .embed-tool");a&&a.addEventListener("click",(function(t){t.target&&t.target.closest(".panel-tools")&&u(t.target.closest(".panel-tools").querySelector(".panel-embed"))}));var n=l(".expand-tool");n&&n.addEventListener("click",(function(t){if(t.target&&t.target.closest(".panel")){var e=t.target.closest(".panel");e.classList.contains("panel-fullsize")?e.classList.remove("panel-fullsize"):e.classList.add("panel-fullsize")}})),(document.querySelectorAll(".notification .delete")||[]).forEach((function(t){var e=t.parentNode;t.addEventListener("click",(function(){e.parentNode.removeChild(e)}))}));var i=Array.prototype.slice.call(document.querySelectorAll(".navbar-burger"),0);i.length>0&&i.forEach((function(t){t.addEventListener("click",(function(){var e=t.dataset.target,a=document.getElementById(e);t.classList.toggle("is-active"),a.classList.toggle("is-active")}))}));var r=l(".preloader"),s=l("main");r&&s&&(r.remove(),s.id="");var o=l(".captcha_container");if(o){var c=o.querySelector("a"),d=o.querySelector("img");c&&d&&c.addEventListener("click",(function(){d.src=d.src.split("?")[0]+"?rand="+Math.random()}))}Array.prototype.forEach.call(l(".js-hidden"),(function(t){u(t)}))},b=function(t){return t.dataset.pasteInfo?JSON.parse(t.dataset.pasteInfo):null};o=function(){y();var t=new URLSearchParams(window.location.search).get("q"),e=document.getElementById("archive");new f(e,{ajaxCallback:function(t){t({data:Array.prototype.map.call(e.querySelectorAll("tbody > tr"),b)})},rowCallback:function(t){var e,a=(e=document.getElementById("js-data-holder"))?{userId:e.dataset.userId,csrfToken:e.dataset.csrfToken}:{userId:null,csrfToken:null},n=parseInt(t.user_id)===parseInt(a.userId),i=n?'\n
\n \n \n \n
\n '):"",r=new Date(t.created_at).toLocaleString(),s=n?''.concat(t.visibility,""):"";return'\n ').concat(h(t.title),'\n ').concat(r,"\n ").concat(s,'\n ').concat(t.views||0,"\n ").concat(v(t.tags),"\n ").concat(i,"\n ")},filterCallback:g,preFilter:t}).attach();var a=document.getElementById("favs");a&&new f(a,{ajaxCallback:function(t){t({data:Array.prototype.map.call(a.querySelectorAll("tbody > tr"),b)})},rowCallback:function(t){var e=t.recently_updated?"":"",a=new Date(t.favourited_at).toLocaleString();return'\n ').concat(h(t.title),'\n ').concat(a,'\n ').concat(e,"\n ").concat(v(t.tags),"\n ")},filterCallback:g}).attach()},"loading"!==document.readyState?o():document.addEventListener("DOMContentLoaded",o); +function t(t){return function(t){if(Array.isArray(t))return n(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||a(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function e(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=a(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var i=0,r=function(){};return{s:r,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,o=!0,l=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return o=t.done,t},e:function(t){l=!0,s=t},f:function(){try{o||null==n.return||n.return()}finally{if(l)throw s}}}}function a(t,e){if(t){if("string"==typeof t)return n(t,e);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?n(t,e):void 0}}function n(t,e){(null==e||e>t.length)&&(e=t.length);for(var a=0,n=new Array(e);a/g,">").replace(/"/g,""").replace(/'/g,"'")},f=function(){function t(e){i(this,t),this.element=e}return s(t,[{key:"attach",value:function(t){this.element.addEventListener("click",(function(e){e.target&&e.target.classList.contains("paginator__button")&&t(+e.target.dataset.page)}))}},{key:"update",value:function(t,e,a){u(this.element);var n=Math.floor(t/e);if(0!==n){var i=a-2<0?0:a-2,r=a+2>n?n:a+2,s=Math.abs(0-a)>2,o=Math.abs(n-a)>2,l=0===a?"disabled":"";this.element.appendChild(d(''))),s&&(this.element.appendChild(d('"))),this.element.appendChild(d('')));for(var c=i;c<=r;c++){var h=c===a?"paginator__button--selected":"";this.element.appendChild(d('")))}o&&(this.element.appendChild(d('')),this.element.appendChild(d('"))));var p=a===n?"disabled":"";this.element.appendChild(d('')))}}}]),t}(),g=function(){function a(t,e){i(this,a),this.element=t,this.container=t.parentElement,this.options=e,this.ajaxCallback=e.ajaxCallback,this.data=[],this.unfilteredData=[],this.totalRecords=-1,this.perPage=20,this.currentPage=0,this.paginator=new f(this.container.querySelector(".paginator")),this.filterCallback=e.filterCallback,this.sortField=null,this.sortDir=!0}return s(a,[{key:"attach",value:function(){var t=this;this.filterField=this.container.querySelector("input.search"),this.filterField&&this.filterCallback&&(this.filterField.addEventListener("keyup",(function(e){e.target&&t._updateFilter(e.target.value)})),this.options.preFilter&&(this.filterField.value=this.options.preFilter)),this.perPageField=this.container.querySelector("select[name=per_page]"),this.perPageField&&this.perPageField.addEventListener("change",(function(e){t.perPage=Number(e.target.value),t._updatePage(0)}));var e=this.element.querySelector("tr.paginator__sort");e&&e.addEventListener("click",(function(e){var a=e.target;if(a.dataset.sortField){if(t.sortField){var n=t.element.querySelector("th[data-sort-field=".concat(t.sortField,"]"));n.classList.remove("paginator__sort--down"),n.classList.remove("paginator__sort--up")}t._updateSort(a.dataset.sortField,!t.sortDir),a.classList.add(t.sortDir?"paginator__sort--up":"paginator__sort--down")}})),this.paginator.attach(this._updatePage.bind(this)),this._loadEntries()}},{key:"_loadEntries",value:function(){var t=this;new Promise(this.ajaxCallback).then((function(e){t.element.classList.remove("hidden"),t.unfilteredData=e.data,t._updateFilter(t.options.preFilter)}))}},{key:"_updateEntries",value:function(t){this.data=t,this.totalRecords=this.data.length;var e=this.element.querySelector("tbody");u(e);for(var a=this.perPage*this.currentPage,n=a+this.perPage>this.totalRecords?this.totalRecords:a+this.perPage,i=a;in[e]?i=1:t[e]\n ').concat(p(t.name),"\n ")})).join("")},y=function(){function t(e){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};i(this,t),this.element=e,this.tags=[],this.options=a,this.maxTags=a.maxTags||10,this.inputNode=null,this.containerNode=null}return s(t,[{key:"attach",value:function(){if(this.element.style.display="none",this.containerNode=d('
'),this.inputNode=d(''),this.containerNode.appendChild(this.inputNode),this.element.parentNode.insertBefore(this.containerNode,this.element.nextSibling),this.element.value){var t,a=e(this.element.value.split(","));try{for(a.s();!(t=a.n()).done;){var n=t.value;this.addTag(n)}}catch(t){a.e(t)}finally{a.f()}}this.containerNode.addEventListener("keydown",this._handleInputKeyUp.bind(this)),this.containerNode.addEventListener("click",this._handleContainerClick.bind(this))}},{key:"detach",value:function(){this.tags.clear(),this.containerNode.remove(),this.element.style.display="inline-block"}},{key:"updateHiddenInputValue",value:function(){this.element.value=this.tags.join(",")}},{key:"deleteTagNode",value:function(t){this.tags.splice(this.tags.indexOf(t.dataset.value.toLowerCase()),1),t.remove(),this.tags.length'+p(t)+''),this.inputNode),this.tags.length>=this.maxTags&&(this.inputNode.disabled=!0))}},{key:"_handleInputKeyUp",value:function(t){var e=this.inputNode.value;"Backspace"===t.key&&""===e?this.inputNode.previousSibling&&(this.deleteTagNode(this.inputNode.previousSibling),this.updateHiddenInputValue()):","===t.key&&(this.addTag(e),this.inputNode.value="",this.updateHiddenInputValue(),t.preventDefault())}},{key:"_handleContainerClick",value:function(t){t.target&&t.target.classList.contains("delete")&&(this.deleteTagNode(t.target.closest(".tag")),this.updateHiddenInputValue())}}]),t}(),b=function(){var t;Array.prototype.forEach.call(c(".js-tag-input"),(function(t){new y(t).attach()})),(t=l('[data-target~="#signin"],[data-target~="#signup"]'))&&(t.href="javascript:void(0)",t.addEventListener("click",(function(){l(".modal").classList.add("is-active")})),l(".modal-button-close").addEventListener("click",(function(){l(".modal").classList.remove("is-active")})));var e=l(".panel-tools .embed-tool");e&&e.addEventListener("click",(function(t){t.target&&t.target.closest(".panel-tools")&&h(t.target.closest(".panel-tools").querySelector(".panel-embed"))}));var a=l(".expand-tool");a&&a.addEventListener("click",(function(t){if(t.target&&t.target.closest(".panel")){var e=t.target.closest(".panel");e.classList.contains("panel-fullsize")?e.classList.remove("panel-fullsize"):e.classList.add("panel-fullsize")}})),(document.querySelectorAll(".notification .delete")||[]).forEach((function(t){var e=t.parentNode;t.addEventListener("click",(function(){e.parentNode.removeChild(e)}))}));var n=Array.prototype.slice.call(document.querySelectorAll(".navbar-burger"),0);n.length>0&&n.forEach((function(t){t.addEventListener("click",(function(){var e=t.dataset.target,a=document.getElementById(e);t.classList.toggle("is-active"),a.classList.toggle("is-active")}))}));var i=l(".preloader"),r=l("main");i&&r&&(i.remove(),r.id="");var s=l(".captcha_container");if(s){var o=s.querySelector("a"),d=s.querySelector("img");o&&d&&o.addEventListener("click",(function(){var t=d.src;-1!==t.indexOf("&refresh")?t=t.split("&rand=")[0]:t+="&refresh",d.src=t+"&rand="+Math.random()}))}var u=c(".js-hidden");u&&Array.prototype.forEach.call(u,(function(t){h(t)}))},k=function(t){return t.dataset.pasteInfo?JSON.parse(t.dataset.pasteInfo):null};o=function(){b();var t=new URLSearchParams(window.location.search).get("q"),e=document.getElementById("archive");new g(e,{ajaxCallback:function(t){t({data:Array.prototype.map.call(e.querySelectorAll("tbody > tr"),k)})},rowCallback:function(t){var e,a=(e=document.getElementById("js-data-holder"))?{userId:e.dataset.userId,csrfToken:e.dataset.csrfToken}:{userId:null,csrfToken:null},n=parseInt(t.user_id)===parseInt(a.userId),i=n?'\n
\n \n \n \n
\n '):"",r=new Date(t.created_at).toLocaleString(),s=n?''.concat(t.visibility,""):"";return'\n ').concat(p(t.title),'\n ').concat(r,"\n ").concat(s,'\n ').concat(t.views||0,"\n ").concat(m(t.tags),"\n ").concat(i,"\n ")},filterCallback:v,preFilter:t}).attach();var a=document.getElementById("favs");a&&new g(a,{ajaxCallback:function(t){t({data:Array.prototype.map.call(a.querySelectorAll("tbody > tr"),k)})},rowCallback:function(t){var e=t.recently_updated?"":"",a=new Date(t.favourited_at).toLocaleString();return'\n ').concat(p(t.title),'\n ').concat(a,'\n ').concat(e,"\n ").concat(m(t.tags),"\n ")},filterCallback:v}).attach()},"loading"!==document.readyState?o():document.addEventListener("DOMContentLoaded",o); //# sourceMappingURL=user_profile.min.js.map diff --git a/public/assets/bundle/user_profile.min.js.map b/public/assets/bundle/user_profile.min.js.map index 207ceb9..e01978b 100644 --- a/public/assets/bundle/user_profile.min.js.map +++ b/public/assets/bundle/user_profile.min.js.map @@ -1 +1 @@ -{"version":3,"file":"user_profile.min.js","sources":["../../../js/dom.js","../../../js/data_tables.js","../../../js/utils.js","../../../js/tag_input.js","../../../js/main.js","../../../js/user_profile.js"],"sourcesContent":["const $ = function(selector) {\n return document.querySelector(selector);\n};\n\nconst $$ = function(selector) {\n return document.querySelectorAll(selector) || [];\n};\n\nconst makeEl = function(html) {\n const template = document.createElement('template');\n\n template.innerHTML = html.trim();\n\n return template.content.firstChild;\n};\n\nconst clearEl = function(el) {\n while (el.firstChild) {\n el.removeChild(el.firstChild);\n }\n};\n\nconst toggleEl = function(el) {\n if (el.classList.contains('is-hidden')) {\n el.classList.remove('is-hidden');\n } else {\n el.classList.add('is-hidden');\n }\n};\n\nconst escape = function(unsafe) {\n return unsafe\n .replace(/&/g, \"&\")\n .replace(//g, \">\")\n .replace(/\"/g, \""\")\n .replace(/'/g, \"'\");\n}\n\nconst whenReady = function(funcp) {\n if (document.readyState !== 'loading') {\n funcp();\n } else {\n document.addEventListener('DOMContentLoaded', funcp);\n }\n}\n\nexport { whenReady, $, $$, makeEl, clearEl, toggleEl, escape };","import { makeEl, clearEl } from \"./dom\";\n\nclass SimplePaginator {\n constructor(element) {\n this.element = element;\n }\n\n attach(pageCallback) {\n this.element.addEventListener('click', evt => {\n if (evt.target && evt.target.classList.contains('paginator__button')) {\n pageCallback(+evt.target.dataset.page);\n }\n });\n }\n\n update(totalRecords, perPage, currentPage) {\n clearEl(this.element);\n\n /* First and last page in existence */\n const firstPage = 0;\n const lastPage = Math.floor(totalRecords / perPage); // ish?\n const numPagesToShow = 2;\n\n if (lastPage === firstPage) {\n return;\n }\n\n /* First and last page the main paginator will show */\n const firstPageShow = (currentPage - numPagesToShow) < firstPage ? firstPage : (currentPage - numPagesToShow);\n const lastPageShow = (currentPage + numPagesToShow) > lastPage ? lastPage : (currentPage + numPagesToShow);\n\n /* Whether to show the first and last pages in existence at the ends of the paginator */\n const showFirstPage = (Math.abs(firstPage - currentPage)) > (numPagesToShow);\n const showLastPage = (Math.abs(lastPage - currentPage)) > (numPagesToShow);\n\n\n const prevButtonDisabled = currentPage === firstPage ? 'disabled' : ''\n\n /* Previous button */\n this.element.appendChild(makeEl(\n ``\n ));\n\n /* First page button */\n if (showFirstPage) {\n this.element.appendChild(makeEl(\n ``\n ));\n this.element.appendChild(makeEl(``));\n }\n\n /* \"window\" buttons */\n for (let i = firstPageShow; i <= lastPageShow; i++) {\n const selected = (i === currentPage ? 'paginator__button--selected' : '');\n this.element.appendChild(makeEl(\n ``\n ));\n }\n\n /* Last page button */\n if (showLastPage) {\n this.element.appendChild(makeEl(``));\n this.element.appendChild(makeEl(\n ``\n ));\n }\n\n const nextButtonDisabled = currentPage === lastPage ? 'disabled' : ''\n /* Next button */\n this.element.appendChild(makeEl(\n ``\n ));\n }\n}\n\nclass DataTable {\n constructor(element, options) {\n this.element = element;\n this.container = element.parentElement;\n this.options = options;\n\n this.ajaxCallback = options.ajaxCallback;\n this.data = [];\n this.unfilteredData = [];\n\n this.totalRecords = -1;\n this.perPage = 20;\n this.currentPage = 0;\n\n this.paginator = new SimplePaginator(this.container.querySelector('.paginator'));\n\n this.filterCallback = options.filterCallback;\n this.sortField = null;\n this.sortDir = true;\n }\n\n attach() {\n this.filterField = this.container.querySelector('input.search');\n if (this.filterField && this.filterCallback) {\n this.filterField.addEventListener('keyup', evt => {\n if (evt.target) {\n this._updateFilter(evt.target.value);\n }\n });\n\n if (this.options.preFilter) {\n this.filterField.value = this.options.preFilter;\n }\n }\n\n this.perPageField = this.container.querySelector('select[name=per_page]');\n\n if (this.perPageField) {\n this.perPageField.addEventListener('change', evt => {\n this.perPage = Number(evt.target.value);\n this._updatePage(0);\n });\n }\n\n const header = this.element.querySelector('tr.paginator__sort');\n\n if (header) {\n header.addEventListener('click', evt => {\n const target = evt.target;\n\n if (!target.dataset.sortField) {\n return;\n }\n\n if (this.sortField) {\n const elem = this.element.querySelector(`th[data-sort-field=${this.sortField}]`)\n elem.classList.remove('paginator__sort--down');\n elem.classList.remove('paginator__sort--up');\n }\n\n this._updateSort(target.dataset.sortField, !this.sortDir);\n\n target.classList.add(this.sortDir ? 'paginator__sort--up' : 'paginator__sort--down');\n });\n }\n\n this.paginator.attach(this._updatePage.bind(this));\n this._loadEntries();\n }\n\n /* Load the requested data from the server, and when done, update the DOM. */\n _loadEntries() {\n new Promise(this.ajaxCallback)\n .then(data => {\n this.element.classList.remove('hidden');\n this.unfilteredData = data.data;\n this._updateFilter(this.options.preFilter);\n });\n }\n\n /* Update the DOM to reflect the current state of the data we have loaded */\n _updateEntries(data) {\n this.data = data;\n this.totalRecords = this.data.length;\n\n const bodyElement = this.element.querySelector('tbody');\n clearEl(bodyElement);\n\n const firstIndex = (this.perPage * this.currentPage);\n const lastIndex = (firstIndex + this.perPage) > this.totalRecords ? this.totalRecords : (firstIndex + this.perPage);\n\n\n for (let i = firstIndex; i < lastIndex; i++) {\n const rowElem = makeEl(this.options.rowCallback(this.data[i]));\n rowElem.classList.add(i % 2 === 0 ? 'odd' : 'even');\n\n bodyElement.appendChild(rowElem);\n }\n\n this.paginator.update(this.totalRecords, this.perPage, this.currentPage);\n }\n\n _updatePage(n) {\n this.currentPage = n;\n this.paginator.update(this.totalRecords, this.perPage, this.currentPage);\n this._updateEntries(this.data);\n }\n\n _updateFilter(query) {\n /* clearing the query */\n if (query === null || query === '') {\n this._updateEntries(this.unfilteredData);\n return;\n }\n\n let data = [];\n for (const datum of this.unfilteredData) {\n if (this.filterCallback(datum, query)) {\n data.push(datum);\n }\n }\n\n this._updatePage(0)\n this._updateEntries(data);\n }\n\n _updateSort(field, direction) {\n this.sortField = field;\n this.sortDir = direction;\n\n let newEntries = [...this.data].sort((a, b) => {\n let sorter = 0;\n\n if (a[field] > b[field]) {\n sorter = 1;\n } else if (a[field] < b[field]) {\n sorter = -1;\n }\n\n if (!direction) {\n sorter = -sorter;\n }\n\n return sorter;\n });\n\n this._updatePage(0);\n this._updateEntries(newEntries);\n }\n}\n\nconst dumbFilterCallback = (datum, query) => {\n if (!query) {\n return true;\n }\n\n if (datum.title.indexOf(query) !== -1) {\n return true;\n }\n\n /* this is inefficient */\n for (const tag of datum.tags) {\n if (tag.name.toLowerCase() === query.toLowerCase()) {\n return true;\n }\n }\n\n return false;\n};\n\nexport { DataTable, dumbFilterCallback };\n","import { escape } from \"./dom\";\n\nconst tagsToHtml = (tags) => {\n\n return tags.map(tagData => {\n let tagColorClass;\n if (tagData.name.indexOf('nsfw') !== -1) {\n tagColorClass = 'is-danger';\n } else if (tagData.name.indexOf('safe') !== -1) {\n tagColorClass = 'is-success';\n } else if (tagData.name.indexOf('/') !== -1) {\n tagColorClass = 'is-primary';\n } else {\n tagColorClass = 'is-info';\n }\n\n return `\n ${escape(tagData.name)}\n `;\n }).join('');\n};\n\nexport { tagsToHtml };\n","import { makeEl, escape } from \"./dom\";\n\nclass TagsInput {\n constructor(element, options = {}) {\n this.element = element;\n this.tags = [];\n this.options = options\n\n this.maxTags = options.maxTags || 10;\n this.inputNode = null;\n this.containerNode = null;\n }\n\n attach() {\n this.element.style.display = 'none';\n\n this.containerNode = makeEl('
');\n this.inputNode = makeEl('');\n this.containerNode.appendChild(this.inputNode);\n\n this.element.parentNode.insertBefore(this.containerNode, this.element.nextSibling);\n\n /* Load existing tags from input */\n if (this.element.value) {\n for (const tag of this.element.value.split(',')) {\n this.addTag(tag);\n }\n }\n\n /* Handle addition and removal of tags via key-presses */\n this.containerNode.addEventListener('keydown', this._handleInputKeyUp.bind(this));\n\n /* Handle deletions by clicking the delete button */\n this.containerNode.addEventListener('click', this._handleContainerClick.bind(this));\n }\n\n detach() {\n this.tags.clear();\n this.containerNode.remove();\n this.element.style.display = 'inline-block';\n }\n\n updateHiddenInputValue() {\n this.element.value = this.tags.join(',');\n }\n\n deleteTagNode(node) {\n this.tags.splice(this.tags.indexOf(node.dataset.value.toLowerCase()), 1);\n node.remove();\n\n /* Below the limit? Make sure the input is enabled. */\n if (this.tags.length < this.maxTags) {\n this.inputNode.disabled = false;\n }\n }\n\n addTag(tagValue) {\n tagValue = tagValue.trim();\n\n /* Tag value is probably not empty and we don't already have the same tag. */\n if (tagValue !== '' && this.tags.indexOf(tagValue.toLowerCase()) === -1) {\n this.tags.push(tagValue.toLowerCase());\n\n this.inputNode.parentNode.insertBefore(\n makeEl('' + escape(tagValue) + ''),\n this.inputNode\n );\n\n /* Too many tags, disable the input for now. */\n if (this.tags.length >= this.maxTags) {\n this.inputNode.disabled = true;\n }\n }\n }\n\n _handleInputKeyUp(evt) {\n let tagValue = this.inputNode.value;\n\n if (evt.key === 'Backspace' && tagValue === '') {\n // Remove the child\n if (this.inputNode.previousSibling) {\n this.deleteTagNode(this.inputNode.previousSibling);\n\n this.updateHiddenInputValue();\n }\n } else if (evt.key === ',') {\n this.addTag(tagValue);\n\n this.inputNode.value = ''\n this.updateHiddenInputValue();\n\n evt.preventDefault();\n }\n }\n\n _handleContainerClick(evt) {\n if (evt.target && evt.target.classList.contains('delete')) {\n this.deleteTagNode(evt.target.closest('.tag'));\n this.updateHiddenInputValue();\n }\n }\n}\n\nexport { TagsInput };\n","import { $, $$, toggleEl } from './dom';\nimport { TagsInput } from \"./tag_input\";\n\nconst setupSignupModal = () => {\n const signupButton = $('[data-target~=\"#signin\"],[data-target~=\"#signup\"]');\n\n if (signupButton) {\n signupButton.href = 'javascript:void(0)';\n\n signupButton.addEventListener('click', () => {\n $('.modal').classList.add('is-active');\n });\n\n $('.modal-button-close').addEventListener('click', () => {\n $('.modal').classList.remove('is-active');\n });\n }\n}\n\nconst globalSetup = () => {\n Array.prototype.forEach.call($$('.js-tag-input'), (el) => {\n new TagsInput(el).attach();\n });\n\n setupSignupModal();\n\n const embedButton = $('.panel-tools .embed-tool');\n\n if (embedButton){\n embedButton.addEventListener('click', (evt) => {\n if (evt.target && evt.target.closest('.panel-tools')) {\n toggleEl(evt.target.closest('.panel-tools').querySelector('.panel-embed'));\n }\n });\n }\n\n const expandButton = $('.expand-tool');\n\n if (expandButton) {\n expandButton.addEventListener('click', (evt) => {\n if (evt.target && evt.target.closest('.panel')) {\n const panel = evt.target.closest('.panel');\n\n if (panel.classList.contains('panel-fullsize')) {\n panel.classList.remove('panel-fullsize');\n } else {\n panel.classList.add('panel-fullsize');\n }\n }\n });\n }\n\n // Notifications\n (document.querySelectorAll('.notification .delete') || []).forEach(($delete) => {\n const $notification = $delete.parentNode;\n\n $delete.addEventListener('click', () => {\n $notification.parentNode.removeChild($notification);\n });\n });\n\n // Hamburger menu\n const $navbarBurgers = Array.prototype.slice.call(document.querySelectorAll('.navbar-burger'), 0);\n if ($navbarBurgers.length > 0) {\n $navbarBurgers.forEach(el => {\n el.addEventListener('click', () => {\n const target = el.dataset.target;\n const $target = document.getElementById(target);\n el.classList.toggle('is-active');\n $target.classList.toggle('is-active');\n });\n });\n }\n\n const preloader = $('.preloader');\n const main = $('main');\n\n if (preloader && main) {\n preloader.remove();\n main.id = '';\n }\n\n const captchaContainer = $('.captcha_container');\n\n if (captchaContainer) {\n const refreshElement = captchaContainer.querySelector('a');\n const imageElement = captchaContainer.querySelector('img');\n\n if (refreshElement && imageElement) {\n refreshElement.addEventListener('click', () => {\n imageElement.src = imageElement.src.split('?')[0] + '?rand=' + Math.random();\n });\n }\n }\n\n Array.prototype.forEach.call($('.js-hidden'), (elem) => {\n toggleEl(elem);\n });\n}\n\nexport { globalSetup };","import { escape, whenReady } from './dom';\nimport { DataTable, dumbFilterCallback } from './data_tables';\nimport { tagsToHtml } from \"./utils\";\nimport { globalSetup } from './main';\n\nconst getUserInfo = () => {\n const elem = document.getElementById('js-data-holder');\n\n if (!elem) {\n return { userId: null, csrfToken: null };\n }\n\n return { userId: elem.dataset.userId, csrfToken: elem.dataset.csrfToken };\n};\n\nconst parsePasteInfo = (elem) => {\n if (!elem.dataset.pasteInfo) {\n return null;\n }\n\n return JSON.parse(elem.dataset.pasteInfo);\n};\n\nwhenReady(() => {\n globalSetup();\n\n const urlParams = new URLSearchParams(window.location.search);\n const myParam = urlParams.get('q');\n const myPastesElem = document.getElementById('archive');\n const table = new DataTable(myPastesElem, {\n ajaxCallback: (resolve) => {\n resolve({\n data: Array.prototype.map.call(myPastesElem.querySelectorAll('tbody > tr'), parsePasteInfo)\n });\n },\n rowCallback: (rowData) => {\n const userData = getUserInfo();\n const ownedByUser = (parseInt(rowData.user_id) === parseInt(userData.userId));\n\n const deleteElem = ownedByUser ? `\n
\n \n \n \n
\n ` : '';\n const pasteCreatedAt = new Date(rowData.created_at).toLocaleString();\n const pasteVisibility = ownedByUser ? `${rowData.visibility}` : '';\n\n return `\n ${escape(rowData.title)}\n ${pasteCreatedAt}\n ${pasteVisibility}\n ${rowData.views || 0}\n ${tagsToHtml(rowData.tags)}\n ${deleteElem}\n `;\n },\n filterCallback: dumbFilterCallback,\n preFilter: myParam\n });\n table.attach();\n\n const myFavesElem = document.getElementById('favs');\n\n if (!myFavesElem) {\n return;\n }\n\n const faveTable = new DataTable(myFavesElem, {\n ajaxCallback: (resolve) => {\n resolve({\n data: Array.prototype.map.call(myFavesElem.querySelectorAll('tbody > tr'), parsePasteInfo)\n });\n },\n rowCallback: (rowData) => {\n const recentUpdate = rowData.recently_updated ?\n `` :\n ``;\n const pasteFavedAt = new Date(rowData.favourited_at).toLocaleString();\n\n // ${escape(rowData.author)}\n return `\n ${escape(rowData.title)}\n ${pasteFavedAt}\n ${recentUpdate}\n ${tagsToHtml(rowData.tags)}\n `;\n },\n filterCallback: dumbFilterCallback\n });\n faveTable.attach();\n});"],"names":["funcp","$","selector","document","querySelector","makeEl","html","template","createElement","innerHTML","trim","content","firstChild","clearEl","el","removeChild","toggleEl","classList","contains","remove","add","escape","unsafe","replace","SimplePaginator","element","pageCallback","addEventListener","evt","target","dataset","page","totalRecords","perPage","currentPage","this","lastPage","Math","floor","firstPageShow","lastPageShow","showFirstPage","abs","showLastPage","prevButtonDisabled","appendChild","i","selected","nextButtonDisabled","DataTable","options","container","parentElement","ajaxCallback","data","unfilteredData","paginator","filterCallback","sortField","sortDir","filterField","_this","_updateFilter","value","preFilter","perPageField","Number","_updatePage","header","elem","_updateSort","attach","bind","_loadEntries","Promise","then","_this2","length","bodyElement","firstIndex","lastIndex","rowElem","rowCallback","update","n","_updateEntries","query","datum","push","field","direction","newEntries","_toConsumableArray","sort","a","b","sorter","dumbFilterCallback","title","indexOf","tags","name","toLowerCase","tagsToHtml","map","tagData","tagColorClass","slug","join","TagsInput","maxTags","inputNode","containerNode","style","display","parentNode","insertBefore","nextSibling","split","tag","addTag","_handleInputKeyUp","_handleContainerClick","clear","node","splice","disabled","tagValue","key","previousSibling","deleteTagNode","updateHiddenInputValue","preventDefault","closest","globalSetup","signupButton","Array","prototype","forEach","call","querySelectorAll","href","embedButton","expandButton","panel","$delete","$notification","$navbarBurgers","slice","$target","getElementById","toggle","preloader","main","id","captchaContainer","refreshElement","imageElement","src","random","parsePasteInfo","pasteInfo","JSON","parse","myParam","URLSearchParams","window","location","search","get","myPastesElem","resolve","rowData","userData","userId","csrfToken","ownedByUser","parseInt","user_id","deleteElem","pasteCreatedAt","Date","created_at","toLocaleString","pasteVisibility","visibility","views","myFavesElem","recentUpdate","recently_updated","pasteFavedAt","favourited_at","readyState"],"mappings":"krDAAA,IAuC2BA,EAvCrBC,EAAI,SAASC,UACRC,SAASC,cAAcF,IAO5BG,EAAS,SAASC,OACdC,EAAWJ,SAASK,cAAc,mBAExCD,EAASE,UAAYH,EAAKI,OAEnBH,EAASI,QAAQC,YAGtBC,EAAU,SAASC,QACdA,EAAGF,YACNE,EAAGC,YAAYD,EAAGF,aAIpBI,EAAW,SAASF,GAClBA,EAAGG,UAAUC,SAAS,aACtBJ,EAAGG,UAAUE,OAAO,aAEpBL,EAAGG,UAAUG,IAAI,cAInBC,EAAS,SAASC,UACbA,EACFC,QAAQ,KAAM,SACdA,QAAQ,KAAM,QACdA,QAAQ,KAAM,QACdA,QAAQ,KAAM,UACdA,QAAQ,KAAM,WClCjBC,wBACUC,kBACHA,QAAUA,kCAGnB,SAAOC,QACED,QAAQE,iBAAiB,SAAS,SAAAC,GAC/BA,EAAIC,QAAUD,EAAIC,OAAOZ,UAAUC,SAAS,sBAC5CQ,GAAcE,EAAIC,OAAOC,QAAQC,+BAK7C,SAAOC,EAAcC,EAASC,GAC1BrB,EAAQsB,KAAKV,aAIPW,EAAWC,KAAKC,MAAMN,EAAeC,MADzB,IAIdG,OAKEG,EAAiBL,EAPA,EAFL,EAAA,EAS8DA,EAPzD,EAQjBM,EAAgBN,EARC,EAQ+BE,EAAWA,EAAYF,EARtD,EAWjBO,EAAiBJ,KAAKK,IAbV,EAa0BR,GAXrB,EAYjBS,EAAgBN,KAAKK,IAAIN,EAAWF,GAZnB,EAejBU,EAjBY,IAiBSV,EAA4B,WAAa,QAG/DT,QAAQoB,YAAYxC,uDACyBuC,yBAAiCV,EAAc,2BAI7FO,SACKhB,QAAQoB,YAAYxC,yDA1BX,eAAA,sBA6BToB,QAAQoB,YAAYxC,2CAIxB,IAAIyC,EAAIP,EAAeO,GAAKN,EAAcM,IAAK,KAC1CC,EAAYD,IAAMZ,EAAc,8BAAgC,QACjET,QAAQoB,YAAYxC,6CACe0C,0BAAwBD,eAAMA,iBAKtEH,SACKlB,QAAQoB,YAAYxC,2CACpBoB,QAAQoB,YAAYxC,yDAC2B+B,eAAaA,sBAI/DY,EAAqBd,IAAgBE,EAAW,WAAa,QAE9DX,QAAQoB,YAAYxC,mDACqB2C,yBAAiCd,EAAc,iCAK/Fe,wBACUxB,EAASyB,kBACZzB,QAAUA,OACV0B,UAAY1B,EAAQ2B,mBACpBF,QAAUA,OAEVG,aAAeH,EAAQG,kBACvBC,KAAO,QACPC,eAAiB,QAEjBvB,cAAgB,OAChBC,QAAU,QACVC,YAAc,OAEdsB,UAAY,IAAIhC,EAAgBW,KAAKgB,UAAU/C,cAAc,oBAE7DqD,eAAiBP,EAAQO,oBACzBC,UAAY,UACZC,SAAU,kCAGnB,2BACSC,YAAczB,KAAKgB,UAAU/C,cAAc,gBAC5C+B,KAAKyB,aAAezB,KAAKsB,sBACpBG,YAAYjC,iBAAiB,SAAS,SAAAC,GACpCA,EAAIC,QACJgC,EAAKC,cAAclC,EAAIC,OAAOkC,UAIjC5B,KAAKe,QAAQc,iBACRJ,YAAYG,MAAQ5B,KAAKe,QAAQc,iBAIzCC,aAAe9B,KAAKgB,UAAU/C,cAAc,yBAE7C+B,KAAK8B,mBACAA,aAAatC,iBAAiB,UAAU,SAAAC,GAC1CiC,EAAK5B,QAAUiC,OAAOtC,EAAIC,OAAOkC,OACjCF,EAAKM,YAAY,UAIlBC,EAASjC,KAAKV,QAAQrB,cAAc,sBAEtCgE,GACAA,EAAOzC,iBAAiB,SAAS,SAAAC,OACvBC,EAASD,EAAIC,UAEdA,EAAOC,QAAQ4B,cAIhBG,EAAKH,UAAW,KACVW,EAAOR,EAAKpC,QAAQrB,2CAAoCyD,EAAKH,gBACnEW,EAAKpD,UAAUE,OAAO,yBACtBkD,EAAKpD,UAAUE,OAAO,uBAG1B0C,EAAKS,YAAYzC,EAAOC,QAAQ4B,WAAYG,EAAKF,SAEjD9B,EAAOZ,UAAUG,IAAIyC,EAAKF,QAAU,sBAAwB,kCAI/DH,UAAUe,OAAOpC,KAAKgC,YAAYK,KAAKrC,YACvCsC,2CAIT,0BACQC,QAAQvC,KAAKkB,cACZsB,MAAK,SAAArB,GACFsB,EAAKnD,QAAQR,UAAUE,OAAO,UAC9ByD,EAAKrB,eAAiBD,EAAKA,KAC3BsB,EAAKd,cAAcc,EAAK1B,QAAQc,4CAK5C,SAAeV,QACNA,KAAOA,OACPtB,aAAeG,KAAKmB,KAAKuB,WAExBC,EAAc3C,KAAKV,QAAQrB,cAAc,SAC/CS,EAAQiE,WAEFC,EAAc5C,KAAKF,QAAUE,KAAKD,YAClC8C,EAAaD,EAAa5C,KAAKF,QAAWE,KAAKH,aAAeG,KAAKH,aAAgB+C,EAAa5C,KAAKF,QAGlGa,EAAIiC,EAAYjC,EAAIkC,EAAWlC,IAAK,KACnCmC,EAAU5E,EAAO8B,KAAKe,QAAQgC,YAAY/C,KAAKmB,KAAKR,KAC1DmC,EAAQhE,UAAUG,IAAI0B,EAAI,GAAM,EAAI,MAAQ,QAE5CgC,EAAYjC,YAAYoC,QAGvBzB,UAAU2B,OAAOhD,KAAKH,aAAcG,KAAKF,QAASE,KAAKD,wCAGhE,SAAYkD,QACHlD,YAAckD,OACd5B,UAAU2B,OAAOhD,KAAKH,aAAcG,KAAKF,QAASE,KAAKD,kBACvDmD,eAAelD,KAAKmB,mCAG7B,SAAcgC,MAEI,OAAVA,GAA4B,KAAVA,SAKlBhC,EAAO,OACSnB,KAAKoB,+CAAgB,KAA9BgC,UACHpD,KAAKsB,eAAe8B,EAAOD,IAC3BhC,EAAKkC,KAAKD,uCAIbpB,YAAY,QACZkB,eAAe/B,aAZX+B,eAAelD,KAAKoB,2CAejC,SAAYkC,EAAOC,QACVhC,UAAY+B,OACZ9B,QAAU+B,MAEXC,EAAaC,EAAIzD,KAAKmB,MAAMuC,MAAK,SAACC,EAAGC,OACjCC,EAAS,SAETF,EAAEL,GAASM,EAAEN,GACbO,EAAS,EACFF,EAAEL,GAASM,EAAEN,KACpBO,GAAU,GAGTN,IACDM,GAAUA,GAGPA,UAGN7B,YAAY,QACZkB,eAAeM,YAItBM,EAAqB,SAACV,EAAOD,OAC1BA,SACM,MAGyB,IAAhCC,EAAMW,MAAMC,QAAQb,UACb,YAIOC,EAAMa,qCAAM,YAClBC,KAAKC,gBAAkBhB,EAAMgB,qBAC1B,wCAIR,GChPLC,EAAa,SAACH,UAETA,EAAKI,KAAI,SAAAC,OACRC,SAEAA,GADkC,IAAlCD,EAAQJ,KAAKF,QAAQ,QACL,aACyB,IAAlCM,EAAQJ,KAAKF,QAAQ,QACZ,cACsB,IAA/BM,EAAQJ,KAAKF,QAAQ,KACZ,aAEA,wCAGUM,EAAQE,iEACCD,eAAkBrF,EAAOoF,EAAQJ,kDAEzEO,KAAK,KCjBNC,wBACUpF,OAASyB,yDAAU,kBACtBzB,QAAUA,OACV2E,KAAO,QACPlD,QAAUA,OAEV4D,QAAU5D,EAAQ4D,SAAW,QAC7BC,UAAY,UACZC,cAAgB,qCAGzB,mBACSvF,QAAQwF,MAAMC,QAAU,YAExBF,cAAgB3G,EAAO,uCACvB0G,UAAY1G,EAAO,mFACnB2G,cAAcnE,YAAYV,KAAK4E,gBAE/BtF,QAAQ0F,WAAWC,aAAajF,KAAK6E,cAAe7E,KAAKV,QAAQ4F,aAGlElF,KAAKV,QAAQsC,MAAO,WACF5B,KAAKV,QAAQsC,MAAMuD,MAAM,qCAAM,KAAtCC,eACFC,OAAOD,wCAKfP,cAAcrF,iBAAiB,UAAWQ,KAAKsF,kBAAkBjD,KAAKrC,YAGtE6E,cAAcrF,iBAAiB,QAASQ,KAAKuF,sBAAsBlD,KAAKrC,6BAGjF,gBACSiE,KAAKuB,aACLX,cAAc7F,cACdM,QAAQwF,MAAMC,QAAU,qDAGjC,gBACSzF,QAAQsC,MAAQ5B,KAAKiE,KAAKQ,KAAK,kCAGxC,SAAcgB,QACLxB,KAAKyB,OAAO1F,KAAKiE,KAAKD,QAAQyB,EAAK9F,QAAQiC,MAAMuC,eAAgB,GACtEsB,EAAKzG,SAGDgB,KAAKiE,KAAKvB,OAAS1C,KAAK2E,eACnBC,UAAUe,UAAW,yBAIlC,SAAOC,GAIc,MAHjBA,EAAWA,EAASrH,UAGkD,IAA/CyB,KAAKiE,KAAKD,QAAQ4B,EAASzB,sBACzCF,KAAKZ,KAAKuC,EAASzB,oBAEnBS,UAAUI,WAAWC,aACtB/G,EAAO,yCAA2CgB,EAAO0G,GAAY,KAAO1G,EAAO0G,GAAY,2CAC/F5F,KAAK4E,WAIL5E,KAAKiE,KAAKvB,QAAU1C,KAAK2E,eACpBC,UAAUe,UAAW,qCAKtC,SAAkBlG,OACVmG,EAAW5F,KAAK4E,UAAUhD,MAEd,cAAZnC,EAAIoG,KAAoC,KAAbD,EAEvB5F,KAAK4E,UAAUkB,uBACVC,cAAc/F,KAAK4E,UAAUkB,sBAE7BE,0BAEU,MAAZvG,EAAIoG,WACNR,OAAOO,QAEPhB,UAAUhD,MAAQ,QAClBoE,yBAELvG,EAAIwG,uDAIZ,SAAsBxG,GACdA,EAAIC,QAAUD,EAAIC,OAAOZ,UAAUC,SAAS,iBACvCgH,cAActG,EAAIC,OAAOwG,QAAQ,cACjCF,mCC/EXG,EAAc,WJfT,IAASpI,EIAVqI,EAgBNC,MAAMC,UAAUC,QAAQC,MJhBRzI,EIgBgB,gBJfzBC,SAASyI,iBAAiB1I,IAAa,KIeI,SAACY,OAC3C+F,EAAU/F,GAAIyD,aAjBhBgE,EAAetI,EAAE,wDAGnBsI,EAAaM,KAAO,qBAEpBN,EAAa5G,iBAAiB,SAAS,WACnC1B,EAAE,UAAUgB,UAAUG,IAAI,gBAG9BnB,EAAE,uBAAuB0B,iBAAiB,SAAS,WAC/C1B,EAAE,UAAUgB,UAAUE,OAAO,qBAY/B2H,EAAc7I,EAAE,4BAElB6I,GACAA,EAAYnH,iBAAiB,SAAS,SAACC,GAC/BA,EAAIC,QAAUD,EAAIC,OAAOwG,QAAQ,iBACjCrH,EAASY,EAAIC,OAAOwG,QAAQ,gBAAgBjI,cAAc,wBAKhE2I,EAAe9I,EAAE,gBAEnB8I,GACAA,EAAapH,iBAAiB,SAAS,SAACC,MAChCA,EAAIC,QAAUD,EAAIC,OAAOwG,QAAQ,UAAW,KACtCW,EAAQpH,EAAIC,OAAOwG,QAAQ,UAE7BW,EAAM/H,UAAUC,SAAS,kBACzB8H,EAAM/H,UAAUE,OAAO,kBAEvB6H,EAAM/H,UAAUG,IAAI,uBAOnCjB,SAASyI,iBAAiB,0BAA4B,IAAIF,SAAQ,SAACO,OAC1DC,EAAgBD,EAAQ9B,WAE9B8B,EAAQtH,iBAAiB,SAAS,WAC9BuH,EAAc/B,WAAWpG,YAAYmI,aAKvCC,EAAiBX,MAAMC,UAAUW,MAAMT,KAAKxI,SAASyI,iBAAiB,kBAAmB,GAC3FO,EAAetE,OAAS,GACxBsE,EAAeT,SAAQ,SAAA5H,GACnBA,EAAGa,iBAAiB,SAAS,eACnBE,EAASf,EAAGgB,QAAQD,OACpBwH,EAAUlJ,SAASmJ,eAAezH,GACxCf,EAAGG,UAAUsI,OAAO,aACpBF,EAAQpI,UAAUsI,OAAO,uBAK/BC,EAAYvJ,EAAE,cACdwJ,EAAOxJ,EAAE,QAEXuJ,GAAaC,IACbD,EAAUrI,SACVsI,EAAKC,GAAK,QAGRC,EAAmB1J,EAAE,yBAEvB0J,EAAkB,KACZC,EAAiBD,EAAiBvJ,cAAc,KAChDyJ,EAAeF,EAAiBvJ,cAAc,OAEhDwJ,GAAkBC,GAClBD,EAAejI,iBAAiB,SAAS,WACrCkI,EAAaC,IAAMD,EAAaC,IAAIxC,MAAM,KAAK,GAAK,SAAWjF,KAAK0H,YAKhFvB,MAAMC,UAAUC,QAAQC,KAAK1I,EAAE,eAAe,SAACoE,GAC3CrD,EAASqD,OCjFX2F,EAAiB,SAAC3F,UACfA,EAAKvC,QAAQmI,UAIXC,KAAKC,MAAM9F,EAAKvC,QAAQmI,WAHpB,MLsBYjK,EKhBjB,WACNsI,QAGM8B,EADY,IAAIC,gBAAgBC,OAAOC,SAASC,QAC5BC,IAAI,KACxBC,EAAevK,SAASmJ,eAAe,WAC/B,IAAIrG,EAAUyH,EAAc,CACtCrH,aAAc,SAACsH,GACXA,EAAQ,CACJrH,KAAMkF,MAAMC,UAAUjC,IAAImC,KAAK+B,EAAa9B,iBAAiB,cAAeoB,MAGpF9E,YAAa,SAAC0F,OA7BZvG,EA8BQwG,GA9BRxG,EAAOlE,SAASmJ,eAAe,mBAM9B,CAAEwB,OAAQzG,EAAKvC,QAAQgJ,OAAQC,UAAW1G,EAAKvC,QAAQiJ,WAHnD,CAAED,OAAQ,KAAMC,UAAW,MA4BxBC,EAAeC,SAASL,EAAQM,WAAaD,SAASJ,EAASC,QAE/DK,EAAaH,4FAC2BJ,EAAQlB,4NAE0BmB,EAASE,sMAGrD,GAC9BK,EAAiB,IAAIC,KAAKT,EAAQU,YAAYC,iBAC9CC,EAAkBR,kCAAuCJ,EAAQa,oBAAoB,+DAG/Db,EAAQlB,gBAAOrI,EAAOuJ,EAAQ1E,2EACtBkF,4CACtBI,6DACsBZ,EAAQc,OAAS,gDACnCnF,EAAWqE,EAAQxE,gDACvB+E,kCAGlB1H,eAAgBwC,EAChBjC,UAAWoG,IAET7F,aAEAoH,EAAcxL,SAASmJ,eAAe,QAEvCqC,GAIa,IAAI1I,EAAU0I,EAAa,CACzCtI,aAAc,SAACsH,GACXA,EAAQ,CACJrH,KAAMkF,MAAMC,UAAUjC,IAAImC,KAAKgD,EAAY/C,iBAAiB,cAAeoB,MAGnF9E,YAAa,SAAC0F,OACJgB,EAAehB,EAAQiB,+IAGvBC,EAAe,IAAIT,KAAKT,EAAQmB,eAAeR,6EAIzBX,EAAQlB,gBAAOrI,EAAOuJ,EAAQ1E,2EACtB4F,kEACAF,gDAClBrF,EAAWqE,EAAQxE,2CAGzC3C,eAAgBwC,IAEV1B,ULnDkB,YAAxBpE,SAAS6L,WACThM,IAEAG,SAASwB,iBAAiB,mBAAoB3B"} \ No newline at end of file +{"version":3,"file":"user_profile.min.js","sources":["../../../js/dom.js","../../../js/data_tables.js","../../../js/utils.js","../../../js/tag_input.js","../../../js/main.js","../../../js/user_profile.js"],"sourcesContent":["const $ = function(selector) {\n return document.querySelector(selector);\n};\n\nconst $$ = function(selector) {\n return document.querySelectorAll(selector) || [];\n};\n\nconst makeEl = function(html) {\n const template = document.createElement('template');\n\n template.innerHTML = html.trim();\n\n return template.content.firstChild;\n};\n\nconst clearEl = function(el) {\n while (el.firstChild) {\n el.removeChild(el.firstChild);\n }\n};\n\nconst toggleEl = function(el) {\n if (el.classList.contains('is-hidden')) {\n el.classList.remove('is-hidden');\n } else {\n el.classList.add('is-hidden');\n }\n};\n\nconst escape = function(unsafe) {\n return unsafe\n .replace(/&/g, \"&\")\n .replace(//g, \">\")\n .replace(/\"/g, \""\")\n .replace(/'/g, \"'\");\n}\n\nconst whenReady = function(funcp) {\n if (document.readyState !== 'loading') {\n funcp();\n } else {\n document.addEventListener('DOMContentLoaded', funcp);\n }\n}\n\nexport { whenReady, $, $$, makeEl, clearEl, toggleEl, escape };","import { makeEl, clearEl } from \"./dom\";\n\nclass SimplePaginator {\n constructor(element) {\n this.element = element;\n }\n\n attach(pageCallback) {\n this.element.addEventListener('click', evt => {\n if (evt.target && evt.target.classList.contains('paginator__button')) {\n pageCallback(+evt.target.dataset.page);\n }\n });\n }\n\n update(totalRecords, perPage, currentPage) {\n clearEl(this.element);\n\n /* First and last page in existence */\n const firstPage = 0;\n const lastPage = Math.floor(totalRecords / perPage); // ish?\n const numPagesToShow = 2;\n\n if (lastPage === firstPage) {\n return;\n }\n\n /* First and last page the main paginator will show */\n const firstPageShow = (currentPage - numPagesToShow) < firstPage ? firstPage : (currentPage - numPagesToShow);\n const lastPageShow = (currentPage + numPagesToShow) > lastPage ? lastPage : (currentPage + numPagesToShow);\n\n /* Whether to show the first and last pages in existence at the ends of the paginator */\n const showFirstPage = (Math.abs(firstPage - currentPage)) > (numPagesToShow);\n const showLastPage = (Math.abs(lastPage - currentPage)) > (numPagesToShow);\n\n\n const prevButtonDisabled = currentPage === firstPage ? 'disabled' : ''\n\n /* Previous button */\n this.element.appendChild(makeEl(\n ``\n ));\n\n /* First page button */\n if (showFirstPage) {\n this.element.appendChild(makeEl(\n ``\n ));\n this.element.appendChild(makeEl(``));\n }\n\n /* \"window\" buttons */\n for (let i = firstPageShow; i <= lastPageShow; i++) {\n const selected = (i === currentPage ? 'paginator__button--selected' : '');\n this.element.appendChild(makeEl(\n ``\n ));\n }\n\n /* Last page button */\n if (showLastPage) {\n this.element.appendChild(makeEl(``));\n this.element.appendChild(makeEl(\n ``\n ));\n }\n\n const nextButtonDisabled = currentPage === lastPage ? 'disabled' : ''\n /* Next button */\n this.element.appendChild(makeEl(\n ``\n ));\n }\n}\n\nclass DataTable {\n constructor(element, options) {\n this.element = element;\n this.container = element.parentElement;\n this.options = options;\n\n this.ajaxCallback = options.ajaxCallback;\n this.data = [];\n this.unfilteredData = [];\n\n this.totalRecords = -1;\n this.perPage = 20;\n this.currentPage = 0;\n\n this.paginator = new SimplePaginator(this.container.querySelector('.paginator'));\n\n this.filterCallback = options.filterCallback;\n this.sortField = null;\n this.sortDir = true;\n }\n\n attach() {\n this.filterField = this.container.querySelector('input.search');\n if (this.filterField && this.filterCallback) {\n this.filterField.addEventListener('keyup', evt => {\n if (evt.target) {\n this._updateFilter(evt.target.value);\n }\n });\n\n if (this.options.preFilter) {\n this.filterField.value = this.options.preFilter;\n }\n }\n\n this.perPageField = this.container.querySelector('select[name=per_page]');\n\n if (this.perPageField) {\n this.perPageField.addEventListener('change', evt => {\n this.perPage = Number(evt.target.value);\n this._updatePage(0);\n });\n }\n\n const header = this.element.querySelector('tr.paginator__sort');\n\n if (header) {\n header.addEventListener('click', evt => {\n const target = evt.target;\n\n if (!target.dataset.sortField) {\n return;\n }\n\n if (this.sortField) {\n const elem = this.element.querySelector(`th[data-sort-field=${this.sortField}]`)\n elem.classList.remove('paginator__sort--down');\n elem.classList.remove('paginator__sort--up');\n }\n\n this._updateSort(target.dataset.sortField, !this.sortDir);\n\n target.classList.add(this.sortDir ? 'paginator__sort--up' : 'paginator__sort--down');\n });\n }\n\n this.paginator.attach(this._updatePage.bind(this));\n this._loadEntries();\n }\n\n /* Load the requested data from the server, and when done, update the DOM. */\n _loadEntries() {\n new Promise(this.ajaxCallback)\n .then(data => {\n this.element.classList.remove('hidden');\n this.unfilteredData = data.data;\n this._updateFilter(this.options.preFilter);\n });\n }\n\n /* Update the DOM to reflect the current state of the data we have loaded */\n _updateEntries(data) {\n this.data = data;\n this.totalRecords = this.data.length;\n\n const bodyElement = this.element.querySelector('tbody');\n clearEl(bodyElement);\n\n const firstIndex = (this.perPage * this.currentPage);\n const lastIndex = (firstIndex + this.perPage) > this.totalRecords ? this.totalRecords : (firstIndex + this.perPage);\n\n\n for (let i = firstIndex; i < lastIndex; i++) {\n const rowElem = makeEl(this.options.rowCallback(this.data[i]));\n rowElem.classList.add(i % 2 === 0 ? 'odd' : 'even');\n\n bodyElement.appendChild(rowElem);\n }\n\n this.paginator.update(this.totalRecords, this.perPage, this.currentPage);\n }\n\n _updatePage(n) {\n this.currentPage = n;\n this.paginator.update(this.totalRecords, this.perPage, this.currentPage);\n this._updateEntries(this.data);\n }\n\n _updateFilter(query) {\n /* clearing the query */\n if (query === null || query === '') {\n this._updateEntries(this.unfilteredData);\n return;\n }\n\n let data = [];\n for (const datum of this.unfilteredData) {\n if (this.filterCallback(datum, query)) {\n data.push(datum);\n }\n }\n\n this._updatePage(0)\n this._updateEntries(data);\n }\n\n _updateSort(field, direction) {\n this.sortField = field;\n this.sortDir = direction;\n\n let newEntries = [...this.data].sort((a, b) => {\n let sorter = 0;\n\n if (a[field] > b[field]) {\n sorter = 1;\n } else if (a[field] < b[field]) {\n sorter = -1;\n }\n\n if (!direction) {\n sorter = -sorter;\n }\n\n return sorter;\n });\n\n this._updatePage(0);\n this._updateEntries(newEntries);\n }\n}\n\nconst dumbFilterCallback = (datum, query) => {\n if (!query) {\n return true;\n }\n\n if (datum.title.indexOf(query) !== -1) {\n return true;\n }\n\n /* this is inefficient */\n for (const tag of datum.tags) {\n if (tag.name.toLowerCase() === query.toLowerCase()) {\n return true;\n }\n }\n\n return false;\n};\n\nexport { DataTable, dumbFilterCallback };\n","import { escape } from \"./dom\";\n\nconst tagsToHtml = (tags) => {\n\n return tags.map(tagData => {\n let tagColorClass;\n if (tagData.name.indexOf('nsfw') !== -1) {\n tagColorClass = 'is-danger';\n } else if (tagData.name.indexOf('safe') !== -1) {\n tagColorClass = 'is-success';\n } else if (tagData.name.indexOf('/') !== -1) {\n tagColorClass = 'is-primary';\n } else {\n tagColorClass = 'is-info';\n }\n\n return `\n ${escape(tagData.name)}\n `;\n }).join('');\n};\n\nexport { tagsToHtml };\n","import { makeEl, escape } from \"./dom\";\n\nclass TagsInput {\n constructor(element, options = {}) {\n this.element = element;\n this.tags = [];\n this.options = options\n\n this.maxTags = options.maxTags || 10;\n this.inputNode = null;\n this.containerNode = null;\n }\n\n attach() {\n this.element.style.display = 'none';\n\n this.containerNode = makeEl('
');\n this.inputNode = makeEl('');\n this.containerNode.appendChild(this.inputNode);\n\n this.element.parentNode.insertBefore(this.containerNode, this.element.nextSibling);\n\n /* Load existing tags from input */\n if (this.element.value) {\n for (const tag of this.element.value.split(',')) {\n this.addTag(tag);\n }\n }\n\n /* Handle addition and removal of tags via key-presses */\n this.containerNode.addEventListener('keydown', this._handleInputKeyUp.bind(this));\n\n /* Handle deletions by clicking the delete button */\n this.containerNode.addEventListener('click', this._handleContainerClick.bind(this));\n }\n\n detach() {\n this.tags.clear();\n this.containerNode.remove();\n this.element.style.display = 'inline-block';\n }\n\n updateHiddenInputValue() {\n this.element.value = this.tags.join(',');\n }\n\n deleteTagNode(node) {\n this.tags.splice(this.tags.indexOf(node.dataset.value.toLowerCase()), 1);\n node.remove();\n\n /* Below the limit? Make sure the input is enabled. */\n if (this.tags.length < this.maxTags) {\n this.inputNode.disabled = false;\n }\n }\n\n addTag(tagValue) {\n tagValue = tagValue.trim();\n\n /* Tag value is probably not empty and we don't already have the same tag. */\n if (tagValue !== '' && this.tags.indexOf(tagValue.toLowerCase()) === -1) {\n this.tags.push(tagValue.toLowerCase());\n\n this.inputNode.parentNode.insertBefore(\n makeEl('' + escape(tagValue) + ''),\n this.inputNode\n );\n\n /* Too many tags, disable the input for now. */\n if (this.tags.length >= this.maxTags) {\n this.inputNode.disabled = true;\n }\n }\n }\n\n _handleInputKeyUp(evt) {\n let tagValue = this.inputNode.value;\n\n if (evt.key === 'Backspace' && tagValue === '') {\n // Remove the child\n if (this.inputNode.previousSibling) {\n this.deleteTagNode(this.inputNode.previousSibling);\n\n this.updateHiddenInputValue();\n }\n } else if (evt.key === ',') {\n this.addTag(tagValue);\n\n this.inputNode.value = ''\n this.updateHiddenInputValue();\n\n evt.preventDefault();\n }\n }\n\n _handleContainerClick(evt) {\n if (evt.target && evt.target.classList.contains('delete')) {\n this.deleteTagNode(evt.target.closest('.tag'));\n this.updateHiddenInputValue();\n }\n }\n}\n\nexport { TagsInput };\n","import { $, $$, toggleEl } from './dom';\nimport { TagsInput } from \"./tag_input\";\n\nconst setupSignupModal = () => {\n const signupButton = $('[data-target~=\"#signin\"],[data-target~=\"#signup\"]');\n\n if (signupButton) {\n signupButton.href = 'javascript:void(0)';\n\n signupButton.addEventListener('click', () => {\n $('.modal').classList.add('is-active');\n });\n\n $('.modal-button-close').addEventListener('click', () => {\n $('.modal').classList.remove('is-active');\n });\n }\n}\n\nconst globalSetup = () => {\n Array.prototype.forEach.call($$('.js-tag-input'), (el) => {\n new TagsInput(el).attach();\n });\n\n setupSignupModal();\n\n const embedButton = $('.panel-tools .embed-tool');\n\n if (embedButton){\n embedButton.addEventListener('click', (evt) => {\n if (evt.target && evt.target.closest('.panel-tools')) {\n toggleEl(evt.target.closest('.panel-tools').querySelector('.panel-embed'));\n }\n });\n }\n\n const expandButton = $('.expand-tool');\n\n if (expandButton) {\n expandButton.addEventListener('click', (evt) => {\n if (evt.target && evt.target.closest('.panel')) {\n const panel = evt.target.closest('.panel');\n\n if (panel.classList.contains('panel-fullsize')) {\n panel.classList.remove('panel-fullsize');\n } else {\n panel.classList.add('panel-fullsize');\n }\n }\n });\n }\n\n // Notifications\n (document.querySelectorAll('.notification .delete') || []).forEach(($delete) => {\n const $notification = $delete.parentNode;\n\n $delete.addEventListener('click', () => {\n $notification.parentNode.removeChild($notification);\n });\n });\n\n // Hamburger menu\n const $navbarBurgers = Array.prototype.slice.call(document.querySelectorAll('.navbar-burger'), 0);\n if ($navbarBurgers.length > 0) {\n $navbarBurgers.forEach(el => {\n el.addEventListener('click', () => {\n const target = el.dataset.target;\n const $target = document.getElementById(target);\n el.classList.toggle('is-active');\n $target.classList.toggle('is-active');\n });\n });\n }\n\n const preloader = $('.preloader');\n const main = $('main');\n\n if (preloader && main) {\n preloader.remove();\n main.id = '';\n }\n\n // CAPTCHA refresh\n const captchaContainer = $('.captcha_container');\n\n if (captchaContainer) {\n const refreshElement = captchaContainer.querySelector('a');\n const imageElement = captchaContainer.querySelector('img');\n\n if (refreshElement && imageElement) {\n refreshElement.addEventListener('click', () => {\n let src = imageElement.src;\n\n if (src.indexOf('&refresh') !== -1) {\n // yeah, it's kinda cancerous. fuck off.\n src = src.split('&rand=')[0];\n } else {\n src += '&refresh';\n }\n\n imageElement.src = src + '&rand=' + Math.random();\n });\n }\n }\n\n const hiddenElements = $$('.js-hidden');\n\n if (hiddenElements) {\n Array.prototype.forEach.call(hiddenElements, (elem) => {\n toggleEl(elem);\n });\n }\n}\n\nexport { globalSetup };","import { escape, whenReady } from './dom';\nimport { DataTable, dumbFilterCallback } from './data_tables';\nimport { tagsToHtml } from \"./utils\";\nimport { globalSetup } from './main';\n\nconst getUserInfo = () => {\n const elem = document.getElementById('js-data-holder');\n\n if (!elem) {\n return { userId: null, csrfToken: null };\n }\n\n return { userId: elem.dataset.userId, csrfToken: elem.dataset.csrfToken };\n};\n\nconst parsePasteInfo = (elem) => {\n if (!elem.dataset.pasteInfo) {\n return null;\n }\n\n return JSON.parse(elem.dataset.pasteInfo);\n};\n\nwhenReady(() => {\n globalSetup();\n\n const urlParams = new URLSearchParams(window.location.search);\n const myParam = urlParams.get('q');\n const myPastesElem = document.getElementById('archive');\n const table = new DataTable(myPastesElem, {\n ajaxCallback: (resolve) => {\n resolve({\n data: Array.prototype.map.call(myPastesElem.querySelectorAll('tbody > tr'), parsePasteInfo)\n });\n },\n rowCallback: (rowData) => {\n const userData = getUserInfo();\n const ownedByUser = (parseInt(rowData.user_id) === parseInt(userData.userId));\n\n const deleteElem = ownedByUser ? `\n
\n \n \n \n
\n ` : '';\n const pasteCreatedAt = new Date(rowData.created_at).toLocaleString();\n const pasteVisibility = ownedByUser ? `${rowData.visibility}` : '';\n\n return `\n ${escape(rowData.title)}\n ${pasteCreatedAt}\n ${pasteVisibility}\n ${rowData.views || 0}\n ${tagsToHtml(rowData.tags)}\n ${deleteElem}\n `;\n },\n filterCallback: dumbFilterCallback,\n preFilter: myParam\n });\n table.attach();\n\n const myFavesElem = document.getElementById('favs');\n\n if (!myFavesElem) {\n return;\n }\n\n const faveTable = new DataTable(myFavesElem, {\n ajaxCallback: (resolve) => {\n resolve({\n data: Array.prototype.map.call(myFavesElem.querySelectorAll('tbody > tr'), parsePasteInfo)\n });\n },\n rowCallback: (rowData) => {\n const recentUpdate = rowData.recently_updated ?\n `` :\n ``;\n const pasteFavedAt = new Date(rowData.favourited_at).toLocaleString();\n\n // ${escape(rowData.author)}\n return `\n ${escape(rowData.title)}\n ${pasteFavedAt}\n ${recentUpdate}\n ${tagsToHtml(rowData.tags)}\n `;\n },\n filterCallback: dumbFilterCallback\n });\n faveTable.attach();\n});"],"names":["funcp","$","selector","document","querySelector","$$","querySelectorAll","makeEl","html","template","createElement","innerHTML","trim","content","firstChild","clearEl","el","removeChild","toggleEl","classList","contains","remove","add","escape","unsafe","replace","SimplePaginator","element","pageCallback","addEventListener","evt","target","dataset","page","totalRecords","perPage","currentPage","this","lastPage","Math","floor","firstPageShow","lastPageShow","showFirstPage","abs","showLastPage","prevButtonDisabled","appendChild","i","selected","nextButtonDisabled","DataTable","options","container","parentElement","ajaxCallback","data","unfilteredData","paginator","filterCallback","sortField","sortDir","filterField","_this","_updateFilter","value","preFilter","perPageField","Number","_updatePage","header","elem","_updateSort","attach","bind","_loadEntries","Promise","then","_this2","length","bodyElement","firstIndex","lastIndex","rowElem","rowCallback","update","n","_updateEntries","query","datum","push","field","direction","newEntries","_toConsumableArray","sort","a","b","sorter","dumbFilterCallback","title","indexOf","tags","name","toLowerCase","tagsToHtml","map","tagData","tagColorClass","slug","join","TagsInput","maxTags","inputNode","containerNode","style","display","parentNode","insertBefore","nextSibling","split","tag","addTag","_handleInputKeyUp","_handleContainerClick","clear","node","splice","disabled","tagValue","key","previousSibling","deleteTagNode","updateHiddenInputValue","preventDefault","closest","globalSetup","signupButton","Array","prototype","forEach","call","href","embedButton","expandButton","panel","$delete","$notification","$navbarBurgers","slice","$target","getElementById","toggle","preloader","main","id","captchaContainer","refreshElement","imageElement","src","random","hiddenElements","parsePasteInfo","pasteInfo","JSON","parse","myParam","URLSearchParams","window","location","search","get","myPastesElem","resolve","rowData","userData","userId","csrfToken","ownedByUser","parseInt","user_id","deleteElem","pasteCreatedAt","Date","created_at","toLocaleString","pasteVisibility","visibility","views","myFavesElem","recentUpdate","recently_updated","pasteFavedAt","favourited_at","readyState"],"mappings":"krDAAA,IAuC2BA,EAvCrBC,EAAI,SAASC,UACRC,SAASC,cAAcF,IAG5BG,EAAK,SAASH,UACTC,SAASG,iBAAiBJ,IAAa,IAG5CK,EAAS,SAASC,OACdC,EAAWN,SAASO,cAAc,mBAExCD,EAASE,UAAYH,EAAKI,OAEnBH,EAASI,QAAQC,YAGtBC,EAAU,SAASC,QACdA,EAAGF,YACNE,EAAGC,YAAYD,EAAGF,aAIpBI,EAAW,SAASF,GAClBA,EAAGG,UAAUC,SAAS,aACtBJ,EAAGG,UAAUE,OAAO,aAEpBL,EAAGG,UAAUG,IAAI,cAInBC,EAAS,SAASC,UACbA,EACFC,QAAQ,KAAM,SACdA,QAAQ,KAAM,QACdA,QAAQ,KAAM,QACdA,QAAQ,KAAM,UACdA,QAAQ,KAAM,WClCjBC,wBACUC,kBACHA,QAAUA,kCAGnB,SAAOC,QACED,QAAQE,iBAAiB,SAAS,SAAAC,GAC/BA,EAAIC,QAAUD,EAAIC,OAAOZ,UAAUC,SAAS,sBAC5CQ,GAAcE,EAAIC,OAAOC,QAAQC,+BAK7C,SAAOC,EAAcC,EAASC,GAC1BrB,EAAQsB,KAAKV,aAIPW,EAAWC,KAAKC,MAAMN,EAAeC,MADzB,IAIdG,OAKEG,EAAiBL,EAPA,EAFL,EAAA,EAS8DA,EAPzD,EAQjBM,EAAgBN,EARC,EAQ+BE,EAAWA,EAAYF,EARtD,EAWjBO,EAAiBJ,KAAKK,IAbV,EAa0BR,GAXrB,EAYjBS,EAAgBN,KAAKK,IAAIN,EAAWF,GAZnB,EAejBU,EAjBY,IAiBSV,EAA4B,WAAa,QAG/DT,QAAQoB,YAAYxC,uDACyBuC,yBAAiCV,EAAc,2BAI7FO,SACKhB,QAAQoB,YAAYxC,yDA1BX,eAAA,sBA6BToB,QAAQoB,YAAYxC,2CAIxB,IAAIyC,EAAIP,EAAeO,GAAKN,EAAcM,IAAK,KAC1CC,EAAYD,IAAMZ,EAAc,8BAAgC,QACjET,QAAQoB,YAAYxC,6CACe0C,0BAAwBD,eAAMA,iBAKtEH,SACKlB,QAAQoB,YAAYxC,2CACpBoB,QAAQoB,YAAYxC,yDAC2B+B,eAAaA,sBAI/DY,EAAqBd,IAAgBE,EAAW,WAAa,QAE9DX,QAAQoB,YAAYxC,mDACqB2C,yBAAiCd,EAAc,iCAK/Fe,wBACUxB,EAASyB,kBACZzB,QAAUA,OACV0B,UAAY1B,EAAQ2B,mBACpBF,QAAUA,OAEVG,aAAeH,EAAQG,kBACvBC,KAAO,QACPC,eAAiB,QAEjBvB,cAAgB,OAChBC,QAAU,QACVC,YAAc,OAEdsB,UAAY,IAAIhC,EAAgBW,KAAKgB,UAAUjD,cAAc,oBAE7DuD,eAAiBP,EAAQO,oBACzBC,UAAY,UACZC,SAAU,kCAGnB,2BACSC,YAAczB,KAAKgB,UAAUjD,cAAc,gBAC5CiC,KAAKyB,aAAezB,KAAKsB,sBACpBG,YAAYjC,iBAAiB,SAAS,SAAAC,GACpCA,EAAIC,QACJgC,EAAKC,cAAclC,EAAIC,OAAOkC,UAIjC5B,KAAKe,QAAQc,iBACRJ,YAAYG,MAAQ5B,KAAKe,QAAQc,iBAIzCC,aAAe9B,KAAKgB,UAAUjD,cAAc,yBAE7CiC,KAAK8B,mBACAA,aAAatC,iBAAiB,UAAU,SAAAC,GAC1CiC,EAAK5B,QAAUiC,OAAOtC,EAAIC,OAAOkC,OACjCF,EAAKM,YAAY,UAIlBC,EAASjC,KAAKV,QAAQvB,cAAc,sBAEtCkE,GACAA,EAAOzC,iBAAiB,SAAS,SAAAC,OACvBC,EAASD,EAAIC,UAEdA,EAAOC,QAAQ4B,cAIhBG,EAAKH,UAAW,KACVW,EAAOR,EAAKpC,QAAQvB,2CAAoC2D,EAAKH,gBACnEW,EAAKpD,UAAUE,OAAO,yBACtBkD,EAAKpD,UAAUE,OAAO,uBAG1B0C,EAAKS,YAAYzC,EAAOC,QAAQ4B,WAAYG,EAAKF,SAEjD9B,EAAOZ,UAAUG,IAAIyC,EAAKF,QAAU,sBAAwB,kCAI/DH,UAAUe,OAAOpC,KAAKgC,YAAYK,KAAKrC,YACvCsC,2CAIT,0BACQC,QAAQvC,KAAKkB,cACZsB,MAAK,SAAArB,GACFsB,EAAKnD,QAAQR,UAAUE,OAAO,UAC9ByD,EAAKrB,eAAiBD,EAAKA,KAC3BsB,EAAKd,cAAcc,EAAK1B,QAAQc,4CAK5C,SAAeV,QACNA,KAAOA,OACPtB,aAAeG,KAAKmB,KAAKuB,WAExBC,EAAc3C,KAAKV,QAAQvB,cAAc,SAC/CW,EAAQiE,WAEFC,EAAc5C,KAAKF,QAAUE,KAAKD,YAClC8C,EAAaD,EAAa5C,KAAKF,QAAWE,KAAKH,aAAeG,KAAKH,aAAgB+C,EAAa5C,KAAKF,QAGlGa,EAAIiC,EAAYjC,EAAIkC,EAAWlC,IAAK,KACnCmC,EAAU5E,EAAO8B,KAAKe,QAAQgC,YAAY/C,KAAKmB,KAAKR,KAC1DmC,EAAQhE,UAAUG,IAAI0B,EAAI,GAAM,EAAI,MAAQ,QAE5CgC,EAAYjC,YAAYoC,QAGvBzB,UAAU2B,OAAOhD,KAAKH,aAAcG,KAAKF,QAASE,KAAKD,wCAGhE,SAAYkD,QACHlD,YAAckD,OACd5B,UAAU2B,OAAOhD,KAAKH,aAAcG,KAAKF,QAASE,KAAKD,kBACvDmD,eAAelD,KAAKmB,mCAG7B,SAAcgC,MAEI,OAAVA,GAA4B,KAAVA,SAKlBhC,EAAO,OACSnB,KAAKoB,+CAAgB,KAA9BgC,UACHpD,KAAKsB,eAAe8B,EAAOD,IAC3BhC,EAAKkC,KAAKD,uCAIbpB,YAAY,QACZkB,eAAe/B,aAZX+B,eAAelD,KAAKoB,2CAejC,SAAYkC,EAAOC,QACVhC,UAAY+B,OACZ9B,QAAU+B,MAEXC,EAAaC,EAAIzD,KAAKmB,MAAMuC,MAAK,SAACC,EAAGC,OACjCC,EAAS,SAETF,EAAEL,GAASM,EAAEN,GACbO,EAAS,EACFF,EAAEL,GAASM,EAAEN,KACpBO,GAAU,GAGTN,IACDM,GAAUA,GAGPA,UAGN7B,YAAY,QACZkB,eAAeM,YAItBM,EAAqB,SAACV,EAAOD,OAC1BA,SACM,MAGyB,IAAhCC,EAAMW,MAAMC,QAAQb,UACb,YAIOC,EAAMa,qCAAM,YAClBC,KAAKC,gBAAkBhB,EAAMgB,qBAC1B,wCAIR,GChPLC,EAAa,SAACH,UAETA,EAAKI,KAAI,SAAAC,OACRC,SAEAA,GADkC,IAAlCD,EAAQJ,KAAKF,QAAQ,QACL,aACyB,IAAlCM,EAAQJ,KAAKF,QAAQ,QACZ,cACsB,IAA/BM,EAAQJ,KAAKF,QAAQ,KACZ,aAEA,wCAGUM,EAAQE,iEACCD,eAAkBrF,EAAOoF,EAAQJ,kDAEzEO,KAAK,KCjBNC,wBACUpF,OAASyB,yDAAU,kBACtBzB,QAAUA,OACV2E,KAAO,QACPlD,QAAUA,OAEV4D,QAAU5D,EAAQ4D,SAAW,QAC7BC,UAAY,UACZC,cAAgB,qCAGzB,mBACSvF,QAAQwF,MAAMC,QAAU,YAExBF,cAAgB3G,EAAO,uCACvB0G,UAAY1G,EAAO,mFACnB2G,cAAcnE,YAAYV,KAAK4E,gBAE/BtF,QAAQ0F,WAAWC,aAAajF,KAAK6E,cAAe7E,KAAKV,QAAQ4F,aAGlElF,KAAKV,QAAQsC,MAAO,WACF5B,KAAKV,QAAQsC,MAAMuD,MAAM,qCAAM,KAAtCC,eACFC,OAAOD,wCAKfP,cAAcrF,iBAAiB,UAAWQ,KAAKsF,kBAAkBjD,KAAKrC,YAGtE6E,cAAcrF,iBAAiB,QAASQ,KAAKuF,sBAAsBlD,KAAKrC,6BAGjF,gBACSiE,KAAKuB,aACLX,cAAc7F,cACdM,QAAQwF,MAAMC,QAAU,qDAGjC,gBACSzF,QAAQsC,MAAQ5B,KAAKiE,KAAKQ,KAAK,kCAGxC,SAAcgB,QACLxB,KAAKyB,OAAO1F,KAAKiE,KAAKD,QAAQyB,EAAK9F,QAAQiC,MAAMuC,eAAgB,GACtEsB,EAAKzG,SAGDgB,KAAKiE,KAAKvB,OAAS1C,KAAK2E,eACnBC,UAAUe,UAAW,yBAIlC,SAAOC,GAIc,MAHjBA,EAAWA,EAASrH,UAGkD,IAA/CyB,KAAKiE,KAAKD,QAAQ4B,EAASzB,sBACzCF,KAAKZ,KAAKuC,EAASzB,oBAEnBS,UAAUI,WAAWC,aACtB/G,EAAO,yCAA2CgB,EAAO0G,GAAY,KAAO1G,EAAO0G,GAAY,2CAC/F5F,KAAK4E,WAIL5E,KAAKiE,KAAKvB,QAAU1C,KAAK2E,eACpBC,UAAUe,UAAW,qCAKtC,SAAkBlG,OACVmG,EAAW5F,KAAK4E,UAAUhD,MAEd,cAAZnC,EAAIoG,KAAoC,KAAbD,EAEvB5F,KAAK4E,UAAUkB,uBACVC,cAAc/F,KAAK4E,UAAUkB,sBAE7BE,0BAEU,MAAZvG,EAAIoG,WACNR,OAAOO,QAEPhB,UAAUhD,MAAQ,QAClBoE,yBAELvG,EAAIwG,uDAIZ,SAAsBxG,GACdA,EAAIC,QAAUD,EAAIC,OAAOZ,UAAUC,SAAS,iBACvCgH,cAActG,EAAIC,OAAOwG,QAAQ,cACjCF,mCC/EXG,EAAc,WAhBK,IACfC,EAgBNC,MAAMC,UAAUC,QAAQC,KAAKxI,EAAG,kBAAkB,SAACW,OAC3C+F,EAAU/F,GAAIyD,aAjBhBgE,EAAexI,EAAE,wDAGnBwI,EAAaK,KAAO,qBAEpBL,EAAa5G,iBAAiB,SAAS,WACnC5B,EAAE,UAAUkB,UAAUG,IAAI,gBAG9BrB,EAAE,uBAAuB4B,iBAAiB,SAAS,WAC/C5B,EAAE,UAAUkB,UAAUE,OAAO,qBAY/B0H,EAAc9I,EAAE,4BAElB8I,GACAA,EAAYlH,iBAAiB,SAAS,SAACC,GAC/BA,EAAIC,QAAUD,EAAIC,OAAOwG,QAAQ,iBACjCrH,EAASY,EAAIC,OAAOwG,QAAQ,gBAAgBnI,cAAc,wBAKhE4I,EAAe/I,EAAE,gBAEnB+I,GACAA,EAAanH,iBAAiB,SAAS,SAACC,MAChCA,EAAIC,QAAUD,EAAIC,OAAOwG,QAAQ,UAAW,KACtCU,EAAQnH,EAAIC,OAAOwG,QAAQ,UAE7BU,EAAM9H,UAAUC,SAAS,kBACzB6H,EAAM9H,UAAUE,OAAO,kBAEvB4H,EAAM9H,UAAUG,IAAI,uBAOnCnB,SAASG,iBAAiB,0BAA4B,IAAIsI,SAAQ,SAACM,OAC1DC,EAAgBD,EAAQ7B,WAE9B6B,EAAQrH,iBAAiB,SAAS,WAC9BsH,EAAc9B,WAAWpG,YAAYkI,aAKvCC,EAAiBV,MAAMC,UAAUU,MAAMR,KAAK1I,SAASG,iBAAiB,kBAAmB,GAC3F8I,EAAerE,OAAS,GACxBqE,EAAeR,SAAQ,SAAA5H,GACnBA,EAAGa,iBAAiB,SAAS,eACnBE,EAASf,EAAGgB,QAAQD,OACpBuH,EAAUnJ,SAASoJ,eAAexH,GACxCf,EAAGG,UAAUqI,OAAO,aACpBF,EAAQnI,UAAUqI,OAAO,uBAK/BC,EAAYxJ,EAAE,cACdyJ,EAAOzJ,EAAE,QAEXwJ,GAAaC,IACbD,EAAUpI,SACVqI,EAAKC,GAAK,QAIRC,EAAmB3J,EAAE,yBAEvB2J,EAAkB,KACZC,EAAiBD,EAAiBxJ,cAAc,KAChD0J,EAAeF,EAAiBxJ,cAAc,OAEhDyJ,GAAkBC,GAClBD,EAAehI,iBAAiB,SAAS,eACjCkI,EAAMD,EAAaC,KAEU,IAA7BA,EAAI1D,QAAQ,YAEZ0D,EAAMA,EAAIvC,MAAM,UAAU,GAE1BuC,GAAO,WAGXD,EAAaC,IAAMA,EAAM,SAAWxH,KAAKyH,gBAK/CC,EAAiB5J,EAAG,cAEtB4J,GACAvB,MAAMC,UAAUC,QAAQC,KAAKoB,GAAgB,SAAC1F,GAC1CrD,EAASqD,OC9Ff2F,EAAiB,SAAC3F,UACfA,EAAKvC,QAAQmI,UAIXC,KAAKC,MAAM9F,EAAKvC,QAAQmI,WAHpB,MLsBYnK,EKhBjB,WACNwI,QAGM8B,EADY,IAAIC,gBAAgBC,OAAOC,SAASC,QAC5BC,IAAI,KACxBC,EAAezK,SAASoJ,eAAe,WAC/B,IAAIpG,EAAUyH,EAAc,CACtCrH,aAAc,SAACsH,GACXA,EAAQ,CACJrH,KAAMkF,MAAMC,UAAUjC,IAAImC,KAAK+B,EAAatK,iBAAiB,cAAe4J,MAGpF9E,YAAa,SAAC0F,OA7BZvG,EA8BQwG,GA9BRxG,EAAOpE,SAASoJ,eAAe,mBAM9B,CAAEyB,OAAQzG,EAAKvC,QAAQgJ,OAAQC,UAAW1G,EAAKvC,QAAQiJ,WAHnD,CAAED,OAAQ,KAAMC,UAAW,MA4BxBC,EAAeC,SAASL,EAAQM,WAAaD,SAASJ,EAASC,QAE/DK,EAAaH,4FAC2BJ,EAAQnB,4NAE0BoB,EAASE,sMAGrD,GAC9BK,EAAiB,IAAIC,KAAKT,EAAQU,YAAYC,iBAC9CC,EAAkBR,kCAAuCJ,EAAQa,oBAAoB,+DAG/Db,EAAQnB,gBAAOpI,EAAOuJ,EAAQ1E,2EACtBkF,4CACtBI,6DACsBZ,EAAQc,OAAS,gDACnCnF,EAAWqE,EAAQxE,gDACvB+E,kCAGlB1H,eAAgBwC,EAChBjC,UAAWoG,IAET7F,aAEAoH,EAAc1L,SAASoJ,eAAe,QAEvCsC,GAIa,IAAI1I,EAAU0I,EAAa,CACzCtI,aAAc,SAACsH,GACXA,EAAQ,CACJrH,KAAMkF,MAAMC,UAAUjC,IAAImC,KAAKgD,EAAYvL,iBAAiB,cAAe4J,MAGnF9E,YAAa,SAAC0F,OACJgB,EAAehB,EAAQiB,+IAGvBC,EAAe,IAAIT,KAAKT,EAAQmB,eAAeR,6EAIzBX,EAAQnB,gBAAOpI,EAAOuJ,EAAQ1E,2EACtB4F,kEACAF,gDAClBrF,EAAWqE,EAAQxE,2CAGzC3C,eAAgBwC,IAEV1B,ULnDkB,YAAxBtE,SAAS+L,WACTlM,IAEAG,SAAS0B,iBAAiB,mBAAoB7B"} \ No newline at end of file diff --git a/public/captcha.php b/public/captcha.php index 47f3f99..aa9134e 100644 --- a/public/captcha.php +++ b/public/captcha.php @@ -8,6 +8,10 @@ if (empty($_GET['t'])) { die('Invalid token provided.'); } +if (isset($_GET['refresh'])) { + setupCaptcha(); +} + $captcha_token = 'captcha/' . md5($_GET['t']); $captcha_code = $redis->get($captcha_token); diff --git a/public/index.php b/public/index.php index e9ec79d..aae4fe1 100644 --- a/public/index.php +++ b/public/index.php @@ -31,7 +31,7 @@ function verifyCaptcha() : string|bool { * Anything unhandled means to expire never. * @return string|null Expiry time, or NULL if expires never. */ -function calculatePasteExpiry(string $expiry) { +function calculatePasteExpiry(string $expiry) : ?string { // used to use mktime if ($expiry === 'self') { return 'SELF'; diff --git a/public/login.php b/public/login.php index 86f366c..5278ed5 100644 --- a/public/login.php +++ b/public/login.php @@ -2,6 +2,7 @@ /** @noinspection PhpDefineCanBeReplacedWithConstInspection */ define('IN_PONEPASTE', 1); require_once(__DIR__ . '/../includes/common.php'); +require_once(__DIR__ . '/../includes/captcha.php'); use PonePaste\Helpers\SessionHelper; use PonePaste\Models\User; @@ -100,7 +101,7 @@ if (isset($_POST['forgot'])) { $username = trim($_POST['username']); $password = pp_password_hash($_POST['password']); - if ($captcha_config['enabled'] && !checkCaptcha($_POST['captcha_token'], trim($_POST['captcha_answer']))) { + if ($captcha_enabled && !checkCaptcha($_POST['captcha_token'], trim($_POST['captcha_answer']))) { $error = 'Incorrect CAPTCHA.'; } elseif (empty($_POST['password']) || empty($_POST['username'])) { $error = 'All fields must be filled out.'; @@ -118,7 +119,6 @@ if (isset($_POST['forgot'])) { 'username' => $username, 'password' => $password, 'recovery_code_hash' => pp_password_hash($recovery_code), - 'date' => $date, 'ip' => $ip ]); $user->save(); diff --git a/public/paste.php b/public/paste.php index 88cf9a5..e7f0b78 100644 --- a/public/paste.php +++ b/public/paste.php @@ -11,7 +11,7 @@ function isRequesterLikelyBot() : bool { return str_contains(strtolower($_SERVER['HTTP_USER_AGENT']), 'bot'); } -function rawView($content, $p_code) { +function rawView($content, $p_code) : void { if ($p_code) { header('Content-Type: text/plain'); echo $content; @@ -192,6 +192,7 @@ if ($paste_code === "pastedown") { $p_content = $parsedown->text($p_content); } else { Highlighter::registerLanguage('green', __DIR__ . '/../config/green.lang.json'); + Highlighter::registerLanguage('plaintext', __DIR__ . '/../vendor/scrivo/highlight.php/Highlight/languages/plaintext.json'); $hl = new Highlighter(false); $highlighted = $hl->highlight($paste_code == 'text' ? 'plaintext' : $paste_code, $p_content)->value; $lines = HighlightUtilities\splitCodeIntoArray($highlighted); diff --git a/theme/bulma/common.php b/theme/bulma/common.php index 5dc1eb2..f595062 100644 --- a/theme/bulma/common.php +++ b/theme/bulma/common.php @@ -211,13 +211,14 @@ $flashes = getFlashes();
- CAPTCHA Image + CAPTCHA Image - + +

and press "Enter"

diff --git a/theme/bulma/login.php b/theme/bulma/login.php index 7e7c538..2abc75d 100644 --- a/theme/bulma/login.php +++ b/theme/bulma/login.php @@ -100,11 +100,17 @@
- CAPTCHA - -

and - press"Enter"

+
+ CAPTCHA Image + + + + + + + +

and press "Enter"

+
diff --git a/theme/bulma/main.php b/theme/bulma/main.php index 3ce785c..7164b32 100644 --- a/theme/bulma/main.php +++ b/theme/bulma/main.php @@ -296,13 +296,14 @@
- CAPTCHA Image + CAPTCHA Image - + +

and press "Enter"

diff --git a/theme/bulma/user_profile.php b/theme/bulma/user_profile.php index 6dde7d4..4b24ea9 100644 --- a/theme/bulma/user_profile.php +++ b/theme/bulma/user_profile.php @@ -22,12 +22,10 @@ 1000 => '[HorseWriter] Have more than 1000 total views' ]; - - - function outputBadges(array $badgeCandidates, int $actualValue, string $imagePrefix) { + function outputBadges(array $badgeCandidates, int $actualValue, string $imagePrefix) : void { foreach ($badgeCandidates as $threshold => $badgeTitle) { if ($actualValue >= $threshold) { - echo "$badgeTitle"; + echo "$badgeTitle"; break; } } diff --git a/theme/bulma/view.php b/theme/bulma/view.php index 95856a9..582929e 100644 --- a/theme/bulma/view.php +++ b/theme/bulma/view.php @@ -208,14 +208,7 @@ $selectedloader = "$bg[$i]"; // set variable equal to which random filename was id !== $paste_owner_id)) { ?>
- - +

@@ -397,12 +390,14 @@ $selectedloader = "$bg[$i]"; // set variable equal to which random filename was var grace2kb = graceRemain / 1000; var graceDisplay = roundToTwo(grace2kb); + var element = document.getElementById('charNum'); + if (graceRemain < 0) { - document.getElementById("charNum").innerHTML = 'File Size: File Size limit reached'; - } else if ((charRemain < 0)) { - document.getElementById("charNum").innerHTML = 'File Size: ' + graceDisplay + '/24Kb Grace Limit'; + element.innerHTML = 'File Size: File Size limit reached'; + } else if (charRemain < 0) { + element.innerHTML = 'File Size: ' + graceDisplay + '/24Kb Grace Limit'; } else { - document.getElementById("charNum").innerHTML = 'File Size: ' + charDisplay + '/1000Kb'; + element.innerHTML = 'File Size: ' + charDisplay + '/1000Kb'; } } diff --git a/vendor/autoload.php b/vendor/autoload.php index a704a36..39b5dd1 100644 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -2,6 +2,24 @@ // autoload.php @generated by Composer +if (PHP_VERSION_ID < 50600) { + if (!headers_sent()) { + header('HTTP/1.1 500 Internal Server Error'); + } + $err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL; + if (!ini_get('display_errors')) { + if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') { + fwrite(STDERR, $err); + } elseif (!headers_sent()) { + echo $err; + } + } + trigger_error( + $err, + E_USER_ERROR + ); +} + require_once __DIR__ . '/composer/autoload_real.php'; return ComposerAutoloaderInit5bf95489f4eff2c10ec062bf7ba377da::getLoader(); diff --git a/vendor/bin/carbon b/vendor/bin/carbon index d6da140..05f6df2 100755 --- a/vendor/bin/carbon +++ b/vendor/bin/carbon @@ -108,7 +108,10 @@ if (PHP_VERSION_ID < 80000) { } } - if (function_exists('stream_wrapper_register') && stream_wrapper_register('phpvfscomposer', 'Composer\BinProxyWrapper')) { + if ( + (function_exists('stream_get_wrappers') && in_array('phpvfscomposer', stream_get_wrappers(), true)) + || (function_exists('stream_wrapper_register') && stream_wrapper_register('phpvfscomposer', 'Composer\BinProxyWrapper')) + ) { include("phpvfscomposer://" . __DIR__ . '/..'.'/nesbot/carbon/bin/carbon'); exit(0); } diff --git a/vendor/brick/math/CHANGELOG.md b/vendor/brick/math/CHANGELOG.md new file mode 100644 index 0000000..17cea8d --- /dev/null +++ b/vendor/brick/math/CHANGELOG.md @@ -0,0 +1,445 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +## [0.11.0](https://github.com/brick/math/releases/tag/0.11.0) - 2023-01-16 + +💥 **Breaking changes** + +- Minimum PHP version is now 8.0 +- Methods accepting a union of types are now strongly typed* +- `MathException` now extends `Exception` instead of `RuntimeException` + +* You may now run into type errors if you were passing `Stringable` objects to `of()` or any of the methods +internally calling `of()`, with `strict_types` enabled. You can fix this by casting `Stringable` objects to `string` +first. + +## [0.10.2](https://github.com/brick/math/releases/tag/0.10.2) - 2022-08-11 + +👌 **Improvements** + +- `BigRational::toFloat()` now simplifies the fraction before performing division (#73) thanks to @olsavmic + +## [0.10.1](https://github.com/brick/math/releases/tag/0.10.1) - 2022-08-02 + +✨ **New features** + +- `BigInteger::gcdMultiple()` returns the GCD of multiple `BigInteger` numbers + +## [0.10.0](https://github.com/brick/math/releases/tag/0.10.0) - 2022-06-18 + +💥 **Breaking changes** + +- Minimum PHP version is now 7.4 + +## [0.9.3](https://github.com/brick/math/releases/tag/0.9.3) - 2021-08-15 + +🚀 **Compatibility with PHP 8.1** + +- Support for custom object serialization; this removes a warning on PHP 8.1 due to the `Serializable` interface being deprecated (#60) thanks @TRowbotham + +## [0.9.2](https://github.com/brick/math/releases/tag/0.9.2) - 2021-01-20 + +🐛 **Bug fix** + +- Incorrect results could be returned when using the BCMath calculator, with a default scale set with `bcscale()`, on PHP >= 7.2 (#55). + +## [0.9.1](https://github.com/brick/math/releases/tag/0.9.1) - 2020-08-19 + +✨ **New features** + +- `BigInteger::not()` returns the bitwise `NOT` value + +🐛 **Bug fixes** + +- `BigInteger::toBytes()` could return an incorrect binary representation for some numbers +- The bitwise operations `and()`, `or()`, `xor()` on `BigInteger` could return an incorrect result when the GMP extension is not available + +## [0.9.0](https://github.com/brick/math/releases/tag/0.9.0) - 2020-08-18 + +👌 **Improvements** + +- `BigNumber::of()` now accepts `.123` and `123.` formats, both of which return a `BigDecimal` + +💥 **Breaking changes** + +- Deprecated method `BigInteger::powerMod()` has been removed - use `modPow()` instead +- Deprecated method `BigInteger::parse()` has been removed - use `fromBase()` instead + +## [0.8.17](https://github.com/brick/math/releases/tag/0.8.17) - 2020-08-19 + +🐛 **Bug fix** + +- `BigInteger::toBytes()` could return an incorrect binary representation for some numbers +- The bitwise operations `and()`, `or()`, `xor()` on `BigInteger` could return an incorrect result when the GMP extension is not available + +## [0.8.16](https://github.com/brick/math/releases/tag/0.8.16) - 2020-08-18 + +🚑 **Critical fix** + +- This version reintroduces the deprecated `BigInteger::parse()` method, that has been removed by mistake in version `0.8.9` and should have lasted for the whole `0.8` release cycle. + +✨ **New features** + +- `BigInteger::modInverse()` calculates a modular multiplicative inverse +- `BigInteger::fromBytes()` creates a `BigInteger` from a byte string +- `BigInteger::toBytes()` converts a `BigInteger` to a byte string +- `BigInteger::randomBits()` creates a pseudo-random `BigInteger` of a given bit length +- `BigInteger::randomRange()` creates a pseudo-random `BigInteger` between two bounds + +💩 **Deprecations** + +- `BigInteger::powerMod()` is now deprecated in favour of `modPow()` + +## [0.8.15](https://github.com/brick/math/releases/tag/0.8.15) - 2020-04-15 + +🐛 **Fixes** + +- added missing `ext-json` requirement, due to `BigNumber` implementing `JsonSerializable` + +⚡️ **Optimizations** + +- additional optimization in `BigInteger::remainder()` + +## [0.8.14](https://github.com/brick/math/releases/tag/0.8.14) - 2020-02-18 + +✨ **New features** + +- `BigInteger::getLowestSetBit()` returns the index of the rightmost one bit + +## [0.8.13](https://github.com/brick/math/releases/tag/0.8.13) - 2020-02-16 + +✨ **New features** + +- `BigInteger::isEven()` tests whether the number is even +- `BigInteger::isOdd()` tests whether the number is odd +- `BigInteger::testBit()` tests if a bit is set +- `BigInteger::getBitLength()` returns the number of bits in the minimal representation of the number + +## [0.8.12](https://github.com/brick/math/releases/tag/0.8.12) - 2020-02-03 + +🛠️ **Maintenance release** + +Classes are now annotated for better static analysis with [psalm](https://psalm.dev/). + +This is a maintenance release: no bug fixes, no new features, no breaking changes. + +## [0.8.11](https://github.com/brick/math/releases/tag/0.8.11) - 2020-01-23 + +✨ **New feature** + +`BigInteger::powerMod()` performs a power-with-modulo operation. Useful for crypto. + +## [0.8.10](https://github.com/brick/math/releases/tag/0.8.10) - 2020-01-21 + +✨ **New feature** + +`BigInteger::mod()` returns the **modulo** of two numbers. The *modulo* differs from the *remainder* when the signs of the operands are different. + +## [0.8.9](https://github.com/brick/math/releases/tag/0.8.9) - 2020-01-08 + +⚡️ **Performance improvements** + +A few additional optimizations in `BigInteger` and `BigDecimal` when one of the operands can be returned as is. Thanks to @tomtomsen in #24. + +## [0.8.8](https://github.com/brick/math/releases/tag/0.8.8) - 2019-04-25 + +🐛 **Bug fixes** + +- `BigInteger::toBase()` could return an empty string for zero values (BCMath & Native calculators only, GMP calculator unaffected) + +✨ **New features** + +- `BigInteger::toArbitraryBase()` converts a number to an arbitrary base, using a custom alphabet +- `BigInteger::fromArbitraryBase()` converts a string in an arbitrary base, using a custom alphabet, back to a number + +These methods can be used as the foundation to convert strings between different bases/alphabets, using BigInteger as an intermediate representation. + +💩 **Deprecations** + +- `BigInteger::parse()` is now deprecated in favour of `fromBase()` + +`BigInteger::fromBase()` works the same way as `parse()`, with 2 minor differences: + +- the `$base` parameter is required, it does not default to `10` +- it throws a `NumberFormatException` instead of an `InvalidArgumentException` when the number is malformed + +## [0.8.7](https://github.com/brick/math/releases/tag/0.8.7) - 2019-04-20 + +**Improvements** + +- Safer conversion from `float` when using custom locales +- **Much faster** `NativeCalculator` implementation 🚀 + +You can expect **at least a 3x performance improvement** for common arithmetic operations when using the library on systems without GMP or BCMath; it gets exponentially faster on multiplications with a high number of digits. This is due to calculations now being performed on whole blocks of digits (the block size depending on the platform, 32-bit or 64-bit) instead of digit-by-digit as before. + +## [0.8.6](https://github.com/brick/math/releases/tag/0.8.6) - 2019-04-11 + +**New method** + +`BigNumber::sum()` returns the sum of one or more numbers. + +## [0.8.5](https://github.com/brick/math/releases/tag/0.8.5) - 2019-02-12 + +**Bug fix**: `of()` factory methods could fail when passing a `float` in environments using a `LC_NUMERIC` locale with a decimal separator other than `'.'` (#20). + +Thanks @manowark 👍 + +## [0.8.4](https://github.com/brick/math/releases/tag/0.8.4) - 2018-12-07 + +**New method** + +`BigDecimal::sqrt()` calculates the square root of a decimal number, to a given scale. + +## [0.8.3](https://github.com/brick/math/releases/tag/0.8.3) - 2018-12-06 + +**New method** + +`BigInteger::sqrt()` calculates the square root of a number (thanks @peter279k). + +**New exception** + +`NegativeNumberException` is thrown when calling `sqrt()` on a negative number. + +## [0.8.2](https://github.com/brick/math/releases/tag/0.8.2) - 2018-11-08 + +**Performance update** + +- Further improvement of `toInt()` performance +- `NativeCalculator` can now perform some multiplications more efficiently + +## [0.8.1](https://github.com/brick/math/releases/tag/0.8.1) - 2018-11-07 + +Performance optimization of `toInt()` methods. + +## [0.8.0](https://github.com/brick/math/releases/tag/0.8.0) - 2018-10-13 + +**Breaking changes** + +The following deprecated methods have been removed. Use the new method name instead: + +| Method removed | Replacement method | +| --- | --- | +| `BigDecimal::getIntegral()` | `BigDecimal::getIntegralPart()` | +| `BigDecimal::getFraction()` | `BigDecimal::getFractionalPart()` | + +--- + +**New features** + +`BigInteger` has been augmented with 5 new methods for bitwise operations: + +| New method | Description | +| --- | --- | +| `and()` | performs a bitwise `AND` operation on two numbers | +| `or()` | performs a bitwise `OR` operation on two numbers | +| `xor()` | performs a bitwise `XOR` operation on two numbers | +| `shiftedLeft()` | returns the number shifted left by a number of bits | +| `shiftedRight()` | returns the number shifted right by a number of bits | + +Thanks to @DASPRiD 👍 + +## [0.7.3](https://github.com/brick/math/releases/tag/0.7.3) - 2018-08-20 + +**New method:** `BigDecimal::hasNonZeroFractionalPart()` + +**Renamed/deprecated methods:** + +- `BigDecimal::getIntegral()` has been renamed to `getIntegralPart()` and is now deprecated +- `BigDecimal::getFraction()` has been renamed to `getFractionalPart()` and is now deprecated + +## [0.7.2](https://github.com/brick/math/releases/tag/0.7.2) - 2018-07-21 + +**Performance update** + +`BigInteger::parse()` and `toBase()` now use GMP's built-in base conversion features when available. + +## [0.7.1](https://github.com/brick/math/releases/tag/0.7.1) - 2018-03-01 + +This is a maintenance release, no code has been changed. + +- When installed with `--no-dev`, the autoloader does not autoload tests anymore +- Tests and other files unnecessary for production are excluded from the dist package + +This will help make installations more compact. + +## [0.7.0](https://github.com/brick/math/releases/tag/0.7.0) - 2017-10-02 + +Methods renamed: + +- `BigNumber:sign()` has been renamed to `getSign()` +- `BigDecimal::unscaledValue()` has been renamed to `getUnscaledValue()` +- `BigDecimal::scale()` has been renamed to `getScale()` +- `BigDecimal::integral()` has been renamed to `getIntegral()` +- `BigDecimal::fraction()` has been renamed to `getFraction()` +- `BigRational::numerator()` has been renamed to `getNumerator()` +- `BigRational::denominator()` has been renamed to `getDenominator()` + +Classes renamed: + +- `ArithmeticException` has been renamed to `MathException` + +## [0.6.2](https://github.com/brick/math/releases/tag/0.6.2) - 2017-10-02 + +The base class for all exceptions is now `MathException`. +`ArithmeticException` has been deprecated, and will be removed in 0.7.0. + +## [0.6.1](https://github.com/brick/math/releases/tag/0.6.1) - 2017-10-02 + +A number of methods have been renamed: + +- `BigNumber:sign()` is deprecated; use `getSign()` instead +- `BigDecimal::unscaledValue()` is deprecated; use `getUnscaledValue()` instead +- `BigDecimal::scale()` is deprecated; use `getScale()` instead +- `BigDecimal::integral()` is deprecated; use `getIntegral()` instead +- `BigDecimal::fraction()` is deprecated; use `getFraction()` instead +- `BigRational::numerator()` is deprecated; use `getNumerator()` instead +- `BigRational::denominator()` is deprecated; use `getDenominator()` instead + +The old methods will be removed in version 0.7.0. + +## [0.6.0](https://github.com/brick/math/releases/tag/0.6.0) - 2017-08-25 + +- Minimum PHP version is now [7.1](https://gophp71.org/); for PHP 5.6 and PHP 7.0 support, use version `0.5` +- Deprecated method `BigDecimal::withScale()` has been removed; use `toScale()` instead +- Method `BigNumber::toInteger()` has been renamed to `toInt()` + +## [0.5.4](https://github.com/brick/math/releases/tag/0.5.4) - 2016-10-17 + +`BigNumber` classes now implement [JsonSerializable](http://php.net/manual/en/class.jsonserializable.php). +The JSON output is always a string. + +## [0.5.3](https://github.com/brick/math/releases/tag/0.5.3) - 2016-03-31 + +This is a bugfix release. Dividing by a negative power of 1 with the same scale as the dividend could trigger an incorrect optimization which resulted in a wrong result. See #6. + +## [0.5.2](https://github.com/brick/math/releases/tag/0.5.2) - 2015-08-06 + +The `$scale` parameter of `BigDecimal::dividedBy()` is now optional again. + +## [0.5.1](https://github.com/brick/math/releases/tag/0.5.1) - 2015-07-05 + +**New method: `BigNumber::toScale()`** + +This allows to convert any `BigNumber` to a `BigDecimal` with a given scale, using rounding if necessary. + +## [0.5.0](https://github.com/brick/math/releases/tag/0.5.0) - 2015-07-04 + +**New features** +- Common `BigNumber` interface for all classes, with the following methods: + - `sign()` and derived methods (`isZero()`, `isPositive()`, ...) + - `compareTo()` and derived methods (`isEqualTo()`, `isGreaterThan()`, ...) that work across different `BigNumber` types + - `toBigInteger()`, `toBigDecimal()`, `toBigRational`() conversion methods + - `toInteger()` and `toFloat()` conversion methods to native types +- Unified `of()` behaviour: every class now accepts any type of number, provided that it can be safely converted to the current type +- New method: `BigDecimal::exactlyDividedBy()`; this method automatically computes the scale of the result, provided that the division yields a finite number of digits +- New methods: `BigRational::quotient()` and `remainder()` +- Fine-grained exceptions: `DivisionByZeroException`, `RoundingNecessaryException`, `NumberFormatException` +- Factory methods `zero()`, `one()` and `ten()` available in all classes +- Rounding mode reintroduced in `BigInteger::dividedBy()` + +This release also comes with many performance improvements. + +--- + +**Breaking changes** +- `BigInteger`: + - `getSign()` is renamed to `sign()` + - `toString()` is renamed to `toBase()` + - `BigInteger::dividedBy()` now throws an exception by default if the remainder is not zero; use `quotient()` to get the previous behaviour +- `BigDecimal`: + - `getSign()` is renamed to `sign()` + - `getUnscaledValue()` is renamed to `unscaledValue()` + - `getScale()` is renamed to `scale()` + - `getIntegral()` is renamed to `integral()` + - `getFraction()` is renamed to `fraction()` + - `divideAndRemainder()` is renamed to `quotientAndRemainder()` + - `dividedBy()` now takes a **mandatory** `$scale` parameter **before** the rounding mode + - `toBigInteger()` does not accept a `$roundingMode` parameter anymore + - `toBigRational()` does not simplify the fraction anymore; explicitly add `->simplified()` to get the previous behaviour +- `BigRational`: + - `getSign()` is renamed to `sign()` + - `getNumerator()` is renamed to `numerator()` + - `getDenominator()` is renamed to `denominator()` + - `of()` is renamed to `nd()`, while `parse()` is renamed to `of()` +- Miscellaneous: + - `ArithmeticException` is moved to an `Exception\` sub-namespace + - `of()` factory methods now throw `NumberFormatException` instead of `InvalidArgumentException` + +## [0.4.3](https://github.com/brick/math/releases/tag/0.4.3) - 2016-03-31 + +Backport of two bug fixes from the 0.5 branch: +- `BigInteger::parse()` did not always throw `InvalidArgumentException` as expected +- Dividing by a negative power of 1 with the same scale as the dividend could trigger an incorrect optimization which resulted in a wrong result. See #6. + +## [0.4.2](https://github.com/brick/math/releases/tag/0.4.2) - 2015-06-16 + +New method: `BigDecimal::stripTrailingZeros()` + +## [0.4.1](https://github.com/brick/math/releases/tag/0.4.1) - 2015-06-12 + +Introducing a `BigRational` class, to perform calculations on fractions of any size. + +## [0.4.0](https://github.com/brick/math/releases/tag/0.4.0) - 2015-06-12 + +Rounding modes have been removed from `BigInteger`, and are now a concept specific to `BigDecimal`. + +`BigInteger::dividedBy()` now always returns the quotient of the division. + +## [0.3.5](https://github.com/brick/math/releases/tag/0.3.5) - 2016-03-31 + +Backport of two bug fixes from the 0.5 branch: + +- `BigInteger::parse()` did not always throw `InvalidArgumentException` as expected +- Dividing by a negative power of 1 with the same scale as the dividend could trigger an incorrect optimization which resulted in a wrong result. See #6. + +## [0.3.4](https://github.com/brick/math/releases/tag/0.3.4) - 2015-06-11 + +New methods: +- `BigInteger::remainder()` returns the remainder of a division only +- `BigInteger::gcd()` returns the greatest common divisor of two numbers + +## [0.3.3](https://github.com/brick/math/releases/tag/0.3.3) - 2015-06-07 + +Fix `toString()` not handling negative numbers. + +## [0.3.2](https://github.com/brick/math/releases/tag/0.3.2) - 2015-06-07 + +`BigInteger` and `BigDecimal` now have a `getSign()` method that returns: +- `-1` if the number is negative +- `0` if the number is zero +- `1` if the number is positive + +## [0.3.1](https://github.com/brick/math/releases/tag/0.3.1) - 2015-06-05 + +Minor performance improvements + +## [0.3.0](https://github.com/brick/math/releases/tag/0.3.0) - 2015-06-04 + +The `$roundingMode` and `$scale` parameters have been swapped in `BigDecimal::dividedBy()`. + +## [0.2.2](https://github.com/brick/math/releases/tag/0.2.2) - 2015-06-04 + +Stronger immutability guarantee for `BigInteger` and `BigDecimal`. + +So far, it would have been possible to break immutability of these classes by calling the `unserialize()` internal function. This release fixes that. + +## [0.2.1](https://github.com/brick/math/releases/tag/0.2.1) - 2015-06-02 + +Added `BigDecimal::divideAndRemainder()` + +## [0.2.0](https://github.com/brick/math/releases/tag/0.2.0) - 2015-05-22 + +- `min()` and `max()` do not accept an `array` anymore, but a variable number of parameters +- **minimum PHP version is now 5.6** +- continuous integration with PHP 7 + +## [0.1.1](https://github.com/brick/math/releases/tag/0.1.1) - 2014-09-01 + +- Added `BigInteger::power()` +- Added HHVM support + +## [0.1.0](https://github.com/brick/math/releases/tag/0.1.0) - 2014-08-31 + +First beta release. + diff --git a/vendor/brick/math/LICENSE b/vendor/brick/math/LICENSE new file mode 100644 index 0000000..f9b724f --- /dev/null +++ b/vendor/brick/math/LICENSE @@ -0,0 +1,20 @@ +The MIT License (MIT) + +Copyright (c) 2013-present Benjamin Morel + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/brick/math/composer.json b/vendor/brick/math/composer.json new file mode 100644 index 0000000..ed817bd --- /dev/null +++ b/vendor/brick/math/composer.json @@ -0,0 +1,34 @@ +{ + "name": "brick/math", + "description": "Arbitrary-precision arithmetic library", + "type": "library", + "keywords": [ + "Brick", + "Math", + "Arbitrary-precision", + "Arithmetic", + "BigInteger", + "BigDecimal", + "BigRational", + "Bignum" + ], + "license": "MIT", + "require": { + "php": "^8.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.0", + "php-coveralls/php-coveralls": "^2.2", + "vimeo/psalm": "5.0.0" + }, + "autoload": { + "psr-4": { + "Brick\\Math\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "Brick\\Math\\Tests\\": "tests/" + } + } +} diff --git a/vendor/brick/math/src/BigDecimal.php b/vendor/brick/math/src/BigDecimal.php new file mode 100644 index 0000000..02fc656 --- /dev/null +++ b/vendor/brick/math/src/BigDecimal.php @@ -0,0 +1,786 @@ +value = $value; + $this->scale = $scale; + } + + /** + * Creates a BigDecimal of the given value. + * + * @throws MathException If the value cannot be converted to a BigDecimal. + * + * @psalm-pure + */ + public static function of(BigNumber|int|float|string $value) : BigDecimal + { + return parent::of($value)->toBigDecimal(); + } + + /** + * Creates a BigDecimal from an unscaled value and a scale. + * + * Example: `(12345, 3)` will result in the BigDecimal `12.345`. + * + * @param BigNumber|int|float|string $value The unscaled value. Must be convertible to a BigInteger. + * @param int $scale The scale of the number, positive or zero. + * + * @throws \InvalidArgumentException If the scale is negative. + * + * @psalm-pure + */ + public static function ofUnscaledValue(BigNumber|int|float|string $value, int $scale = 0) : BigDecimal + { + if ($scale < 0) { + throw new \InvalidArgumentException('The scale cannot be negative.'); + } + + return new BigDecimal((string) BigInteger::of($value), $scale); + } + + /** + * Returns a BigDecimal representing zero, with a scale of zero. + * + * @psalm-pure + */ + public static function zero() : BigDecimal + { + /** + * @psalm-suppress ImpureStaticVariable + * @var BigDecimal|null $zero + */ + static $zero; + + if ($zero === null) { + $zero = new BigDecimal('0'); + } + + return $zero; + } + + /** + * Returns a BigDecimal representing one, with a scale of zero. + * + * @psalm-pure + */ + public static function one() : BigDecimal + { + /** + * @psalm-suppress ImpureStaticVariable + * @var BigDecimal|null $one + */ + static $one; + + if ($one === null) { + $one = new BigDecimal('1'); + } + + return $one; + } + + /** + * Returns a BigDecimal representing ten, with a scale of zero. + * + * @psalm-pure + */ + public static function ten() : BigDecimal + { + /** + * @psalm-suppress ImpureStaticVariable + * @var BigDecimal|null $ten + */ + static $ten; + + if ($ten === null) { + $ten = new BigDecimal('10'); + } + + return $ten; + } + + /** + * Returns the sum of this number and the given one. + * + * The result has a scale of `max($this->scale, $that->scale)`. + * + * @param BigNumber|int|float|string $that The number to add. Must be convertible to a BigDecimal. + * + * @throws MathException If the number is not valid, or is not convertible to a BigDecimal. + */ + public function plus(BigNumber|int|float|string $that) : BigDecimal + { + $that = BigDecimal::of($that); + + if ($that->value === '0' && $that->scale <= $this->scale) { + return $this; + } + + if ($this->value === '0' && $this->scale <= $that->scale) { + return $that; + } + + [$a, $b] = $this->scaleValues($this, $that); + + $value = Calculator::get()->add($a, $b); + $scale = $this->scale > $that->scale ? $this->scale : $that->scale; + + return new BigDecimal($value, $scale); + } + + /** + * Returns the difference of this number and the given one. + * + * The result has a scale of `max($this->scale, $that->scale)`. + * + * @param BigNumber|int|float|string $that The number to subtract. Must be convertible to a BigDecimal. + * + * @throws MathException If the number is not valid, or is not convertible to a BigDecimal. + */ + public function minus(BigNumber|int|float|string $that) : BigDecimal + { + $that = BigDecimal::of($that); + + if ($that->value === '0' && $that->scale <= $this->scale) { + return $this; + } + + [$a, $b] = $this->scaleValues($this, $that); + + $value = Calculator::get()->sub($a, $b); + $scale = $this->scale > $that->scale ? $this->scale : $that->scale; + + return new BigDecimal($value, $scale); + } + + /** + * Returns the product of this number and the given one. + * + * The result has a scale of `$this->scale + $that->scale`. + * + * @param BigNumber|int|float|string $that The multiplier. Must be convertible to a BigDecimal. + * + * @throws MathException If the multiplier is not a valid number, or is not convertible to a BigDecimal. + */ + public function multipliedBy(BigNumber|int|float|string $that) : BigDecimal + { + $that = BigDecimal::of($that); + + if ($that->value === '1' && $that->scale === 0) { + return $this; + } + + if ($this->value === '1' && $this->scale === 0) { + return $that; + } + + $value = Calculator::get()->mul($this->value, $that->value); + $scale = $this->scale + $that->scale; + + return new BigDecimal($value, $scale); + } + + /** + * Returns the result of the division of this number by the given one, at the given scale. + * + * @param BigNumber|int|float|string $that The divisor. + * @param int|null $scale The desired scale, or null to use the scale of this number. + * @param int $roundingMode An optional rounding mode. + * + * @throws \InvalidArgumentException If the scale or rounding mode is invalid. + * @throws MathException If the number is invalid, is zero, or rounding was necessary. + */ + public function dividedBy(BigNumber|int|float|string $that, ?int $scale = null, int $roundingMode = RoundingMode::UNNECESSARY) : BigDecimal + { + $that = BigDecimal::of($that); + + if ($that->isZero()) { + throw DivisionByZeroException::divisionByZero(); + } + + if ($scale === null) { + $scale = $this->scale; + } elseif ($scale < 0) { + throw new \InvalidArgumentException('Scale cannot be negative.'); + } + + if ($that->value === '1' && $that->scale === 0 && $scale === $this->scale) { + return $this; + } + + $p = $this->valueWithMinScale($that->scale + $scale); + $q = $that->valueWithMinScale($this->scale - $scale); + + $result = Calculator::get()->divRound($p, $q, $roundingMode); + + return new BigDecimal($result, $scale); + } + + /** + * Returns the exact result of the division of this number by the given one. + * + * The scale of the result is automatically calculated to fit all the fraction digits. + * + * @param BigNumber|int|float|string $that The divisor. Must be convertible to a BigDecimal. + * + * @throws MathException If the divisor is not a valid number, is not convertible to a BigDecimal, is zero, + * or the result yields an infinite number of digits. + */ + public function exactlyDividedBy(BigNumber|int|float|string $that) : BigDecimal + { + $that = BigDecimal::of($that); + + if ($that->value === '0') { + throw DivisionByZeroException::divisionByZero(); + } + + [, $b] = $this->scaleValues($this, $that); + + $d = \rtrim($b, '0'); + $scale = \strlen($b) - \strlen($d); + + $calculator = Calculator::get(); + + foreach ([5, 2] as $prime) { + for (;;) { + $lastDigit = (int) $d[-1]; + + if ($lastDigit % $prime !== 0) { + break; + } + + $d = $calculator->divQ($d, (string) $prime); + $scale++; + } + } + + return $this->dividedBy($that, $scale)->stripTrailingZeros(); + } + + /** + * Returns this number exponentiated to the given value. + * + * The result has a scale of `$this->scale * $exponent`. + * + * @throws \InvalidArgumentException If the exponent is not in the range 0 to 1,000,000. + */ + public function power(int $exponent) : BigDecimal + { + if ($exponent === 0) { + return BigDecimal::one(); + } + + if ($exponent === 1) { + return $this; + } + + if ($exponent < 0 || $exponent > Calculator::MAX_POWER) { + throw new \InvalidArgumentException(\sprintf( + 'The exponent %d is not in the range 0 to %d.', + $exponent, + Calculator::MAX_POWER + )); + } + + return new BigDecimal(Calculator::get()->pow($this->value, $exponent), $this->scale * $exponent); + } + + /** + * Returns the quotient of the division of this number by this given one. + * + * The quotient has a scale of `0`. + * + * @param BigNumber|int|float|string $that The divisor. Must be convertible to a BigDecimal. + * + * @throws MathException If the divisor is not a valid decimal number, or is zero. + */ + public function quotient(BigNumber|int|float|string $that) : BigDecimal + { + $that = BigDecimal::of($that); + + if ($that->isZero()) { + throw DivisionByZeroException::divisionByZero(); + } + + $p = $this->valueWithMinScale($that->scale); + $q = $that->valueWithMinScale($this->scale); + + $quotient = Calculator::get()->divQ($p, $q); + + return new BigDecimal($quotient, 0); + } + + /** + * Returns the remainder of the division of this number by this given one. + * + * The remainder has a scale of `max($this->scale, $that->scale)`. + * + * @param BigNumber|int|float|string $that The divisor. Must be convertible to a BigDecimal. + * + * @throws MathException If the divisor is not a valid decimal number, or is zero. + */ + public function remainder(BigNumber|int|float|string $that) : BigDecimal + { + $that = BigDecimal::of($that); + + if ($that->isZero()) { + throw DivisionByZeroException::divisionByZero(); + } + + $p = $this->valueWithMinScale($that->scale); + $q = $that->valueWithMinScale($this->scale); + + $remainder = Calculator::get()->divR($p, $q); + + $scale = $this->scale > $that->scale ? $this->scale : $that->scale; + + return new BigDecimal($remainder, $scale); + } + + /** + * Returns the quotient and remainder of the division of this number by the given one. + * + * The quotient has a scale of `0`, and the remainder has a scale of `max($this->scale, $that->scale)`. + * + * @param BigNumber|int|float|string $that The divisor. Must be convertible to a BigDecimal. + * + * @return BigDecimal[] An array containing the quotient and the remainder. + * + * @throws MathException If the divisor is not a valid decimal number, or is zero. + */ + public function quotientAndRemainder(BigNumber|int|float|string $that) : array + { + $that = BigDecimal::of($that); + + if ($that->isZero()) { + throw DivisionByZeroException::divisionByZero(); + } + + $p = $this->valueWithMinScale($that->scale); + $q = $that->valueWithMinScale($this->scale); + + [$quotient, $remainder] = Calculator::get()->divQR($p, $q); + + $scale = $this->scale > $that->scale ? $this->scale : $that->scale; + + $quotient = new BigDecimal($quotient, 0); + $remainder = new BigDecimal($remainder, $scale); + + return [$quotient, $remainder]; + } + + /** + * Returns the square root of this number, rounded down to the given number of decimals. + * + * @throws \InvalidArgumentException If the scale is negative. + * @throws NegativeNumberException If this number is negative. + */ + public function sqrt(int $scale) : BigDecimal + { + if ($scale < 0) { + throw new \InvalidArgumentException('Scale cannot be negative.'); + } + + if ($this->value === '0') { + return new BigDecimal('0', $scale); + } + + if ($this->value[0] === '-') { + throw new NegativeNumberException('Cannot calculate the square root of a negative number.'); + } + + $value = $this->value; + $addDigits = 2 * $scale - $this->scale; + + if ($addDigits > 0) { + // add zeros + $value .= \str_repeat('0', $addDigits); + } elseif ($addDigits < 0) { + // trim digits + if (-$addDigits >= \strlen($this->value)) { + // requesting a scale too low, will always yield a zero result + return new BigDecimal('0', $scale); + } + + $value = \substr($value, 0, $addDigits); + } + + $value = Calculator::get()->sqrt($value); + + return new BigDecimal($value, $scale); + } + + /** + * Returns a copy of this BigDecimal with the decimal point moved $n places to the left. + */ + public function withPointMovedLeft(int $n) : BigDecimal + { + if ($n === 0) { + return $this; + } + + if ($n < 0) { + return $this->withPointMovedRight(-$n); + } + + return new BigDecimal($this->value, $this->scale + $n); + } + + /** + * Returns a copy of this BigDecimal with the decimal point moved $n places to the right. + */ + public function withPointMovedRight(int $n) : BigDecimal + { + if ($n === 0) { + return $this; + } + + if ($n < 0) { + return $this->withPointMovedLeft(-$n); + } + + $value = $this->value; + $scale = $this->scale - $n; + + if ($scale < 0) { + if ($value !== '0') { + $value .= \str_repeat('0', -$scale); + } + $scale = 0; + } + + return new BigDecimal($value, $scale); + } + + /** + * Returns a copy of this BigDecimal with any trailing zeros removed from the fractional part. + */ + public function stripTrailingZeros() : BigDecimal + { + if ($this->scale === 0) { + return $this; + } + + $trimmedValue = \rtrim($this->value, '0'); + + if ($trimmedValue === '') { + return BigDecimal::zero(); + } + + $trimmableZeros = \strlen($this->value) - \strlen($trimmedValue); + + if ($trimmableZeros === 0) { + return $this; + } + + if ($trimmableZeros > $this->scale) { + $trimmableZeros = $this->scale; + } + + $value = \substr($this->value, 0, -$trimmableZeros); + $scale = $this->scale - $trimmableZeros; + + return new BigDecimal($value, $scale); + } + + /** + * Returns the absolute value of this number. + */ + public function abs() : BigDecimal + { + return $this->isNegative() ? $this->negated() : $this; + } + + /** + * Returns the negated value of this number. + */ + public function negated() : BigDecimal + { + return new BigDecimal(Calculator::get()->neg($this->value), $this->scale); + } + + public function compareTo(BigNumber|int|float|string $that) : int + { + $that = BigNumber::of($that); + + if ($that instanceof BigInteger) { + $that = $that->toBigDecimal(); + } + + if ($that instanceof BigDecimal) { + [$a, $b] = $this->scaleValues($this, $that); + + return Calculator::get()->cmp($a, $b); + } + + return - $that->compareTo($this); + } + + public function getSign() : int + { + return ($this->value === '0') ? 0 : (($this->value[0] === '-') ? -1 : 1); + } + + public function getUnscaledValue() : BigInteger + { + return self::newBigInteger($this->value); + } + + public function getScale() : int + { + return $this->scale; + } + + /** + * Returns a string representing the integral part of this decimal number. + * + * Example: `-123.456` => `-123`. + */ + public function getIntegralPart() : string + { + if ($this->scale === 0) { + return $this->value; + } + + $value = $this->getUnscaledValueWithLeadingZeros(); + + return \substr($value, 0, -$this->scale); + } + + /** + * Returns a string representing the fractional part of this decimal number. + * + * If the scale is zero, an empty string is returned. + * + * Examples: `-123.456` => '456', `123` => ''. + */ + public function getFractionalPart() : string + { + if ($this->scale === 0) { + return ''; + } + + $value = $this->getUnscaledValueWithLeadingZeros(); + + return \substr($value, -$this->scale); + } + + /** + * Returns whether this decimal number has a non-zero fractional part. + */ + public function hasNonZeroFractionalPart() : bool + { + return $this->getFractionalPart() !== \str_repeat('0', $this->scale); + } + + public function toBigInteger() : BigInteger + { + $zeroScaleDecimal = $this->scale === 0 ? $this : $this->dividedBy(1, 0); + + return self::newBigInteger($zeroScaleDecimal->value); + } + + public function toBigDecimal() : BigDecimal + { + return $this; + } + + public function toBigRational() : BigRational + { + $numerator = self::newBigInteger($this->value); + $denominator = self::newBigInteger('1' . \str_repeat('0', $this->scale)); + + return self::newBigRational($numerator, $denominator, false); + } + + public function toScale(int $scale, int $roundingMode = RoundingMode::UNNECESSARY) : BigDecimal + { + if ($scale === $this->scale) { + return $this; + } + + return $this->dividedBy(BigDecimal::one(), $scale, $roundingMode); + } + + public function toInt() : int + { + return $this->toBigInteger()->toInt(); + } + + public function toFloat() : float + { + return (float) (string) $this; + } + + public function __toString() : string + { + if ($this->scale === 0) { + return $this->value; + } + + $value = $this->getUnscaledValueWithLeadingZeros(); + + return \substr($value, 0, -$this->scale) . '.' . \substr($value, -$this->scale); + } + + /** + * This method is required for serializing the object and SHOULD NOT be accessed directly. + * + * @internal + * + * @return array{value: string, scale: int} + */ + public function __serialize(): array + { + return ['value' => $this->value, 'scale' => $this->scale]; + } + + /** + * This method is only here to allow unserializing the object and cannot be accessed directly. + * + * @internal + * @psalm-suppress RedundantPropertyInitializationCheck + * + * @param array{value: string, scale: int} $data + * + * @throws \LogicException + */ + public function __unserialize(array $data): void + { + if (isset($this->value)) { + throw new \LogicException('__unserialize() is an internal function, it must not be called directly.'); + } + + $this->value = $data['value']; + $this->scale = $data['scale']; + } + + /** + * This method is required by interface Serializable and SHOULD NOT be accessed directly. + * + * @internal + */ + public function serialize() : string + { + return $this->value . ':' . $this->scale; + } + + /** + * This method is only here to implement interface Serializable and cannot be accessed directly. + * + * @internal + * @psalm-suppress RedundantPropertyInitializationCheck + * + * @throws \LogicException + */ + public function unserialize($value) : void + { + if (isset($this->value)) { + throw new \LogicException('unserialize() is an internal function, it must not be called directly.'); + } + + [$value, $scale] = \explode(':', $value); + + $this->value = $value; + $this->scale = (int) $scale; + } + + /** + * Puts the internal values of the given decimal numbers on the same scale. + * + * @return array{string, string} The scaled integer values of $x and $y. + */ + private function scaleValues(BigDecimal $x, BigDecimal $y) : array + { + $a = $x->value; + $b = $y->value; + + if ($b !== '0' && $x->scale > $y->scale) { + $b .= \str_repeat('0', $x->scale - $y->scale); + } elseif ($a !== '0' && $x->scale < $y->scale) { + $a .= \str_repeat('0', $y->scale - $x->scale); + } + + return [$a, $b]; + } + + private function valueWithMinScale(int $scale) : string + { + $value = $this->value; + + if ($this->value !== '0' && $scale > $this->scale) { + $value .= \str_repeat('0', $scale - $this->scale); + } + + return $value; + } + + /** + * Adds leading zeros if necessary to the unscaled value to represent the full decimal number. + */ + private function getUnscaledValueWithLeadingZeros() : string + { + $value = $this->value; + $targetLength = $this->scale + 1; + $negative = ($value[0] === '-'); + $length = \strlen($value); + + if ($negative) { + $length--; + } + + if ($length >= $targetLength) { + return $this->value; + } + + if ($negative) { + $value = \substr($value, 1); + } + + $value = \str_pad($value, $targetLength, '0', STR_PAD_LEFT); + + if ($negative) { + $value = '-' . $value; + } + + return $value; + } +} diff --git a/vendor/brick/math/src/BigInteger.php b/vendor/brick/math/src/BigInteger.php new file mode 100644 index 0000000..4356793 --- /dev/null +++ b/vendor/brick/math/src/BigInteger.php @@ -0,0 +1,1079 @@ +value = $value; + } + + /** + * Creates a BigInteger of the given value. + * + * @throws MathException If the value cannot be converted to a BigInteger. + * + * @psalm-pure + */ + public static function of(BigNumber|int|float|string $value) : BigInteger + { + return parent::of($value)->toBigInteger(); + } + + /** + * Creates a number from a string in a given base. + * + * The string can optionally be prefixed with the `+` or `-` sign. + * + * Bases greater than 36 are not supported by this method, as there is no clear consensus on which of the lowercase + * or uppercase characters should come first. Instead, this method accepts any base up to 36, and does not + * differentiate lowercase and uppercase characters, which are considered equal. + * + * For bases greater than 36, and/or custom alphabets, use the fromArbitraryBase() method. + * + * @param string $number The number to convert, in the given base. + * @param int $base The base of the number, between 2 and 36. + * + * @throws NumberFormatException If the number is empty, or contains invalid chars for the given base. + * @throws \InvalidArgumentException If the base is out of range. + * + * @psalm-pure + */ + public static function fromBase(string $number, int $base) : BigInteger + { + if ($number === '') { + throw new NumberFormatException('The number cannot be empty.'); + } + + if ($base < 2 || $base > 36) { + throw new \InvalidArgumentException(\sprintf('Base %d is not in range 2 to 36.', $base)); + } + + if ($number[0] === '-') { + $sign = '-'; + $number = \substr($number, 1); + } elseif ($number[0] === '+') { + $sign = ''; + $number = \substr($number, 1); + } else { + $sign = ''; + } + + if ($number === '') { + throw new NumberFormatException('The number cannot be empty.'); + } + + $number = \ltrim($number, '0'); + + if ($number === '') { + // The result will be the same in any base, avoid further calculation. + return BigInteger::zero(); + } + + if ($number === '1') { + // The result will be the same in any base, avoid further calculation. + return new BigInteger($sign . '1'); + } + + $pattern = '/[^' . \substr(Calculator::ALPHABET, 0, $base) . ']/'; + + if (\preg_match($pattern, \strtolower($number), $matches) === 1) { + throw new NumberFormatException(\sprintf('"%s" is not a valid character in base %d.', $matches[0], $base)); + } + + if ($base === 10) { + // The number is usable as is, avoid further calculation. + return new BigInteger($sign . $number); + } + + $result = Calculator::get()->fromBase($number, $base); + + return new BigInteger($sign . $result); + } + + /** + * Parses a string containing an integer in an arbitrary base, using a custom alphabet. + * + * Because this method accepts an alphabet with any character, including dash, it does not handle negative numbers. + * + * @param string $number The number to parse. + * @param string $alphabet The alphabet, for example '01' for base 2, or '01234567' for base 8. + * + * @throws NumberFormatException If the given number is empty or contains invalid chars for the given alphabet. + * @throws \InvalidArgumentException If the alphabet does not contain at least 2 chars. + * + * @psalm-pure + */ + public static function fromArbitraryBase(string $number, string $alphabet) : BigInteger + { + if ($number === '') { + throw new NumberFormatException('The number cannot be empty.'); + } + + $base = \strlen($alphabet); + + if ($base < 2) { + throw new \InvalidArgumentException('The alphabet must contain at least 2 chars.'); + } + + $pattern = '/[^' . \preg_quote($alphabet, '/') . ']/'; + + if (\preg_match($pattern, $number, $matches) === 1) { + throw NumberFormatException::charNotInAlphabet($matches[0]); + } + + $number = Calculator::get()->fromArbitraryBase($number, $alphabet, $base); + + return new BigInteger($number); + } + + /** + * Translates a string of bytes containing the binary representation of a BigInteger into a BigInteger. + * + * The input string is assumed to be in big-endian byte-order: the most significant byte is in the zeroth element. + * + * If `$signed` is true, the input is assumed to be in two's-complement representation, and the leading bit is + * interpreted as a sign bit. If `$signed` is false, the input is interpreted as an unsigned number, and the + * resulting BigInteger will always be positive or zero. + * + * This method can be used to retrieve a number exported by `toBytes()`, as long as the `$signed` flags match. + * + * @param string $value The byte string. + * @param bool $signed Whether to interpret as a signed number in two's-complement representation with a leading + * sign bit. + * + * @throws NumberFormatException If the string is empty. + */ + public static function fromBytes(string $value, bool $signed = true) : BigInteger + { + if ($value === '') { + throw new NumberFormatException('The byte string must not be empty.'); + } + + $twosComplement = false; + + if ($signed) { + $x = \ord($value[0]); + + if (($twosComplement = ($x >= 0x80))) { + $value = ~$value; + } + } + + $number = self::fromBase(\bin2hex($value), 16); + + if ($twosComplement) { + return $number->plus(1)->negated(); + } + + return $number; + } + + /** + * Generates a pseudo-random number in the range 0 to 2^numBits - 1. + * + * Using the default random bytes generator, this method is suitable for cryptographic use. + * + * @psalm-param (callable(int): string)|null $randomBytesGenerator + * + * @param int $numBits The number of bits. + * @param callable|null $randomBytesGenerator A function that accepts a number of bytes as an integer, and returns a + * string of random bytes of the given length. Defaults to the + * `random_bytes()` function. + * + * @throws \InvalidArgumentException If $numBits is negative. + */ + public static function randomBits(int $numBits, ?callable $randomBytesGenerator = null) : BigInteger + { + if ($numBits < 0) { + throw new \InvalidArgumentException('The number of bits cannot be negative.'); + } + + if ($numBits === 0) { + return BigInteger::zero(); + } + + if ($randomBytesGenerator === null) { + $randomBytesGenerator = 'random_bytes'; + } + + $byteLength = \intdiv($numBits - 1, 8) + 1; + + $extraBits = ($byteLength * 8 - $numBits); + $bitmask = \chr(0xFF >> $extraBits); + + $randomBytes = $randomBytesGenerator($byteLength); + $randomBytes[0] = $randomBytes[0] & $bitmask; + + return self::fromBytes($randomBytes, false); + } + + /** + * Generates a pseudo-random number between `$min` and `$max`. + * + * Using the default random bytes generator, this method is suitable for cryptographic use. + * + * @psalm-param (callable(int): string)|null $randomBytesGenerator + * + * @param BigNumber|int|float|string $min The lower bound. Must be convertible to a BigInteger. + * @param BigNumber|int|float|string $max The upper bound. Must be convertible to a BigInteger. + * @param callable|null $randomBytesGenerator A function that accepts a number of bytes as an integer, + * and returns a string of random bytes of the given length. + * Defaults to the `random_bytes()` function. + * + * @throws MathException If one of the parameters cannot be converted to a BigInteger, + * or `$min` is greater than `$max`. + */ + public static function randomRange( + BigNumber|int|float|string $min, + BigNumber|int|float|string $max, + ?callable $randomBytesGenerator = null + ) : BigInteger { + $min = BigInteger::of($min); + $max = BigInteger::of($max); + + if ($min->isGreaterThan($max)) { + throw new MathException('$min cannot be greater than $max.'); + } + + if ($min->isEqualTo($max)) { + return $min; + } + + $diff = $max->minus($min); + $bitLength = $diff->getBitLength(); + + // try until the number is in range (50% to 100% chance of success) + do { + $randomNumber = self::randomBits($bitLength, $randomBytesGenerator); + } while ($randomNumber->isGreaterThan($diff)); + + return $randomNumber->plus($min); + } + + /** + * Returns a BigInteger representing zero. + * + * @psalm-pure + */ + public static function zero() : BigInteger + { + /** + * @psalm-suppress ImpureStaticVariable + * @var BigInteger|null $zero + */ + static $zero; + + if ($zero === null) { + $zero = new BigInteger('0'); + } + + return $zero; + } + + /** + * Returns a BigInteger representing one. + * + * @psalm-pure + */ + public static function one() : BigInteger + { + /** + * @psalm-suppress ImpureStaticVariable + * @var BigInteger|null $one + */ + static $one; + + if ($one === null) { + $one = new BigInteger('1'); + } + + return $one; + } + + /** + * Returns a BigInteger representing ten. + * + * @psalm-pure + */ + public static function ten() : BigInteger + { + /** + * @psalm-suppress ImpureStaticVariable + * @var BigInteger|null $ten + */ + static $ten; + + if ($ten === null) { + $ten = new BigInteger('10'); + } + + return $ten; + } + + public static function gcdMultiple(BigInteger $a, BigInteger ...$n): BigInteger + { + $result = $a; + + foreach ($n as $next) { + $result = $result->gcd($next); + + if ($result->isEqualTo(1)) { + return $result; + } + } + + return $result; + } + + /** + * Returns the sum of this number and the given one. + * + * @param BigNumber|int|float|string $that The number to add. Must be convertible to a BigInteger. + * + * @throws MathException If the number is not valid, or is not convertible to a BigInteger. + */ + public function plus(BigNumber|int|float|string $that) : BigInteger + { + $that = BigInteger::of($that); + + if ($that->value === '0') { + return $this; + } + + if ($this->value === '0') { + return $that; + } + + $value = Calculator::get()->add($this->value, $that->value); + + return new BigInteger($value); + } + + /** + * Returns the difference of this number and the given one. + * + * @param BigNumber|int|float|string $that The number to subtract. Must be convertible to a BigInteger. + * + * @throws MathException If the number is not valid, or is not convertible to a BigInteger. + */ + public function minus(BigNumber|int|float|string $that) : BigInteger + { + $that = BigInteger::of($that); + + if ($that->value === '0') { + return $this; + } + + $value = Calculator::get()->sub($this->value, $that->value); + + return new BigInteger($value); + } + + /** + * Returns the product of this number and the given one. + * + * @param BigNumber|int|float|string $that The multiplier. Must be convertible to a BigInteger. + * + * @throws MathException If the multiplier is not a valid number, or is not convertible to a BigInteger. + */ + public function multipliedBy(BigNumber|int|float|string $that) : BigInteger + { + $that = BigInteger::of($that); + + if ($that->value === '1') { + return $this; + } + + if ($this->value === '1') { + return $that; + } + + $value = Calculator::get()->mul($this->value, $that->value); + + return new BigInteger($value); + } + + /** + * Returns the result of the division of this number by the given one. + * + * @param BigNumber|int|float|string $that The divisor. Must be convertible to a BigInteger. + * @param int $roundingMode An optional rounding mode. + * + * @throws MathException If the divisor is not a valid number, is not convertible to a BigInteger, is zero, + * or RoundingMode::UNNECESSARY is used and the remainder is not zero. + */ + public function dividedBy(BigNumber|int|float|string $that, int $roundingMode = RoundingMode::UNNECESSARY) : BigInteger + { + $that = BigInteger::of($that); + + if ($that->value === '1') { + return $this; + } + + if ($that->value === '0') { + throw DivisionByZeroException::divisionByZero(); + } + + $result = Calculator::get()->divRound($this->value, $that->value, $roundingMode); + + return new BigInteger($result); + } + + /** + * Returns this number exponentiated to the given value. + * + * @throws \InvalidArgumentException If the exponent is not in the range 0 to 1,000,000. + */ + public function power(int $exponent) : BigInteger + { + if ($exponent === 0) { + return BigInteger::one(); + } + + if ($exponent === 1) { + return $this; + } + + if ($exponent < 0 || $exponent > Calculator::MAX_POWER) { + throw new \InvalidArgumentException(\sprintf( + 'The exponent %d is not in the range 0 to %d.', + $exponent, + Calculator::MAX_POWER + )); + } + + return new BigInteger(Calculator::get()->pow($this->value, $exponent)); + } + + /** + * Returns the quotient of the division of this number by the given one. + * + * @param BigNumber|int|float|string $that The divisor. Must be convertible to a BigInteger. + * + * @throws DivisionByZeroException If the divisor is zero. + */ + public function quotient(BigNumber|int|float|string $that) : BigInteger + { + $that = BigInteger::of($that); + + if ($that->value === '1') { + return $this; + } + + if ($that->value === '0') { + throw DivisionByZeroException::divisionByZero(); + } + + $quotient = Calculator::get()->divQ($this->value, $that->value); + + return new BigInteger($quotient); + } + + /** + * Returns the remainder of the division of this number by the given one. + * + * The remainder, when non-zero, has the same sign as the dividend. + * + * @param BigNumber|int|float|string $that The divisor. Must be convertible to a BigInteger. + * + * @throws DivisionByZeroException If the divisor is zero. + */ + public function remainder(BigNumber|int|float|string $that) : BigInteger + { + $that = BigInteger::of($that); + + if ($that->value === '1') { + return BigInteger::zero(); + } + + if ($that->value === '0') { + throw DivisionByZeroException::divisionByZero(); + } + + $remainder = Calculator::get()->divR($this->value, $that->value); + + return new BigInteger($remainder); + } + + /** + * Returns the quotient and remainder of the division of this number by the given one. + * + * @param BigNumber|int|float|string $that The divisor. Must be convertible to a BigInteger. + * + * @return BigInteger[] An array containing the quotient and the remainder. + * + * @throws DivisionByZeroException If the divisor is zero. + */ + public function quotientAndRemainder(BigNumber|int|float|string $that) : array + { + $that = BigInteger::of($that); + + if ($that->value === '0') { + throw DivisionByZeroException::divisionByZero(); + } + + [$quotient, $remainder] = Calculator::get()->divQR($this->value, $that->value); + + return [ + new BigInteger($quotient), + new BigInteger($remainder) + ]; + } + + /** + * Returns the modulo of this number and the given one. + * + * The modulo operation yields the same result as the remainder operation when both operands are of the same sign, + * and may differ when signs are different. + * + * The result of the modulo operation, when non-zero, has the same sign as the divisor. + * + * @param BigNumber|int|float|string $that The divisor. Must be convertible to a BigInteger. + * + * @throws DivisionByZeroException If the divisor is zero. + */ + public function mod(BigNumber|int|float|string $that) : BigInteger + { + $that = BigInteger::of($that); + + if ($that->value === '0') { + throw DivisionByZeroException::modulusMustNotBeZero(); + } + + $value = Calculator::get()->mod($this->value, $that->value); + + return new BigInteger($value); + } + + /** + * Returns the modular multiplicative inverse of this BigInteger modulo $m. + * + * @throws DivisionByZeroException If $m is zero. + * @throws NegativeNumberException If $m is negative. + * @throws MathException If this BigInteger has no multiplicative inverse mod m (that is, this BigInteger + * is not relatively prime to m). + */ + public function modInverse(BigInteger $m) : BigInteger + { + if ($m->value === '0') { + throw DivisionByZeroException::modulusMustNotBeZero(); + } + + if ($m->isNegative()) { + throw new NegativeNumberException('Modulus must not be negative.'); + } + + if ($m->value === '1') { + return BigInteger::zero(); + } + + $value = Calculator::get()->modInverse($this->value, $m->value); + + if ($value === null) { + throw new MathException('Unable to compute the modInverse for the given modulus.'); + } + + return new BigInteger($value); + } + + /** + * Returns this number raised into power with modulo. + * + * This operation only works on positive numbers. + * + * @param BigNumber|int|float|string $exp The exponent. Must be positive or zero. + * @param BigNumber|int|float|string $mod The modulus. Must be strictly positive. + * + * @throws NegativeNumberException If any of the operands is negative. + * @throws DivisionByZeroException If the modulus is zero. + */ + public function modPow(BigNumber|int|float|string $exp, BigNumber|int|float|string $mod) : BigInteger + { + $exp = BigInteger::of($exp); + $mod = BigInteger::of($mod); + + if ($this->isNegative() || $exp->isNegative() || $mod->isNegative()) { + throw new NegativeNumberException('The operands cannot be negative.'); + } + + if ($mod->isZero()) { + throw DivisionByZeroException::modulusMustNotBeZero(); + } + + $result = Calculator::get()->modPow($this->value, $exp->value, $mod->value); + + return new BigInteger($result); + } + + /** + * Returns the greatest common divisor of this number and the given one. + * + * The GCD is always positive, unless both operands are zero, in which case it is zero. + * + * @param BigNumber|int|float|string $that The operand. Must be convertible to an integer number. + */ + public function gcd(BigNumber|int|float|string $that) : BigInteger + { + $that = BigInteger::of($that); + + if ($that->value === '0' && $this->value[0] !== '-') { + return $this; + } + + if ($this->value === '0' && $that->value[0] !== '-') { + return $that; + } + + $value = Calculator::get()->gcd($this->value, $that->value); + + return new BigInteger($value); + } + + /** + * Returns the integer square root number of this number, rounded down. + * + * The result is the largest x such that x² ≤ n. + * + * @throws NegativeNumberException If this number is negative. + */ + public function sqrt() : BigInteger + { + if ($this->value[0] === '-') { + throw new NegativeNumberException('Cannot calculate the square root of a negative number.'); + } + + $value = Calculator::get()->sqrt($this->value); + + return new BigInteger($value); + } + + /** + * Returns the absolute value of this number. + */ + public function abs() : BigInteger + { + return $this->isNegative() ? $this->negated() : $this; + } + + /** + * Returns the inverse of this number. + */ + public function negated() : BigInteger + { + return new BigInteger(Calculator::get()->neg($this->value)); + } + + /** + * Returns the integer bitwise-and combined with another integer. + * + * This method returns a negative BigInteger if and only if both operands are negative. + * + * @param BigNumber|int|float|string $that The operand. Must be convertible to an integer number. + */ + public function and(BigNumber|int|float|string $that) : BigInteger + { + $that = BigInteger::of($that); + + return new BigInteger(Calculator::get()->and($this->value, $that->value)); + } + + /** + * Returns the integer bitwise-or combined with another integer. + * + * This method returns a negative BigInteger if and only if either of the operands is negative. + * + * @param BigNumber|int|float|string $that The operand. Must be convertible to an integer number. + */ + public function or(BigNumber|int|float|string $that) : BigInteger + { + $that = BigInteger::of($that); + + return new BigInteger(Calculator::get()->or($this->value, $that->value)); + } + + /** + * Returns the integer bitwise-xor combined with another integer. + * + * This method returns a negative BigInteger if and only if exactly one of the operands is negative. + * + * @param BigNumber|int|float|string $that The operand. Must be convertible to an integer number. + */ + public function xor(BigNumber|int|float|string $that) : BigInteger + { + $that = BigInteger::of($that); + + return new BigInteger(Calculator::get()->xor($this->value, $that->value)); + } + + /** + * Returns the bitwise-not of this BigInteger. + */ + public function not() : BigInteger + { + return $this->negated()->minus(1); + } + + /** + * Returns the integer left shifted by a given number of bits. + */ + public function shiftedLeft(int $distance) : BigInteger + { + if ($distance === 0) { + return $this; + } + + if ($distance < 0) { + return $this->shiftedRight(- $distance); + } + + return $this->multipliedBy(BigInteger::of(2)->power($distance)); + } + + /** + * Returns the integer right shifted by a given number of bits. + */ + public function shiftedRight(int $distance) : BigInteger + { + if ($distance === 0) { + return $this; + } + + if ($distance < 0) { + return $this->shiftedLeft(- $distance); + } + + $operand = BigInteger::of(2)->power($distance); + + if ($this->isPositiveOrZero()) { + return $this->quotient($operand); + } + + return $this->dividedBy($operand, RoundingMode::UP); + } + + /** + * Returns the number of bits in the minimal two's-complement representation of this BigInteger, excluding a sign bit. + * + * For positive BigIntegers, this is equivalent to the number of bits in the ordinary binary representation. + * Computes (ceil(log2(this < 0 ? -this : this+1))). + */ + public function getBitLength() : int + { + if ($this->value === '0') { + return 0; + } + + if ($this->isNegative()) { + return $this->abs()->minus(1)->getBitLength(); + } + + return \strlen($this->toBase(2)); + } + + /** + * Returns the index of the rightmost (lowest-order) one bit in this BigInteger. + * + * Returns -1 if this BigInteger contains no one bits. + */ + public function getLowestSetBit() : int + { + $n = $this; + $bitLength = $this->getBitLength(); + + for ($i = 0; $i <= $bitLength; $i++) { + if ($n->isOdd()) { + return $i; + } + + $n = $n->shiftedRight(1); + } + + return -1; + } + + /** + * Returns whether this number is even. + */ + public function isEven() : bool + { + return \in_array($this->value[-1], ['0', '2', '4', '6', '8'], true); + } + + /** + * Returns whether this number is odd. + */ + public function isOdd() : bool + { + return \in_array($this->value[-1], ['1', '3', '5', '7', '9'], true); + } + + /** + * Returns true if and only if the designated bit is set. + * + * Computes ((this & (1<shiftedRight($n)->isOdd(); + } + + public function compareTo(BigNumber|int|float|string $that) : int + { + $that = BigNumber::of($that); + + if ($that instanceof BigInteger) { + return Calculator::get()->cmp($this->value, $that->value); + } + + return - $that->compareTo($this); + } + + public function getSign() : int + { + return ($this->value === '0') ? 0 : (($this->value[0] === '-') ? -1 : 1); + } + + public function toBigInteger() : BigInteger + { + return $this; + } + + public function toBigDecimal() : BigDecimal + { + return self::newBigDecimal($this->value); + } + + public function toBigRational() : BigRational + { + return self::newBigRational($this, BigInteger::one(), false); + } + + public function toScale(int $scale, int $roundingMode = RoundingMode::UNNECESSARY) : BigDecimal + { + return $this->toBigDecimal()->toScale($scale, $roundingMode); + } + + public function toInt() : int + { + $intValue = (int) $this->value; + + if ($this->value !== (string) $intValue) { + throw IntegerOverflowException::toIntOverflow($this); + } + + return $intValue; + } + + public function toFloat() : float + { + return (float) $this->value; + } + + /** + * Returns a string representation of this number in the given base. + * + * The output will always be lowercase for bases greater than 10. + * + * @throws \InvalidArgumentException If the base is out of range. + */ + public function toBase(int $base) : string + { + if ($base === 10) { + return $this->value; + } + + if ($base < 2 || $base > 36) { + throw new \InvalidArgumentException(\sprintf('Base %d is out of range [2, 36]', $base)); + } + + return Calculator::get()->toBase($this->value, $base); + } + + /** + * Returns a string representation of this number in an arbitrary base with a custom alphabet. + * + * Because this method accepts an alphabet with any character, including dash, it does not handle negative numbers; + * a NegativeNumberException will be thrown when attempting to call this method on a negative number. + * + * @param string $alphabet The alphabet, for example '01' for base 2, or '01234567' for base 8. + * + * @throws NegativeNumberException If this number is negative. + * @throws \InvalidArgumentException If the given alphabet does not contain at least 2 chars. + */ + public function toArbitraryBase(string $alphabet) : string + { + $base = \strlen($alphabet); + + if ($base < 2) { + throw new \InvalidArgumentException('The alphabet must contain at least 2 chars.'); + } + + if ($this->value[0] === '-') { + throw new NegativeNumberException(__FUNCTION__ . '() does not support negative numbers.'); + } + + return Calculator::get()->toArbitraryBase($this->value, $alphabet, $base); + } + + /** + * Returns a string of bytes containing the binary representation of this BigInteger. + * + * The string is in big-endian byte-order: the most significant byte is in the zeroth element. + * + * If `$signed` is true, the output will be in two's-complement representation, and a sign bit will be prepended to + * the output. If `$signed` is false, no sign bit will be prepended, and this method will throw an exception if the + * number is negative. + * + * The string will contain the minimum number of bytes required to represent this BigInteger, including a sign bit + * if `$signed` is true. + * + * This representation is compatible with the `fromBytes()` factory method, as long as the `$signed` flags match. + * + * @param bool $signed Whether to output a signed number in two's-complement representation with a leading sign bit. + * + * @throws NegativeNumberException If $signed is false, and the number is negative. + */ + public function toBytes(bool $signed = true) : string + { + if (! $signed && $this->isNegative()) { + throw new NegativeNumberException('Cannot convert a negative number to a byte string when $signed is false.'); + } + + $hex = $this->abs()->toBase(16); + + if (\strlen($hex) % 2 !== 0) { + $hex = '0' . $hex; + } + + $baseHexLength = \strlen($hex); + + if ($signed) { + if ($this->isNegative()) { + $bin = \hex2bin($hex); + assert($bin !== false); + + $hex = \bin2hex(~$bin); + $hex = self::fromBase($hex, 16)->plus(1)->toBase(16); + + $hexLength = \strlen($hex); + + if ($hexLength < $baseHexLength) { + $hex = \str_repeat('0', $baseHexLength - $hexLength) . $hex; + } + + if ($hex[0] < '8') { + $hex = 'FF' . $hex; + } + } else { + if ($hex[0] >= '8') { + $hex = '00' . $hex; + } + } + } + + return \hex2bin($hex); + } + + public function __toString() : string + { + return $this->value; + } + + /** + * This method is required for serializing the object and SHOULD NOT be accessed directly. + * + * @internal + * + * @return array{value: string} + */ + public function __serialize(): array + { + return ['value' => $this->value]; + } + + /** + * This method is only here to allow unserializing the object and cannot be accessed directly. + * + * @internal + * @psalm-suppress RedundantPropertyInitializationCheck + * + * @param array{value: string} $data + * + * @throws \LogicException + */ + public function __unserialize(array $data): void + { + if (isset($this->value)) { + throw new \LogicException('__unserialize() is an internal function, it must not be called directly.'); + } + + $this->value = $data['value']; + } + + /** + * This method is required by interface Serializable and SHOULD NOT be accessed directly. + * + * @internal + */ + public function serialize() : string + { + return $this->value; + } + + /** + * This method is only here to implement interface Serializable and cannot be accessed directly. + * + * @internal + * @psalm-suppress RedundantPropertyInitializationCheck + * + * @throws \LogicException + */ + public function unserialize($value) : void + { + if (isset($this->value)) { + throw new \LogicException('unserialize() is an internal function, it must not be called directly.'); + } + + $this->value = $value; + } +} diff --git a/vendor/brick/math/src/BigNumber.php b/vendor/brick/math/src/BigNumber.php new file mode 100644 index 0000000..80146d2 --- /dev/null +++ b/vendor/brick/math/src/BigNumber.php @@ -0,0 +1,512 @@ +[\-\+])?' . + '(?:' . + '(?:' . + '(?[0-9]+)?' . + '(?\.)?' . + '(?[0-9]+)?' . + '(?:[eE](?[\-\+]?[0-9]+))?' . + ')|(?:' . + '(?[0-9]+)' . + '\/?' . + '(?[0-9]+)' . + ')' . + ')' . + '$/'; + + /** + * Creates a BigNumber of the given value. + * + * The concrete return type is dependent on the given value, with the following rules: + * + * - BigNumber instances are returned as is + * - integer numbers are returned as BigInteger + * - floating point numbers are converted to a string then parsed as such + * - strings containing a `/` character are returned as BigRational + * - strings containing a `.` character or using an exponential notation are returned as BigDecimal + * - strings containing only digits with an optional leading `+` or `-` sign are returned as BigInteger + * + * @throws NumberFormatException If the format of the number is not valid. + * @throws DivisionByZeroException If the value represents a rational number with a denominator of zero. + * + * @psalm-pure + */ + public static function of(BigNumber|int|float|string $value) : BigNumber + { + if ($value instanceof BigNumber) { + return $value; + } + + if (\is_int($value)) { + return new BigInteger((string) $value); + } + + $value = \is_float($value) ? self::floatToString($value) : $value; + + $throw = static function() use ($value) : void { + throw new NumberFormatException(\sprintf( + 'The given value "%s" does not represent a valid number.', + $value + )); + }; + + if (\preg_match(self::PARSE_REGEXP, $value, $matches) !== 1) { + $throw(); + } + + $getMatch = static fn(string $value): ?string => (($matches[$value] ?? '') !== '') ? $matches[$value] : null; + + $sign = $getMatch('sign'); + $numerator = $getMatch('numerator'); + $denominator = $getMatch('denominator'); + + if ($numerator !== null) { + assert($denominator !== null); + + if ($sign !== null) { + $numerator = $sign . $numerator; + } + + $numerator = self::cleanUp($numerator); + $denominator = self::cleanUp($denominator); + + if ($denominator === '0') { + throw DivisionByZeroException::denominatorMustNotBeZero(); + } + + return new BigRational( + new BigInteger($numerator), + new BigInteger($denominator), + false + ); + } + + $point = $getMatch('point'); + $integral = $getMatch('integral'); + $fractional = $getMatch('fractional'); + $exponent = $getMatch('exponent'); + + if ($integral === null && $fractional === null) { + $throw(); + } + + if ($integral === null) { + $integral = '0'; + } + + if ($point !== null || $exponent !== null) { + $fractional = ($fractional ?? ''); + $exponent = ($exponent !== null) ? (int) $exponent : 0; + + if ($exponent === PHP_INT_MIN || $exponent === PHP_INT_MAX) { + throw new NumberFormatException('Exponent too large.'); + } + + $unscaledValue = self::cleanUp(($sign ?? ''). $integral . $fractional); + + $scale = \strlen($fractional) - $exponent; + + if ($scale < 0) { + if ($unscaledValue !== '0') { + $unscaledValue .= \str_repeat('0', - $scale); + } + $scale = 0; + } + + return new BigDecimal($unscaledValue, $scale); + } + + $integral = self::cleanUp(($sign ?? '') . $integral); + + return new BigInteger($integral); + } + + /** + * Safely converts float to string, avoiding locale-dependent issues. + * + * @see https://github.com/brick/math/pull/20 + * + * @psalm-pure + * @psalm-suppress ImpureFunctionCall + */ + private static function floatToString(float $float) : string + { + $currentLocale = \setlocale(LC_NUMERIC, '0'); + \setlocale(LC_NUMERIC, 'C'); + + $result = (string) $float; + + \setlocale(LC_NUMERIC, $currentLocale); + + return $result; + } + + /** + * Proxy method to access BigInteger's protected constructor from sibling classes. + * + * @internal + * @psalm-pure + */ + protected function newBigInteger(string $value) : BigInteger + { + return new BigInteger($value); + } + + /** + * Proxy method to access BigDecimal's protected constructor from sibling classes. + * + * @internal + * @psalm-pure + */ + protected function newBigDecimal(string $value, int $scale = 0) : BigDecimal + { + return new BigDecimal($value, $scale); + } + + /** + * Proxy method to access BigRational's protected constructor from sibling classes. + * + * @internal + * @psalm-pure + */ + protected function newBigRational(BigInteger $numerator, BigInteger $denominator, bool $checkDenominator) : BigRational + { + return new BigRational($numerator, $denominator, $checkDenominator); + } + + /** + * Returns the minimum of the given values. + * + * @param BigNumber|int|float|string ...$values The numbers to compare. All the numbers need to be convertible + * to an instance of the class this method is called on. + * + * @throws \InvalidArgumentException If no values are given. + * @throws MathException If an argument is not valid. + * + * @psalm-suppress LessSpecificReturnStatement + * @psalm-suppress MoreSpecificReturnType + * @psalm-pure + */ + public static function min(BigNumber|int|float|string ...$values) : static + { + $min = null; + + foreach ($values as $value) { + $value = static::of($value); + + if ($min === null || $value->isLessThan($min)) { + $min = $value; + } + } + + if ($min === null) { + throw new \InvalidArgumentException(__METHOD__ . '() expects at least one value.'); + } + + return $min; + } + + /** + * Returns the maximum of the given values. + * + * @param BigNumber|int|float|string ...$values The numbers to compare. All the numbers need to be convertible + * to an instance of the class this method is called on. + * + * @throws \InvalidArgumentException If no values are given. + * @throws MathException If an argument is not valid. + * + * @psalm-suppress LessSpecificReturnStatement + * @psalm-suppress MoreSpecificReturnType + * @psalm-pure + */ + public static function max(BigNumber|int|float|string ...$values) : static + { + $max = null; + + foreach ($values as $value) { + $value = static::of($value); + + if ($max === null || $value->isGreaterThan($max)) { + $max = $value; + } + } + + if ($max === null) { + throw new \InvalidArgumentException(__METHOD__ . '() expects at least one value.'); + } + + return $max; + } + + /** + * Returns the sum of the given values. + * + * @param BigNumber|int|float|string ...$values The numbers to add. All the numbers need to be convertible + * to an instance of the class this method is called on. + * + * @throws \InvalidArgumentException If no values are given. + * @throws MathException If an argument is not valid. + * + * @psalm-pure + */ + public static function sum(BigNumber|int|float|string ...$values) : static + { + /** @var static|null $sum */ + $sum = null; + + foreach ($values as $value) { + $value = static::of($value); + + $sum = $sum === null ? $value : self::add($sum, $value); + } + + if ($sum === null) { + throw new \InvalidArgumentException(__METHOD__ . '() expects at least one value.'); + } + + return $sum; + } + + /** + * Adds two BigNumber instances in the correct order to avoid a RoundingNecessaryException. + * + * @todo This could be better resolved by creating an abstract protected method in BigNumber, and leaving to + * concrete classes the responsibility to perform the addition themselves or delegate it to the given number, + * depending on their ability to perform the operation. This will also require a version bump because we're + * potentially breaking custom BigNumber implementations (if any...) + * + * @psalm-pure + */ + private static function add(BigNumber $a, BigNumber $b) : BigNumber + { + if ($a instanceof BigRational) { + return $a->plus($b); + } + + if ($b instanceof BigRational) { + return $b->plus($a); + } + + if ($a instanceof BigDecimal) { + return $a->plus($b); + } + + if ($b instanceof BigDecimal) { + return $b->plus($a); + } + + /** @var BigInteger $a */ + + return $a->plus($b); + } + + /** + * Removes optional leading zeros and + sign from the given number. + * + * @param string $number The number, validated as a non-empty string of digits with optional leading sign. + * + * @psalm-pure + */ + private static function cleanUp(string $number) : string + { + $firstChar = $number[0]; + + if ($firstChar === '+' || $firstChar === '-') { + $number = \substr($number, 1); + } + + $number = \ltrim($number, '0'); + + if ($number === '') { + return '0'; + } + + if ($firstChar === '-') { + return '-' . $number; + } + + return $number; + } + + /** + * Checks if this number is equal to the given one. + */ + public function isEqualTo(BigNumber|int|float|string $that) : bool + { + return $this->compareTo($that) === 0; + } + + /** + * Checks if this number is strictly lower than the given one. + */ + public function isLessThan(BigNumber|int|float|string $that) : bool + { + return $this->compareTo($that) < 0; + } + + /** + * Checks if this number is lower than or equal to the given one. + */ + public function isLessThanOrEqualTo(BigNumber|int|float|string $that) : bool + { + return $this->compareTo($that) <= 0; + } + + /** + * Checks if this number is strictly greater than the given one. + */ + public function isGreaterThan(BigNumber|int|float|string $that) : bool + { + return $this->compareTo($that) > 0; + } + + /** + * Checks if this number is greater than or equal to the given one. + */ + public function isGreaterThanOrEqualTo(BigNumber|int|float|string $that) : bool + { + return $this->compareTo($that) >= 0; + } + + /** + * Checks if this number equals zero. + */ + public function isZero() : bool + { + return $this->getSign() === 0; + } + + /** + * Checks if this number is strictly negative. + */ + public function isNegative() : bool + { + return $this->getSign() < 0; + } + + /** + * Checks if this number is negative or zero. + */ + public function isNegativeOrZero() : bool + { + return $this->getSign() <= 0; + } + + /** + * Checks if this number is strictly positive. + */ + public function isPositive() : bool + { + return $this->getSign() > 0; + } + + /** + * Checks if this number is positive or zero. + */ + public function isPositiveOrZero() : bool + { + return $this->getSign() >= 0; + } + + /** + * Returns the sign of this number. + * + * @return int -1 if the number is negative, 0 if zero, 1 if positive. + */ + abstract public function getSign() : int; + + /** + * Compares this number to the given one. + * + * @return int [-1,0,1] If `$this` is lower than, equal to, or greater than `$that`. + * + * @throws MathException If the number is not valid. + */ + abstract public function compareTo(BigNumber|int|float|string $that) : int; + + /** + * Converts this number to a BigInteger. + * + * @throws RoundingNecessaryException If this number cannot be converted to a BigInteger without rounding. + */ + abstract public function toBigInteger() : BigInteger; + + /** + * Converts this number to a BigDecimal. + * + * @throws RoundingNecessaryException If this number cannot be converted to a BigDecimal without rounding. + */ + abstract public function toBigDecimal() : BigDecimal; + + /** + * Converts this number to a BigRational. + */ + abstract public function toBigRational() : BigRational; + + /** + * Converts this number to a BigDecimal with the given scale, using rounding if necessary. + * + * @param int $scale The scale of the resulting `BigDecimal`. + * @param int $roundingMode A `RoundingMode` constant. + * + * @throws RoundingNecessaryException If this number cannot be converted to the given scale without rounding. + * This only applies when RoundingMode::UNNECESSARY is used. + */ + abstract public function toScale(int $scale, int $roundingMode = RoundingMode::UNNECESSARY) : BigDecimal; + + /** + * Returns the exact value of this number as a native integer. + * + * If this number cannot be converted to a native integer without losing precision, an exception is thrown. + * Note that the acceptable range for an integer depends on the platform and differs for 32-bit and 64-bit. + * + * @throws MathException If this number cannot be exactly converted to a native integer. + */ + abstract public function toInt() : int; + + /** + * Returns an approximation of this number as a floating-point value. + * + * Note that this method can discard information as the precision of a floating-point value + * is inherently limited. + * + * If the number is greater than the largest representable floating point number, positive infinity is returned. + * If the number is less than the smallest representable floating point number, negative infinity is returned. + */ + abstract public function toFloat() : float; + + /** + * Returns a string representation of this number. + * + * The output of this method can be parsed by the `of()` factory method; + * this will yield an object equal to this one, without any information loss. + */ + abstract public function __toString() : string; + + public function jsonSerialize() : string + { + return $this->__toString(); + } +} diff --git a/vendor/brick/math/src/BigRational.php b/vendor/brick/math/src/BigRational.php new file mode 100644 index 0000000..31f2904 --- /dev/null +++ b/vendor/brick/math/src/BigRational.php @@ -0,0 +1,445 @@ +isZero()) { + throw DivisionByZeroException::denominatorMustNotBeZero(); + } + + if ($denominator->isNegative()) { + $numerator = $numerator->negated(); + $denominator = $denominator->negated(); + } + } + + $this->numerator = $numerator; + $this->denominator = $denominator; + } + + /** + * Creates a BigRational of the given value. + * + * @throws MathException If the value cannot be converted to a BigRational. + * + * @psalm-pure + */ + public static function of(BigNumber|int|float|string $value) : BigRational + { + return parent::of($value)->toBigRational(); + } + + /** + * Creates a BigRational out of a numerator and a denominator. + * + * If the denominator is negative, the signs of both the numerator and the denominator + * will be inverted to ensure that the denominator is always positive. + * + * @param BigNumber|int|float|string $numerator The numerator. Must be convertible to a BigInteger. + * @param BigNumber|int|float|string $denominator The denominator. Must be convertible to a BigInteger. + * + * @throws NumberFormatException If an argument does not represent a valid number. + * @throws RoundingNecessaryException If an argument represents a non-integer number. + * @throws DivisionByZeroException If the denominator is zero. + * + * @psalm-pure + */ + public static function nd( + BigNumber|int|float|string $numerator, + BigNumber|int|float|string $denominator, + ) : BigRational { + $numerator = BigInteger::of($numerator); + $denominator = BigInteger::of($denominator); + + return new BigRational($numerator, $denominator, true); + } + + /** + * Returns a BigRational representing zero. + * + * @psalm-pure + */ + public static function zero() : BigRational + { + /** + * @psalm-suppress ImpureStaticVariable + * @var BigRational|null $zero + */ + static $zero; + + if ($zero === null) { + $zero = new BigRational(BigInteger::zero(), BigInteger::one(), false); + } + + return $zero; + } + + /** + * Returns a BigRational representing one. + * + * @psalm-pure + */ + public static function one() : BigRational + { + /** + * @psalm-suppress ImpureStaticVariable + * @var BigRational|null $one + */ + static $one; + + if ($one === null) { + $one = new BigRational(BigInteger::one(), BigInteger::one(), false); + } + + return $one; + } + + /** + * Returns a BigRational representing ten. + * + * @psalm-pure + */ + public static function ten() : BigRational + { + /** + * @psalm-suppress ImpureStaticVariable + * @var BigRational|null $ten + */ + static $ten; + + if ($ten === null) { + $ten = new BigRational(BigInteger::ten(), BigInteger::one(), false); + } + + return $ten; + } + + public function getNumerator() : BigInteger + { + return $this->numerator; + } + + public function getDenominator() : BigInteger + { + return $this->denominator; + } + + /** + * Returns the quotient of the division of the numerator by the denominator. + */ + public function quotient() : BigInteger + { + return $this->numerator->quotient($this->denominator); + } + + /** + * Returns the remainder of the division of the numerator by the denominator. + */ + public function remainder() : BigInteger + { + return $this->numerator->remainder($this->denominator); + } + + /** + * Returns the quotient and remainder of the division of the numerator by the denominator. + * + * @return BigInteger[] + */ + public function quotientAndRemainder() : array + { + return $this->numerator->quotientAndRemainder($this->denominator); + } + + /** + * Returns the sum of this number and the given one. + * + * @param BigNumber|int|float|string $that The number to add. + * + * @throws MathException If the number is not valid. + */ + public function plus(BigNumber|int|float|string $that) : BigRational + { + $that = BigRational::of($that); + + $numerator = $this->numerator->multipliedBy($that->denominator); + $numerator = $numerator->plus($that->numerator->multipliedBy($this->denominator)); + $denominator = $this->denominator->multipliedBy($that->denominator); + + return new BigRational($numerator, $denominator, false); + } + + /** + * Returns the difference of this number and the given one. + * + * @param BigNumber|int|float|string $that The number to subtract. + * + * @throws MathException If the number is not valid. + */ + public function minus(BigNumber|int|float|string $that) : BigRational + { + $that = BigRational::of($that); + + $numerator = $this->numerator->multipliedBy($that->denominator); + $numerator = $numerator->minus($that->numerator->multipliedBy($this->denominator)); + $denominator = $this->denominator->multipliedBy($that->denominator); + + return new BigRational($numerator, $denominator, false); + } + + /** + * Returns the product of this number and the given one. + * + * @param BigNumber|int|float|string $that The multiplier. + * + * @throws MathException If the multiplier is not a valid number. + */ + public function multipliedBy(BigNumber|int|float|string $that) : BigRational + { + $that = BigRational::of($that); + + $numerator = $this->numerator->multipliedBy($that->numerator); + $denominator = $this->denominator->multipliedBy($that->denominator); + + return new BigRational($numerator, $denominator, false); + } + + /** + * Returns the result of the division of this number by the given one. + * + * @param BigNumber|int|float|string $that The divisor. + * + * @throws MathException If the divisor is not a valid number, or is zero. + */ + public function dividedBy(BigNumber|int|float|string $that) : BigRational + { + $that = BigRational::of($that); + + $numerator = $this->numerator->multipliedBy($that->denominator); + $denominator = $this->denominator->multipliedBy($that->numerator); + + return new BigRational($numerator, $denominator, true); + } + + /** + * Returns this number exponentiated to the given value. + * + * @throws \InvalidArgumentException If the exponent is not in the range 0 to 1,000,000. + */ + public function power(int $exponent) : BigRational + { + if ($exponent === 0) { + $one = BigInteger::one(); + + return new BigRational($one, $one, false); + } + + if ($exponent === 1) { + return $this; + } + + return new BigRational( + $this->numerator->power($exponent), + $this->denominator->power($exponent), + false + ); + } + + /** + * Returns the reciprocal of this BigRational. + * + * The reciprocal has the numerator and denominator swapped. + * + * @throws DivisionByZeroException If the numerator is zero. + */ + public function reciprocal() : BigRational + { + return new BigRational($this->denominator, $this->numerator, true); + } + + /** + * Returns the absolute value of this BigRational. + */ + public function abs() : BigRational + { + return new BigRational($this->numerator->abs(), $this->denominator, false); + } + + /** + * Returns the negated value of this BigRational. + */ + public function negated() : BigRational + { + return new BigRational($this->numerator->negated(), $this->denominator, false); + } + + /** + * Returns the simplified value of this BigRational. + */ + public function simplified() : BigRational + { + $gcd = $this->numerator->gcd($this->denominator); + + $numerator = $this->numerator->quotient($gcd); + $denominator = $this->denominator->quotient($gcd); + + return new BigRational($numerator, $denominator, false); + } + + public function compareTo(BigNumber|int|float|string $that) : int + { + return $this->minus($that)->getSign(); + } + + public function getSign() : int + { + return $this->numerator->getSign(); + } + + public function toBigInteger() : BigInteger + { + $simplified = $this->simplified(); + + if (! $simplified->denominator->isEqualTo(1)) { + throw new RoundingNecessaryException('This rational number cannot be represented as an integer value without rounding.'); + } + + return $simplified->numerator; + } + + public function toBigDecimal() : BigDecimal + { + return $this->numerator->toBigDecimal()->exactlyDividedBy($this->denominator); + } + + public function toBigRational() : BigRational + { + return $this; + } + + public function toScale(int $scale, int $roundingMode = RoundingMode::UNNECESSARY) : BigDecimal + { + return $this->numerator->toBigDecimal()->dividedBy($this->denominator, $scale, $roundingMode); + } + + public function toInt() : int + { + return $this->toBigInteger()->toInt(); + } + + public function toFloat() : float + { + $simplified = $this->simplified(); + return $simplified->numerator->toFloat() / $simplified->denominator->toFloat(); + } + + public function __toString() : string + { + $numerator = (string) $this->numerator; + $denominator = (string) $this->denominator; + + if ($denominator === '1') { + return $numerator; + } + + return $this->numerator . '/' . $this->denominator; + } + + /** + * This method is required for serializing the object and SHOULD NOT be accessed directly. + * + * @internal + * + * @return array{numerator: BigInteger, denominator: BigInteger} + */ + public function __serialize(): array + { + return ['numerator' => $this->numerator, 'denominator' => $this->denominator]; + } + + /** + * This method is only here to allow unserializing the object and cannot be accessed directly. + * + * @internal + * @psalm-suppress RedundantPropertyInitializationCheck + * + * @param array{numerator: BigInteger, denominator: BigInteger} $data + * + * @throws \LogicException + */ + public function __unserialize(array $data): void + { + if (isset($this->numerator)) { + throw new \LogicException('__unserialize() is an internal function, it must not be called directly.'); + } + + $this->numerator = $data['numerator']; + $this->denominator = $data['denominator']; + } + + /** + * This method is required by interface Serializable and SHOULD NOT be accessed directly. + * + * @internal + */ + public function serialize() : string + { + return $this->numerator . '/' . $this->denominator; + } + + /** + * This method is only here to implement interface Serializable and cannot be accessed directly. + * + * @internal + * @psalm-suppress RedundantPropertyInitializationCheck + * + * @throws \LogicException + */ + public function unserialize($value) : void + { + if (isset($this->numerator)) { + throw new \LogicException('unserialize() is an internal function, it must not be called directly.'); + } + + [$numerator, $denominator] = \explode('/', $value); + + $this->numerator = BigInteger::of($numerator); + $this->denominator = BigInteger::of($denominator); + } +} diff --git a/vendor/brick/math/src/Exception/DivisionByZeroException.php b/vendor/brick/math/src/Exception/DivisionByZeroException.php new file mode 100644 index 0000000..ce7769a --- /dev/null +++ b/vendor/brick/math/src/Exception/DivisionByZeroException.php @@ -0,0 +1,35 @@ + 126) { + $char = \strtoupper(\dechex($ord)); + + if ($ord < 10) { + $char = '0' . $char; + } + } else { + $char = '"' . $char . '"'; + } + + return new self(sprintf('Char %s is not a valid character in the given alphabet.', $char)); + } +} diff --git a/vendor/brick/math/src/Exception/RoundingNecessaryException.php b/vendor/brick/math/src/Exception/RoundingNecessaryException.php new file mode 100644 index 0000000..57bfcd8 --- /dev/null +++ b/vendor/brick/math/src/Exception/RoundingNecessaryException.php @@ -0,0 +1,19 @@ +init($a, $b); + + if ($aNeg && ! $bNeg) { + return -1; + } + + if ($bNeg && ! $aNeg) { + return 1; + } + + $aLen = \strlen($aDig); + $bLen = \strlen($bDig); + + if ($aLen < $bLen) { + $result = -1; + } elseif ($aLen > $bLen) { + $result = 1; + } else { + $result = $aDig <=> $bDig; + } + + return $aNeg ? -$result : $result; + } + + /** + * Adds two numbers. + */ + abstract public function add(string $a, string $b) : string; + + /** + * Subtracts two numbers. + */ + abstract public function sub(string $a, string $b) : string; + + /** + * Multiplies two numbers. + */ + abstract public function mul(string $a, string $b) : string; + + /** + * Returns the quotient of the division of two numbers. + * + * @param string $a The dividend. + * @param string $b The divisor, must not be zero. + * + * @return string The quotient. + */ + abstract public function divQ(string $a, string $b) : string; + + /** + * Returns the remainder of the division of two numbers. + * + * @param string $a The dividend. + * @param string $b The divisor, must not be zero. + * + * @return string The remainder. + */ + abstract public function divR(string $a, string $b) : string; + + /** + * Returns the quotient and remainder of the division of two numbers. + * + * @param string $a The dividend. + * @param string $b The divisor, must not be zero. + * + * @return array{string, string} An array containing the quotient and remainder. + */ + abstract public function divQR(string $a, string $b) : array; + + /** + * Exponentiates a number. + * + * @param string $a The base number. + * @param int $e The exponent, validated as an integer between 0 and MAX_POWER. + * + * @return string The power. + */ + abstract public function pow(string $a, int $e) : string; + + /** + * @param string $b The modulus; must not be zero. + */ + public function mod(string $a, string $b) : string + { + return $this->divR($this->add($this->divR($a, $b), $b), $b); + } + + /** + * Returns the modular multiplicative inverse of $x modulo $m. + * + * If $x has no multiplicative inverse mod m, this method must return null. + * + * This method can be overridden by the concrete implementation if the underlying library has built-in support. + * + * @param string $m The modulus; must not be negative or zero. + */ + public function modInverse(string $x, string $m) : ?string + { + if ($m === '1') { + return '0'; + } + + $modVal = $x; + + if ($x[0] === '-' || ($this->cmp($this->abs($x), $m) >= 0)) { + $modVal = $this->mod($x, $m); + } + + [$g, $x] = $this->gcdExtended($modVal, $m); + + if ($g !== '1') { + return null; + } + + return $this->mod($this->add($this->mod($x, $m), $m), $m); + } + + /** + * Raises a number into power with modulo. + * + * @param string $base The base number; must be positive or zero. + * @param string $exp The exponent; must be positive or zero. + * @param string $mod The modulus; must be strictly positive. + */ + abstract public function modPow(string $base, string $exp, string $mod) : string; + + /** + * Returns the greatest common divisor of the two numbers. + * + * This method can be overridden by the concrete implementation if the underlying library + * has built-in support for GCD calculations. + * + * @return string The GCD, always positive, or zero if both arguments are zero. + */ + public function gcd(string $a, string $b) : string + { + if ($a === '0') { + return $this->abs($b); + } + + if ($b === '0') { + return $this->abs($a); + } + + return $this->gcd($b, $this->divR($a, $b)); + } + + /** + * @return array{string, string, string} GCD, X, Y + */ + private function gcdExtended(string $a, string $b) : array + { + if ($a === '0') { + return [$b, '0', '1']; + } + + [$gcd, $x1, $y1] = $this->gcdExtended($this->mod($b, $a), $a); + + $x = $this->sub($y1, $this->mul($this->divQ($b, $a), $x1)); + $y = $x1; + + return [$gcd, $x, $y]; + } + + /** + * Returns the square root of the given number, rounded down. + * + * The result is the largest x such that x² ≤ n. + * The input MUST NOT be negative. + */ + abstract public function sqrt(string $n) : string; + + /** + * Converts a number from an arbitrary base. + * + * This method can be overridden by the concrete implementation if the underlying library + * has built-in support for base conversion. + * + * @param string $number The number, positive or zero, non-empty, case-insensitively validated for the given base. + * @param int $base The base of the number, validated from 2 to 36. + * + * @return string The converted number, following the Calculator conventions. + */ + public function fromBase(string $number, int $base) : string + { + return $this->fromArbitraryBase(\strtolower($number), self::ALPHABET, $base); + } + + /** + * Converts a number to an arbitrary base. + * + * This method can be overridden by the concrete implementation if the underlying library + * has built-in support for base conversion. + * + * @param string $number The number to convert, following the Calculator conventions. + * @param int $base The base to convert to, validated from 2 to 36. + * + * @return string The converted number, lowercase. + */ + public function toBase(string $number, int $base) : string + { + $negative = ($number[0] === '-'); + + if ($negative) { + $number = \substr($number, 1); + } + + $number = $this->toArbitraryBase($number, self::ALPHABET, $base); + + if ($negative) { + return '-' . $number; + } + + return $number; + } + + /** + * Converts a non-negative number in an arbitrary base using a custom alphabet, to base 10. + * + * @param string $number The number to convert, validated as a non-empty string, + * containing only chars in the given alphabet/base. + * @param string $alphabet The alphabet that contains every digit, validated as 2 chars minimum. + * @param int $base The base of the number, validated from 2 to alphabet length. + * + * @return string The number in base 10, following the Calculator conventions. + */ + final public function fromArbitraryBase(string $number, string $alphabet, int $base) : string + { + // remove leading "zeros" + $number = \ltrim($number, $alphabet[0]); + + if ($number === '') { + return '0'; + } + + // optimize for "one" + if ($number === $alphabet[1]) { + return '1'; + } + + $result = '0'; + $power = '1'; + + $base = (string) $base; + + for ($i = \strlen($number) - 1; $i >= 0; $i--) { + $index = \strpos($alphabet, $number[$i]); + + if ($index !== 0) { + $result = $this->add($result, ($index === 1) + ? $power + : $this->mul($power, (string) $index) + ); + } + + if ($i !== 0) { + $power = $this->mul($power, $base); + } + } + + return $result; + } + + /** + * Converts a non-negative number to an arbitrary base using a custom alphabet. + * + * @param string $number The number to convert, positive or zero, following the Calculator conventions. + * @param string $alphabet The alphabet that contains every digit, validated as 2 chars minimum. + * @param int $base The base to convert to, validated from 2 to alphabet length. + * + * @return string The converted number in the given alphabet. + */ + final public function toArbitraryBase(string $number, string $alphabet, int $base) : string + { + if ($number === '0') { + return $alphabet[0]; + } + + $base = (string) $base; + $result = ''; + + while ($number !== '0') { + [$number, $remainder] = $this->divQR($number, $base); + $remainder = (int) $remainder; + + $result .= $alphabet[$remainder]; + } + + return \strrev($result); + } + + /** + * Performs a rounded division. + * + * Rounding is performed when the remainder of the division is not zero. + * + * @param string $a The dividend. + * @param string $b The divisor, must not be zero. + * @param int $roundingMode The rounding mode. + * + * @throws \InvalidArgumentException If the rounding mode is invalid. + * @throws RoundingNecessaryException If RoundingMode::UNNECESSARY is provided but rounding is necessary. + * + * @psalm-suppress ImpureFunctionCall + */ + final public function divRound(string $a, string $b, int $roundingMode) : string + { + [$quotient, $remainder] = $this->divQR($a, $b); + + $hasDiscardedFraction = ($remainder !== '0'); + $isPositiveOrZero = ($a[0] === '-') === ($b[0] === '-'); + + $discardedFractionSign = function() use ($remainder, $b) : int { + $r = $this->abs($this->mul($remainder, '2')); + $b = $this->abs($b); + + return $this->cmp($r, $b); + }; + + $increment = false; + + switch ($roundingMode) { + case RoundingMode::UNNECESSARY: + if ($hasDiscardedFraction) { + throw RoundingNecessaryException::roundingNecessary(); + } + break; + + case RoundingMode::UP: + $increment = $hasDiscardedFraction; + break; + + case RoundingMode::DOWN: + break; + + case RoundingMode::CEILING: + $increment = $hasDiscardedFraction && $isPositiveOrZero; + break; + + case RoundingMode::FLOOR: + $increment = $hasDiscardedFraction && ! $isPositiveOrZero; + break; + + case RoundingMode::HALF_UP: + $increment = $discardedFractionSign() >= 0; + break; + + case RoundingMode::HALF_DOWN: + $increment = $discardedFractionSign() > 0; + break; + + case RoundingMode::HALF_CEILING: + $increment = $isPositiveOrZero ? $discardedFractionSign() >= 0 : $discardedFractionSign() > 0; + break; + + case RoundingMode::HALF_FLOOR: + $increment = $isPositiveOrZero ? $discardedFractionSign() > 0 : $discardedFractionSign() >= 0; + break; + + case RoundingMode::HALF_EVEN: + $lastDigit = (int) $quotient[-1]; + $lastDigitIsEven = ($lastDigit % 2 === 0); + $increment = $lastDigitIsEven ? $discardedFractionSign() > 0 : $discardedFractionSign() >= 0; + break; + + default: + throw new \InvalidArgumentException('Invalid rounding mode.'); + } + + if ($increment) { + return $this->add($quotient, $isPositiveOrZero ? '1' : '-1'); + } + + return $quotient; + } + + /** + * Calculates bitwise AND of two numbers. + * + * This method can be overridden by the concrete implementation if the underlying library + * has built-in support for bitwise operations. + */ + public function and(string $a, string $b) : string + { + return $this->bitwise('and', $a, $b); + } + + /** + * Calculates bitwise OR of two numbers. + * + * This method can be overridden by the concrete implementation if the underlying library + * has built-in support for bitwise operations. + */ + public function or(string $a, string $b) : string + { + return $this->bitwise('or', $a, $b); + } + + /** + * Calculates bitwise XOR of two numbers. + * + * This method can be overridden by the concrete implementation if the underlying library + * has built-in support for bitwise operations. + */ + public function xor(string $a, string $b) : string + { + return $this->bitwise('xor', $a, $b); + } + + /** + * Performs a bitwise operation on a decimal number. + * + * @param 'and'|'or'|'xor' $operator The operator to use. + * @param string $a The left operand. + * @param string $b The right operand. + */ + private function bitwise(string $operator, string $a, string $b) : string + { + [$aNeg, $bNeg, $aDig, $bDig] = $this->init($a, $b); + + $aBin = $this->toBinary($aDig); + $bBin = $this->toBinary($bDig); + + $aLen = \strlen($aBin); + $bLen = \strlen($bBin); + + if ($aLen > $bLen) { + $bBin = \str_repeat("\x00", $aLen - $bLen) . $bBin; + } elseif ($bLen > $aLen) { + $aBin = \str_repeat("\x00", $bLen - $aLen) . $aBin; + } + + if ($aNeg) { + $aBin = $this->twosComplement($aBin); + } + if ($bNeg) { + $bBin = $this->twosComplement($bBin); + } + + switch ($operator) { + case 'and': + $value = $aBin & $bBin; + $negative = ($aNeg and $bNeg); + break; + + case 'or': + $value = $aBin | $bBin; + $negative = ($aNeg or $bNeg); + break; + + case 'xor': + $value = $aBin ^ $bBin; + $negative = ($aNeg xor $bNeg); + break; + + // @codeCoverageIgnoreStart + default: + throw new \InvalidArgumentException('Invalid bitwise operator.'); + // @codeCoverageIgnoreEnd + } + + if ($negative) { + $value = $this->twosComplement($value); + } + + $result = $this->toDecimal($value); + + return $negative ? $this->neg($result) : $result; + } + + /** + * @param string $number A positive, binary number. + */ + private function twosComplement(string $number) : string + { + $xor = \str_repeat("\xff", \strlen($number)); + + $number ^= $xor; + + for ($i = \strlen($number) - 1; $i >= 0; $i--) { + $byte = \ord($number[$i]); + + if (++$byte !== 256) { + $number[$i] = \chr($byte); + break; + } + + $number[$i] = "\x00"; + + if ($i === 0) { + $number = "\x01" . $number; + } + } + + return $number; + } + + /** + * Converts a decimal number to a binary string. + * + * @param string $number The number to convert, positive or zero, only digits. + */ + private function toBinary(string $number) : string + { + $result = ''; + + while ($number !== '0') { + [$number, $remainder] = $this->divQR($number, '256'); + $result .= \chr((int) $remainder); + } + + return \strrev($result); + } + + /** + * Returns the positive decimal representation of a binary number. + * + * @param string $bytes The bytes representing the number. + */ + private function toDecimal(string $bytes) : string + { + $result = '0'; + $power = '1'; + + for ($i = \strlen($bytes) - 1; $i >= 0; $i--) { + $index = \ord($bytes[$i]); + + if ($index !== 0) { + $result = $this->add($result, ($index === 1) + ? $power + : $this->mul($power, (string) $index) + ); + } + + if ($i !== 0) { + $power = $this->mul($power, '256'); + } + } + + return $result; + } +} diff --git a/vendor/brick/math/src/Internal/Calculator/BcMathCalculator.php b/vendor/brick/math/src/Internal/Calculator/BcMathCalculator.php new file mode 100644 index 0000000..5457a3c --- /dev/null +++ b/vendor/brick/math/src/Internal/Calculator/BcMathCalculator.php @@ -0,0 +1,75 @@ +maxDigits = 9; + break; + + case 8: + $this->maxDigits = 18; + break; + + default: + throw new \RuntimeException('The platform is not 32-bit or 64-bit as expected.'); + } + } + + public function add(string $a, string $b) : string + { + /** + * @psalm-var numeric-string $a + * @psalm-var numeric-string $b + */ + $result = $a + $b; + + if (is_int($result)) { + return (string) $result; + } + + if ($a === '0') { + return $b; + } + + if ($b === '0') { + return $a; + } + + [$aNeg, $bNeg, $aDig, $bDig] = $this->init($a, $b); + + $result = $aNeg === $bNeg ? $this->doAdd($aDig, $bDig) : $this->doSub($aDig, $bDig); + + if ($aNeg) { + $result = $this->neg($result); + } + + return $result; + } + + public function sub(string $a, string $b) : string + { + return $this->add($a, $this->neg($b)); + } + + public function mul(string $a, string $b) : string + { + /** + * @psalm-var numeric-string $a + * @psalm-var numeric-string $b + */ + $result = $a * $b; + + if (is_int($result)) { + return (string) $result; + } + + if ($a === '0' || $b === '0') { + return '0'; + } + + if ($a === '1') { + return $b; + } + + if ($b === '1') { + return $a; + } + + if ($a === '-1') { + return $this->neg($b); + } + + if ($b === '-1') { + return $this->neg($a); + } + + [$aNeg, $bNeg, $aDig, $bDig] = $this->init($a, $b); + + $result = $this->doMul($aDig, $bDig); + + if ($aNeg !== $bNeg) { + $result = $this->neg($result); + } + + return $result; + } + + public function divQ(string $a, string $b) : string + { + return $this->divQR($a, $b)[0]; + } + + public function divR(string $a, string $b): string + { + return $this->divQR($a, $b)[1]; + } + + public function divQR(string $a, string $b) : array + { + if ($a === '0') { + return ['0', '0']; + } + + if ($a === $b) { + return ['1', '0']; + } + + if ($b === '1') { + return [$a, '0']; + } + + if ($b === '-1') { + return [$this->neg($a), '0']; + } + + /** @psalm-var numeric-string $a */ + $na = $a * 1; // cast to number + + if (is_int($na)) { + /** @psalm-var numeric-string $b */ + $nb = $b * 1; + + if (is_int($nb)) { + // the only division that may overflow is PHP_INT_MIN / -1, + // which cannot happen here as we've already handled a divisor of -1 above. + $r = $na % $nb; + $q = ($na - $r) / $nb; + + assert(is_int($q)); + + return [ + (string) $q, + (string) $r + ]; + } + } + + [$aNeg, $bNeg, $aDig, $bDig] = $this->init($a, $b); + + [$q, $r] = $this->doDiv($aDig, $bDig); + + if ($aNeg !== $bNeg) { + $q = $this->neg($q); + } + + if ($aNeg) { + $r = $this->neg($r); + } + + return [$q, $r]; + } + + public function pow(string $a, int $e) : string + { + if ($e === 0) { + return '1'; + } + + if ($e === 1) { + return $a; + } + + $odd = $e % 2; + $e -= $odd; + + $aa = $this->mul($a, $a); + + /** @psalm-suppress PossiblyInvalidArgument We're sure that $e / 2 is an int now */ + $result = $this->pow($aa, $e / 2); + + if ($odd === 1) { + $result = $this->mul($result, $a); + } + + return $result; + } + + /** + * Algorithm from: https://www.geeksforgeeks.org/modular-exponentiation-power-in-modular-arithmetic/ + */ + public function modPow(string $base, string $exp, string $mod) : string + { + // special case: the algorithm below fails with 0 power 0 mod 1 (returns 1 instead of 0) + if ($base === '0' && $exp === '0' && $mod === '1') { + return '0'; + } + + // special case: the algorithm below fails with power 0 mod 1 (returns 1 instead of 0) + if ($exp === '0' && $mod === '1') { + return '0'; + } + + $x = $base; + + $res = '1'; + + // numbers are positive, so we can use remainder instead of modulo + $x = $this->divR($x, $mod); + + while ($exp !== '0') { + if (in_array($exp[-1], ['1', '3', '5', '7', '9'])) { // odd + $res = $this->divR($this->mul($res, $x), $mod); + } + + $exp = $this->divQ($exp, '2'); + $x = $this->divR($this->mul($x, $x), $mod); + } + + return $res; + } + + /** + * Adapted from https://cp-algorithms.com/num_methods/roots_newton.html + */ + public function sqrt(string $n) : string + { + if ($n === '0') { + return '0'; + } + + // initial approximation + $x = \str_repeat('9', \intdiv(\strlen($n), 2) ?: 1); + + $decreased = false; + + for (;;) { + $nx = $this->divQ($this->add($x, $this->divQ($n, $x)), '2'); + + if ($x === $nx || $this->cmp($nx, $x) > 0 && $decreased) { + break; + } + + $decreased = $this->cmp($nx, $x) < 0; + $x = $nx; + } + + return $x; + } + + /** + * Performs the addition of two non-signed large integers. + */ + private function doAdd(string $a, string $b) : string + { + [$a, $b, $length] = $this->pad($a, $b); + + $carry = 0; + $result = ''; + + for ($i = $length - $this->maxDigits;; $i -= $this->maxDigits) { + $blockLength = $this->maxDigits; + + if ($i < 0) { + $blockLength += $i; + /** @psalm-suppress LoopInvalidation */ + $i = 0; + } + + /** @psalm-var numeric-string $blockA */ + $blockA = \substr($a, $i, $blockLength); + + /** @psalm-var numeric-string $blockB */ + $blockB = \substr($b, $i, $blockLength); + + $sum = (string) ($blockA + $blockB + $carry); + $sumLength = \strlen($sum); + + if ($sumLength > $blockLength) { + $sum = \substr($sum, 1); + $carry = 1; + } else { + if ($sumLength < $blockLength) { + $sum = \str_repeat('0', $blockLength - $sumLength) . $sum; + } + $carry = 0; + } + + $result = $sum . $result; + + if ($i === 0) { + break; + } + } + + if ($carry === 1) { + $result = '1' . $result; + } + + return $result; + } + + /** + * Performs the subtraction of two non-signed large integers. + */ + private function doSub(string $a, string $b) : string + { + if ($a === $b) { + return '0'; + } + + // Ensure that we always subtract to a positive result: biggest minus smallest. + $cmp = $this->doCmp($a, $b); + + $invert = ($cmp === -1); + + if ($invert) { + $c = $a; + $a = $b; + $b = $c; + } + + [$a, $b, $length] = $this->pad($a, $b); + + $carry = 0; + $result = ''; + + $complement = 10 ** $this->maxDigits; + + for ($i = $length - $this->maxDigits;; $i -= $this->maxDigits) { + $blockLength = $this->maxDigits; + + if ($i < 0) { + $blockLength += $i; + /** @psalm-suppress LoopInvalidation */ + $i = 0; + } + + /** @psalm-var numeric-string $blockA */ + $blockA = \substr($a, $i, $blockLength); + + /** @psalm-var numeric-string $blockB */ + $blockB = \substr($b, $i, $blockLength); + + $sum = $blockA - $blockB - $carry; + + if ($sum < 0) { + $sum += $complement; + $carry = 1; + } else { + $carry = 0; + } + + $sum = (string) $sum; + $sumLength = \strlen($sum); + + if ($sumLength < $blockLength) { + $sum = \str_repeat('0', $blockLength - $sumLength) . $sum; + } + + $result = $sum . $result; + + if ($i === 0) { + break; + } + } + + // Carry cannot be 1 when the loop ends, as a > b + assert($carry === 0); + + $result = \ltrim($result, '0'); + + if ($invert) { + $result = $this->neg($result); + } + + return $result; + } + + /** + * Performs the multiplication of two non-signed large integers. + */ + private function doMul(string $a, string $b) : string + { + $x = \strlen($a); + $y = \strlen($b); + + $maxDigits = \intdiv($this->maxDigits, 2); + $complement = 10 ** $maxDigits; + + $result = '0'; + + for ($i = $x - $maxDigits;; $i -= $maxDigits) { + $blockALength = $maxDigits; + + if ($i < 0) { + $blockALength += $i; + /** @psalm-suppress LoopInvalidation */ + $i = 0; + } + + $blockA = (int) \substr($a, $i, $blockALength); + + $line = ''; + $carry = 0; + + for ($j = $y - $maxDigits;; $j -= $maxDigits) { + $blockBLength = $maxDigits; + + if ($j < 0) { + $blockBLength += $j; + /** @psalm-suppress LoopInvalidation */ + $j = 0; + } + + $blockB = (int) \substr($b, $j, $blockBLength); + + $mul = $blockA * $blockB + $carry; + $value = $mul % $complement; + $carry = ($mul - $value) / $complement; + + $value = (string) $value; + $value = \str_pad($value, $maxDigits, '0', STR_PAD_LEFT); + + $line = $value . $line; + + if ($j === 0) { + break; + } + } + + if ($carry !== 0) { + $line = $carry . $line; + } + + $line = \ltrim($line, '0'); + + if ($line !== '') { + $line .= \str_repeat('0', $x - $blockALength - $i); + $result = $this->add($result, $line); + } + + if ($i === 0) { + break; + } + } + + return $result; + } + + /** + * Performs the division of two non-signed large integers. + * + * @return string[] The quotient and remainder. + */ + private function doDiv(string $a, string $b) : array + { + $cmp = $this->doCmp($a, $b); + + if ($cmp === -1) { + return ['0', $a]; + } + + $x = \strlen($a); + $y = \strlen($b); + + // we now know that a >= b && x >= y + + $q = '0'; // quotient + $r = $a; // remainder + $z = $y; // focus length, always $y or $y+1 + + for (;;) { + $focus = \substr($a, 0, $z); + + $cmp = $this->doCmp($focus, $b); + + if ($cmp === -1) { + if ($z === $x) { // remainder < dividend + break; + } + + $z++; + } + + $zeros = \str_repeat('0', $x - $z); + + $q = $this->add($q, '1' . $zeros); + $a = $this->sub($a, $b . $zeros); + + $r = $a; + + if ($r === '0') { // remainder == 0 + break; + } + + $x = \strlen($a); + + if ($x < $y) { // remainder < dividend + break; + } + + $z = $y; + } + + return [$q, $r]; + } + + /** + * Compares two non-signed large numbers. + * + * @return int [-1, 0, 1] + */ + private function doCmp(string $a, string $b) : int + { + $x = \strlen($a); + $y = \strlen($b); + + $cmp = $x <=> $y; + + if ($cmp !== 0) { + return $cmp; + } + + return \strcmp($a, $b) <=> 0; // enforce [-1, 0, 1] + } + + /** + * Pads the left of one of the given numbers with zeros if necessary to make both numbers the same length. + * + * The numbers must only consist of digits, without leading minus sign. + * + * @return array{string, string, int} + */ + private function pad(string $a, string $b) : array + { + $x = \strlen($a); + $y = \strlen($b); + + if ($x > $y) { + $b = \str_repeat('0', $x - $y) . $b; + + return [$a, $b, $x]; + } + + if ($x < $y) { + $a = \str_repeat('0', $y - $x) . $a; + + return [$a, $b, $y]; + } + + return [$a, $b, $x]; + } +} diff --git a/vendor/brick/math/src/RoundingMode.php b/vendor/brick/math/src/RoundingMode.php new file mode 100644 index 0000000..06936d8 --- /dev/null +++ b/vendor/brick/math/src/RoundingMode.php @@ -0,0 +1,107 @@ += 0.5; otherwise, behaves as for DOWN. + * Note that this is the rounding mode commonly taught at school. + */ + public const HALF_UP = 5; + + /** + * Rounds towards "nearest neighbor" unless both neighbors are equidistant, in which case round down. + * + * Behaves as for UP if the discarded fraction is > 0.5; otherwise, behaves as for DOWN. + */ + public const HALF_DOWN = 6; + + /** + * Rounds towards "nearest neighbor" unless both neighbors are equidistant, in which case round towards positive infinity. + * + * If the result is positive, behaves as for HALF_UP; if negative, behaves as for HALF_DOWN. + */ + public const HALF_CEILING = 7; + + /** + * Rounds towards "nearest neighbor" unless both neighbors are equidistant, in which case round towards negative infinity. + * + * If the result is positive, behaves as for HALF_DOWN; if negative, behaves as for HALF_UP. + */ + public const HALF_FLOOR = 8; + + /** + * Rounds towards the "nearest neighbor" unless both neighbors are equidistant, in which case rounds towards the even neighbor. + * + * Behaves as for HALF_UP if the digit to the left of the discarded fraction is odd; + * behaves as for HALF_DOWN if it's even. + * + * Note that this is the rounding mode that statistically minimizes + * cumulative error when applied repeatedly over a sequence of calculations. + * It is sometimes known as "Banker's rounding", and is chiefly used in the USA. + */ + public const HALF_EVEN = 9; +} diff --git a/vendor/composer/ClassLoader.php b/vendor/composer/ClassLoader.php index afef3fa..a72151c 100644 --- a/vendor/composer/ClassLoader.php +++ b/vendor/composer/ClassLoader.php @@ -42,6 +42,9 @@ namespace Composer\Autoload; */ class ClassLoader { + /** @var \Closure(string):void */ + private static $includeFile; + /** @var ?string */ private $vendorDir; @@ -106,6 +109,7 @@ class ClassLoader public function __construct($vendorDir = null) { $this->vendorDir = $vendorDir; + self::initializeIncludeClosure(); } /** @@ -425,7 +429,8 @@ class ClassLoader public function loadClass($class) { if ($file = $this->findFile($class)) { - includeFile($file); + $includeFile = self::$includeFile; + $includeFile($file); return true; } @@ -555,18 +560,26 @@ class ClassLoader return false; } -} -/** - * Scope isolated include. - * - * Prevents access to $this/self from included files. - * - * @param string $file - * @return void - * @private - */ -function includeFile($file) -{ - include $file; + /** + * @return void + */ + private static function initializeIncludeClosure() + { + if (self::$includeFile !== null) { + return; + } + + /** + * Scope isolated include. + * + * Prevents access to $this/self from included files. + * + * @param string $file + * @return void + */ + self::$includeFile = \Closure::bind(static function($file) { + include $file; + }, null, null); + } } diff --git a/vendor/composer/InstalledVersions.php b/vendor/composer/InstalledVersions.php index d50e0c9..c6b54af 100644 --- a/vendor/composer/InstalledVersions.php +++ b/vendor/composer/InstalledVersions.php @@ -21,12 +21,14 @@ use Composer\Semver\VersionParser; * See also https://getcomposer.org/doc/07-runtime.md#installed-versions * * To require its presence, you can require `composer-runtime-api ^2.0` + * + * @final */ class InstalledVersions { /** * @var mixed[]|null - * @psalm-var array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array}|array{}|null + * @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array}|array{}|null */ private static $installed; @@ -37,7 +39,7 @@ class InstalledVersions /** * @var array[] - * @psalm-var array}> + * @psalm-var array}> */ private static $installedByVendor = array(); @@ -241,7 +243,7 @@ class InstalledVersions /** * @return array - * @psalm-return array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string} + * @psalm-return array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool} */ public static function getRootPackage() { @@ -255,7 +257,7 @@ class InstalledVersions * * @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect. * @return array[] - * @psalm-return array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array} + * @psalm-return array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} */ public static function getRawData() { @@ -278,7 +280,7 @@ class InstalledVersions * Returns the raw data of all installed.php which are currently loaded for custom implementations * * @return array[] - * @psalm-return list}> + * @psalm-return list}> */ public static function getAllRawData() { @@ -301,7 +303,7 @@ class InstalledVersions * @param array[] $data A vendor/composer/installed.php data set * @return void * - * @psalm-param array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array} $data + * @psalm-param array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $data */ public static function reload($data) { @@ -311,7 +313,7 @@ class InstalledVersions /** * @return array[] - * @psalm-return list}> + * @psalm-return list}> */ private static function getInstalled() { diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php index 53268f2..cae0fc2 100644 --- a/vendor/composer/autoload_classmap.php +++ b/vendor/composer/autoload_classmap.php @@ -2,7 +2,7 @@ // autoload_classmap.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( diff --git a/vendor/composer/autoload_files.php b/vendor/composer/autoload_files.php index 27d1e41..86a7fd1 100644 --- a/vendor/composer/autoload_files.php +++ b/vendor/composer/autoload_files.php @@ -2,18 +2,19 @@ // autoload_files.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php', + '60799491728b879e74601d83e38b2cad' => $vendorDir . '/illuminate/collections/helpers.php', '320cde22f66dd4f5d3fd621d3e88b98f' => $vendorDir . '/symfony/polyfill-ctype/bootstrap.php', '8825ede83f2f289127722d4e842cf7e8' => $vendorDir . '/symfony/polyfill-intl-grapheme/bootstrap.php', 'e69f7f6ee287b969198c3c9d6777bd38' => $vendorDir . '/symfony/polyfill-intl-normalizer/bootstrap.php', - 'b6b991a57620e2fb6b2f66f03fe9ddc2' => $vendorDir . '/symfony/string/Resources/functions.php', - '60799491728b879e74601d83e38b2cad' => $vendorDir . '/illuminate/collections/helpers.php', 'a4a119a56e50fbb293281d9a48007e0e' => $vendorDir . '/symfony/polyfill-php80/bootstrap.php', 'a1105708a18b76903365ca1c4aa61b02' => $vendorDir . '/symfony/translation/Resources/functions.php', + '6e3fae29631ef280660b3cdad06f25a8' => $vendorDir . '/symfony/deprecation-contracts/function.php', + 'b6b991a57620e2fb6b2f66f03fe9ddc2' => $vendorDir . '/symfony/string/Resources/functions.php', '72579e7bd17821bb1321b87411366eae' => $vendorDir . '/illuminate/support/helpers.php', 'b6ec61354e97f32c0ae683041c78392a' => $vendorDir . '/scrivo/highlight.php/HighlightUtilities/functions.php', ); diff --git a/vendor/composer/autoload_namespaces.php b/vendor/composer/autoload_namespaces.php index 1a6b3c3..edba334 100644 --- a/vendor/composer/autoload_namespaces.php +++ b/vendor/composer/autoload_namespaces.php @@ -2,7 +2,7 @@ // autoload_namespaces.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( diff --git a/vendor/composer/autoload_psr4.php b/vendor/composer/autoload_psr4.php index c1eeded..0e17613 100644 --- a/vendor/composer/autoload_psr4.php +++ b/vendor/composer/autoload_psr4.php @@ -2,7 +2,7 @@ // autoload_psr4.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( @@ -20,10 +20,11 @@ return array( 'Psr\\SimpleCache\\' => array($vendorDir . '/psr/simple-cache/src'), 'Psr\\Container\\' => array($vendorDir . '/psr/container/src'), 'PonePaste\\' => array($baseDir . '/includes'), - 'Illuminate\\Support\\' => array($vendorDir . '/illuminate/collections', $vendorDir . '/illuminate/conditionable', $vendorDir . '/illuminate/macroable', $vendorDir . '/illuminate/support'), + 'Illuminate\\Support\\' => array($vendorDir . '/illuminate/macroable', $vendorDir . '/illuminate/conditionable', $vendorDir . '/illuminate/collections', $vendorDir . '/illuminate/support'), 'Illuminate\\Database\\' => array($vendorDir . '/illuminate/database'), 'Illuminate\\Contracts\\' => array($vendorDir . '/illuminate/contracts'), 'Illuminate\\Container\\' => array($vendorDir . '/illuminate/container'), 'Doctrine\\Inflector\\' => array($vendorDir . '/doctrine/inflector/lib/Doctrine/Inflector'), 'Carbon\\' => array($vendorDir . '/nesbot/carbon/src/Carbon'), + 'Brick\\Math\\' => array($vendorDir . '/brick/math/src'), ); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index 3f53fab..12b9ee8 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -25,56 +25,26 @@ class ComposerAutoloaderInit5bf95489f4eff2c10ec062bf7ba377da require __DIR__ . '/platform_check.php'; spl_autoload_register(array('ComposerAutoloaderInit5bf95489f4eff2c10ec062bf7ba377da', 'loadClassLoader'), true, true); - self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__))); + self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); spl_autoload_unregister(array('ComposerAutoloaderInit5bf95489f4eff2c10ec062bf7ba377da', 'loadClassLoader')); - $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); - if ($useStaticLoader) { - require __DIR__ . '/autoload_static.php'; - - call_user_func(\Composer\Autoload\ComposerStaticInit5bf95489f4eff2c10ec062bf7ba377da::getInitializer($loader)); - } else { - $map = require __DIR__ . '/autoload_namespaces.php'; - foreach ($map as $namespace => $path) { - $loader->set($namespace, $path); - } - - $map = require __DIR__ . '/autoload_psr4.php'; - foreach ($map as $namespace => $path) { - $loader->setPsr4($namespace, $path); - } - - $classMap = require __DIR__ . '/autoload_classmap.php'; - if ($classMap) { - $loader->addClassMap($classMap); - } - } + require __DIR__ . '/autoload_static.php'; + call_user_func(\Composer\Autoload\ComposerStaticInit5bf95489f4eff2c10ec062bf7ba377da::getInitializer($loader)); $loader->register(true); - if ($useStaticLoader) { - $includeFiles = Composer\Autoload\ComposerStaticInit5bf95489f4eff2c10ec062bf7ba377da::$files; - } else { - $includeFiles = require __DIR__ . '/autoload_files.php'; - } - foreach ($includeFiles as $fileIdentifier => $file) { - composerRequire5bf95489f4eff2c10ec062bf7ba377da($fileIdentifier, $file); + $filesToLoad = \Composer\Autoload\ComposerStaticInit5bf95489f4eff2c10ec062bf7ba377da::$files; + $requireFile = \Closure::bind(static function ($fileIdentifier, $file) { + if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { + $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; + + require $file; + } + }, null, null); + foreach ($filesToLoad as $fileIdentifier => $file) { + $requireFile($fileIdentifier, $file); } return $loader; } } - -/** - * @param string $fileIdentifier - * @param string $file - * @return void - */ -function composerRequire5bf95489f4eff2c10ec062bf7ba377da($fileIdentifier, $file) -{ - if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { - $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; - - require $file; - } -} diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 10a5be8..4b70215 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -8,13 +8,14 @@ class ComposerStaticInit5bf95489f4eff2c10ec062bf7ba377da { public static $files = array ( '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php', + '60799491728b879e74601d83e38b2cad' => __DIR__ . '/..' . '/illuminate/collections/helpers.php', '320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php', '8825ede83f2f289127722d4e842cf7e8' => __DIR__ . '/..' . '/symfony/polyfill-intl-grapheme/bootstrap.php', 'e69f7f6ee287b969198c3c9d6777bd38' => __DIR__ . '/..' . '/symfony/polyfill-intl-normalizer/bootstrap.php', - 'b6b991a57620e2fb6b2f66f03fe9ddc2' => __DIR__ . '/..' . '/symfony/string/Resources/functions.php', - '60799491728b879e74601d83e38b2cad' => __DIR__ . '/..' . '/illuminate/collections/helpers.php', 'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php', 'a1105708a18b76903365ca1c4aa61b02' => __DIR__ . '/..' . '/symfony/translation/Resources/functions.php', + '6e3fae29631ef280660b3cdad06f25a8' => __DIR__ . '/..' . '/symfony/deprecation-contracts/function.php', + 'b6b991a57620e2fb6b2f66f03fe9ddc2' => __DIR__ . '/..' . '/symfony/string/Resources/functions.php', '72579e7bd17821bb1321b87411366eae' => __DIR__ . '/..' . '/illuminate/support/helpers.php', 'b6ec61354e97f32c0ae683041c78392a' => __DIR__ . '/..' . '/scrivo/highlight.php/HighlightUtilities/functions.php', ); @@ -58,6 +59,10 @@ class ComposerStaticInit5bf95489f4eff2c10ec062bf7ba377da array ( 'Carbon\\' => 7, ), + 'B' => + array ( + 'Brick\\Math\\' => 11, + ), ); public static $prefixDirsPsr4 = array ( @@ -119,9 +124,9 @@ class ComposerStaticInit5bf95489f4eff2c10ec062bf7ba377da ), 'Illuminate\\Support\\' => array ( - 0 => __DIR__ . '/..' . '/illuminate/collections', + 0 => __DIR__ . '/..' . '/illuminate/macroable', 1 => __DIR__ . '/..' . '/illuminate/conditionable', - 2 => __DIR__ . '/..' . '/illuminate/macroable', + 2 => __DIR__ . '/..' . '/illuminate/collections', 3 => __DIR__ . '/..' . '/illuminate/support', ), 'Illuminate\\Database\\' => @@ -144,6 +149,10 @@ class ComposerStaticInit5bf95489f4eff2c10ec062bf7ba377da array ( 0 => __DIR__ . '/..' . '/nesbot/carbon/src/Carbon', ), + 'Brick\\Math\\' => + array ( + 0 => __DIR__ . '/..' . '/brick/math/src', + ), ); public static $prefixesPsr0 = array ( diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 7cca9bf..0a17f7b 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -1,32 +1,90 @@ { "packages": [ { - "name": "doctrine/inflector", - "version": "2.0.4", - "version_normalized": "2.0.4.0", + "name": "brick/math", + "version": "0.11.0", + "version_normalized": "0.11.0.0", "source": { "type": "git", - "url": "https://github.com/doctrine/inflector.git", - "reference": "8b7ff3e4b7de6b2c84da85637b59fd2880ecaa89" + "url": "https://github.com/brick/math.git", + "reference": "0ad82ce168c82ba30d1c01ec86116ab52f589478" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/inflector/zipball/8b7ff3e4b7de6b2c84da85637b59fd2880ecaa89", - "reference": "8b7ff3e4b7de6b2c84da85637b59fd2880ecaa89", + "url": "https://api.github.com/repos/brick/math/zipball/0ad82ce168c82ba30d1c01ec86116ab52f589478", + "reference": "0ad82ce168c82ba30d1c01ec86116ab52f589478", + "shasum": "" + }, + "require": { + "php": "^8.0" + }, + "require-dev": { + "php-coveralls/php-coveralls": "^2.2", + "phpunit/phpunit": "^9.0", + "vimeo/psalm": "5.0.0" + }, + "time": "2023-01-15T23:15:59+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "Brick\\Math\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Arbitrary-precision arithmetic library", + "keywords": [ + "Arbitrary-precision", + "BigInteger", + "BigRational", + "arithmetic", + "bigdecimal", + "bignum", + "brick", + "math" + ], + "support": { + "issues": "https://github.com/brick/math/issues", + "source": "https://github.com/brick/math/tree/0.11.0" + }, + "funding": [ + { + "url": "https://github.com/BenMorel", + "type": "github" + } + ], + "install-path": "../brick/math" + }, + { + "name": "doctrine/inflector", + "version": "2.0.6", + "version_normalized": "2.0.6.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/inflector.git", + "reference": "d9d313a36c872fd6ee06d9a6cbcf713eaa40f024" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/inflector/zipball/d9d313a36c872fd6ee06d9a6cbcf713eaa40f024", + "reference": "d9d313a36c872fd6ee06d9a6cbcf713eaa40f024", "shasum": "" }, "require": { "php": "^7.2 || ^8.0" }, "require-dev": { - "doctrine/coding-standard": "^8.2", - "phpstan/phpstan": "^0.12", - "phpstan/phpstan-phpunit": "^0.12", - "phpstan/phpstan-strict-rules": "^0.12", - "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0", - "vimeo/psalm": "^4.10" + "doctrine/coding-standard": "^10", + "phpstan/phpstan": "^1.8", + "phpstan/phpstan-phpunit": "^1.1", + "phpstan/phpstan-strict-rules": "^1.3", + "phpunit/phpunit": "^8.5 || ^9.5", + "vimeo/psalm": "^4.25" }, - "time": "2021-10-22T20:16:43+00:00", + "time": "2022-10-20T09:10:12+00:00", "type": "library", "installation-source": "dist", "autoload": { @@ -76,7 +134,7 @@ ], "support": { "issues": "https://github.com/doctrine/inflector/issues", - "source": "https://github.com/doctrine/inflector/tree/2.0.4" + "source": "https://github.com/doctrine/inflector/tree/2.0.6" }, "funding": [ { @@ -149,17 +207,17 @@ }, { "name": "illuminate/collections", - "version": "v9.4.1", - "version_normalized": "9.4.1.0", + "version": "v9.52.4", + "version_normalized": "9.52.4.0", "source": { "type": "git", "url": "https://github.com/illuminate/collections.git", - "reference": "22c4bb17f4e6c6fb470b5957e8232b1b5baf76b0" + "reference": "0168d0e44ea0c4fe5451fe08cde7049b9e9f9741" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/collections/zipball/22c4bb17f4e6c6fb470b5957e8232b1b5baf76b0", - "reference": "22c4bb17f4e6c6fb470b5957e8232b1b5baf76b0", + "url": "https://api.github.com/repos/illuminate/collections/zipball/0168d0e44ea0c4fe5451fe08cde7049b9e9f9741", + "reference": "0168d0e44ea0c4fe5451fe08cde7049b9e9f9741", "shasum": "" }, "require": { @@ -171,7 +229,7 @@ "suggest": { "symfony/var-dumper": "Required to use the dump method (^6.0)." }, - "time": "2022-03-07T15:02:25+00:00", + "time": "2023-02-22T11:32:27+00:00", "type": "library", "extra": { "branch-alias": { @@ -207,23 +265,23 @@ }, { "name": "illuminate/conditionable", - "version": "v9.4.1", - "version_normalized": "9.4.1.0", + "version": "v9.52.4", + "version_normalized": "9.52.4.0", "source": { "type": "git", "url": "https://github.com/illuminate/conditionable.git", - "reference": "56b4ba1166c264064bf63896f498a2bee320d16a" + "reference": "bea24daa0fa84b7e7b0d5b84f62c71b7e2dc3364" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/conditionable/zipball/56b4ba1166c264064bf63896f498a2bee320d16a", - "reference": "56b4ba1166c264064bf63896f498a2bee320d16a", + "url": "https://api.github.com/repos/illuminate/conditionable/zipball/bea24daa0fa84b7e7b0d5b84f62c71b7e2dc3364", + "reference": "bea24daa0fa84b7e7b0d5b84f62c71b7e2dc3364", "shasum": "" }, "require": { "php": "^8.0.2" }, - "time": "2022-02-28T16:37:46+00:00", + "time": "2023-02-01T21:42:32+00:00", "type": "library", "extra": { "branch-alias": { @@ -256,17 +314,17 @@ }, { "name": "illuminate/container", - "version": "v9.4.1", - "version_normalized": "9.4.1.0", + "version": "v9.52.4", + "version_normalized": "9.52.4.0", "source": { "type": "git", "url": "https://github.com/illuminate/container.git", - "reference": "66f9049b19fb34e74134c6eeff92a442cee068e5" + "reference": "1641dda2d0750b68bb1264a3b37ff3973f2e6265" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/container/zipball/66f9049b19fb34e74134c6eeff92a442cee068e5", - "reference": "66f9049b19fb34e74134c6eeff92a442cee068e5", + "url": "https://api.github.com/repos/illuminate/container/zipball/1641dda2d0750b68bb1264a3b37ff3973f2e6265", + "reference": "1641dda2d0750b68bb1264a3b37ff3973f2e6265", "shasum": "" }, "require": { @@ -277,7 +335,7 @@ "provide": { "psr/container-implementation": "1.1|2.0" }, - "time": "2022-03-03T14:08:19+00:00", + "time": "2023-01-24T16:54:18+00:00", "type": "library", "extra": { "branch-alias": { @@ -310,17 +368,17 @@ }, { "name": "illuminate/contracts", - "version": "v9.4.1", - "version_normalized": "9.4.1.0", + "version": "v9.52.4", + "version_normalized": "9.52.4.0", "source": { "type": "git", "url": "https://github.com/illuminate/contracts.git", - "reference": "ce68106c575410c71f92ac1c91c5d95c561033bc" + "reference": "44f65d723b13823baa02ff69751a5948bde60c22" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/contracts/zipball/ce68106c575410c71f92ac1c91c5d95c561033bc", - "reference": "ce68106c575410c71f92ac1c91c5d95c561033bc", + "url": "https://api.github.com/repos/illuminate/contracts/zipball/44f65d723b13823baa02ff69751a5948bde60c22", + "reference": "44f65d723b13823baa02ff69751a5948bde60c22", "shasum": "" }, "require": { @@ -328,7 +386,7 @@ "psr/container": "^1.1.1|^2.0.1", "psr/simple-cache": "^1.0|^2.0|^3.0" }, - "time": "2022-03-04T18:18:32+00:00", + "time": "2023-02-08T14:36:30+00:00", "type": "library", "extra": { "branch-alias": { @@ -361,39 +419,41 @@ }, { "name": "illuminate/database", - "version": "v9.4.1", - "version_normalized": "9.4.1.0", + "version": "v9.52.4", + "version_normalized": "9.52.4.0", "source": { "type": "git", "url": "https://github.com/illuminate/database.git", - "reference": "0fffd6ba91eb58330cbf7331c77ea38c2a16b5d9" + "reference": "fc7e9cf5d4c7c4c0a2800c0d345cc9985fb1b040" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/database/zipball/0fffd6ba91eb58330cbf7331c77ea38c2a16b5d9", - "reference": "0fffd6ba91eb58330cbf7331c77ea38c2a16b5d9", + "url": "https://api.github.com/repos/illuminate/database/zipball/fc7e9cf5d4c7c4c0a2800c0d345cc9985fb1b040", + "reference": "fc7e9cf5d4c7c4c0a2800c0d345cc9985fb1b040", "shasum": "" }, "require": { - "ext-json": "*", + "brick/math": "^0.9.3|^0.10.2|^0.11", + "ext-pdo": "*", "illuminate/collections": "^9.0", "illuminate/container": "^9.0", "illuminate/contracts": "^9.0", "illuminate/macroable": "^9.0", "illuminate/support": "^9.0", "php": "^8.0.2", - "symfony/console": "^6.0" + "symfony/console": "^6.0.9" }, "suggest": { "doctrine/dbal": "Required to rename columns and drop SQLite columns (^2.13.3|^3.1.4).", - "fakerphp/faker": "Required to use the eloquent factory builder (^1.9.1).", + "ext-filter": "Required to use the Postgres database driver.", + "fakerphp/faker": "Required to use the eloquent factory builder (^1.21).", "illuminate/console": "Required to use the database commands (^9.0).", "illuminate/events": "Required to use the observers with Eloquent (^9.0).", "illuminate/filesystem": "Required to use the migrations (^9.0).", "illuminate/pagination": "Required to paginate the result set (^9.0).", "symfony/finder": "Required to use Eloquent model factories (^6.0)." }, - "time": "2022-03-07T01:28:38+00:00", + "time": "2023-02-12T20:16:50+00:00", "type": "library", "extra": { "branch-alias": { @@ -432,23 +492,23 @@ }, { "name": "illuminate/macroable", - "version": "v9.4.1", - "version_normalized": "9.4.1.0", + "version": "v9.52.4", + "version_normalized": "9.52.4.0", "source": { "type": "git", "url": "https://github.com/illuminate/macroable.git", - "reference": "25a2c6dac2b7541ecbadef952702e84ae15f5354" + "reference": "e3bfaf6401742a9c6abca61b9b10e998e5b6449a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/macroable/zipball/25a2c6dac2b7541ecbadef952702e84ae15f5354", - "reference": "25a2c6dac2b7541ecbadef952702e84ae15f5354", + "url": "https://api.github.com/repos/illuminate/macroable/zipball/e3bfaf6401742a9c6abca61b9b10e998e5b6449a", + "reference": "e3bfaf6401742a9c6abca61b9b10e998e5b6449a", "shasum": "" }, "require": { "php": "^8.0.2" }, - "time": "2022-02-01T14:44:21+00:00", + "time": "2022-08-09T13:29:29+00:00", "type": "library", "extra": { "branch-alias": { @@ -481,28 +541,29 @@ }, { "name": "illuminate/support", - "version": "v9.4.1", - "version_normalized": "9.4.1.0", + "version": "v9.52.4", + "version_normalized": "9.52.4.0", "source": { "type": "git", "url": "https://github.com/illuminate/support.git", - "reference": "568ed7a21a75e0bd9ca641b6c4a626872ee26d6f" + "reference": "63dcb4523ccdfc01cdf5be17791f07cc20982a1e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/support/zipball/568ed7a21a75e0bd9ca641b6c4a626872ee26d6f", - "reference": "568ed7a21a75e0bd9ca641b6c4a626872ee26d6f", + "url": "https://api.github.com/repos/illuminate/support/zipball/63dcb4523ccdfc01cdf5be17791f07cc20982a1e", + "reference": "63dcb4523ccdfc01cdf5be17791f07cc20982a1e", "shasum": "" }, "require": { "doctrine/inflector": "^2.0", - "ext-json": "*", + "ext-ctype": "*", + "ext-filter": "*", "ext-mbstring": "*", "illuminate/collections": "^9.0", "illuminate/conditionable": "^9.0", "illuminate/contracts": "^9.0", "illuminate/macroable": "^9.0", - "nesbot/carbon": "^2.53.1", + "nesbot/carbon": "^2.62.1", "php": "^8.0.2", "voku/portable-ascii": "^2.0" }, @@ -512,12 +573,13 @@ "suggest": { "illuminate/filesystem": "Required to use the composer class (^9.0).", "league/commonmark": "Required to use Str::markdown() and Stringable::markdown() (^2.0.2).", - "ramsey/uuid": "Required to use Str::uuid() (^4.2.2).", + "ramsey/uuid": "Required to use Str::uuid() (^4.7).", "symfony/process": "Required to use the composer class (^6.0).", + "symfony/uid": "Required to use Str::ulid() (^6.0).", "symfony/var-dumper": "Required to use the dd function (^6.0).", "vlucas/phpdotenv": "Required to use the Env class and env helper (^5.4.1)." }, - "time": "2022-03-08T14:39:38+00:00", + "time": "2023-02-13T16:54:43+00:00", "type": "library", "extra": { "branch-alias": { @@ -553,17 +615,17 @@ }, { "name": "nesbot/carbon", - "version": "2.57.0", - "version_normalized": "2.57.0.0", + "version": "2.66.0", + "version_normalized": "2.66.0.0", "source": { "type": "git", "url": "https://github.com/briannesbitt/Carbon.git", - "reference": "4a54375c21eea4811dbd1149fe6b246517554e78" + "reference": "496712849902241f04902033b0441b269effe001" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/4a54375c21eea4811dbd1149fe6b246517554e78", - "reference": "4a54375c21eea4811dbd1149fe6b246517554e78", + "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/496712849902241f04902033b0441b269effe001", + "reference": "496712849902241f04902033b0441b269effe001", "shasum": "" }, "require": { @@ -574,17 +636,19 @@ "symfony/translation": "^3.4 || ^4.0 || ^5.0 || ^6.0" }, "require-dev": { - "doctrine/dbal": "^2.0 || ^3.0", + "doctrine/dbal": "^2.0 || ^3.1.4", "doctrine/orm": "^2.7", "friendsofphp/php-cs-fixer": "^3.0", "kylekatarnls/multi-tester": "^2.0", + "ondrejmirtes/better-reflection": "*", "phpmd/phpmd": "^2.9", "phpstan/extension-installer": "^1.0", - "phpstan/phpstan": "^0.12.54 || ^1.0", - "phpunit/phpunit": "^7.5.20 || ^8.5.14", + "phpstan/phpstan": "^0.12.99 || ^1.7.14", + "phpunit/php-file-iterator": "^2.0.5 || ^3.0.6", + "phpunit/phpunit": "^7.5.20 || ^8.5.26 || ^9.5.20", "squizlabs/php_codesniffer": "^3.4" }, - "time": "2022-02-13T18:13:33+00:00", + "time": "2023-01-29T18:53:47+00:00", "bin": [ "bin/carbon" ], @@ -640,11 +704,15 @@ }, "funding": [ { - "url": "https://opencollective.com/Carbon", - "type": "open_collective" + "url": "https://github.com/sponsors/kylekatarnls", + "type": "github" }, { - "url": "https://tidelift.com/funding/github/packagist/nesbot/carbon", + "url": "https://opencollective.com/Carbon#sponsor", + "type": "opencollective" + }, + { + "url": "https://tidelift.com/subscription/pkg/packagist-nesbot-carbon?utm_source=packagist-nesbot-carbon&utm_medium=referral&utm_campaign=readme", "type": "tidelift" } ], @@ -843,21 +911,22 @@ }, { "name": "symfony/console", - "version": "v6.0.5", - "version_normalized": "6.0.5.0", + "version": "v6.2.5", + "version_normalized": "6.2.5.0", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "3bebf4108b9e07492a2a4057d207aa5a77d146b1" + "reference": "3e294254f2191762c1d137aed4b94e966965e985" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/3bebf4108b9e07492a2a4057d207aa5a77d146b1", - "reference": "3bebf4108b9e07492a2a4057d207aa5a77d146b1", + "url": "https://api.github.com/repos/symfony/console/zipball/3e294254f2191762c1d137aed4b94e966965e985", + "reference": "3e294254f2191762c1d137aed4b94e966965e985", "shasum": "" }, "require": { - "php": ">=8.0.2", + "php": ">=8.1", + "symfony/deprecation-contracts": "^2.1|^3", "symfony/polyfill-mbstring": "~1.0", "symfony/service-contracts": "^1.1|^2|^3", "symfony/string": "^5.4|^6.0" @@ -887,7 +956,7 @@ "symfony/lock": "", "symfony/process": "" }, - "time": "2022-02-25T10:48:52+00:00", + "time": "2023-01-01T08:38:09+00:00", "type": "library", "installation-source": "dist", "autoload": { @@ -921,7 +990,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v6.0.5" + "source": "https://github.com/symfony/console/tree/v6.2.5" }, "funding": [ { @@ -940,18 +1009,88 @@ "install-path": "../symfony/console" }, { - "name": "symfony/polyfill-ctype", - "version": "v1.25.0", - "version_normalized": "1.25.0.0", + "name": "symfony/deprecation-contracts", + "version": "v3.2.0", + "version_normalized": "3.2.0.0", "source": { "type": "git", - "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "30885182c981ab175d4d034db0f6f469898070ab" + "url": "https://github.com/symfony/deprecation-contracts.git", + "reference": "1ee04c65529dea5d8744774d474e7cbd2f1206d3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/30885182c981ab175d4d034db0f6f469898070ab", - "reference": "30885182c981ab175d4d034db0f6f469898070ab", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/1ee04c65529dea5d8744774d474e7cbd2f1206d3", + "reference": "1ee04c65529dea5d8744774d474e7cbd2f1206d3", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "time": "2022-11-25T10:21:52+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.3-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "installation-source": "dist", + "autoload": { + "files": [ + "function.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "A generic function and convention to trigger deprecation notices", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.2.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "install-path": "../symfony/deprecation-contracts" + }, + { + "name": "symfony/polyfill-ctype", + "version": "v1.27.0", + "version_normalized": "1.27.0.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "5bbc823adecdae860bb64756d639ecfec17b050a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/5bbc823adecdae860bb64756d639ecfec17b050a", + "reference": "5bbc823adecdae860bb64756d639ecfec17b050a", "shasum": "" }, "require": { @@ -963,11 +1102,11 @@ "suggest": { "ext-ctype": "For best performance" }, - "time": "2021-10-20T20:35:02+00:00", + "time": "2022-11-03T14:55:06+00:00", "type": "library", "extra": { "branch-alias": { - "dev-main": "1.23-dev" + "dev-main": "1.27-dev" }, "thanks": { "name": "symfony/polyfill", @@ -1006,7 +1145,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.25.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.27.0" }, "funding": [ { @@ -1026,17 +1165,17 @@ }, { "name": "symfony/polyfill-intl-grapheme", - "version": "v1.25.0", - "version_normalized": "1.25.0.0", + "version": "v1.27.0", + "version_normalized": "1.27.0.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-grapheme.git", - "reference": "81b86b50cf841a64252b439e738e97f4a34e2783" + "reference": "511a08c03c1960e08a883f4cffcacd219b758354" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/81b86b50cf841a64252b439e738e97f4a34e2783", - "reference": "81b86b50cf841a64252b439e738e97f4a34e2783", + "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/511a08c03c1960e08a883f4cffcacd219b758354", + "reference": "511a08c03c1960e08a883f4cffcacd219b758354", "shasum": "" }, "require": { @@ -1045,11 +1184,11 @@ "suggest": { "ext-intl": "For best performance" }, - "time": "2021-11-23T21:10:46+00:00", + "time": "2022-11-03T14:55:06+00:00", "type": "library", "extra": { "branch-alias": { - "dev-main": "1.23-dev" + "dev-main": "1.27-dev" }, "thanks": { "name": "symfony/polyfill", @@ -1090,7 +1229,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.25.0" + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.27.0" }, "funding": [ { @@ -1110,17 +1249,17 @@ }, { "name": "symfony/polyfill-intl-normalizer", - "version": "v1.25.0", - "version_normalized": "1.25.0.0", + "version": "v1.27.0", + "version_normalized": "1.27.0.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-normalizer.git", - "reference": "8590a5f561694770bdcd3f9b5c69dde6945028e8" + "reference": "19bd1e4fcd5b91116f14d8533c57831ed00571b6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/8590a5f561694770bdcd3f9b5c69dde6945028e8", - "reference": "8590a5f561694770bdcd3f9b5c69dde6945028e8", + "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/19bd1e4fcd5b91116f14d8533c57831ed00571b6", + "reference": "19bd1e4fcd5b91116f14d8533c57831ed00571b6", "shasum": "" }, "require": { @@ -1129,11 +1268,11 @@ "suggest": { "ext-intl": "For best performance" }, - "time": "2021-02-19T12:13:01+00:00", + "time": "2022-11-03T14:55:06+00:00", "type": "library", "extra": { "branch-alias": { - "dev-main": "1.23-dev" + "dev-main": "1.27-dev" }, "thanks": { "name": "symfony/polyfill", @@ -1177,7 +1316,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.25.0" + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.27.0" }, "funding": [ { @@ -1197,17 +1336,17 @@ }, { "name": "symfony/polyfill-mbstring", - "version": "v1.25.0", - "version_normalized": "1.25.0.0", + "version": "v1.27.0", + "version_normalized": "1.27.0.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "0abb51d2f102e00a4eefcf46ba7fec406d245825" + "reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/0abb51d2f102e00a4eefcf46ba7fec406d245825", - "reference": "0abb51d2f102e00a4eefcf46ba7fec406d245825", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/8ad114f6b39e2c98a8b0e3bd907732c207c2b534", + "reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534", "shasum": "" }, "require": { @@ -1219,11 +1358,11 @@ "suggest": { "ext-mbstring": "For best performance" }, - "time": "2021-11-30T18:21:41+00:00", + "time": "2022-11-03T14:55:06+00:00", "type": "library", "extra": { "branch-alias": { - "dev-main": "1.23-dev" + "dev-main": "1.27-dev" }, "thanks": { "name": "symfony/polyfill", @@ -1263,7 +1402,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.25.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.27.0" }, "funding": [ { @@ -1283,27 +1422,27 @@ }, { "name": "symfony/polyfill-php80", - "version": "v1.25.0", - "version_normalized": "1.25.0.0", + "version": "v1.27.0", + "version_normalized": "1.27.0.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "4407588e0d3f1f52efb65fbe92babe41f37fe50c" + "reference": "7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/4407588e0d3f1f52efb65fbe92babe41f37fe50c", - "reference": "4407588e0d3f1f52efb65fbe92babe41f37fe50c", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936", + "reference": "7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936", "shasum": "" }, "require": { "php": ">=7.1" }, - "time": "2022-03-04T08:16:47+00:00", + "time": "2022-11-03T14:55:06+00:00", "type": "library", "extra": { "branch-alias": { - "dev-main": "1.23-dev" + "dev-main": "1.27-dev" }, "thanks": { "name": "symfony/polyfill", @@ -1349,7 +1488,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.25.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.27.0" }, "funding": [ { @@ -1369,21 +1508,21 @@ }, { "name": "symfony/service-contracts", - "version": "v3.0.0", - "version_normalized": "3.0.0.0", + "version": "v3.2.0", + "version_normalized": "3.2.0.0", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "36715ebf9fb9db73db0cb24263c79077c6fe8603" + "reference": "aac98028c69df04ee77eb69b96b86ee51fbf4b75" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/36715ebf9fb9db73db0cb24263c79077c6fe8603", - "reference": "36715ebf9fb9db73db0cb24263c79077c6fe8603", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/aac98028c69df04ee77eb69b96b86ee51fbf4b75", + "reference": "aac98028c69df04ee77eb69b96b86ee51fbf4b75", "shasum": "" }, "require": { - "php": ">=8.0.2", + "php": ">=8.1", "psr/container": "^2.0" }, "conflict": { @@ -1392,11 +1531,11 @@ "suggest": { "symfony/service-implementation": "" }, - "time": "2021-11-04T17:53:12+00:00", + "time": "2022-11-25T10:21:52+00:00", "type": "library", "extra": { "branch-alias": { - "dev-main": "3.0-dev" + "dev-main": "3.3-dev" }, "thanks": { "name": "symfony/contracts", @@ -1407,7 +1546,10 @@ "autoload": { "psr-4": { "Symfony\\Contracts\\Service\\": "" - } + }, + "exclude-from-classmap": [ + "/Test/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -1434,7 +1576,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/service-contracts/tree/v3.0.0" + "source": "https://github.com/symfony/service-contracts/tree/v3.2.0" }, "funding": [ { @@ -1454,21 +1596,21 @@ }, { "name": "symfony/string", - "version": "v6.0.3", - "version_normalized": "6.0.3.0", + "version": "v6.2.5", + "version_normalized": "6.2.5.0", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "522144f0c4c004c80d56fa47e40e17028e2eefc2" + "reference": "b2dac0fa27b1ac0f9c0c0b23b43977f12308d0b0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/522144f0c4c004c80d56fa47e40e17028e2eefc2", - "reference": "522144f0c4c004c80d56fa47e40e17028e2eefc2", + "url": "https://api.github.com/repos/symfony/string/zipball/b2dac0fa27b1ac0f9c0c0b23b43977f12308d0b0", + "reference": "b2dac0fa27b1ac0f9c0c0b23b43977f12308d0b0", "shasum": "" }, "require": { - "php": ">=8.0.2", + "php": ">=8.1", "symfony/polyfill-ctype": "~1.8", "symfony/polyfill-intl-grapheme": "~1.0", "symfony/polyfill-intl-normalizer": "~1.0", @@ -1480,10 +1622,11 @@ "require-dev": { "symfony/error-handler": "^5.4|^6.0", "symfony/http-client": "^5.4|^6.0", + "symfony/intl": "^6.2", "symfony/translation-contracts": "^2.0|^3.0", "symfony/var-exporter": "^5.4|^6.0" }, - "time": "2022-01-02T09:55:41+00:00", + "time": "2023-01-01T08:38:09+00:00", "type": "library", "installation-source": "dist", "autoload": { @@ -1522,7 +1665,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v6.0.3" + "source": "https://github.com/symfony/string/tree/v6.2.5" }, "funding": [ { @@ -1542,21 +1685,21 @@ }, { "name": "symfony/translation", - "version": "v6.0.6", - "version_normalized": "6.0.6.0", + "version": "v6.2.5", + "version_normalized": "6.2.5.0", "source": { "type": "git", "url": "https://github.com/symfony/translation.git", - "reference": "f6639cb9b5e0c57fe31e3263b900a77eedb0c908" + "reference": "60556925a703cfbc1581cde3b3f35b0bb0ea904c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation/zipball/f6639cb9b5e0c57fe31e3263b900a77eedb0c908", - "reference": "f6639cb9b5e0c57fe31e3263b900a77eedb0c908", + "url": "https://api.github.com/repos/symfony/translation/zipball/60556925a703cfbc1581cde3b3f35b0bb0ea904c", + "reference": "60556925a703cfbc1581cde3b3f35b0bb0ea904c", "shasum": "" }, "require": { - "php": ">=8.0.2", + "php": ">=8.1", "symfony/polyfill-mbstring": "~1.0", "symfony/translation-contracts": "^2.3|^3.0" }, @@ -1572,6 +1715,7 @@ "symfony/translation-implementation": "2.3|3.0" }, "require-dev": { + "nikic/php-parser": "^4.13", "psr/log": "^1|^2|^3", "symfony/config": "^5.4|^6.0", "symfony/console": "^5.4|^6.0", @@ -1581,15 +1725,17 @@ "symfony/http-kernel": "^5.4|^6.0", "symfony/intl": "^5.4|^6.0", "symfony/polyfill-intl-icu": "^1.21", + "symfony/routing": "^5.4|^6.0", "symfony/service-contracts": "^1.1.2|^2|^3", "symfony/yaml": "^5.4|^6.0" }, "suggest": { + "nikic/php-parser": "To use PhpAstExtractor", "psr/log-implementation": "To use logging capability in translator", "symfony/config": "", "symfony/yaml": "" }, - "time": "2022-03-02T12:58:14+00:00", + "time": "2023-01-05T07:00:27+00:00", "type": "library", "installation-source": "dist", "autoload": { @@ -1620,7 +1766,7 @@ "description": "Provides tools to internationalize your application", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/translation/tree/v6.0.6" + "source": "https://github.com/symfony/translation/tree/v6.2.5" }, "funding": [ { @@ -1640,30 +1786,30 @@ }, { "name": "symfony/translation-contracts", - "version": "v3.0.0", - "version_normalized": "3.0.0.0", + "version": "v3.2.0", + "version_normalized": "3.2.0.0", "source": { "type": "git", "url": "https://github.com/symfony/translation-contracts.git", - "reference": "1b6ea5a7442af5a12dba3dbd6d71034b5b234e77" + "reference": "68cce71402305a015f8c1589bfada1280dc64fe7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation-contracts/zipball/1b6ea5a7442af5a12dba3dbd6d71034b5b234e77", - "reference": "1b6ea5a7442af5a12dba3dbd6d71034b5b234e77", + "url": "https://api.github.com/repos/symfony/translation-contracts/zipball/68cce71402305a015f8c1589bfada1280dc64fe7", + "reference": "68cce71402305a015f8c1589bfada1280dc64fe7", "shasum": "" }, "require": { - "php": ">=8.0.2" + "php": ">=8.1" }, "suggest": { "symfony/translation-implementation": "" }, - "time": "2021-09-07T12:43:40+00:00", + "time": "2022-11-25T10:21:52+00:00", "type": "library", "extra": { "branch-alias": { - "dev-main": "3.0-dev" + "dev-main": "3.3-dev" }, "thanks": { "name": "symfony/contracts", @@ -1674,7 +1820,10 @@ "autoload": { "psr-4": { "Symfony\\Contracts\\Translation\\": "" - } + }, + "exclude-from-classmap": [ + "/Test/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -1701,7 +1850,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/translation-contracts/tree/v3.0.0" + "source": "https://github.com/symfony/translation-contracts/tree/v3.2.0" }, "funding": [ { diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index 22b7924..8cdf4c8 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -1,121 +1,130 @@ array( + 'name' => 'aftercase/ponepaste', 'pretty_version' => 'dev-main', 'version' => 'dev-main', + 'reference' => '8914700af7493ab2f4da22d60e13d47c410057ab', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), - 'reference' => '6f1363aafe558eeabeb9ac6985892803b5bd14f7', - 'name' => 'aftercase/ponepaste', 'dev' => true, ), 'versions' => array( 'aftercase/ponepaste' => array( 'pretty_version' => 'dev-main', 'version' => 'dev-main', + 'reference' => '8914700af7493ab2f4da22d60e13d47c410057ab', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), - 'reference' => '6f1363aafe558eeabeb9ac6985892803b5bd14f7', + 'dev_requirement' => false, + ), + 'brick/math' => array( + 'pretty_version' => '0.11.0', + 'version' => '0.11.0.0', + 'reference' => '0ad82ce168c82ba30d1c01ec86116ab52f589478', + 'type' => 'library', + 'install_path' => __DIR__ . '/../brick/math', + 'aliases' => array(), 'dev_requirement' => false, ), 'doctrine/inflector' => array( - 'pretty_version' => '2.0.4', - 'version' => '2.0.4.0', + 'pretty_version' => '2.0.6', + 'version' => '2.0.6.0', + 'reference' => 'd9d313a36c872fd6ee06d9a6cbcf713eaa40f024', 'type' => 'library', 'install_path' => __DIR__ . '/../doctrine/inflector', 'aliases' => array(), - 'reference' => '8b7ff3e4b7de6b2c84da85637b59fd2880ecaa89', 'dev_requirement' => false, ), 'erusev/parsedown' => array( 'pretty_version' => '1.7.4', 'version' => '1.7.4.0', + 'reference' => 'cb17b6477dfff935958ba01325f2e8a2bfa6dab3', 'type' => 'library', 'install_path' => __DIR__ . '/../erusev/parsedown', 'aliases' => array(), - 'reference' => 'cb17b6477dfff935958ba01325f2e8a2bfa6dab3', 'dev_requirement' => false, ), 'illuminate/collections' => array( - 'pretty_version' => 'v9.4.1', - 'version' => '9.4.1.0', + 'pretty_version' => 'v9.52.4', + 'version' => '9.52.4.0', + 'reference' => '0168d0e44ea0c4fe5451fe08cde7049b9e9f9741', 'type' => 'library', 'install_path' => __DIR__ . '/../illuminate/collections', 'aliases' => array(), - 'reference' => '22c4bb17f4e6c6fb470b5957e8232b1b5baf76b0', 'dev_requirement' => false, ), 'illuminate/conditionable' => array( - 'pretty_version' => 'v9.4.1', - 'version' => '9.4.1.0', + 'pretty_version' => 'v9.52.4', + 'version' => '9.52.4.0', + 'reference' => 'bea24daa0fa84b7e7b0d5b84f62c71b7e2dc3364', 'type' => 'library', 'install_path' => __DIR__ . '/../illuminate/conditionable', 'aliases' => array(), - 'reference' => '56b4ba1166c264064bf63896f498a2bee320d16a', 'dev_requirement' => false, ), 'illuminate/container' => array( - 'pretty_version' => 'v9.4.1', - 'version' => '9.4.1.0', + 'pretty_version' => 'v9.52.4', + 'version' => '9.52.4.0', + 'reference' => '1641dda2d0750b68bb1264a3b37ff3973f2e6265', 'type' => 'library', 'install_path' => __DIR__ . '/../illuminate/container', 'aliases' => array(), - 'reference' => '66f9049b19fb34e74134c6eeff92a442cee068e5', 'dev_requirement' => false, ), 'illuminate/contracts' => array( - 'pretty_version' => 'v9.4.1', - 'version' => '9.4.1.0', + 'pretty_version' => 'v9.52.4', + 'version' => '9.52.4.0', + 'reference' => '44f65d723b13823baa02ff69751a5948bde60c22', 'type' => 'library', 'install_path' => __DIR__ . '/../illuminate/contracts', 'aliases' => array(), - 'reference' => 'ce68106c575410c71f92ac1c91c5d95c561033bc', 'dev_requirement' => false, ), 'illuminate/database' => array( - 'pretty_version' => 'v9.4.1', - 'version' => '9.4.1.0', + 'pretty_version' => 'v9.52.4', + 'version' => '9.52.4.0', + 'reference' => 'fc7e9cf5d4c7c4c0a2800c0d345cc9985fb1b040', 'type' => 'library', 'install_path' => __DIR__ . '/../illuminate/database', 'aliases' => array(), - 'reference' => '0fffd6ba91eb58330cbf7331c77ea38c2a16b5d9', 'dev_requirement' => false, ), 'illuminate/macroable' => array( - 'pretty_version' => 'v9.4.1', - 'version' => '9.4.1.0', + 'pretty_version' => 'v9.52.4', + 'version' => '9.52.4.0', + 'reference' => 'e3bfaf6401742a9c6abca61b9b10e998e5b6449a', 'type' => 'library', 'install_path' => __DIR__ . '/../illuminate/macroable', 'aliases' => array(), - 'reference' => '25a2c6dac2b7541ecbadef952702e84ae15f5354', 'dev_requirement' => false, ), 'illuminate/support' => array( - 'pretty_version' => 'v9.4.1', - 'version' => '9.4.1.0', + 'pretty_version' => 'v9.52.4', + 'version' => '9.52.4.0', + 'reference' => '63dcb4523ccdfc01cdf5be17791f07cc20982a1e', 'type' => 'library', 'install_path' => __DIR__ . '/../illuminate/support', 'aliases' => array(), - 'reference' => '568ed7a21a75e0bd9ca641b6c4a626872ee26d6f', 'dev_requirement' => false, ), 'nesbot/carbon' => array( - 'pretty_version' => '2.57.0', - 'version' => '2.57.0.0', + 'pretty_version' => '2.66.0', + 'version' => '2.66.0.0', + 'reference' => '496712849902241f04902033b0441b269effe001', 'type' => 'library', 'install_path' => __DIR__ . '/../nesbot/carbon', 'aliases' => array(), - 'reference' => '4a54375c21eea4811dbd1149fe6b246517554e78', 'dev_requirement' => false, ), 'psr/container' => array( 'pretty_version' => '2.0.2', 'version' => '2.0.2.0', + 'reference' => 'c71ecc56dfe541dbd90c5360474fbc405f8d5963', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/container', 'aliases' => array(), - 'reference' => 'c71ecc56dfe541dbd90c5360474fbc405f8d5963', 'dev_requirement' => false, ), 'psr/container-implementation' => array( @@ -133,109 +142,118 @@ 'psr/simple-cache' => array( 'pretty_version' => '3.0.0', 'version' => '3.0.0.0', + 'reference' => '764e0b3939f5ca87cb904f570ef9be2d78a07865', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/simple-cache', 'aliases' => array(), - 'reference' => '764e0b3939f5ca87cb904f570ef9be2d78a07865', 'dev_requirement' => false, ), 'scrivo/highlight.php' => array( 'pretty_version' => 'v9.18.1.9', 'version' => '9.18.1.9', + 'reference' => 'd45585504777e6194a91dffc7270ca39833787f8', 'type' => 'library', 'install_path' => __DIR__ . '/../scrivo/highlight.php', 'aliases' => array(), - 'reference' => 'd45585504777e6194a91dffc7270ca39833787f8', 'dev_requirement' => false, ), 'symfony/console' => array( - 'pretty_version' => 'v6.0.5', - 'version' => '6.0.5.0', + 'pretty_version' => 'v6.2.5', + 'version' => '6.2.5.0', + 'reference' => '3e294254f2191762c1d137aed4b94e966965e985', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/console', 'aliases' => array(), - 'reference' => '3bebf4108b9e07492a2a4057d207aa5a77d146b1', + 'dev_requirement' => false, + ), + 'symfony/deprecation-contracts' => array( + 'pretty_version' => 'v3.2.0', + 'version' => '3.2.0.0', + 'reference' => '1ee04c65529dea5d8744774d474e7cbd2f1206d3', + 'type' => 'library', + 'install_path' => __DIR__ . '/../symfony/deprecation-contracts', + 'aliases' => array(), 'dev_requirement' => false, ), 'symfony/polyfill-ctype' => array( - 'pretty_version' => 'v1.25.0', - 'version' => '1.25.0.0', + 'pretty_version' => 'v1.27.0', + 'version' => '1.27.0.0', + 'reference' => '5bbc823adecdae860bb64756d639ecfec17b050a', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/polyfill-ctype', 'aliases' => array(), - 'reference' => '30885182c981ab175d4d034db0f6f469898070ab', 'dev_requirement' => false, ), 'symfony/polyfill-intl-grapheme' => array( - 'pretty_version' => 'v1.25.0', - 'version' => '1.25.0.0', + 'pretty_version' => 'v1.27.0', + 'version' => '1.27.0.0', + 'reference' => '511a08c03c1960e08a883f4cffcacd219b758354', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/polyfill-intl-grapheme', 'aliases' => array(), - 'reference' => '81b86b50cf841a64252b439e738e97f4a34e2783', 'dev_requirement' => false, ), 'symfony/polyfill-intl-normalizer' => array( - 'pretty_version' => 'v1.25.0', - 'version' => '1.25.0.0', + 'pretty_version' => 'v1.27.0', + 'version' => '1.27.0.0', + 'reference' => '19bd1e4fcd5b91116f14d8533c57831ed00571b6', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/polyfill-intl-normalizer', 'aliases' => array(), - 'reference' => '8590a5f561694770bdcd3f9b5c69dde6945028e8', 'dev_requirement' => false, ), 'symfony/polyfill-mbstring' => array( - 'pretty_version' => 'v1.25.0', - 'version' => '1.25.0.0', + 'pretty_version' => 'v1.27.0', + 'version' => '1.27.0.0', + 'reference' => '8ad114f6b39e2c98a8b0e3bd907732c207c2b534', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/polyfill-mbstring', 'aliases' => array(), - 'reference' => '0abb51d2f102e00a4eefcf46ba7fec406d245825', 'dev_requirement' => false, ), 'symfony/polyfill-php80' => array( - 'pretty_version' => 'v1.25.0', - 'version' => '1.25.0.0', + 'pretty_version' => 'v1.27.0', + 'version' => '1.27.0.0', + 'reference' => '7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/polyfill-php80', 'aliases' => array(), - 'reference' => '4407588e0d3f1f52efb65fbe92babe41f37fe50c', 'dev_requirement' => false, ), 'symfony/service-contracts' => array( - 'pretty_version' => 'v3.0.0', - 'version' => '3.0.0.0', + 'pretty_version' => 'v3.2.0', + 'version' => '3.2.0.0', + 'reference' => 'aac98028c69df04ee77eb69b96b86ee51fbf4b75', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/service-contracts', 'aliases' => array(), - 'reference' => '36715ebf9fb9db73db0cb24263c79077c6fe8603', 'dev_requirement' => false, ), 'symfony/string' => array( - 'pretty_version' => 'v6.0.3', - 'version' => '6.0.3.0', + 'pretty_version' => 'v6.2.5', + 'version' => '6.2.5.0', + 'reference' => 'b2dac0fa27b1ac0f9c0c0b23b43977f12308d0b0', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/string', 'aliases' => array(), - 'reference' => '522144f0c4c004c80d56fa47e40e17028e2eefc2', 'dev_requirement' => false, ), 'symfony/translation' => array( - 'pretty_version' => 'v6.0.6', - 'version' => '6.0.6.0', + 'pretty_version' => 'v6.2.5', + 'version' => '6.2.5.0', + 'reference' => '60556925a703cfbc1581cde3b3f35b0bb0ea904c', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/translation', 'aliases' => array(), - 'reference' => 'f6639cb9b5e0c57fe31e3263b900a77eedb0c908', 'dev_requirement' => false, ), 'symfony/translation-contracts' => array( - 'pretty_version' => 'v3.0.0', - 'version' => '3.0.0.0', + 'pretty_version' => 'v3.2.0', + 'version' => '3.2.0.0', + 'reference' => '68cce71402305a015f8c1589bfada1280dc64fe7', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/translation-contracts', 'aliases' => array(), - 'reference' => '1b6ea5a7442af5a12dba3dbd6d71034b5b234e77', 'dev_requirement' => false, ), 'symfony/translation-implementation' => array( @@ -247,10 +265,10 @@ 'voku/portable-ascii' => array( 'pretty_version' => '2.0.1', 'version' => '2.0.1.0', + 'reference' => 'b56450eed252f6801410d810c8e1727224ae0743', 'type' => 'library', 'install_path' => __DIR__ . '/../voku/portable-ascii', 'aliases' => array(), - 'reference' => 'b56450eed252f6801410d810c8e1727224ae0743', 'dev_requirement' => false, ), ), diff --git a/vendor/composer/platform_check.php b/vendor/composer/platform_check.php index b168ddd..4c3a5d6 100644 --- a/vendor/composer/platform_check.php +++ b/vendor/composer/platform_check.php @@ -4,8 +4,8 @@ $issues = array(); -if (!(PHP_VERSION_ID >= 80002)) { - $issues[] = 'Your Composer dependencies require a PHP version ">= 8.0.2". You are running ' . PHP_VERSION . '.'; +if (!(PHP_VERSION_ID >= 80100)) { + $issues[] = 'Your Composer dependencies require a PHP version ">= 8.1.0". You are running ' . PHP_VERSION . '.'; } if ($issues) { diff --git a/vendor/doctrine/inflector/composer.json b/vendor/doctrine/inflector/composer.json index f08fdc3..862ea5c 100644 --- a/vendor/doctrine/inflector/composer.json +++ b/vendor/doctrine/inflector/composer.json @@ -16,12 +16,12 @@ "php": "^7.2 || ^8.0" }, "require-dev": { - "doctrine/coding-standard": "^8.2", - "phpstan/phpstan": "^0.12", - "phpstan/phpstan-phpunit": "^0.12", - "phpstan/phpstan-strict-rules": "^0.12", - "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0", - "vimeo/psalm": "^4.10" + "doctrine/coding-standard": "^10", + "phpstan/phpstan": "^1.8", + "phpstan/phpstan-phpunit": "^1.1", + "phpstan/phpstan-strict-rules": "^1.3", + "phpunit/phpunit": "^8.5 || ^9.5", + "vimeo/psalm": "^4.25" }, "autoload": { "psr-4": { @@ -32,5 +32,10 @@ "psr-4": { "Doctrine\\Tests\\Inflector\\": "tests/Doctrine/Tests/Inflector" } + }, + "config": { + "allow-plugins": { + "dealerdirect/phpcodesniffer-composer-installer": true + } } } diff --git a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/English/Inflectible.php b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/English/Inflectible.php index 8f0919f..db884ca 100644 --- a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/English/Inflectible.php +++ b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/English/Inflectible.php @@ -11,9 +11,7 @@ use Doctrine\Inflector\Rules\Word; class Inflectible { - /** - * @return Transformation[] - */ + /** @return Transformation[] */ public static function getSingular(): iterable { yield new Transformation(new Pattern('(s)tatuses$'), '\1\2tatus'); @@ -56,12 +54,12 @@ class Inflectible yield new Transformation(new Pattern('(f)eet$'), '\1oot'); yield new Transformation(new Pattern('(n)ews$'), '\1\2ews'); yield new Transformation(new Pattern('eaus$'), 'eau'); + yield new Transformation(new Pattern('^tights$'), 'tights'); + yield new Transformation(new Pattern('^shorts$'), 'shorts'); yield new Transformation(new Pattern('s$'), ''); } - /** - * @return Transformation[] - */ + /** @return Transformation[] */ public static function getPlural(): iterable { yield new Transformation(new Pattern('(s)tatus$'), '\1\2tatuses'); @@ -91,14 +89,13 @@ class Inflectible yield new Transformation(new Pattern('$'), 's'); } - /** - * @return Substitution[] - */ + /** @return Substitution[] */ public static function getIrregular(): iterable { yield new Substitution(new Word('atlas'), new Word('atlases')); yield new Substitution(new Word('axe'), new Word('axes')); yield new Substitution(new Word('beef'), new Word('beefs')); + yield new Substitution(new Word('blouse'), new Word('blouses')); yield new Substitution(new Word('brother'), new Word('brothers')); yield new Substitution(new Word('cafe'), new Word('cafes')); yield new Substitution(new Word('chateau'), new Word('chateaux')); @@ -151,6 +148,7 @@ class Inflectible yield new Substitution(new Word('runner-up'), new Word('runners-up')); yield new Substitution(new Word('safe'), new Word('safes')); yield new Substitution(new Word('sex'), new Word('sexes')); + yield new Substitution(new Word('sieve'), new Word('sieves')); yield new Substitution(new Word('soliloquy'), new Word('soliloquies')); yield new Substitution(new Word('son-in-law'), new Word('sons-in-law')); yield new Substitution(new Word('syllabus'), new Word('syllabi')); diff --git a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/English/Uninflected.php b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/English/Uninflected.php index e2656cc..02257de 100644 --- a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/English/Uninflected.php +++ b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/English/Uninflected.php @@ -8,9 +8,7 @@ use Doctrine\Inflector\Rules\Pattern; final class Uninflected { - /** - * @return Pattern[] - */ + /** @return Pattern[] */ public static function getSingular(): iterable { yield from self::getDefault(); @@ -30,9 +28,7 @@ final class Uninflected yield new Pattern('utopia'); } - /** - * @return Pattern[] - */ + /** @return Pattern[] */ public static function getPlural(): iterable { yield from self::getDefault(); @@ -43,9 +39,7 @@ final class Uninflected yield new Pattern('media'); } - /** - * @return Pattern[] - */ + /** @return Pattern[] */ private static function getDefault(): iterable { yield new Pattern('\w+media'); @@ -64,6 +58,7 @@ final class Uninflected yield new Pattern('butter'); yield new Pattern('cantus'); yield new Pattern('carp'); + yield new Pattern('cattle'); yield new Pattern('chassis'); yield new Pattern('clippers'); yield new Pattern('clothing'); @@ -111,6 +106,7 @@ final class Uninflected yield new Pattern('jackanapes'); yield new Pattern('jeans'); yield new Pattern('jedi'); + yield new Pattern('kin'); yield new Pattern('kiplingese'); yield new Pattern('knowledge'); yield new Pattern('kongoese'); diff --git a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/French/Inflectible.php b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/French/Inflectible.php index c8f1f8f..05b535a 100644 --- a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/French/Inflectible.php +++ b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/French/Inflectible.php @@ -11,9 +11,7 @@ use Doctrine\Inflector\Rules\Word; class Inflectible { - /** - * @return Transformation[] - */ + /** @return Transformation[] */ public static function getSingular(): iterable { yield new Transformation(new Pattern('/(b|cor|ém|gemm|soupir|trav|vant|vitr)aux$/'), '\1ail'); @@ -23,9 +21,7 @@ class Inflectible yield new Transformation(new Pattern('/s$/'), ''); } - /** - * @return Transformation[] - */ + /** @return Transformation[] */ public static function getPlural(): iterable { yield new Transformation(new Pattern('/(s|x|z)$/'), '\1'); @@ -38,9 +34,7 @@ class Inflectible yield new Transformation(new Pattern('/$/'), 's'); } - /** - * @return Substitution[] - */ + /** @return Substitution[] */ public static function getIrregular(): iterable { yield new Substitution(new Word('monsieur'), new Word('messieurs')); diff --git a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/French/Uninflected.php b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/French/Uninflected.php index 3cf2444..9747f91 100644 --- a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/French/Uninflected.php +++ b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/French/Uninflected.php @@ -8,25 +8,19 @@ use Doctrine\Inflector\Rules\Pattern; final class Uninflected { - /** - * @return Pattern[] - */ + /** @return Pattern[] */ public static function getSingular(): iterable { yield from self::getDefault(); } - /** - * @return Pattern[] - */ + /** @return Pattern[] */ public static function getPlural(): iterable { yield from self::getDefault(); } - /** - * @return Pattern[] - */ + /** @return Pattern[] */ private static function getDefault(): iterable { yield new Pattern(''); diff --git a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/NorwegianBokmal/Inflectible.php b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/NorwegianBokmal/Inflectible.php index c00317d..1e952d8 100644 --- a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/NorwegianBokmal/Inflectible.php +++ b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/NorwegianBokmal/Inflectible.php @@ -11,18 +11,14 @@ use Doctrine\Inflector\Rules\Word; class Inflectible { - /** - * @return Transformation[] - */ + /** @return Transformation[] */ public static function getSingular(): iterable { yield new Transformation(new Pattern('/re$/i'), 'r'); yield new Transformation(new Pattern('/er$/i'), ''); } - /** - * @return Transformation[] - */ + /** @return Transformation[] */ public static function getPlural(): iterable { yield new Transformation(new Pattern('/e$/i'), 'er'); @@ -30,9 +26,7 @@ class Inflectible yield new Transformation(new Pattern('/$/'), 'er'); } - /** - * @return Substitution[] - */ + /** @return Substitution[] */ public static function getIrregular(): iterable { yield new Substitution(new Word('konto'), new Word('konti')); diff --git a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/NorwegianBokmal/Uninflected.php b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/NorwegianBokmal/Uninflected.php index 5d878c6..5d8d3b3 100644 --- a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/NorwegianBokmal/Uninflected.php +++ b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/NorwegianBokmal/Uninflected.php @@ -8,25 +8,19 @@ use Doctrine\Inflector\Rules\Pattern; final class Uninflected { - /** - * @return Pattern[] - */ + /** @return Pattern[] */ public static function getSingular(): iterable { yield from self::getDefault(); } - /** - * @return Pattern[] - */ + /** @return Pattern[] */ public static function getPlural(): iterable { yield from self::getDefault(); } - /** - * @return Pattern[] - */ + /** @return Pattern[] */ private static function getDefault(): iterable { yield new Pattern('barn'); diff --git a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Portuguese/Inflectible.php b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Portuguese/Inflectible.php index 95564d4..0d41fe7 100644 --- a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Portuguese/Inflectible.php +++ b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Portuguese/Inflectible.php @@ -11,9 +11,7 @@ use Doctrine\Inflector\Rules\Word; class Inflectible { - /** - * @return Transformation[] - */ + /** @return Transformation[] */ public static function getSingular(): iterable { yield new Transformation(new Pattern('/^(g|)ases$/i'), '\1ás'); @@ -34,9 +32,7 @@ class Inflectible yield new Transformation(new Pattern('/([^ê])s$/i'), '\1'); } - /** - * @return Transformation[] - */ + /** @return Transformation[] */ public static function getPlural(): iterable { yield new Transformation(new Pattern('/^(alem|c|p)ao$/i'), '\1aes'); @@ -58,9 +54,7 @@ class Inflectible yield new Transformation(new Pattern('/$/'), 's'); } - /** - * @return Substitution[] - */ + /** @return Substitution[] */ public static function getIrregular(): iterable { yield new Substitution(new Word('abdomen'), new Word('abdomens')); diff --git a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Portuguese/Uninflected.php b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Portuguese/Uninflected.php index 58c34f9..b8e988f 100644 --- a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Portuguese/Uninflected.php +++ b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Portuguese/Uninflected.php @@ -8,25 +8,19 @@ use Doctrine\Inflector\Rules\Pattern; final class Uninflected { - /** - * @return Pattern[] - */ + /** @return Pattern[] */ public static function getSingular(): iterable { yield from self::getDefault(); } - /** - * @return Pattern[] - */ + /** @return Pattern[] */ public static function getPlural(): iterable { yield from self::getDefault(); } - /** - * @return Pattern[] - */ + /** @return Pattern[] */ private static function getDefault(): iterable { yield new Pattern('tórax'); diff --git a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Spanish/Inflectible.php b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Spanish/Inflectible.php index c6862fa..9129460 100644 --- a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Spanish/Inflectible.php +++ b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Spanish/Inflectible.php @@ -11,9 +11,7 @@ use Doctrine\Inflector\Rules\Word; class Inflectible { - /** - * @return Transformation[] - */ + /** @return Transformation[] */ public static function getSingular(): iterable { yield new Transformation(new Pattern('/ereses$/'), 'erés'); @@ -23,9 +21,7 @@ class Inflectible yield new Transformation(new Pattern('/s$/'), ''); } - /** - * @return Transformation[] - */ + /** @return Transformation[] */ public static function getPlural(): iterable { yield new Transformation(new Pattern('/ú([sn])$/i'), 'u\1es'); @@ -39,9 +35,7 @@ class Inflectible yield new Transformation(new Pattern('/$/'), 's'); } - /** - * @return Substitution[] - */ + /** @return Substitution[] */ public static function getIrregular(): iterable { yield new Substitution(new Word('el'), new Word('los')); diff --git a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Spanish/Uninflected.php b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Spanish/Uninflected.php index c743b39..c26ebe9 100644 --- a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Spanish/Uninflected.php +++ b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Spanish/Uninflected.php @@ -8,25 +8,19 @@ use Doctrine\Inflector\Rules\Pattern; final class Uninflected { - /** - * @return Pattern[] - */ + /** @return Pattern[] */ public static function getSingular(): iterable { yield from self::getDefault(); } - /** - * @return Pattern[] - */ + /** @return Pattern[] */ public static function getPlural(): iterable { yield from self::getDefault(); } - /** - * @return Pattern[] - */ + /** @return Pattern[] */ private static function getDefault(): iterable { yield new Pattern('lunes'); diff --git a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Turkish/Inflectible.php b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Turkish/Inflectible.php index d7b7064..a2bda0d 100644 --- a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Turkish/Inflectible.php +++ b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Turkish/Inflectible.php @@ -11,26 +11,20 @@ use Doctrine\Inflector\Rules\Word; class Inflectible { - /** - * @return Transformation[] - */ + /** @return Transformation[] */ public static function getSingular(): iterable { yield new Transformation(new Pattern('/l[ae]r$/i'), ''); } - /** - * @return Transformation[] - */ + /** @return Transformation[] */ public static function getPlural(): iterable { yield new Transformation(new Pattern('/([eöiü][^aoıueöiü]{0,6})$/u'), '\1ler'); yield new Transformation(new Pattern('/([aoıu][^aoıueöiü]{0,6})$/u'), '\1lar'); } - /** - * @return Substitution[] - */ + /** @return Substitution[] */ public static function getIrregular(): iterable { yield new Substitution(new Word('ben'), new Word('biz')); diff --git a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Turkish/Uninflected.php b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Turkish/Uninflected.php index a75d248..ec1c37d 100644 --- a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Turkish/Uninflected.php +++ b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Turkish/Uninflected.php @@ -8,25 +8,19 @@ use Doctrine\Inflector\Rules\Pattern; final class Uninflected { - /** - * @return Pattern[] - */ + /** @return Pattern[] */ public static function getSingular(): iterable { yield from self::getDefault(); } - /** - * @return Pattern[] - */ + /** @return Pattern[] */ public static function getPlural(): iterable { yield from self::getDefault(); } - /** - * @return Pattern[] - */ + /** @return Pattern[] */ private static function getDefault(): iterable { yield new Pattern('lunes'); diff --git a/vendor/doctrine/inflector/phpstan.neon.dist b/vendor/doctrine/inflector/phpstan.neon.dist deleted file mode 100644 index 5f3f16b..0000000 --- a/vendor/doctrine/inflector/phpstan.neon.dist +++ /dev/null @@ -1,13 +0,0 @@ -includes: - - vendor/phpstan/phpstan-phpunit/extension.neon - - vendor/phpstan/phpstan-phpunit/rules.neon - - vendor/phpstan/phpstan-strict-rules/rules.neon - -parameters: - level: 7 - paths: - - lib - - tests - - excludes_analyse: - - %rootDir%/../../../tests/Doctrine/Tests/Common/* diff --git a/vendor/doctrine/inflector/psalm.xml b/vendor/doctrine/inflector/psalm.xml deleted file mode 100644 index 677e8d4..0000000 --- a/vendor/doctrine/inflector/psalm.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - diff --git a/vendor/illuminate/collections/Arr.php b/vendor/illuminate/collections/Arr.php index 58c5e78..69220d5 100644 --- a/vendor/illuminate/collections/Arr.php +++ b/vendor/illuminate/collections/Arr.php @@ -2,6 +2,7 @@ namespace Illuminate\Support; +use ArgumentCountError; use ArrayAccess; use Illuminate\Support\Traits\Macroable; use InvalidArgumentException; @@ -25,7 +26,7 @@ class Arr * Add an element to an array using "dot" notation if it doesn't exist. * * @param array $array - * @param string $key + * @param string|int|float $key * @param mixed $value * @return array */ @@ -142,7 +143,7 @@ class Arr * Get all of the given array except for a specified array of keys. * * @param array $array - * @param array|string $keys + * @param array|string|int|float $keys * @return array */ public static function except($array, $keys) @@ -169,6 +170,10 @@ class Arr return $array->offsetExists($key); } + if (is_float($key)) { + $key = (string) $key; + } + return array_key_exists($key, $array); } @@ -252,7 +257,7 @@ class Arr * Remove one or many array items from a given array using "dot" notation. * * @param array $array - * @param array|string $keys + * @param array|string|int|float $keys * @return void */ public static function forget(&$array, $keys) @@ -281,7 +286,7 @@ class Arr while (count($parts) > 1) { $part = array_shift($parts); - if (isset($array[$part]) && is_array($array[$part])) { + if (isset($array[$part]) && static::accessible($array[$part])) { $array = &$array[$part]; } else { continue 2; @@ -423,11 +428,38 @@ class Arr return ! self::isAssoc($array); } + /** + * Join all items using a string. The final items can use a separate glue string. + * + * @param array $array + * @param string $glue + * @param string $finalGlue + * @return string + */ + public static function join($array, $glue, $finalGlue = '') + { + if ($finalGlue === '') { + return implode($glue, $array); + } + + if (count($array) === 0) { + return ''; + } + + if (count($array) === 1) { + return end($array); + } + + $finalItem = array_pop($array); + + return implode($glue, $array).$finalGlue.$finalItem; + } + /** * Key an associative array by a field or using a callback. * * @param array $array - * @param callable|array|string + * @param callable|array|string $keyBy * @return array */ public static function keyBy($array, $keyBy) @@ -435,6 +467,20 @@ class Arr return Collection::make($array)->keyBy($keyBy)->all(); } + /** + * Prepend the key names of an associative array. + * + * @param array $array + * @param string $prependWith + * @return array + */ + public static function prependKeysWith($array, $prependWith) + { + return Collection::make($array)->mapWithKeys(function ($item, $key) use ($prependWith) { + return [$prependWith.$key => $item]; + })->all(); + } + /** * Get a subset of the items from the given array. * @@ -499,6 +545,26 @@ class Arr return [$value, $key]; } + /** + * Run a map over each of the items in the array. + * + * @param array $array + * @param callable $callback + * @return array + */ + public static function map(array $array, callable $callback) + { + $keys = array_keys($array); + + try { + $items = array_map($callback, $array, $keys); + } catch (ArgumentCountError) { + $items = array_map($callback, $array); + } + + return array_combine($keys, $items); + } + /** * Push an item onto the beginning of an array. * @@ -522,7 +588,7 @@ class Arr * Get a value from the array, and remove it. * * @param array $array - * @param string $key + * @param string|int $key * @param mixed $default * @return mixed */ @@ -551,7 +617,7 @@ class Arr * * @param array $array * @param int|null $number - * @param bool|false $preserveKeys + * @param bool $preserveKeys * @return mixed * * @throws \InvalidArgumentException @@ -599,7 +665,7 @@ class Arr * If no key is given to the method, the entire array will be replaced. * * @param array $array - * @param string|null $key + * @param string|int|null $key * @param mixed $value * @return array */ @@ -665,6 +731,18 @@ class Arr return Collection::make($array)->sortBy($callback)->all(); } + /** + * Sort the array in descending order using the given callback or "dot" notation. + * + * @param array $array + * @param callable|array|string|null $callback + * @return array + */ + public static function sortDesc($array, $callback = null) + { + return Collection::make($array)->sortByDesc($callback)->all(); + } + /** * Recursively sort an array by keys and values. * @@ -717,6 +795,29 @@ class Arr return implode(' ', $classes); } + /** + * Conditionally compile styles from an array into a style list. + * + * @param array $array + * @return string + */ + public static function toCssStyles($array) + { + $styleList = static::wrap($array); + + $styles = []; + + foreach ($styleList as $class => $constraint) { + if (is_numeric($class)) { + $styles[] = Str::finish($constraint, ';'); + } elseif ($constraint) { + $styles[] = Str::finish($class, ';'); + } + } + + return implode(' ', $styles); + } + /** * Filter the array using the given callback. * @@ -737,9 +838,7 @@ class Arr */ public static function whereNotNull($array) { - return static::where($array, function ($value) { - return ! is_null($value); - }); + return static::where($array, fn ($value) => ! is_null($value)); } /** diff --git a/vendor/illuminate/collections/Collection.php b/vendor/illuminate/collections/Collection.php index 907016d..e5e82bf 100644 --- a/vendor/illuminate/collections/Collection.php +++ b/vendor/illuminate/collections/Collection.php @@ -84,11 +84,9 @@ class Collection implements ArrayAccess, CanBeEscapedWhenCastToString, Enumerabl { $callback = $this->valueRetriever($callback); - $items = $this->map(function ($value) use ($callback) { - return $callback($value); - })->filter(function ($value) { - return ! is_null($value); - }); + $items = $this + ->map(fn ($value) => $callback($value)) + ->filter(fn ($value) => ! is_null($value)); if ($count = $items->count()) { return $items->sum() / $count; @@ -104,9 +102,8 @@ class Collection implements ArrayAccess, CanBeEscapedWhenCastToString, Enumerabl public function median($key = null) { $values = (isset($key) ? $this->pluck($key) : $this) - ->filter(function ($item) { - return ! is_null($item); - })->sort()->values(); + ->filter(fn ($item) => ! is_null($item)) + ->sort()->values(); $count = $values->count(); @@ -141,17 +138,14 @@ class Collection implements ArrayAccess, CanBeEscapedWhenCastToString, Enumerabl $counts = new static; - $collection->each(function ($value) use ($counts) { - $counts[$value] = isset($counts[$value]) ? $counts[$value] + 1 : 1; - }); + $collection->each(fn ($value) => $counts[$value] = isset($counts[$value]) ? $counts[$value] + 1 : 1); $sorted = $counts->sort(); $highestValue = $sorted->last(); - return $sorted->filter(function ($value) use ($highestValue) { - return $value == $highestValue; - })->sort()->keys()->all(); + return $sorted->filter(fn ($value) => $value == $highestValue) + ->sort()->keys()->all(); } /** @@ -187,6 +181,26 @@ class Collection implements ArrayAccess, CanBeEscapedWhenCastToString, Enumerabl return $this->contains($this->operatorForWhere(...func_get_args())); } + /** + * Determine if an item exists, using strict comparison. + * + * @param (callable(TValue): bool)|TValue|array-key $key + * @param TValue|null $value + * @return bool + */ + public function containsStrict($key, $value = null) + { + if (func_num_args() === 2) { + return $this->contains(fn ($item) => data_get($item, $key) === $value); + } + + if ($this->useAsCallable($key)) { + return ! is_null($this->first($key)); + } + + return in_array($key, $this->items, true); + } + /** * Determine if an item is not contained in the collection. * @@ -333,14 +347,10 @@ class Collection implements ArrayAccess, CanBeEscapedWhenCastToString, Enumerabl protected function duplicateComparator($strict) { if ($strict) { - return function ($a, $b) { - return $a === $b; - }; + return fn ($a, $b) => $a === $b; } - return function ($a, $b) { - return $a == $b; - }; + return fn ($a, $b) => $a == $b; } /** @@ -488,7 +498,11 @@ class Collection implements ArrayAccess, CanBeEscapedWhenCastToString, Enumerabl } foreach ($groupKeys as $groupKey) { - $groupKey = is_bool($groupKey) ? (int) $groupKey : $groupKey; + $groupKey = match (true) { + is_bool($groupKey) => (int) $groupKey, + $groupKey instanceof \Stringable => (string) $groupKey, + default => $groupKey, + }; if (! array_key_exists($groupKey, $results)) { $results[$groupKey] = new static; @@ -577,12 +591,16 @@ class Collection implements ArrayAccess, CanBeEscapedWhenCastToString, Enumerabl /** * Concatenate values of a given key as a string. * - * @param string $value + * @param callable|string $value * @param string|null $glue * @return string */ public function implode($value, $glue = null) { + if ($this->useAsCallable($value)) { + return implode($glue ?? '', $this->map($value)->all()); + } + $first = $this->first(); if (is_array($first) || (is_object($first) && ! $first instanceof Stringable)) { @@ -603,6 +621,41 @@ class Collection implements ArrayAccess, CanBeEscapedWhenCastToString, Enumerabl return new static(array_intersect($this->items, $this->getArrayableItems($items))); } + /** + * Intersect the collection with the given items, using the callback. + * + * @param \Illuminate\Contracts\Support\Arrayable|iterable $items + * @param callable(TValue, TValue): int $callback + * @return static + */ + public function intersectUsing($items, callable $callback) + { + return new static(array_uintersect($this->items, $this->getArrayableItems($items), $callback)); + } + + /** + * Intersect the collection with the given items with additional index check. + * + * @param \Illuminate\Contracts\Support\Arrayable|iterable $items + * @return static + */ + public function intersectAssoc($items) + { + return new static(array_intersect_assoc($this->items, $this->getArrayableItems($items))); + } + + /** + * Intersect the collection with the given items with additional index check, using the callback. + * + * @param \Illuminate\Contracts\Support\Arrayable|iterable $items + * @param callable(TValue, TValue): int $callback + * @return static + */ + public function intersectAssocUsing($items, callable $callback) + { + return new static(array_intersect_uassoc($this->items, $this->getArrayableItems($items), $callback)); + } + /** * Intersect the collection with the given items by key. * @@ -693,9 +746,9 @@ class Collection implements ArrayAccess, CanBeEscapedWhenCastToString, Enumerabl /** * Get the values of a given key. * - * @param string|array $value + * @param string|int|array $value * @param string|null $key - * @return static + * @return static */ public function pluck($value, $key = null) { @@ -712,11 +765,7 @@ class Collection implements ArrayAccess, CanBeEscapedWhenCastToString, Enumerabl */ public function map(callable $callback) { - $keys = array_keys($this->items); - - $items = array_map($callback, $this->items, $keys); - - return new static(array_combine($keys, $items)); + return new static(Arr::map($this->items, $callback)); } /** @@ -807,7 +856,7 @@ class Collection implements ArrayAccess, CanBeEscapedWhenCastToString, Enumerabl * @template TCombineValue * * @param \Illuminate\Contracts\Support\Arrayable|iterable $values - * @return static + * @return static */ public function combine($values) { @@ -838,8 +887,8 @@ class Collection implements ArrayAccess, CanBeEscapedWhenCastToString, Enumerabl $position = 0; - foreach ($this->items as $item) { - if ($position % $step === $offset) { + foreach ($this->slice($offset)->items as $item) { + if ($position % $step === 0) { $new[] = $item; } @@ -852,7 +901,7 @@ class Collection implements ArrayAccess, CanBeEscapedWhenCastToString, Enumerabl /** * Get the items with the specified keys. * - * @param \Illuminate\Support\Enumerable|array $keys + * @param \Illuminate\Support\Enumerable|array|string|null $keys * @return static */ public function only($keys) @@ -974,7 +1023,7 @@ class Collection implements ArrayAccess, CanBeEscapedWhenCastToString, Enumerabl /** * Get one or a specified number of items randomly from the collection. * - * @param int|null $number + * @param (callable(self): int)|int|null $number * @return static|TValue * * @throws \InvalidArgumentException @@ -985,6 +1034,10 @@ class Collection implements ArrayAccess, CanBeEscapedWhenCastToString, Enumerabl return Arr::random($this->items); } + if (is_callable($number)) { + return new static(Arr::random($this->items, $number($this))); + } + return new static(Arr::random($this->items, $number)); } @@ -1317,7 +1370,7 @@ class Collection implements ArrayAccess, CanBeEscapedWhenCastToString, Enumerabl /** * Sort the collection using the given callback. * - * @param array|(callable(TValue, TKey): mixed)|string $callback + * @param array|(callable(TValue, TKey): mixed)|string $callback * @param int $options * @param bool $descending * @return static @@ -1355,14 +1408,14 @@ class Collection implements ArrayAccess, CanBeEscapedWhenCastToString, Enumerabl /** * Sort the collection using multiple comparisons. * - * @param array $comparisons + * @param array $comparisons * @return static */ protected function sortByMany(array $comparisons = []) { $items = $this->items; - usort($items, function ($a, $b) use ($comparisons) { + uasort($items, function ($a, $b) use ($comparisons) { foreach ($comparisons as $comparison) { $comparison = Arr::wrap($comparison); @@ -1397,7 +1450,7 @@ class Collection implements ArrayAccess, CanBeEscapedWhenCastToString, Enumerabl /** * Sort the collection in descending order using the given callback. * - * @param array|(callable(TValue, TKey): mixed)|string $callback + * @param array|(callable(TValue, TKey): mixed)|string $callback * @param int $options * @return static */ @@ -1574,13 +1627,9 @@ class Collection implements ArrayAccess, CanBeEscapedWhenCastToString, Enumerabl */ public function zip($items) { - $arrayableItems = array_map(function ($items) { - return $this->getArrayableItems($items); - }, func_get_args()); + $arrayableItems = array_map(fn ($items) => $this->getArrayableItems($items), func_get_args()); - $params = array_merge([function () { - return new static(func_get_args()); - }, $this->items], $arrayableItems); + $params = array_merge([fn () => new static(func_get_args()), $this->items], $arrayableItems); return new static(array_map(...$params)); } @@ -1622,7 +1671,7 @@ class Collection implements ArrayAccess, CanBeEscapedWhenCastToString, Enumerabl /** * Count the number of items in the collection by a field or using a callback. * - * @param (callable(TValue, TKey): mixed)|string|null $countBy + * @param (callable(TValue, TKey): array-key)|string|null $countBy * @return static */ public function countBy($countBy = null) diff --git a/vendor/illuminate/collections/Enumerable.php b/vendor/illuminate/collections/Enumerable.php index 74e9046..070b565 100644 --- a/vendor/illuminate/collections/Enumerable.php +++ b/vendor/illuminate/collections/Enumerable.php @@ -51,11 +51,10 @@ interface Enumerable extends Arrayable, Countable, IteratorAggregate, Jsonable, /** * Wrap the given value in a collection if applicable. * - * @template TWrapKey of array-key * @template TWrapValue * - * @param iterable $value - * @return static + * @param iterable|TWrapValue $value + * @return static */ public static function wrap($value); @@ -460,8 +459,10 @@ interface Enumerable extends Arrayable, Countable, IteratorAggregate, Jsonable, /** * Filter the items, removing any items that don't match the given type(s). * - * @param class-string|array $type - * @return static + * @template TWhereInstanceOf + * + * @param class-string|array> $type + * @return static */ public function whereInstanceOf($type); @@ -678,8 +679,11 @@ interface Enumerable extends Arrayable, Countable, IteratorAggregate, Jsonable, /** * Map a collection and flatten the result by a single level. * - * @param callable(TValue, TKey): mixed $callback - * @return static + * @template TFlatMapKey of array-key + * @template TFlatMapValue + * + * @param callable(TValue, TKey): (\Illuminate\Support\Collection|array) $callback + * @return static */ public function flatMap(callable $callback); @@ -717,7 +721,7 @@ interface Enumerable extends Arrayable, Countable, IteratorAggregate, Jsonable, * @template TCombineValue * * @param \Illuminate\Contracts\Support\Arrayable|iterable $values - * @return static + * @return static */ public function combine($values); @@ -733,7 +737,7 @@ interface Enumerable extends Arrayable, Countable, IteratorAggregate, Jsonable, * Get the min value of a given key. * * @param (callable(TValue):mixed)|string|null $callback - * @return TValue + * @return mixed */ public function min($callback = null); @@ -741,7 +745,7 @@ interface Enumerable extends Arrayable, Countable, IteratorAggregate, Jsonable, * Get the max value of a given key. * * @param (callable(TValue):mixed)|string|null $callback - * @return TValue + * @return mixed */ public function max($callback = null); @@ -757,7 +761,7 @@ interface Enumerable extends Arrayable, Countable, IteratorAggregate, Jsonable, /** * Get the items with the specified keys. * - * @param \Illuminate\Support\Enumerable|array $keys + * @param \Illuminate\Support\Enumerable|array|string $keys * @return static */ public function only($keys); @@ -980,7 +984,7 @@ interface Enumerable extends Arrayable, Countable, IteratorAggregate, Jsonable, /** * Sort the collection using the given callback. * - * @param array|(callable(TValue, TKey): mixed)|string $callback + * @param array|(callable(TValue, TKey): mixed)|string $callback * @param int $options * @param bool $descending * @return static @@ -990,7 +994,7 @@ interface Enumerable extends Arrayable, Countable, IteratorAggregate, Jsonable, /** * Sort the collection in descending order using the given callback. * - * @param array|(callable(TValue, TKey): mixed)|string $callback + * @param array|(callable(TValue, TKey): mixed)|string $callback * @param int $options * @return static */ @@ -1099,7 +1103,7 @@ interface Enumerable extends Arrayable, Countable, IteratorAggregate, Jsonable, /** * Create a collection of all elements that do not pass a given truth test. * - * @param (callable(TValue, TKey): bool)|bool $callback + * @param (callable(TValue, TKey): bool)|bool|TValue $callback * @return static */ public function reject($callback = true); @@ -1163,10 +1167,10 @@ interface Enumerable extends Arrayable, Countable, IteratorAggregate, Jsonable, /** * Count the number of items in the collection by a field or using a callback. * - * @param (callable(TValue, TKey): mixed)|string|null $countBy + * @param (callable(TValue, TKey): array-key)|string|null $countBy * @return static */ - public function countBy($callback = null); + public function countBy($countBy = null); /** * Zip the collection together with one or more arrays. @@ -1198,9 +1202,9 @@ interface Enumerable extends Arrayable, Countable, IteratorAggregate, Jsonable, /** * Convert the object into something JSON serializable. * - * @return array + * @return mixed */ - public function jsonSerialize(): array; + public function jsonSerialize(): mixed; /** * Get the collection of items as JSON. diff --git a/vendor/illuminate/collections/LazyCollection.php b/vendor/illuminate/collections/LazyCollection.php index 2a9b93c..8119b3a 100644 --- a/vendor/illuminate/collections/LazyCollection.php +++ b/vendor/illuminate/collections/LazyCollection.php @@ -236,6 +236,32 @@ class LazyCollection implements CanBeEscapedWhenCastToString, Enumerable return $this->contains($this->operatorForWhere(...func_get_args())); } + /** + * Determine if an item exists, using strict comparison. + * + * @param (callable(TValue): bool)|TValue|array-key $key + * @param TValue|null $value + * @return bool + */ + public function containsStrict($key, $value = null) + { + if (func_num_args() === 2) { + return $this->contains(fn ($item) => data_get($item, $key) === $value); + } + + if ($this->useAsCallable($key)) { + return ! is_null($this->first($key)); + } + + foreach ($this as $item) { + if ($item === $key) { + return true; + } + } + + return false; + } + /** * Determine if an item is not contained in the enumerable. * @@ -266,7 +292,7 @@ class LazyCollection implements CanBeEscapedWhenCastToString, Enumerable /** * Count the number of items in the collection by a field or using a callback. * - * @param (callable(TValue, TKey): mixed)|string|null $countBy + * @param (callable(TValue, TKey): array-key)|string|null $countBy * @return static */ public function countBy($countBy = null) @@ -398,15 +424,13 @@ class LazyCollection implements CanBeEscapedWhenCastToString, Enumerable /** * Run a filter over each of the items. * - * @param (callable(TValue): bool)|null $callback + * @param (callable(TValue, TKey): bool)|null $callback * @return static */ public function filter(callable $callback = null) { if (is_null($callback)) { - $callback = function ($value) { - return (bool) $value; - }; + $callback = fn ($value) => (bool) $value; } return new static(function () use ($callback) { @@ -586,7 +610,7 @@ class LazyCollection implements CanBeEscapedWhenCastToString, Enumerable /** * Concatenate values of a given key as a string. * - * @param string $value + * @param callable|string $value * @param string|null $glue * @return string */ @@ -606,6 +630,41 @@ class LazyCollection implements CanBeEscapedWhenCastToString, Enumerable return $this->passthru('intersect', func_get_args()); } + /** + * Intersect the collection with the given items, using the callback. + * + * @param \Illuminate\Contracts\Support\Arrayable|iterable $items + * @param callable(TValue, TValue): int $callback + * @return static + */ + public function intersectUsing() + { + return $this->passthru('intersectUsing', func_get_args()); + } + + /** + * Intersect the collection with the given items with additional index check. + * + * @param \Illuminate\Contracts\Support\Arrayable|iterable $items + * @return static + */ + public function intersectAssoc($items) + { + return $this->passthru('intersectAssoc', func_get_args()); + } + + /** + * Intersect the collection with the given items with additional index check, using the callback. + * + * @param \Illuminate\Contracts\Support\Arrayable|iterable $items + * @param callable(TValue, TValue): int $callback + * @return static + */ + public function intersectAssocUsing($items, callable $callback) + { + return $this->passthru('intersectAssocUsing', func_get_args()); + } + /** * Intersect the collection with the given items by key. * @@ -798,7 +857,7 @@ class LazyCollection implements CanBeEscapedWhenCastToString, Enumerable * @template TCombineValue * * @param \IteratorAggregate|array|(callable(): \Generator) $values - * @return static + * @return static */ public function combine($values) { @@ -848,8 +907,8 @@ class LazyCollection implements CanBeEscapedWhenCastToString, Enumerable return new static(function () use ($step, $offset) { $position = 0; - foreach ($this as $item) { - if ($position % $step === $offset) { + foreach ($this->slice($offset) as $item) { + if ($position % $step === 0) { yield $item; } @@ -861,7 +920,7 @@ class LazyCollection implements CanBeEscapedWhenCastToString, Enumerable /** * Get the items with the specified keys. * - * @param \Illuminate\Support\Enumerable|array $keys + * @param \Illuminate\Support\Enumerable|array|string $keys * @return static */ public function only($keys) @@ -1296,7 +1355,7 @@ class LazyCollection implements CanBeEscapedWhenCastToString, Enumerable /** * Sort the collection using the given callback. * - * @param array|(callable(TValue, TKey): mixed)|string $callback + * @param array|(callable(TValue, TKey): mixed)|string $callback * @param int $options * @param bool $descending * @return static @@ -1309,7 +1368,7 @@ class LazyCollection implements CanBeEscapedWhenCastToString, Enumerable /** * Sort the collection in descending order using the given callback. * - * @param array|(callable(TValue, TKey): mixed)|string $callback + * @param array|(callable(TValue, TKey): mixed)|string $callback * @param int $options * @return static */ @@ -1439,9 +1498,7 @@ class LazyCollection implements CanBeEscapedWhenCastToString, Enumerable /** @var callable(TValue, TKey): bool $callback */ $callback = $this->useAsCallable($value) ? $value : $this->equality($value); - return $this->takeUntil(function ($item, $key) use ($callback) { - return ! $callback($item, $key); - }); + return $this->takeUntil(fn ($item, $key) => ! $callback($item, $key)); } /** @@ -1610,7 +1667,15 @@ class LazyCollection implements CanBeEscapedWhenCastToString, Enumerable return new ArrayIterator($source); } - return $source(); + if (is_callable($source)) { + $maybeTraversable = $source(); + + return $maybeTraversable instanceof Traversable + ? $maybeTraversable + : new ArrayIterator(Arr::wrap($maybeTraversable)); + } + + return new ArrayIterator((array) $source); } /** diff --git a/vendor/illuminate/collections/Traits/EnumeratesValues.php b/vendor/illuminate/collections/Traits/EnumeratesValues.php index fec5502..2ffbe8d 100644 --- a/vendor/illuminate/collections/Traits/EnumeratesValues.php +++ b/vendor/illuminate/collections/Traits/EnumeratesValues.php @@ -15,6 +15,7 @@ use JsonSerializable; use Symfony\Component\VarDumper\VarDumper; use Traversable; use UnexpectedValueException; +use UnitEnum; /** * @template TKey of array-key @@ -113,11 +114,10 @@ trait EnumeratesValues /** * Wrap the given value in a collection if applicable. * - * @template TWrapKey of array-key * @template TWrapValue * - * @param iterable $value - * @return static + * @param iterable|TWrapValue $value + * @return static */ public static function wrap($value) { @@ -194,34 +194,6 @@ trait EnumeratesValues return $this->contains(...func_get_args()); } - /** - * Determine if an item exists, using strict comparison. - * - * @param (callable(TValue): bool)|TValue|array-key $key - * @param TValue|null $value - * @return bool - */ - public function containsStrict($key, $value = null) - { - if (func_num_args() === 2) { - return $this->contains(function ($item) use ($key, $value) { - return data_get($item, $key) === $value; - }); - } - - if ($this->useAsCallable($key)) { - return ! is_null($this->first($key)); - } - - foreach ($this as $item) { - if ($item === $key) { - return true; - } - } - - return false; - } - /** * Dump the items and end the script. * @@ -311,7 +283,7 @@ trait EnumeratesValues /** * Get the first item by the given key value pair. * - * @param string $key + * @param callable|string $key * @param mixed $operator * @param mixed $value * @return TValue|null @@ -321,6 +293,22 @@ trait EnumeratesValues return $this->first($this->operatorForWhere(...func_get_args())); } + /** + * Get a single key's value from the first matching item in the collection. + * + * @param string $key + * @param mixed $default + * @return mixed + */ + public function value($key, $default = null) + { + if ($value = $this->firstWhere($key)) { + return data_get($value, $key, $default); + } + + return value($default); + } + /** * Determine if the collection is not empty. * @@ -369,8 +357,11 @@ trait EnumeratesValues /** * Map a collection and flatten the result by a single level. * - * @param callable(TValue, TKey): mixed $callback - * @return static + * @template TFlatMapKey of array-key + * @template TFlatMapValue + * + * @param callable(TValue, TKey): (\Illuminate\Support\Collection|array) $callback + * @return static */ public function flatMap(callable $callback) { @@ -387,43 +378,35 @@ trait EnumeratesValues */ public function mapInto($class) { - return $this->map(function ($value, $key) use ($class) { - return new $class($value, $key); - }); + return $this->map(fn ($value, $key) => new $class($value, $key)); } /** * Get the min value of a given key. * * @param (callable(TValue):mixed)|string|null $callback - * @return TValue + * @return mixed */ public function min($callback = null) { $callback = $this->valueRetriever($callback); - return $this->map(function ($value) use ($callback) { - return $callback($value); - })->filter(function ($value) { - return ! is_null($value); - })->reduce(function ($result, $value) { - return is_null($result) || $value < $result ? $value : $result; - }); + return $this->map(fn ($value) => $callback($value)) + ->filter(fn ($value) => ! is_null($value)) + ->reduce(fn ($result, $value) => is_null($result) || $value < $result ? $value : $result); } /** * Get the max value of a given key. * * @param (callable(TValue):mixed)|string|null $callback - * @return TValue + * @return mixed */ public function max($callback = null) { $callback = $this->valueRetriever($callback); - return $this->filter(function ($value) { - return ! is_null($value); - })->reduce(function ($result, $item) use ($callback) { + return $this->filter(fn ($value) => ! is_null($value))->reduce(function ($result, $item) use ($callback) { $value = $callback($item); return is_null($result) || $value > $result ? $value : $result; @@ -484,9 +467,7 @@ trait EnumeratesValues ? $this->identity() : $this->valueRetriever($callback); - return $this->reduce(function ($result, $item) use ($callback) { - return $result + $callback($item); - }, 0); + return $this->reduce(fn ($result, $item) => $result + $callback($item), 0); } /** @@ -548,7 +529,7 @@ trait EnumeratesValues /** * Filter items by the given key value pair. * - * @param string $key + * @param callable|string $key * @param mixed $operator * @param mixed $value * @return static @@ -604,9 +585,7 @@ trait EnumeratesValues { $values = $this->getArrayableItems($values); - return $this->filter(function ($item) use ($key, $values, $strict) { - return in_array(data_get($item, $key), $values, $strict); - }); + return $this->filter(fn ($item) => in_array(data_get($item, $key), $values, $strict)); } /** @@ -642,9 +621,9 @@ trait EnumeratesValues */ public function whereNotBetween($key, $values) { - return $this->filter(function ($item) use ($key, $values) { - return data_get($item, $key) < reset($values) || data_get($item, $key) > end($values); - }); + return $this->filter( + fn ($item) => data_get($item, $key) < reset($values) || data_get($item, $key) > end($values) + ); } /** @@ -659,9 +638,7 @@ trait EnumeratesValues { $values = $this->getArrayableItems($values); - return $this->reject(function ($item) use ($key, $values, $strict) { - return in_array(data_get($item, $key), $values, $strict); - }); + return $this->reject(fn ($item) => in_array(data_get($item, $key), $values, $strict)); } /** @@ -679,8 +656,10 @@ trait EnumeratesValues /** * Filter the items, removing any items that don't match the given type(s). * - * @param class-string|array $type - * @return static + * @template TWhereInstanceOf + * + * @param class-string|array> $type + * @return static */ public function whereInstanceOf($type) { @@ -732,9 +711,7 @@ trait EnumeratesValues public function pipeThrough($callbacks) { return Collection::make($callbacks)->reduce( - function ($carry, $callback) { - return $callback($carry); - }, + fn ($carry, $callback) => $callback($carry), $this, ); } @@ -778,7 +755,7 @@ trait EnumeratesValues if (! is_array($result)) { throw new UnexpectedValueException(sprintf( - "%s::reduceMany expects reducer to return an array, but got a '%s' instead.", + "%s::reduceSpread expects reducer to return an array, but got a '%s' instead.", class_basename(static::class), gettype($result) )); } @@ -790,7 +767,7 @@ trait EnumeratesValues /** * Create a collection of all elements that do not pass a given truth test. * - * @param (callable(TValue, TKey): bool)|bool $callback + * @param (callable(TValue, TKey): bool)|bool|TValue $callback * @return static */ public function reject($callback = true) @@ -867,9 +844,7 @@ trait EnumeratesValues */ public function toArray() { - return $this->map(function ($value) { - return $value instanceof Arrayable ? $value->toArray() : $value; - })->all(); + return $this->map(fn ($value) => $value instanceof Arrayable ? $value->toArray() : $value)->all(); } /** @@ -981,12 +956,14 @@ trait EnumeratesValues return $items->all(); } elseif ($items instanceof Arrayable) { return $items->toArray(); + } elseif ($items instanceof Traversable) { + return iterator_to_array($items); } elseif ($items instanceof Jsonable) { return json_decode($items->toJson(), true); } elseif ($items instanceof JsonSerializable) { return (array) $items->jsonSerialize(); - } elseif ($items instanceof Traversable) { - return iterator_to_array($items); + } elseif ($items instanceof UnitEnum) { + return [$items]; } return (array) $items; @@ -995,13 +972,17 @@ trait EnumeratesValues /** * Get an operator checker callback. * - * @param string $key + * @param callable|string $key * @param string|null $operator * @param mixed $value * @return \Closure */ protected function operatorForWhere($key, $operator = null, $value = null) { + if ($this->useAsCallable($key)) { + return $key; + } + if (func_num_args() === 1) { $value = true; @@ -1037,6 +1018,7 @@ trait EnumeratesValues case '>=': return $retrieved >= $value; case '===': return $retrieved === $value; case '!==': return $retrieved !== $value; + case '<=>': return $retrieved <=> $value; } }; } @@ -1064,9 +1046,7 @@ trait EnumeratesValues return $value; } - return function ($item) use ($value) { - return data_get($item, $value); - }; + return fn ($item) => data_get($item, $value); } /** @@ -1077,9 +1057,7 @@ trait EnumeratesValues */ protected function equality($value) { - return function ($item) use ($value) { - return $item === $value; - }; + return fn ($item) => $item === $value; } /** @@ -1090,9 +1068,7 @@ trait EnumeratesValues */ protected function negate(Closure $callback) { - return function (...$params) use ($callback) { - return ! $callback(...$params); - }; + return fn (...$params) => ! $callback(...$params); } /** @@ -1102,8 +1078,6 @@ trait EnumeratesValues */ protected function identity() { - return function ($value) { - return $value; - }; + return fn ($value) => $value; } } diff --git a/vendor/illuminate/collections/helpers.php b/vendor/illuminate/collections/helpers.php index 45fc6d4..9babf4e 100644 --- a/vendor/illuminate/collections/helpers.php +++ b/vendor/illuminate/collections/helpers.php @@ -13,7 +13,7 @@ if (! function_exists('collect')) { * @param \Illuminate\Contracts\Support\Arrayable|iterable|null $value * @return \Illuminate\Support\Collection */ - function collect($value = null) + function collect($value = []) { return new Collection($value); } @@ -180,6 +180,7 @@ if (! function_exists('value')) { * Return the default value of the given value. * * @param mixed $value + * @param mixed ...$args * @return mixed */ function value($value, ...$args) diff --git a/vendor/illuminate/conditionable/HigherOrderWhenProxy.php b/vendor/illuminate/conditionable/HigherOrderWhenProxy.php index 173a783..579114c 100644 --- a/vendor/illuminate/conditionable/HigherOrderWhenProxy.php +++ b/vendor/illuminate/conditionable/HigherOrderWhenProxy.php @@ -18,17 +18,54 @@ class HigherOrderWhenProxy */ protected $condition; + /** + * Indicates whether the proxy has a condition. + * + * @var bool + */ + protected $hasCondition = false; + + /** + * Determine whether the condition should be negated. + * + * @var bool + */ + protected $negateConditionOnCapture; + /** * Create a new proxy instance. * * @param mixed $target - * @param bool $condition * @return void */ - public function __construct($target, $condition) + public function __construct($target) { $this->target = $target; - $this->condition = $condition; + } + + /** + * Set the condition on the proxy. + * + * @param bool $condition + * @return $this + */ + public function condition($condition) + { + [$this->condition, $this->hasCondition] = [$condition, true]; + + return $this; + } + + /** + * Indicate that the condition should be negated. + * + * @return $this + */ + public function negateConditionOnCapture() + { + $this->negateConditionOnCapture = true; + + return $this; } /** @@ -39,6 +76,12 @@ class HigherOrderWhenProxy */ public function __get($key) { + if (! $this->hasCondition) { + $condition = $this->target->{$key}; + + return $this->condition($this->negateConditionOnCapture ? ! $condition : $condition); + } + return $this->condition ? $this->target->{$key} : $this->target; @@ -53,6 +96,12 @@ class HigherOrderWhenProxy */ public function __call($method, $parameters) { + if (! $this->hasCondition) { + $condition = $this->target->{$method}(...$parameters); + + return $this->condition($this->negateConditionOnCapture ? ! $condition : $condition); + } + return $this->condition ? $this->target->{$method}(...$parameters) : $this->target; diff --git a/vendor/illuminate/conditionable/Traits/Conditionable.php b/vendor/illuminate/conditionable/Traits/Conditionable.php index 81451bc..1930743 100644 --- a/vendor/illuminate/conditionable/Traits/Conditionable.php +++ b/vendor/illuminate/conditionable/Traits/Conditionable.php @@ -13,17 +13,21 @@ trait Conditionable * @template TWhenParameter * @template TWhenReturnType * - * @param (\Closure($this): TWhenParameter)|TWhenParameter $value + * @param (\Closure($this): TWhenParameter)|TWhenParameter|null $value * @param (callable($this, TWhenParameter): TWhenReturnType)|null $callback * @param (callable($this, TWhenParameter): TWhenReturnType)|null $default * @return $this|TWhenReturnType */ - public function when($value, callable $callback = null, callable $default = null) + public function when($value = null, callable $callback = null, callable $default = null) { $value = $value instanceof Closure ? $value($this) : $value; - if (! $callback) { - return new HigherOrderWhenProxy($this, $value); + if (func_num_args() === 0) { + return new HigherOrderWhenProxy($this); + } + + if (func_num_args() === 1) { + return (new HigherOrderWhenProxy($this))->condition($value); } if ($value) { @@ -41,17 +45,21 @@ trait Conditionable * @template TUnlessParameter * @template TUnlessReturnType * - * @param (\Closure($this): TUnlessParameter)|TUnlessParameter $value + * @param (\Closure($this): TUnlessParameter)|TUnlessParameter|null $value * @param (callable($this, TUnlessParameter): TUnlessReturnType)|null $callback * @param (callable($this, TUnlessParameter): TUnlessReturnType)|null $default * @return $this|TUnlessReturnType */ - public function unless($value, callable $callback = null, callable $default = null) + public function unless($value = null, callable $callback = null, callable $default = null) { $value = $value instanceof Closure ? $value($this) : $value; - if (! $callback) { - return new HigherOrderWhenProxy($this, ! $value); + if (func_num_args() === 0) { + return (new HigherOrderWhenProxy($this))->negateConditionOnCapture(); + } + + if (func_num_args() === 1) { + return (new HigherOrderWhenProxy($this))->condition(! $value); } if (! $value) { diff --git a/vendor/illuminate/container/Container.php b/vendor/illuminate/container/Container.php index 37ae6e0..519fcdf 100755 --- a/vendor/illuminate/container/Container.php +++ b/vendor/illuminate/container/Container.php @@ -426,9 +426,7 @@ class Container implements ArrayAccess, ContainerContract public function scopedIf($abstract, $concrete = null) { if (! $this->bound($abstract)) { - $this->scopedInstances[] = $abstract; - - $this->singleton($abstract, $concrete); + $this->scoped($abstract, $concrete); } } @@ -633,9 +631,7 @@ class Container implements ArrayAccess, ContainerContract */ public function wrap(Closure $callback, array $parameters = []) { - return function () use ($callback, $parameters) { - return $this->call($callback, $parameters); - }; + return fn () => $this->call($callback, $parameters); } /** @@ -650,7 +646,25 @@ class Container implements ArrayAccess, ContainerContract */ public function call($callback, array $parameters = [], $defaultMethod = null) { - return BoundMethod::call($this, $callback, $parameters, $defaultMethod); + $pushedToBuildStack = false; + + if (is_array($callback) && ! in_array( + $className = (is_string($callback[0]) ? $callback[0] : get_class($callback[0])), + $this->buildStack, + true + )) { + $this->buildStack[] = $className; + + $pushedToBuildStack = true; + } + + $result = BoundMethod::call($this, $callback, $parameters, $defaultMethod); + + if ($pushedToBuildStack) { + array_pop($this->buildStack); + } + + return $result; } /** @@ -661,9 +675,7 @@ class Container implements ArrayAccess, ContainerContract */ public function factory($abstract) { - return function () use ($abstract) { - return $this->make($abstract); - }; + return fn () => $this->make($abstract); } /** @@ -708,7 +720,7 @@ class Container implements ArrayAccess, ContainerContract throw $e; } - throw new EntryNotFoundException($id, $e->getCode(), $e); + throw new EntryNotFoundException($id, is_int($e->getCode()) ? $e->getCode() : 0, $e); } } @@ -1008,6 +1020,10 @@ class Container implements ArrayAccess, ContainerContract return $parameter->getDefaultValue(); } + if ($parameter->isVariadic()) { + return []; + } + $this->unresolvablePrimitive($parameter); } @@ -1063,9 +1079,7 @@ class Container implements ArrayAccess, ContainerContract return $this->make($className); } - return array_map(function ($abstract) { - return $this->resolve($abstract); - }, $concrete); + return array_map(fn ($abstract) => $this->resolve($abstract), $concrete); } /** @@ -1426,9 +1440,7 @@ class Container implements ArrayAccess, ContainerContract */ public function offsetSet($key, $value): void { - $this->bind($key, $value instanceof Closure ? $value : function () use ($value) { - return $value; - }); + $this->bind($key, $value instanceof Closure ? $value : fn () => $value); } /** diff --git a/vendor/illuminate/container/ContextualBindingBuilder.php b/vendor/illuminate/container/ContextualBindingBuilder.php index ae4c02a..707b74c 100644 --- a/vendor/illuminate/container/ContextualBindingBuilder.php +++ b/vendor/illuminate/container/ContextualBindingBuilder.php @@ -91,8 +91,6 @@ class ContextualBindingBuilder implements ContextualBindingBuilderContract */ public function giveConfig($key, $default = null) { - $this->give(function ($container) use ($key, $default) { - return $container->get('config')->get($key, $default); - }); + $this->give(fn ($container) => $container->get('config')->get($key, $default)); } } diff --git a/vendor/illuminate/contracts/Broadcasting/ShouldBeUnique.php b/vendor/illuminate/contracts/Broadcasting/ShouldBeUnique.php new file mode 100644 index 0000000..c72b7a8 --- /dev/null +++ b/vendor/illuminate/contracts/Broadcasting/ShouldBeUnique.php @@ -0,0 +1,8 @@ +|CastsAttributes|CastsInboundAttributes */ public static function castUsing(array $arguments); } diff --git a/vendor/illuminate/contracts/Database/Eloquent/CastsAttributes.php b/vendor/illuminate/contracts/Database/Eloquent/CastsAttributes.php index 808d005..878169c 100644 --- a/vendor/illuminate/contracts/Database/Eloquent/CastsAttributes.php +++ b/vendor/illuminate/contracts/Database/Eloquent/CastsAttributes.php @@ -2,6 +2,10 @@ namespace Illuminate\Contracts\Database\Eloquent; +/** + * @template TGet + * @template TSet + */ interface CastsAttributes { /** @@ -11,7 +15,7 @@ interface CastsAttributes * @param string $key * @param mixed $value * @param array $attributes - * @return mixed + * @return TGet|null */ public function get($model, string $key, $value, array $attributes); @@ -20,7 +24,7 @@ interface CastsAttributes * * @param \Illuminate\Database\Eloquent\Model $model * @param string $key - * @param mixed $value + * @param TSet|null $value * @param array $attributes * @return mixed */ diff --git a/vendor/illuminate/contracts/Database/ModelIdentifier.php b/vendor/illuminate/contracts/Database/ModelIdentifier.php index 9893d28..aacd18c 100644 --- a/vendor/illuminate/contracts/Database/ModelIdentifier.php +++ b/vendor/illuminate/contracts/Database/ModelIdentifier.php @@ -34,6 +34,13 @@ class ModelIdentifier */ public $connection; + /** + * The class name of the model collection. + * + * @var string|null + */ + public $collectionClass; + /** * Create a new model identifier. * @@ -50,4 +57,17 @@ class ModelIdentifier $this->relations = $relations; $this->connection = $connection; } + + /** + * Specify the collection class that should be used when serializing / restoring collections. + * + * @param string|null $collectionClass + * @return $this + */ + public function useCollectionClass(?string $collectionClass) + { + $this->collectionClass = $collectionClass; + + return $this; + } } diff --git a/vendor/illuminate/contracts/Foundation/Application.php b/vendor/illuminate/contracts/Foundation/Application.php index b46c6de..3c4fbad 100644 --- a/vendor/illuminate/contracts/Foundation/Application.php +++ b/vendor/illuminate/contracts/Foundation/Application.php @@ -64,7 +64,7 @@ interface Application extends Container /** * Get or check the current application environment. * - * @param string|array $environments + * @param string|array ...$environments * @return string|bool */ public function environment(...$environments); diff --git a/vendor/illuminate/contracts/Mail/Attachable.php b/vendor/illuminate/contracts/Mail/Attachable.php new file mode 100644 index 0000000..6804ec3 --- /dev/null +++ b/vendor/illuminate/contracts/Mail/Attachable.php @@ -0,0 +1,13 @@ +last()->{$alias}; + $lastId = data_get($results->last(), $alias); if ($lastId === null) { throw new RuntimeException("The chunkById operation was aborted because the [{$alias}] column is not present in the query result."); @@ -326,7 +326,7 @@ trait BuildsQueries * Paginate the given query using a cursor paginator. * * @param int $perPage - * @param array $columns + * @param array|string $columns * @param string $cursorName * @param \Illuminate\Pagination\Cursor|string|null $cursor * @return \Illuminate\Contracts\Pagination\CursorPaginator @@ -343,6 +343,8 @@ trait BuildsQueries if (! is_null($cursor)) { $addCursorConditions = function (self $builder, $previousColumn, $i) use (&$addCursorConditions, $cursor, $orders) { + $unionBuilders = isset($builder->unions) ? collect($builder->unions)->pluck('query') : collect(); + if (! is_null($previousColumn)) { $originalColumn = $this->getOriginalColumnNameForCursorPagination($this, $previousColumn); @@ -351,9 +353,19 @@ trait BuildsQueries '=', $cursor->parameter($previousColumn) ); + + $unionBuilders->each(function ($unionBuilder) use ($previousColumn, $cursor) { + $unionBuilder->where( + $this->getOriginalColumnNameForCursorPagination($this, $previousColumn), + '=', + $cursor->parameter($previousColumn) + ); + + $this->addBinding($unionBuilder->getRawBindings()['where'], 'union'); + }); } - $builder->where(function (self $builder) use ($addCursorConditions, $cursor, $orders, $i) { + $builder->where(function (self $builder) use ($addCursorConditions, $cursor, $orders, $i, $unionBuilders) { ['column' => $column, 'direction' => $direction] = $orders[$i]; $originalColumn = $this->getOriginalColumnNameForCursorPagination($this, $column); @@ -369,6 +381,24 @@ trait BuildsQueries $addCursorConditions($builder, $column, $i + 1); }); } + + $unionBuilders->each(function ($unionBuilder) use ($column, $direction, $cursor, $i, $orders, $addCursorConditions) { + $unionBuilder->where(function ($unionBuilder) use ($column, $direction, $cursor, $i, $orders, $addCursorConditions) { + $unionBuilder->where( + $this->getOriginalColumnNameForCursorPagination($this, $column), + $direction === 'asc' ? '>' : '<', + $cursor->parameter($column) + ); + + if ($i < $orders->count() - 1) { + $unionBuilder->orWhere(function (self $builder) use ($addCursorConditions, $column, $i) { + $addCursorConditions($builder, $column, $i + 1); + }); + } + + $this->addBinding($unionBuilder->getRawBindings()['where'], 'union'); + }); + }); }); }; @@ -397,10 +427,10 @@ trait BuildsQueries if (! is_null($columns)) { foreach ($columns as $column) { - if (($position = stripos($column, ' as ')) !== false) { - $as = substr($column, $position, 4); + if (($position = strripos($column, ' as ')) !== false) { + $original = substr($column, 0, $position); - [$original, $alias] = explode($as, $column); + $alias = substr($column, $position + 4); if ($parameter === $alias || $builder->getGrammar()->wrap($parameter) === $alias) { return $original; diff --git a/vendor/illuminate/database/Concerns/CompilesJsonPaths.php b/vendor/illuminate/database/Concerns/CompilesJsonPaths.php new file mode 100644 index 0000000..ade5461 --- /dev/null +++ b/vendor/illuminate/database/Concerns/CompilesJsonPaths.php @@ -0,0 +1,64 @@ +', $column, 2); + + $field = $this->wrap($parts[0]); + + $path = count($parts) > 1 ? ', '.$this->wrapJsonPath($parts[1], '->') : ''; + + return [$field, $path]; + } + + /** + * Wrap the given JSON path. + * + * @param string $value + * @param string $delimiter + * @return string + */ + protected function wrapJsonPath($value, $delimiter = '->') + { + $value = preg_replace("/([\\\\]+)?\\'/", "''", $value); + + $jsonPath = collect(explode($delimiter, $value)) + ->map(fn ($segment) => $this->wrapJsonPathSegment($segment)) + ->join('.'); + + return "'$".(str_starts_with($jsonPath, '[') ? '' : '.').$jsonPath."'"; + } + + /** + * Wrap the given JSON path segment. + * + * @param string $segment + * @return string + */ + protected function wrapJsonPathSegment($segment) + { + if (preg_match('/(\[[^\]]+\])+$/', $segment, $parts)) { + $key = Str::beforeLast($segment, $parts[0]); + + if (! empty($key)) { + return '"'.$key.'"'.$parts[0]; + } + + return $parts[0]; + } + + return '"'.$segment.'"'; + } +} diff --git a/vendor/illuminate/database/Concerns/ManagesTransactions.php b/vendor/illuminate/database/Concerns/ManagesTransactions.php index 3b1875f..14661cc 100644 --- a/vendor/illuminate/database/Concerns/ManagesTransactions.php +++ b/vendor/illuminate/database/Concerns/ManagesTransactions.php @@ -3,6 +3,7 @@ namespace Illuminate\Database\Concerns; use Closure; +use Illuminate\Database\DeadlockException; use RuntimeException; use Throwable; @@ -31,7 +32,7 @@ trait ManagesTransactions // If we catch an exception we'll rollback this transaction and try again if we // are not out of attempts. If we are out of attempts we will just throw the - // exception back out and let the developer handle an uncaught exceptions. + // exception back out, and let the developer handle an uncaught exception. catch (Throwable $e) { $this->handleTransactionException( $e, $currentAttempt, $attempts @@ -42,12 +43,13 @@ trait ManagesTransactions try { if ($this->transactions == 1) { + $this->fireConnectionEvent('committing'); $this->getPdo()->commit(); } $this->transactions = max(0, $this->transactions - 1); - if ($this->transactions == 0) { + if ($this->afterCommitCallbacksShouldBeExecuted()) { $this->transactionsManager?->commit($this->getName()); } } catch (Throwable $e) { @@ -87,7 +89,7 @@ trait ManagesTransactions $this->getName(), $this->transactions ); - throw $e; + throw new DeadlockException($e->getMessage(), is_int($e->getCode()) ? $e->getCode() : 0, $e); } // If there was an exception we will rollback this transaction and then we @@ -187,19 +189,32 @@ trait ManagesTransactions */ public function commit() { - if ($this->transactions == 1) { + if ($this->transactionLevel() == 1) { + $this->fireConnectionEvent('committing'); $this->getPdo()->commit(); } $this->transactions = max(0, $this->transactions - 1); - if ($this->transactions == 0) { + if ($this->afterCommitCallbacksShouldBeExecuted()) { $this->transactionsManager?->commit($this->getName()); } $this->fireConnectionEvent('committed'); } + /** + * Determine if after commit callbacks should be executed. + * + * @return bool + */ + protected function afterCommitCallbacksShouldBeExecuted() + { + return $this->transactions == 0 || + ($this->transactionsManager && + $this->transactionsManager->callbackApplicableTransactions()->count() === 1); + } + /** * Handle an exception encountered when committing a transaction. * @@ -214,8 +229,7 @@ trait ManagesTransactions { $this->transactions = max(0, $this->transactions - 1); - if ($this->causedByConcurrencyError($e) && - $currentAttempt < $maxAttempts) { + if ($this->causedByConcurrencyError($e) && $currentAttempt < $maxAttempts) { return; } @@ -276,7 +290,11 @@ trait ManagesTransactions protected function performRollBack($toLevel) { if ($toLevel == 0) { - $this->getPdo()->rollBack(); + $pdo = $this->getPdo(); + + if ($pdo->inTransaction()) { + $pdo->rollBack(); + } } elseif ($this->queryGrammar->supportsSavepoints()) { $this->getPdo()->exec( $this->queryGrammar->compileSavepointRollBack('trans'.($toLevel + 1)) diff --git a/vendor/illuminate/database/Concerns/ParsesSearchPath.php b/vendor/illuminate/database/Concerns/ParsesSearchPath.php index 437ff2b..e822c72 100644 --- a/vendor/illuminate/database/Concerns/ParsesSearchPath.php +++ b/vendor/illuminate/database/Concerns/ParsesSearchPath.php @@ -18,12 +18,8 @@ trait ParsesSearchPath $searchPath = $matches[0]; } - $searchPath ??= []; - - array_walk($searchPath, static function (&$schema) { - $schema = trim($schema, '\'"'); - }); - - return $searchPath; + return array_map(function ($schema) { + return trim($schema, '\'"'); + }, $searchPath ?? []); } } diff --git a/vendor/illuminate/database/Connection.php b/vendor/illuminate/database/Connection.php index 90d625f..c4bcb72 100755 --- a/vendor/illuminate/database/Connection.php +++ b/vendor/illuminate/database/Connection.php @@ -2,6 +2,7 @@ namespace Illuminate\Database; +use Carbon\CarbonInterval; use Closure; use DateTimeInterface; use Doctrine\DBAL\Connection as DoctrineConnection; @@ -12,6 +13,7 @@ use Illuminate\Database\Events\QueryExecuted; use Illuminate\Database\Events\StatementPrepared; use Illuminate\Database\Events\TransactionBeginning; use Illuminate\Database\Events\TransactionCommitted; +use Illuminate\Database\Events\TransactionCommitting; use Illuminate\Database\Events\TransactionRolledBack; use Illuminate\Database\Query\Builder as QueryBuilder; use Illuminate\Database\Query\Expression; @@ -19,7 +21,8 @@ use Illuminate\Database\Query\Grammars\Grammar as QueryGrammar; use Illuminate\Database\Query\Processors\Processor; use Illuminate\Database\Schema\Builder as SchemaBuilder; use Illuminate\Support\Arr; -use LogicException; +use Illuminate\Support\InteractsWithTime; +use Illuminate\Support\Traits\Macroable; use PDO; use PDOStatement; use RuntimeException; @@ -28,7 +31,9 @@ class Connection implements ConnectionInterface { use DetectsConcurrencyErrors, DetectsLostConnections, - Concerns\ManagesTransactions; + Concerns\ManagesTransactions, + InteractsWithTime, + Macroable; /** * The active PDO connection. @@ -156,6 +161,20 @@ class Connection implements ConnectionInterface */ protected $loggingQueries = false; + /** + * The duration of all executed queries in milliseconds. + * + * @var float + */ + protected $totalQueryDuration = 0.0; + + /** + * All of the registered query duration handlers. + * + * @var array + */ + protected $queryDurationHandlers = []; + /** * Indicates if the connection is in a "dry run". * @@ -166,7 +185,7 @@ class Connection implements ConnectionInterface /** * All of the callbacks that should be invoked before a query is executed. * - * @var array + * @var \Closure[] */ protected $beforeExecutingCallbacks = []; @@ -180,14 +199,14 @@ class Connection implements ConnectionInterface /** * Type mappings that should be registered with new Doctrine connections. * - * @var array + * @var array */ protected $doctrineTypeMappings = []; /** * The connection resolvers. * - * @var array + * @var \Closure[] */ protected static $resolvers = []; @@ -334,6 +353,33 @@ class Connection implements ConnectionInterface return array_shift($records); } + /** + * Run a select statement and return the first column of the first row. + * + * @param string $query + * @param array $bindings + * @param bool $useReadPdo + * @return mixed + * + * @throws \Illuminate\Database\MultipleColumnsSelectedException + */ + public function scalar($query, $bindings = [], $useReadPdo = true) + { + $record = $this->selectOne($query, $bindings, $useReadPdo); + + if (is_null($record)) { + return null; + } + + $record = (array) $record; + + if (count($record) > 1) { + throw new MultipleColumnsSelectedException; + } + + return reset($record); + } + /** * Run a select statement against the database. * @@ -424,9 +470,7 @@ class Connection implements ConnectionInterface { $statement->setFetchMode($this->fetchMode); - $this->event(new StatementPrepared( - $this, $statement - )); + $this->event(new StatementPrepared($this, $statement)); return $statement; } @@ -729,6 +773,8 @@ class Connection implements ConnectionInterface */ public function logQuery($query, $bindings, $time = null) { + $this->totalQueryDuration += $time ?? 0.0; + $this->event(new QueryExecuted($query, $bindings, $time, $this)); if ($this->loggingQueries) { @@ -747,6 +793,71 @@ class Connection implements ConnectionInterface return round((microtime(true) - $start) * 1000, 2); } + /** + * Register a callback to be invoked when the connection queries for longer than a given amount of time. + * + * @param \DateTimeInterface|\Carbon\CarbonInterval|float|int $threshold + * @param callable $handler + * @return void + */ + public function whenQueryingForLongerThan($threshold, $handler) + { + $threshold = $threshold instanceof DateTimeInterface + ? $this->secondsUntil($threshold) * 1000 + : $threshold; + + $threshold = $threshold instanceof CarbonInterval + ? $threshold->totalMilliseconds + : $threshold; + + $this->queryDurationHandlers[] = [ + 'has_run' => false, + 'handler' => $handler, + ]; + + $key = count($this->queryDurationHandlers) - 1; + + $this->listen(function ($event) use ($threshold, $handler, $key) { + if (! $this->queryDurationHandlers[$key]['has_run'] && $this->totalQueryDuration() > $threshold) { + $handler($this, $event); + + $this->queryDurationHandlers[$key]['has_run'] = true; + } + }); + } + + /** + * Allow all the query duration handlers to run again, even if they have already run. + * + * @return void + */ + public function allowQueryDurationHandlersToRunAgain() + { + foreach ($this->queryDurationHandlers as $key => $queryDurationHandler) { + $this->queryDurationHandlers[$key]['has_run'] = false; + } + } + + /** + * Get the duration of all run queries in milliseconds. + * + * @return float + */ + public function totalQueryDuration() + { + return $this->totalQueryDuration; + } + + /** + * Reset the duration of all run queries. + * + * @return void + */ + public function resetTotalQueryDuration() + { + $this->totalQueryDuration = 0.0; + } + /** * Handle a query exception. * @@ -794,9 +905,9 @@ class Connection implements ConnectionInterface /** * Reconnect to the database. * - * @return void + * @return mixed|false * - * @throws \LogicException + * @throws \Illuminate\Database\LostConnectionException */ public function reconnect() { @@ -806,7 +917,7 @@ class Connection implements ConnectionInterface return call_user_func($this->reconnector, $this); } - throw new LogicException('Lost connection and no reconnector available.'); + throw new LostConnectionException('Lost connection and no reconnector available.'); } /** @@ -829,6 +940,8 @@ class Connection implements ConnectionInterface public function disconnect() { $this->setPdo(null)->setReadPdo(null); + + $this->doctrineConnection = null; } /** @@ -852,9 +965,7 @@ class Connection implements ConnectionInterface */ public function listen(Closure $callback) { - if (isset($this->events)) { - $this->events->listen(Events\QueryExecuted::class, $callback); - } + $this->events?->listen(Events\QueryExecuted::class, $callback); } /** @@ -865,13 +976,10 @@ class Connection implements ConnectionInterface */ protected function fireConnectionEvent($event) { - if (! isset($this->events)) { - return; - } - - return $this->events->dispatch(match ($event) { + return $this->events?->dispatch(match ($event) { 'beganTransaction' => new TransactionBeginning($this), 'committed' => new TransactionCommitted($this), + 'committing' => new TransactionCommitting($this), 'rollingBack' => new TransactionRolledBack($this), default => null, }); @@ -885,9 +993,7 @@ class Connection implements ConnectionInterface */ protected function event($event) { - if (isset($this->events)) { - $this->events->dispatch($event); - } + $this->events?->dispatch($event); } /** @@ -970,6 +1076,16 @@ class Connection implements ConnectionInterface return class_exists('Doctrine\DBAL\Connection'); } + /** + * Indicates whether native alter operations will be used when dropping or renaming columns, even if Doctrine DBAL is installed. + * + * @return bool + */ + public function usingNativeSchemaOperations() + { + return ! $this->isDoctrineAvailable() || SchemaBuilder::$alwaysUsesNativeSchemaOperationsIfPossible; + } + /** * Get a Doctrine Schema Column instance. * @@ -1030,7 +1146,7 @@ class Connection implements ConnectionInterface /** * Register a custom Doctrine mapping type. * - * @param string $class + * @param Type|class-string $class * @param string $name * @param string $type * @return void @@ -1038,7 +1154,7 @@ class Connection implements ConnectionInterface * @throws \Doctrine\DBAL\DBALException * @throws \RuntimeException */ - public function registerDoctrineType(string $class, string $name, string $type): void + public function registerDoctrineType(Type|string $class, string $name, string $type): void { if (! $this->isDoctrineAvailable()) { throw new RuntimeException( @@ -1047,7 +1163,8 @@ class Connection implements ConnectionInterface } if (! Type::hasType($name)) { - Type::addType($name, $class); + Type::getTypeRegistry() + ->register($name, is_string($class) ? new $class() : $class); } $this->doctrineTypeMappings[$name] = $type; diff --git a/vendor/illuminate/database/ConnectionResolver.php b/vendor/illuminate/database/ConnectionResolver.php index ebfc15c..dd16ffd 100755 --- a/vendor/illuminate/database/ConnectionResolver.php +++ b/vendor/illuminate/database/ConnectionResolver.php @@ -7,7 +7,7 @@ class ConnectionResolver implements ConnectionResolverInterface /** * All of the registered connections. * - * @var array + * @var \Illuminate\Database\ConnectionInterface[] */ protected $connections = []; @@ -21,7 +21,7 @@ class ConnectionResolver implements ConnectionResolverInterface /** * Create a new connection resolver instance. * - * @param array $connections + * @param array $connections * @return void */ public function __construct(array $connections = []) diff --git a/vendor/illuminate/database/Connectors/ConnectionFactory.php b/vendor/illuminate/database/Connectors/ConnectionFactory.php index e057470..80b25d0 100755 --- a/vendor/illuminate/database/Connectors/ConnectionFactory.php +++ b/vendor/illuminate/database/Connectors/ConnectionFactory.php @@ -177,7 +177,7 @@ class ConnectionFactory protected function createPdoResolverWithHosts(array $config) { return function () use ($config) { - foreach (Arr::shuffle($hosts = $this->parseHosts($config)) as $key => $host) { + foreach (Arr::shuffle($this->parseHosts($config)) as $host) { $config['host'] = $host; try { @@ -218,9 +218,7 @@ class ConnectionFactory */ protected function createPdoResolverWithoutHosts(array $config) { - return function () use ($config) { - return $this->createConnector($config)->connect($config); - }; + return fn () => $this->createConnector($config)->connect($config); } /** diff --git a/vendor/illuminate/database/Connectors/PostgresConnector.php b/vendor/illuminate/database/Connectors/PostgresConnector.php index 6331bc2..c54163f 100755 --- a/vendor/illuminate/database/Connectors/PostgresConnector.php +++ b/vendor/illuminate/database/Connectors/PostgresConnector.php @@ -163,6 +163,11 @@ class PostgresConnector extends Connector implements ConnectorInterface $host = isset($host) ? "host={$host};" : ''; + // Sometimes - users may need to connect to a database that has a different + // name than the database used for "information_schema" queries. This is + // typically the case if using "pgbouncer" type software when pooling. + $database = $connect_via_database ?? $database; + $dsn = "pgsql:{$host}dbname='{$database}'"; // If a port was specified, we will add it to this Postgres DSN connections diff --git a/vendor/illuminate/database/Connectors/SQLiteConnector.php b/vendor/illuminate/database/Connectors/SQLiteConnector.php index 90dc16b..ddedfbf 100755 --- a/vendor/illuminate/database/Connectors/SQLiteConnector.php +++ b/vendor/illuminate/database/Connectors/SQLiteConnector.php @@ -2,7 +2,7 @@ namespace Illuminate\Database\Connectors; -use InvalidArgumentException; +use Illuminate\Database\SQLiteDatabaseDoesNotExistException; class SQLiteConnector extends Connector implements ConnectorInterface { @@ -12,7 +12,7 @@ class SQLiteConnector extends Connector implements ConnectorInterface * @param array $config * @return \PDO * - * @throws \InvalidArgumentException + * @throws \Illuminate\Database\SQLiteDatabaseDoesNotExistException */ public function connect(array $config) { @@ -31,7 +31,7 @@ class SQLiteConnector extends Connector implements ConnectorInterface // as the developer probably wants to know if the database exists and this // SQLite driver will not throw any exception if it does not by default. if ($path === false) { - throw new InvalidArgumentException("Database ({$config['database']}) does not exist."); + throw new SQLiteDatabaseDoesNotExistException($config['database']); } return $this->createConnection("sqlite:{$path}", $config, $options); diff --git a/vendor/illuminate/database/Connectors/SqlServerConnector.php b/vendor/illuminate/database/Connectors/SqlServerConnector.php index caefa68..b6ed47d 100755 --- a/vendor/illuminate/database/Connectors/SqlServerConnector.php +++ b/vendor/illuminate/database/Connectors/SqlServerConnector.php @@ -29,7 +29,31 @@ class SqlServerConnector extends Connector implements ConnectorInterface { $options = $this->getOptions($config); - return $this->createConnection($this->getDsn($config), $config, $options); + $connection = $this->createConnection($this->getDsn($config), $config, $options); + + $this->configureIsolationLevel($connection, $config); + + return $connection; + } + + /** + * Set the connection transaction isolation level. + * + * https://learn.microsoft.com/en-us/sql/t-sql/statements/set-transaction-isolation-level-transact-sql + * + * @param \PDO $connection + * @param array $config + * @return void + */ + protected function configureIsolationLevel($connection, array $config) + { + if (! isset($config['isolation_level'])) { + return; + } + + $connection->prepare( + "SET TRANSACTION ISOLATION LEVEL {$config['isolation_level']}" + )->execute(); } /** @@ -160,6 +184,10 @@ class SqlServerConnector extends Connector implements ConnectorInterface $arguments['LoginTimeout'] = $config['login_timeout']; } + if (isset($config['authentication'])) { + $arguments['Authentication'] = $config['authentication']; + } + return $this->buildConnectString('sqlsrv', $arguments); } diff --git a/vendor/illuminate/database/Console/DatabaseInspectionCommand.php b/vendor/illuminate/database/Console/DatabaseInspectionCommand.php new file mode 100644 index 0000000..e3391a0 --- /dev/null +++ b/vendor/illuminate/database/Console/DatabaseInspectionCommand.php @@ -0,0 +1,246 @@ + 'string', + 'citext' => 'string', + 'enum' => 'string', + 'geometry' => 'string', + 'geomcollection' => 'string', + 'linestring' => 'string', + 'ltree' => 'string', + 'multilinestring' => 'string', + 'multipoint' => 'string', + 'multipolygon' => 'string', + 'point' => 'string', + 'polygon' => 'string', + 'sysname' => 'string', + ]; + + /** + * The Composer instance. + * + * @var \Illuminate\Support\Composer + */ + protected $composer; + + /** + * Create a new command instance. + * + * @param \Illuminate\Support\Composer|null $composer + * @return void + */ + public function __construct(Composer $composer = null) + { + parent::__construct(); + + $this->composer = $composer ?? $this->laravel->make(Composer::class); + } + + /** + * Register the custom Doctrine type mappings for inspection commands. + * + * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform + * @return void + */ + protected function registerTypeMappings(AbstractPlatform $platform) + { + foreach ($this->typeMappings as $type => $value) { + $platform->registerDoctrineTypeMapping($type, $value); + } + } + + /** + * Get a human-readable platform name for the given platform. + * + * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform + * @param string $database + * @return string + */ + protected function getPlatformName(AbstractPlatform $platform, $database) + { + return match (class_basename($platform)) { + 'MySQLPlatform' => 'MySQL <= 5', + 'MySQL57Platform' => 'MySQL 5.7', + 'MySQL80Platform' => 'MySQL 8', + 'PostgreSQL100Platform', 'PostgreSQLPlatform' => 'Postgres', + 'SqlitePlatform' => 'SQLite', + 'SQLServerPlatform' => 'SQL Server', + 'SQLServer2012Platform' => 'SQL Server 2012', + default => $database, + }; + } + + /** + * Get the size of a table in bytes. + * + * @param \Illuminate\Database\ConnectionInterface $connection + * @param string $table + * @return int|null + */ + protected function getTableSize(ConnectionInterface $connection, string $table) + { + return match (true) { + $connection instanceof MySqlConnection => $this->getMySQLTableSize($connection, $table), + $connection instanceof PostgresConnection => $this->getPostgresTableSize($connection, $table), + $connection instanceof SQLiteConnection => $this->getSqliteTableSize($connection, $table), + default => null, + }; + } + + /** + * Get the size of a MySQL table in bytes. + * + * @param \Illuminate\Database\ConnectionInterface $connection + * @param string $table + * @return mixed + */ + protected function getMySQLTableSize(ConnectionInterface $connection, string $table) + { + $result = $connection->selectOne('SELECT (data_length + index_length) AS size FROM information_schema.TABLES WHERE table_schema = ? AND table_name = ?', [ + $connection->getDatabaseName(), + $table, + ]); + + return Arr::wrap((array) $result)['size']; + } + + /** + * Get the size of a Postgres table in bytes. + * + * @param \Illuminate\Database\ConnectionInterface $connection + * @param string $table + * @return mixed + */ + protected function getPostgresTableSize(ConnectionInterface $connection, string $table) + { + $result = $connection->selectOne('SELECT pg_total_relation_size(?) AS size;', [ + $table, + ]); + + return Arr::wrap((array) $result)['size']; + } + + /** + * Get the size of a SQLite table in bytes. + * + * @param \Illuminate\Database\ConnectionInterface $connection + * @param string $table + * @return mixed + */ + protected function getSqliteTableSize(ConnectionInterface $connection, string $table) + { + try { + $result = $connection->selectOne('SELECT SUM(pgsize) AS size FROM dbstat WHERE name=?', [ + $table, + ]); + + return Arr::wrap((array) $result)['size']; + } catch (QueryException $e) { + return null; + } + } + + /** + * Get the number of open connections for a database. + * + * @param \Illuminate\Database\ConnectionInterface $connection + * @return int|null + */ + protected function getConnectionCount(ConnectionInterface $connection) + { + $result = match (true) { + $connection instanceof MySqlConnection => $connection->selectOne('show status where variable_name = "threads_connected"'), + $connection instanceof PostgresConnection => $connection->selectOne('select count(*) AS "Value" from pg_stat_activity'), + $connection instanceof SqlServerConnection => $connection->selectOne('SELECT COUNT(*) Value FROM sys.dm_exec_sessions WHERE status = ?', ['running']), + default => null, + }; + + if (! $result) { + return null; + } + + return Arr::wrap((array) $result)['Value']; + } + + /** + * Get the connection configuration details for the given connection. + * + * @param string $database + * @return array + */ + protected function getConfigFromDatabase($database) + { + $database ??= config('database.default'); + + return Arr::except(config('database.connections.'.$database), ['password']); + } + + /** + * Ensure the dependencies for the database commands are available. + * + * @return bool + */ + protected function ensureDependenciesExist() + { + return tap(interface_exists('Doctrine\DBAL\Driver'), function ($dependenciesExist) { + if (! $dependenciesExist && $this->components->confirm('Inspecting database information requires the Doctrine DBAL (doctrine/dbal) package. Would you like to install it?')) { + $this->installDependencies(); + } + }); + } + + /** + * Install the command's dependencies. + * + * @return void + * + * @throws \Symfony\Component\Process\Exception\ProcessSignaledException + */ + protected function installDependencies() + { + $command = collect($this->composer->findComposer()) + ->push('require doctrine/dbal') + ->implode(' '); + + $process = Process::fromShellCommandline($command, null, null, null, null); + + if ('\\' !== DIRECTORY_SEPARATOR && file_exists('/dev/tty') && is_readable('/dev/tty')) { + try { + $process->setTty(true); + } catch (RuntimeException $e) { + $this->components->warn($e->getMessage()); + } + } + + try { + $process->run(fn ($type, $line) => $this->output->write($line)); + } catch (ProcessSignaledException $e) { + if (extension_loaded('pcntl') && $e->getSignal() !== SIGINT) { + throw $e; + } + } + } +} diff --git a/vendor/illuminate/database/Console/DbCommand.php b/vendor/illuminate/database/Console/DbCommand.php index c2c4593..caecafe 100644 --- a/vendor/illuminate/database/Console/DbCommand.php +++ b/vendor/illuminate/database/Console/DbCommand.php @@ -34,6 +34,14 @@ class DbCommand extends Command { $connection = $this->getConnection(); + if (! isset($connection['host']) && $connection['driver'] !== 'sqlite') { + $this->components->error('No host specified for this database connection.'); + $this->line(' Use the [--read] and [--write] options to specify a read or write connection.'); + $this->newLine(); + + return Command::FAILURE; + } + (new Process( array_merge([$this->getCommand($connection)], $this->commandArguments($connection)), null, diff --git a/vendor/illuminate/database/Console/DumpCommand.php b/vendor/illuminate/database/Console/DumpCommand.php index bf0568f..3f21aaf 100644 --- a/vendor/illuminate/database/Console/DumpCommand.php +++ b/vendor/illuminate/database/Console/DumpCommand.php @@ -9,7 +9,9 @@ use Illuminate\Database\ConnectionResolverInterface; use Illuminate\Database\Events\SchemaDumped; use Illuminate\Filesystem\Filesystem; use Illuminate\Support\Facades\Config; +use Symfony\Component\Console\Attribute\AsCommand; +#[AsCommand(name: 'schema:dump')] class DumpCommand extends Command { /** @@ -28,6 +30,8 @@ class DumpCommand extends Command * This name is used to identify the command during lazy loading. * * @var string|null + * + * @deprecated */ protected static $defaultName = 'schema:dump'; @@ -55,15 +59,17 @@ class DumpCommand extends Command $dispatcher->dispatch(new SchemaDumped($connection, $path)); - $this->info('Database schema dumped successfully.'); + $info = 'Database schema dumped'; if ($this->option('prune')) { (new Filesystem)->deleteDirectory( database_path('migrations'), $preserve = false ); - $this->info('Migrations pruned successfully.'); + $info .= ' and pruned'; } + + $this->components->info($info.' successfully.'); } /** @@ -88,7 +94,7 @@ class DumpCommand extends Command */ protected function path(Connection $connection) { - return tap($this->option('path') ?: database_path('schema/'.$connection->getName().'-schema.dump'), function ($path) { + return tap($this->option('path') ?: database_path('schema/'.$connection->getName().'-schema.sql'), function ($path) { (new Filesystem)->ensureDirectoryExists(dirname($path)); }); } diff --git a/vendor/illuminate/database/Console/Factories/FactoryMakeCommand.php b/vendor/illuminate/database/Console/Factories/FactoryMakeCommand.php index 0b3039a..48c4375 100644 --- a/vendor/illuminate/database/Console/Factories/FactoryMakeCommand.php +++ b/vendor/illuminate/database/Console/Factories/FactoryMakeCommand.php @@ -4,8 +4,10 @@ namespace Illuminate\Database\Console\Factories; use Illuminate\Console\GeneratorCommand; use Illuminate\Support\Str; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputOption; +#[AsCommand(name: 'make:factory')] class FactoryMakeCommand extends GeneratorCommand { /** @@ -21,6 +23,8 @@ class FactoryMakeCommand extends GeneratorCommand * This name is used to identify the command during lazy loading. * * @var string|null + * + * @deprecated */ protected static $defaultName = 'make:factory'; @@ -77,11 +81,9 @@ class FactoryMakeCommand extends GeneratorCommand $model = class_basename($namespaceModel); - if (Str::startsWith($namespaceModel, $this->rootNamespace().'Models')) { - $namespace = Str::beforeLast('Database\\Factories\\'.Str::after($namespaceModel, $this->rootNamespace().'Models\\'), '\\'); - } else { - $namespace = 'Database\\Factories'; - } + $namespace = $this->getNamespace( + Str::replaceFirst($this->rootNamespace(), 'Database\\Factories\\', $this->qualifyClass($this->getNameInput())) + ); $replace = [ '{{ factoryNamespace }}' => $namespace, diff --git a/vendor/illuminate/database/Console/Migrations/FreshCommand.php b/vendor/illuminate/database/Console/Migrations/FreshCommand.php index 7bfba0d..e319e74 100644 --- a/vendor/illuminate/database/Console/Migrations/FreshCommand.php +++ b/vendor/illuminate/database/Console/Migrations/FreshCommand.php @@ -39,12 +39,16 @@ class FreshCommand extends Command $database = $this->input->getOption('database'); - $this->call('db:wipe', array_filter([ + $this->newLine(); + + $this->components->task('Dropping all tables', fn () => $this->callSilent('db:wipe', array_filter([ '--database' => $database, '--drop-views' => $this->option('drop-views'), '--drop-types' => $this->option('drop-types'), '--force' => true, - ])); + ])) == 0); + + $this->newLine(); $this->call('migrate', array_filter([ '--database' => $database, diff --git a/vendor/illuminate/database/Console/Migrations/InstallCommand.php b/vendor/illuminate/database/Console/Migrations/InstallCommand.php index d69c2ab..901a83b 100755 --- a/vendor/illuminate/database/Console/Migrations/InstallCommand.php +++ b/vendor/illuminate/database/Console/Migrations/InstallCommand.php @@ -53,7 +53,7 @@ class InstallCommand extends Command $this->repository->createRepository(); - $this->info('Migration table created successfully.'); + $this->components->info('Migration table created successfully.'); } /** diff --git a/vendor/illuminate/database/Console/Migrations/MigrateCommand.php b/vendor/illuminate/database/Console/Migrations/MigrateCommand.php index ec35f8f..fc43bf5 100755 --- a/vendor/illuminate/database/Console/Migrations/MigrateCommand.php +++ b/vendor/illuminate/database/Console/Migrations/MigrateCommand.php @@ -3,12 +3,16 @@ namespace Illuminate\Database\Console\Migrations; use Illuminate\Console\ConfirmableTrait; +use Illuminate\Contracts\Console\Isolatable; use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Database\Events\SchemaLoaded; use Illuminate\Database\Migrations\Migrator; +use Illuminate\Database\SQLiteDatabaseDoesNotExistException; use Illuminate\Database\SqlServerConnection; +use PDOException; +use Throwable; -class MigrateCommand extends BaseCommand +class MigrateCommand extends BaseCommand implements Isolatable { use ConfirmableTrait; @@ -24,6 +28,7 @@ class MigrateCommand extends BaseCommand {--schema-path= : The path to a schema dump file} {--pretend : Dump the SQL queries that would be run} {--seed : Indicates if the seed task should be re-run} + {--seeder= : The class name of the root seeder} {--step : Force the migrations to be run so they can be rolled back individually}'; /** @@ -79,7 +84,7 @@ class MigrateCommand extends BaseCommand // Next, we will check to see if a path option has been defined. If it has // we will use the path relative to the root of this installation folder // so that migrations may be run for any path within the applications. - $this->migrator->setOutput($this->output) + $migrations = $this->migrator->setOutput($this->output) ->run($this->getMigrationPaths(), [ 'pretend' => $this->option('pretend'), 'step' => $this->option('step'), @@ -89,7 +94,10 @@ class MigrateCommand extends BaseCommand // seed task to re-populate the database, which is convenient when adding // a migration and a seed at the same time, as it is only this command. if ($this->option('seed') && ! $this->option('pretend')) { - $this->call('db:seed', ['--force' => true]); + $this->call('db:seed', [ + '--class' => $this->option('seeder') ?: 'Database\\Seeders\\DatabaseSeeder', + '--force' => true, + ]); } }); @@ -103,10 +111,16 @@ class MigrateCommand extends BaseCommand */ protected function prepareDatabase() { - if (! $this->migrator->repositoryExists()) { - $this->call('migrate:install', array_filter([ - '--database' => $this->option('database'), - ])); + if (! $this->repositoryExists()) { + $this->components->info('Preparing database.'); + + $this->components->task('Creating migration table', function () { + return $this->callSilent('migrate:install', array_filter([ + '--database' => $this->option('database'), + ])) == 0; + }); + + $this->newLine(); } if (! $this->migrator->hasRunAnyMigrations() && ! $this->option('pretend')) { @@ -114,6 +128,98 @@ class MigrateCommand extends BaseCommand } } + /** + * Determine if the migrator repository exists. + * + * @return bool + */ + protected function repositoryExists() + { + return retry(2, fn () => $this->migrator->repositoryExists(), 0, function ($e) { + try { + if ($e->getPrevious() instanceof SQLiteDatabaseDoesNotExistException) { + return $this->createMissingSqliteDatbase($e->getPrevious()->path); + } + + $connection = $this->migrator->resolveConnection($this->option('database')); + + if ( + $e->getPrevious() instanceof PDOException && + $e->getPrevious()->getCode() === 1049 && + $connection->getDriverName() === 'mysql') { + return $this->createMissingMysqlDatabase($connection); + } + + return false; + } catch (Throwable) { + return false; + } + }); + } + + /** + * Create a missing SQLite database. + * + * @param string $path + * @return bool + */ + protected function createMissingSqliteDatbase($path) + { + if ($this->option('force')) { + return touch($path); + } + + if ($this->option('no-interaction')) { + return false; + } + + $this->components->warn('The SQLite database does not exist: '.$path); + + if (! $this->components->confirm('Would you like to create it?')) { + return false; + } + + return touch($path); + } + + /** + * Create a missing MySQL database. + * + * @return bool + */ + protected function createMissingMysqlDatabase($connection) + { + if ($this->laravel['config']->get("database.connections.{$connection->getName()}.database") !== $connection->getDatabaseName()) { + return false; + } + + if (! $this->option('force') && $this->option('no-interaction')) { + return false; + } + + if (! $this->option('force') && ! $this->option('no-interaction')) { + $this->components->warn("The database '{$connection->getDatabaseName()}' does not exist on the '{$connection->getName()}' connection."); + + if (! $this->components->confirm('Would you like to create it?')) { + return false; + } + } + + try { + $this->laravel['config']->set("database.connections.{$connection->getName()}.database", null); + + $this->laravel['db']->purge(); + + $freshConnection = $this->migrator->resolveConnection($this->option('database')); + + return tap($freshConnection->unprepared("CREATE DATABASE IF NOT EXISTS `{$connection->getDatabaseName()}`"), function () { + $this->laravel['db']->purge(); + }); + } finally { + $this->laravel['config']->set("database.connections.{$connection->getName()}.database", $connection->getDatabaseName()); + } + } + /** * Load the schema state to seed the initial database schema structure. * @@ -131,20 +237,20 @@ class MigrateCommand extends BaseCommand return; } - $this->line('Loading stored database schema: '.$path); + $this->components->info('Loading stored database schemas.'); - $startTime = microtime(true); + $this->components->task($path, function () use ($connection, $path) { + // Since the schema file will create the "migrations" table and reload it to its + // proper state, we need to delete it here so we don't get an error that this + // table already exists when the stored database schema file gets executed. + $this->migrator->deleteRepository(); - // Since the schema file will create the "migrations" table and reload it to its - // proper state, we need to delete it here so we don't get an error that this - // table already exists when the stored database schema file gets executed. - $this->migrator->deleteRepository(); + $connection->getSchemaState()->handleOutputUsing(function ($type, $buffer) { + $this->output->write($buffer); + })->load($path); + }); - $connection->getSchemaState()->handleOutputUsing(function ($type, $buffer) { - $this->output->write($buffer); - })->load($path); - - $runTime = number_format((microtime(true) - $startTime) * 1000, 2); + $this->newLine(); // Finally, we will fire an event that this schema has been loaded so developers // can perform any post schema load tasks that are necessary in listeners for @@ -152,8 +258,6 @@ class MigrateCommand extends BaseCommand $this->dispatcher->dispatch( new SchemaLoaded($connection, $path) ); - - $this->line('Loaded stored database schema. ('.$runTime.'ms)'); } /** diff --git a/vendor/illuminate/database/Console/Migrations/MigrateMakeCommand.php b/vendor/illuminate/database/Console/Migrations/MigrateMakeCommand.php index 95c3a20..75c0634 100644 --- a/vendor/illuminate/database/Console/Migrations/MigrateMakeCommand.php +++ b/vendor/illuminate/database/Console/Migrations/MigrateMakeCommand.php @@ -2,11 +2,12 @@ namespace Illuminate\Database\Console\Migrations; +use Illuminate\Contracts\Console\PromptsForMissingInput; use Illuminate\Database\Migrations\MigrationCreator; use Illuminate\Support\Composer; use Illuminate\Support\Str; -class MigrateMakeCommand extends BaseCommand +class MigrateMakeCommand extends BaseCommand implements PromptsForMissingInput { /** * The console command signature. @@ -18,7 +19,7 @@ class MigrateMakeCommand extends BaseCommand {--table= : The table to migrate} {--path= : The location where the migration file should be created} {--realpath : Indicate any provided migration file paths are pre-resolved absolute paths} - {--fullpath : Output the full path of the migration}'; + {--fullpath : Output the full path of the migration (Deprecated)}'; /** * The console command description. @@ -110,11 +111,7 @@ class MigrateMakeCommand extends BaseCommand $name, $this->getMigrationPath(), $table, $create ); - if (! $this->option('fullpath')) { - $file = pathinfo($file, PATHINFO_FILENAME); - } - - $this->line("Created Migration: {$file}"); + $this->components->info(sprintf('Migration [%s] created successfully.', $file)); } /** @@ -132,4 +129,16 @@ class MigrateMakeCommand extends BaseCommand return parent::getMigrationPath(); } + + /** + * Prompt for missing input arguments using the returned questions. + * + * @return array + */ + protected function promptForMissingArgumentsUsing() + { + return [ + 'name' => 'What should the migration be named?', + ]; + } } diff --git a/vendor/illuminate/database/Console/Migrations/ResetCommand.php b/vendor/illuminate/database/Console/Migrations/ResetCommand.php index 1f2babb..c5952fa 100755 --- a/vendor/illuminate/database/Console/Migrations/ResetCommand.php +++ b/vendor/illuminate/database/Console/Migrations/ResetCommand.php @@ -60,7 +60,7 @@ class ResetCommand extends BaseCommand // start trying to rollback and re-run all of the migrations. If it's not // present we'll just bail out with an info message for the developers. if (! $this->migrator->repositoryExists()) { - return $this->comment('Migration table not found.'); + return $this->components->warn('Migration table not found.'); } $this->migrator->setOutput($this->output)->reset( diff --git a/vendor/illuminate/database/Console/Migrations/StatusCommand.php b/vendor/illuminate/database/Console/Migrations/StatusCommand.php index 2cf82f9..aa01f07 100644 --- a/vendor/illuminate/database/Console/Migrations/StatusCommand.php +++ b/vendor/illuminate/database/Console/Migrations/StatusCommand.php @@ -51,7 +51,7 @@ class StatusCommand extends BaseCommand { return $this->migrator->usingConnection($this->option('database'), function () { if (! $this->migrator->repositoryExists()) { - $this->error('Migration table not found.'); + $this->components->error('Migration table not found.'); return 1; } @@ -61,15 +61,27 @@ class StatusCommand extends BaseCommand $batches = $this->migrator->getRepository()->getMigrationBatches(); if (count($migrations = $this->getStatusFor($ran, $batches)) > 0) { - $this->table(['Ran?', 'Migration', 'Batch'], $migrations); + $this->newLine(); + + $this->components->twoColumnDetail('Migration name', 'Batch / Status'); + + $migrations + ->when($this->option('pending'), fn ($collection) => $collection->filter(function ($migration) { + return str($migration[1])->contains('Pending'); + })) + ->each( + fn ($migration) => $this->components->twoColumnDetail($migration[0], $migration[1]) + ); + + $this->newLine(); } else { - $this->error('No migrations found'); + $this->components->info('No migrations found'); } }); } /** - * Get the status for the given ran migrations. + * Get the status for the given run migrations. * * @param array $ran * @param array $batches @@ -81,9 +93,15 @@ class StatusCommand extends BaseCommand ->map(function ($migration) use ($ran, $batches) { $migrationName = $this->migrator->getMigrationName($migration); - return in_array($migrationName, $ran) - ? ['Yes', $migrationName, $batches[$migrationName]] - : ['No', $migrationName]; + $status = in_array($migrationName, $ran) + ? 'Ran' + : 'Pending'; + + if (in_array($migrationName, $ran)) { + $status = '['.$batches[$migrationName].'] '.$status; + } + + return [$migrationName, $status]; }); } @@ -106,9 +124,8 @@ class StatusCommand extends BaseCommand { return [ ['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use'], - + ['pending', null, InputOption::VALUE_NONE, 'Only list pending migrations'], ['path', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'The path(s) to the migrations files to use'], - ['realpath', null, InputOption::VALUE_NONE, 'Indicate any provided migration file paths are pre-resolved absolute paths'], ]; } diff --git a/vendor/illuminate/database/Console/MonitorCommand.php b/vendor/illuminate/database/Console/MonitorCommand.php new file mode 100644 index 0000000..5d0f3ed --- /dev/null +++ b/vendor/illuminate/database/Console/MonitorCommand.php @@ -0,0 +1,151 @@ +connection = $connection; + $this->events = $events; + } + + /** + * Execute the console command. + * + * @return void + */ + public function handle() + { + $databases = $this->parseDatabases($this->option('databases')); + + $this->displayConnections($databases); + + if ($this->option('max')) { + $this->dispatchEvents($databases); + } + } + + /** + * Parse the database into an array of the connections. + * + * @param string $databases + * @return \Illuminate\Support\Collection + */ + protected function parseDatabases($databases) + { + return collect(explode(',', $databases))->map(function ($database) { + if (! $database) { + $database = $this->laravel['config']['database.default']; + } + + $maxConnections = $this->option('max'); + + return [ + 'database' => $database, + 'connections' => $connections = $this->getConnectionCount($this->connection->connection($database)), + 'status' => $maxConnections && $connections >= $maxConnections ? 'ALERT' : 'OK', + ]; + }); + } + + /** + * Display the databases and their connection counts in the console. + * + * @param \Illuminate\Support\Collection $databases + * @return void + */ + protected function displayConnections($databases) + { + $this->newLine(); + + $this->components->twoColumnDetail('Database name', 'Connections'); + + $databases->each(function ($database) { + $status = '['.$database['connections'].'] '.$database['status']; + + $this->components->twoColumnDetail($database['database'], $status); + }); + + $this->newLine(); + } + + /** + * Dispatch the database monitoring events. + * + * @param \Illuminate\Support\Collection $databases + * @return void + */ + protected function dispatchEvents($databases) + { + $databases->each(function ($database) { + if ($database['status'] === 'OK') { + return; + } + + $this->events->dispatch( + new DatabaseBusy( + $database['database'], + $database['connections'] + ) + ); + }); + } +} diff --git a/vendor/illuminate/database/Console/PruneCommand.php b/vendor/illuminate/database/Console/PruneCommand.php index aeb10e2..7ea6cec 100644 --- a/vendor/illuminate/database/Console/PruneCommand.php +++ b/vendor/illuminate/database/Console/PruneCommand.php @@ -43,7 +43,7 @@ class PruneCommand extends Command $models = $this->models(); if ($models->isEmpty()) { - $this->info('No prunable models found.'); + $this->components->info('No prunable models found.'); return; } @@ -56,29 +56,50 @@ class PruneCommand extends Command return; } - $events->listen(ModelsPruned::class, function ($event) { - $this->info("{$event->count} [{$event->model}] records have been pruned."); + $pruning = []; + + $events->listen(ModelsPruned::class, function ($event) use (&$pruning) { + if (! in_array($event->model, $pruning)) { + $pruning[] = $event->model; + + $this->newLine(); + + $this->components->info(sprintf('Pruning [%s] records.', $event->model)); + } + + $this->components->twoColumnDetail($event->model, "{$event->count} records"); }); $models->each(function ($model) { - $instance = new $model; - - $chunkSize = property_exists($instance, 'prunableChunkSize') - ? $instance->prunableChunkSize - : $this->option('chunk'); - - $total = $this->isPrunable($model) - ? $instance->pruneAll($chunkSize) - : 0; - - if ($total == 0) { - $this->info("No prunable [$model] records found."); - } + $this->pruneModel($model); }); $events->forget(ModelsPruned::class); } + /** + * Prune the given model. + * + * @param string $model + * @return void + */ + protected function pruneModel(string $model) + { + $instance = new $model; + + $chunkSize = property_exists($instance, 'prunableChunkSize') + ? $instance->prunableChunkSize + : $this->option('chunk'); + + $total = $this->isPrunable($model) + ? $instance->pruneAll($chunkSize) + : 0; + + if ($total == 0) { + $this->components->info("No prunable [$model] records found."); + } + } + /** * Determine the models that should be pruned. * @@ -87,7 +108,9 @@ class PruneCommand extends Command protected function models() { if (! empty($models = $this->option('model'))) { - return collect($models); + return collect($models)->filter(function ($model) { + return class_exists($model); + })->values(); } $except = $this->option('except'); @@ -111,13 +134,15 @@ class PruneCommand extends Command }); })->filter(function ($model) { return $this->isPrunable($model); + })->filter(function ($model) { + return class_exists($model); })->values(); } /** * Get the default path where models are located. * - * @return string + * @return string|string[] */ protected function getDefaultPath() { @@ -153,9 +178,9 @@ class PruneCommand extends Command })->count(); if ($count === 0) { - $this->info("No prunable [$model] records found."); + $this->components->info("No prunable [$model] records found."); } else { - $this->info("{$count} [{$model}] records will be pruned."); + $this->components->info("{$count} [{$model}] records will be pruned."); } } } diff --git a/vendor/illuminate/database/Console/Seeds/SeedCommand.php b/vendor/illuminate/database/Console/Seeds/SeedCommand.php index 1d0b96e..2359586 100644 --- a/vendor/illuminate/database/Console/Seeds/SeedCommand.php +++ b/vendor/illuminate/database/Console/Seeds/SeedCommand.php @@ -6,9 +6,11 @@ use Illuminate\Console\Command; use Illuminate\Console\ConfirmableTrait; use Illuminate\Database\ConnectionResolverInterface as Resolver; use Illuminate\Database\Eloquent\Model; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; +#[AsCommand(name: 'db:seed')] class SeedCommand extends Command { use ConfirmableTrait; @@ -26,6 +28,8 @@ class SeedCommand extends Command * This name is used to identify the command during lazy loading. * * @var string|null + * + * @deprecated */ protected static $defaultName = 'db:seed'; @@ -67,6 +71,8 @@ class SeedCommand extends Command return 1; } + $this->components->info('Seeding database.'); + $previousConnection = $this->resolver->getDefaultConnection(); $this->resolver->setDefaultConnection($this->getDatabase()); @@ -79,8 +85,6 @@ class SeedCommand extends Command $this->resolver->setDefaultConnection($previousConnection); } - $this->info('Database seeding completed successfully.'); - return 0; } diff --git a/vendor/illuminate/database/Console/Seeds/SeederMakeCommand.php b/vendor/illuminate/database/Console/Seeds/SeederMakeCommand.php index 716f187..8ba01cb 100644 --- a/vendor/illuminate/database/Console/Seeds/SeederMakeCommand.php +++ b/vendor/illuminate/database/Console/Seeds/SeederMakeCommand.php @@ -3,7 +3,10 @@ namespace Illuminate\Database\Console\Seeds; use Illuminate\Console\GeneratorCommand; +use Illuminate\Support\Str; +use Symfony\Component\Console\Attribute\AsCommand; +#[AsCommand(name: 'make:seeder')] class SeederMakeCommand extends GeneratorCommand { /** @@ -19,6 +22,8 @@ class SeederMakeCommand extends GeneratorCommand * This name is used to identify the command during lazy loading. * * @var string|null + * + * @deprecated */ protected static $defaultName = 'make:seeder'; @@ -77,21 +82,22 @@ class SeederMakeCommand extends GeneratorCommand */ protected function getPath($name) { + $name = str_replace('\\', '/', Str::replaceFirst($this->rootNamespace(), '', $name)); + if (is_dir($this->laravel->databasePath().'/seeds')) { return $this->laravel->databasePath().'/seeds/'.$name.'.php'; - } else { - return $this->laravel->databasePath().'/seeders/'.$name.'.php'; } + + return $this->laravel->databasePath().'/seeders/'.$name.'.php'; } /** - * Parse the class name and format according to the root namespace. + * Get the root namespace for the class. * - * @param string $name * @return string */ - protected function qualifyClass($name) + protected function rootNamespace() { - return $name; + return 'Database\Seeders\\'; } } diff --git a/vendor/illuminate/database/Console/Seeds/stubs/seeder.stub b/vendor/illuminate/database/Console/Seeds/stubs/seeder.stub index 29e4af4..19ae5f5 100644 --- a/vendor/illuminate/database/Console/Seeds/stubs/seeder.stub +++ b/vendor/illuminate/database/Console/Seeds/stubs/seeder.stub @@ -1,6 +1,6 @@ Note: This can be slow on large databases }; + {--views : Show the database views Note: This can be slow on large databases }'; + + /** + * The console command description. + * + * @var string + */ + protected $description = 'Display information about the given database'; + + /** + * Execute the console command. + * + * @param \Illuminate\Database\ConnectionResolverInterface $connections + * @return int + */ + public function handle(ConnectionResolverInterface $connections) + { + if (! $this->ensureDependenciesExist()) { + return 1; + } + + $connection = $connections->connection($database = $this->input->getOption('database')); + + $schema = $connection->getDoctrineSchemaManager(); + + $this->registerTypeMappings($schema->getDatabasePlatform()); + + $data = [ + 'platform' => [ + 'config' => $this->getConfigFromDatabase($database), + 'name' => $this->getPlatformName($schema->getDatabasePlatform(), $database), + 'open_connections' => $this->getConnectionCount($connection), + ], + 'tables' => $this->tables($connection, $schema), + ]; + + if ($this->option('views')) { + $data['views'] = $this->collectViews($connection, $schema); + } + + $this->display($data); + + return 0; + } + + /** + * Get information regarding the tables within the database. + * + * @param \Illuminate\Database\ConnectionInterface $connection + * @param \Doctrine\DBAL\Schema\AbstractSchemaManager $schema + * @return \Illuminate\Support\Collection + */ + protected function tables(ConnectionInterface $connection, AbstractSchemaManager $schema) + { + return collect($schema->listTables())->map(fn (Table $table, $index) => [ + 'table' => $table->getName(), + 'size' => $this->getTableSize($connection, $table->getName()), + 'rows' => $this->option('counts') ? $connection->table($table->getName())->count() : null, + 'engine' => rescue(fn () => $table->getOption('engine'), null, false), + 'comment' => $table->getComment(), + ]); + } + + /** + * Get information regarding the views within the database. + * + * @param \Illuminate\Database\ConnectionInterface $connection + * @param \Doctrine\DBAL\Schema\AbstractSchemaManager $schema + * @return \Illuminate\Support\Collection + */ + protected function collectViews(ConnectionInterface $connection, AbstractSchemaManager $schema) + { + return collect($schema->listViews()) + ->reject(fn (View $view) => str($view->getName()) + ->startsWith(['pg_catalog', 'information_schema', 'spt_'])) + ->map(fn (View $view) => [ + 'view' => $view->getName(), + 'rows' => $connection->table($view->getName())->count(), + ]); + } + + /** + * Render the database information. + * + * @param array $data + * @return void + */ + protected function display(array $data) + { + $this->option('json') ? $this->displayJson($data) : $this->displayForCli($data); + } + + /** + * Render the database information as JSON. + * + * @param array $data + * @return void + */ + protected function displayJson(array $data) + { + $this->output->writeln(json_encode($data)); + } + + /** + * Render the database information formatted for the CLI. + * + * @param array $data + * @return void + */ + protected function displayForCli(array $data) + { + $platform = $data['platform']; + $tables = $data['tables']; + $views = $data['views'] ?? null; + + $this->newLine(); + + $this->components->twoColumnDetail(''.$platform['name'].''); + $this->components->twoColumnDetail('Database', Arr::get($platform['config'], 'database')); + $this->components->twoColumnDetail('Host', Arr::get($platform['config'], 'host')); + $this->components->twoColumnDetail('Port', Arr::get($platform['config'], 'port')); + $this->components->twoColumnDetail('Username', Arr::get($platform['config'], 'username')); + $this->components->twoColumnDetail('URL', Arr::get($platform['config'], 'url')); + $this->components->twoColumnDetail('Open Connections', $platform['open_connections']); + $this->components->twoColumnDetail('Tables', $tables->count()); + + if ($tableSizeSum = $tables->sum('size')) { + $this->components->twoColumnDetail('Total Size', number_format($tableSizeSum / 1024 / 1024, 2).'MiB'); + } + + $this->newLine(); + + if ($tables->isNotEmpty()) { + $this->components->twoColumnDetail('Table', 'Size (MiB)'.($this->option('counts') ? ' / Rows' : '')); + + $tables->each(function ($table) { + if ($tableSize = $table['size']) { + $tableSize = number_format($tableSize / 1024 / 1024, 2); + } + + $this->components->twoColumnDetail( + $table['table'].($this->output->isVerbose() ? ' '.$table['engine'].'' : null), + ($tableSize ? $tableSize : '—').($this->option('counts') ? ' / '.number_format($table['rows']).'' : '') + ); + + if ($this->output->isVerbose()) { + if ($table['comment']) { + $this->components->bulletList([ + $table['comment'], + ]); + } + } + }); + + $this->newLine(); + } + + if ($views && $views->isNotEmpty()) { + $this->components->twoColumnDetail('View', 'Rows'); + + $views->each(fn ($view) => $this->components->twoColumnDetail($view['view'], number_format($view['rows']))); + + $this->newLine(); + } + } +} diff --git a/vendor/illuminate/database/Console/TableCommand.php b/vendor/illuminate/database/Console/TableCommand.php new file mode 100644 index 0000000..3b08bde --- /dev/null +++ b/vendor/illuminate/database/Console/TableCommand.php @@ -0,0 +1,246 @@ +ensureDependenciesExist()) { + return 1; + } + + $connection = $connections->connection($this->input->getOption('database')); + + $schema = $connection->getDoctrineSchemaManager(); + + $this->registerTypeMappings($schema->getDatabasePlatform()); + + $table = $this->argument('table') ?: $this->components->choice( + 'Which table would you like to inspect?', + collect($schema->listTables())->flatMap(fn (Table $table) => [$table->getName()])->toArray() + ); + + if (! $schema->tablesExist([$table])) { + return $this->components->warn("Table [{$table}] doesn't exist."); + } + + $table = $schema->listTableDetails($table); + + $columns = $this->columns($table); + $indexes = $this->indexes($table); + $foreignKeys = $this->foreignKeys($table); + + $data = [ + 'table' => [ + 'name' => $table->getName(), + 'columns' => $columns->count(), + 'size' => $this->getTableSize($connection, $table->getName()), + ], + 'columns' => $columns, + 'indexes' => $indexes, + 'foreign_keys' => $foreignKeys, + ]; + + $this->display($data); + + return 0; + } + + /** + * Get the information regarding the table's columns. + * + * @param \Doctrine\DBAL\Schema\Table $table + * @return \Illuminate\Support\Collection + */ + protected function columns(Table $table) + { + return collect($table->getColumns())->map(fn (Column $column) => [ + 'column' => $column->getName(), + 'attributes' => $this->getAttributesForColumn($column), + 'default' => $column->getDefault(), + 'type' => $column->getType()->getName(), + ]); + } + + /** + * Get the attributes for a table column. + * + * @param \Doctrine\DBAL\Schema\Column $column + * @return \Illuminate\Support\Collection + */ + protected function getAttributesForColumn(Column $column) + { + return collect([ + $column->getAutoincrement() ? 'autoincrement' : null, + 'type' => $column->getType()->getName(), + $column->getUnsigned() ? 'unsigned' : null, + ! $column->getNotNull() ? 'nullable' : null, + ])->filter(); + } + + /** + * Get the information regarding the table's indexes. + * + * @param \Doctrine\DBAL\Schema\Table $table + * @return \Illuminate\Support\Collection + */ + protected function indexes(Table $table) + { + return collect($table->getIndexes())->map(fn (Index $index) => [ + 'name' => $index->getName(), + 'columns' => collect($index->getColumns()), + 'attributes' => $this->getAttributesForIndex($index), + ]); + } + + /** + * Get the attributes for a table index. + * + * @param \Doctrine\DBAL\Schema\Index $index + * @return \Illuminate\Support\Collection + */ + protected function getAttributesForIndex(Index $index) + { + return collect([ + 'compound' => count($index->getColumns()) > 1, + 'unique' => $index->isUnique(), + 'primary' => $index->isPrimary(), + ])->filter()->keys()->map(fn ($attribute) => Str::lower($attribute)); + } + + /** + * Get the information regarding the table's foreign keys. + * + * @param \Doctrine\DBAL\Schema\Table $table + * @return \Illuminate\Support\Collection + */ + protected function foreignKeys(Table $table) + { + return collect($table->getForeignKeys())->map(fn (ForeignKeyConstraint $foreignKey) => [ + 'name' => $foreignKey->getName(), + 'local_table' => $table->getName(), + 'local_columns' => collect($foreignKey->getLocalColumns()), + 'foreign_table' => $foreignKey->getForeignTableName(), + 'foreign_columns' => collect($foreignKey->getForeignColumns()), + 'on_update' => Str::lower(rescue(fn () => $foreignKey->getOption('onUpdate'), 'N/A')), + 'on_delete' => Str::lower(rescue(fn () => $foreignKey->getOption('onDelete'), 'N/A')), + ]); + } + + /** + * Render the table information. + * + * @param array $data + * @return void + */ + protected function display(array $data) + { + $this->option('json') ? $this->displayJson($data) : $this->displayForCli($data); + } + + /** + * Render the table information as JSON. + * + * @param array $data + * @return void + */ + protected function displayJson(array $data) + { + $this->output->writeln(json_encode($data)); + } + + /** + * Render the table information formatted for the CLI. + * + * @param array $data + * @return void + */ + protected function displayForCli(array $data) + { + [$table, $columns, $indexes, $foreignKeys] = [ + $data['table'], $data['columns'], $data['indexes'], $data['foreign_keys'], + ]; + + $this->newLine(); + + $this->components->twoColumnDetail(''.$table['name'].''); + $this->components->twoColumnDetail('Columns', $table['columns']); + + if ($size = $table['size']) { + $this->components->twoColumnDetail('Size', number_format($size / 1024 / 1024, 2).'MiB'); + } + + $this->newLine(); + + if ($columns->isNotEmpty()) { + $this->components->twoColumnDetail('Column', 'Type'); + + $columns->each(function ($column) { + $this->components->twoColumnDetail( + $column['column'].' '.$column['attributes']->implode(', ').'', + ($column['default'] ? ''.$column['default'].' ' : '').''.$column['type'].'' + ); + }); + + $this->newLine(); + } + + if ($indexes->isNotEmpty()) { + $this->components->twoColumnDetail('Index'); + + $indexes->each(function ($index) { + $this->components->twoColumnDetail( + $index['name'].' '.$index['columns']->implode(', ').'', + $index['attributes']->implode(', ') + ); + }); + + $this->newLine(); + } + + if ($foreignKeys->isNotEmpty()) { + $this->components->twoColumnDetail('Foreign Key', 'On Update / On Delete'); + + $foreignKeys->each(function ($foreignKey) { + $this->components->twoColumnDetail( + $foreignKey['name'].' '.$foreignKey['local_columns']->implode(', ').' references '.$foreignKey['foreign_columns']->implode(', ').' on '.$foreignKey['foreign_table'].'', + $foreignKey['on_update'].' / '.$foreignKey['on_delete'], + ); + }); + + $this->newLine(); + } + } +} diff --git a/vendor/illuminate/database/Console/WipeCommand.php b/vendor/illuminate/database/Console/WipeCommand.php index 2a7c1e5..cb26922 100644 --- a/vendor/illuminate/database/Console/WipeCommand.php +++ b/vendor/illuminate/database/Console/WipeCommand.php @@ -4,8 +4,10 @@ namespace Illuminate\Database\Console; use Illuminate\Console\Command; use Illuminate\Console\ConfirmableTrait; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputOption; +#[AsCommand(name: 'db:wipe')] class WipeCommand extends Command { use ConfirmableTrait; @@ -23,6 +25,8 @@ class WipeCommand extends Command * This name is used to identify the command during lazy loading. * * @var string|null + * + * @deprecated */ protected static $defaultName = 'db:wipe'; @@ -49,17 +53,17 @@ class WipeCommand extends Command if ($this->option('drop-views')) { $this->dropAllViews($database); - $this->info('Dropped all views successfully.'); + $this->components->info('Dropped all views successfully.'); } $this->dropAllTables($database); - $this->info('Dropped all tables successfully.'); + $this->components->info('Dropped all tables successfully.'); if ($this->option('drop-types')) { $this->dropAllTypes($database); - $this->info('Dropped all types successfully.'); + $this->components->info('Dropped all types successfully.'); } return 0; diff --git a/vendor/illuminate/database/DatabaseManager.php b/vendor/illuminate/database/DatabaseManager.php index 59283b1..fc81353 100755 --- a/vendor/illuminate/database/DatabaseManager.php +++ b/vendor/illuminate/database/DatabaseManager.php @@ -4,9 +4,11 @@ namespace Illuminate\Database; use Doctrine\DBAL\Types\Type; use Illuminate\Database\Connectors\ConnectionFactory; +use Illuminate\Database\Events\ConnectionEstablished; use Illuminate\Support\Arr; use Illuminate\Support\ConfigurationUrlParser; use Illuminate\Support\Str; +use Illuminate\Support\Traits\Macroable; use InvalidArgumentException; use PDO; use RuntimeException; @@ -16,6 +18,10 @@ use RuntimeException; */ class DatabaseManager implements ConnectionResolverInterface { + use Macroable { + __call as macroCall; + } + /** * The application instance. * @@ -33,14 +39,14 @@ class DatabaseManager implements ConnectionResolverInterface /** * The active connection instances. * - * @var array + * @var array */ protected $connections = []; /** * The custom connection resolvers. * - * @var array + * @var array */ protected $extensions = []; @@ -54,7 +60,7 @@ class DatabaseManager implements ConnectionResolverInterface /** * The custom Doctrine column types. * - * @var array + * @var array */ protected $doctrineTypes = []; @@ -94,6 +100,12 @@ class DatabaseManager implements ConnectionResolverInterface $this->connections[$name] = $this->configure( $this->makeConnection($database), $type ); + + if ($this->app->bound('events')) { + $this->app['events']->dispatch( + new ConnectionEstablished($this->connections[$name]) + ); + } } return $this->connections[$name]; @@ -364,7 +376,7 @@ class DatabaseManager implements ConnectionResolverInterface /** * Get all of the support drivers. * - * @return array + * @return string[] */ public function supportedDrivers() { @@ -374,7 +386,7 @@ class DatabaseManager implements ConnectionResolverInterface /** * Get all of the drivers that are actually available. * - * @return array + * @return string[] */ public function availableDrivers() { @@ -410,7 +422,7 @@ class DatabaseManager implements ConnectionResolverInterface /** * Return all of the created connections. * - * @return array + * @return array */ public function getConnections() { @@ -450,6 +462,10 @@ class DatabaseManager implements ConnectionResolverInterface */ public function __call($method, $parameters) { + if (static::hasMacro($method)) { + return $this->macroCall($method, $parameters); + } + return $this->connection()->$method(...$parameters); } } diff --git a/vendor/illuminate/database/DatabaseTransactionsManager.php b/vendor/illuminate/database/DatabaseTransactionsManager.php index 8c36504..8d14518 100755 --- a/vendor/illuminate/database/DatabaseTransactionsManager.php +++ b/vendor/illuminate/database/DatabaseTransactionsManager.php @@ -11,6 +11,13 @@ class DatabaseTransactionsManager */ protected $transactions; + /** + * The database transaction that should be ignored by callbacks. + * + * @var \Illuminate\Database\DatabaseTransactionRecord + */ + protected $callbacksShouldIgnore; + /** * Create a new database transactions manager instance. * @@ -44,10 +51,13 @@ class DatabaseTransactionsManager */ public function rollback($connection, $level) { - $this->transactions = $this->transactions->reject(function ($transaction) use ($connection, $level) { - return $transaction->connection == $connection && - $transaction->level > $level; - })->values(); + $this->transactions = $this->transactions->reject( + fn ($transaction) => $transaction->connection == $connection && $transaction->level > $level + )->values(); + + if ($this->transactions->isEmpty()) { + $this->callbacksShouldIgnore = null; + } } /** @@ -59,14 +69,16 @@ class DatabaseTransactionsManager public function commit($connection) { [$forThisConnection, $forOtherConnections] = $this->transactions->partition( - function ($transaction) use ($connection) { - return $transaction->connection == $connection; - } + fn ($transaction) => $transaction->connection == $connection ); $this->transactions = $forOtherConnections->values(); $forThisConnection->map->executeCallbacks(); + + if ($this->transactions->isEmpty()) { + $this->callbacksShouldIgnore = null; + } } /** @@ -77,13 +89,38 @@ class DatabaseTransactionsManager */ public function addCallback($callback) { - if ($current = $this->transactions->last()) { + if ($current = $this->callbackApplicableTransactions()->last()) { return $current->addCallback($callback); } $callback(); } + /** + * Specify that callbacks should ignore the given transaction when determining if they should be executed. + * + * @param \Illuminate\Database\DatabaseTransactionRecord $transaction + * @return $this + */ + public function callbacksShouldIgnore(DatabaseTransactionRecord $transaction) + { + $this->callbacksShouldIgnore = $transaction; + + return $this; + } + + /** + * Get the transactions that are applicable to callbacks. + * + * @return \Illuminate\Support\Collection + */ + public function callbackApplicableTransactions() + { + return $this->transactions->reject(function ($transaction) { + return $transaction === $this->callbacksShouldIgnore; + })->values(); + } + /** * Get all the transactions. * diff --git a/vendor/illuminate/database/DeadlockException.php b/vendor/illuminate/database/DeadlockException.php new file mode 100644 index 0000000..375a39b --- /dev/null +++ b/vendor/illuminate/database/DeadlockException.php @@ -0,0 +1,10 @@ +query->whereIn($this->model->getQualifiedKeyName(), $id); + if (in_array($this->model->getKeyType(), ['int', 'integer'])) { + $this->query->whereIntegerInRaw($this->model->getQualifiedKeyName(), $id); + } else { + $this->query->whereIn($this->model->getQualifiedKeyName(), $id); + } return $this; } @@ -251,7 +261,11 @@ class Builder implements BuilderContract } if (is_array($id) || $id instanceof Arrayable) { - $this->query->whereNotIn($this->model->getQualifiedKeyName(), $id); + if (in_array($this->model->getKeyType(), ['int', 'integer'])) { + $this->query->whereIntegerNotInRaw($this->model->getQualifiedKeyName(), $id); + } else { + $this->query->whereNotIn($this->model->getQualifiedKeyName(), $id); + } return $this; } @@ -416,7 +430,7 @@ class Builder implements BuilderContract * Find a model by its primary key. * * @param mixed $id - * @param array $columns + * @param array|string $columns * @return \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Collection|static[]|static|null */ public function find($id, $columns = ['*']) @@ -432,7 +446,7 @@ class Builder implements BuilderContract * Find multiple models by their primary keys. * * @param \Illuminate\Contracts\Support\Arrayable|array $ids - * @param array $columns + * @param array|string $columns * @return \Illuminate\Database\Eloquent\Collection */ public function findMany($ids, $columns = ['*']) @@ -450,7 +464,7 @@ class Builder implements BuilderContract * Find a model by its primary key or throw an exception. * * @param mixed $id - * @param array $columns + * @param array|string $columns * @return \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Collection|static|static[] * * @throws \Illuminate\Database\Eloquent\ModelNotFoundException<\Illuminate\Database\Eloquent\Model> @@ -484,7 +498,7 @@ class Builder implements BuilderContract * Find a model by its primary key or return fresh model instance. * * @param mixed $id - * @param array $columns + * @param array|string $columns * @return \Illuminate\Database\Eloquent\Model|static */ public function findOrNew($id, $columns = ['*']) @@ -496,6 +510,29 @@ class Builder implements BuilderContract return $this->newModelInstance(); } + /** + * Find a model by its primary key or call a callback. + * + * @param mixed $id + * @param \Closure|array|string $columns + * @param \Closure|null $callback + * @return \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Collection|static[]|static|mixed + */ + public function findOr($id, $columns = ['*'], Closure $callback = null) + { + if ($columns instanceof Closure) { + $callback = $columns; + + $columns = ['*']; + } + + if (! is_null($model = $this->find($id, $columns))) { + return $model; + } + + return $callback(); + } + /** * Get the first record matching the attributes or instantiate it. * @@ -547,7 +584,7 @@ class Builder implements BuilderContract /** * Execute the query and get the first result or throw an exception. * - * @param array $columns + * @param array|string $columns * @return \Illuminate\Database\Eloquent\Model|static * * @throws \Illuminate\Database\Eloquent\ModelNotFoundException<\Illuminate\Database\Eloquent\Model> @@ -564,7 +601,7 @@ class Builder implements BuilderContract /** * Execute the query and get the first result or call a callback. * - * @param \Closure|array $columns + * @param \Closure|array|string $columns * @param \Closure|null $callback * @return \Illuminate\Database\Eloquent\Model|static|mixed */ @@ -812,7 +849,7 @@ class Builder implements BuilderContract } /** - * Get an array with the values of a given column. + * Get a collection with the values of a given column. * * @param string|\Illuminate\Database\Query\Expression $column * @param string|null $key @@ -839,8 +876,8 @@ class Builder implements BuilderContract /** * Paginate the given query. * - * @param int|null $perPage - * @param array $columns + * @param int|null|\Closure $perPage + * @param array|string $columns * @param string $pageName * @param int|null $page * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator @@ -851,11 +888,16 @@ class Builder implements BuilderContract { $page = $page ?: Paginator::resolveCurrentPage($pageName); - $perPage = $perPage ?: $this->model->getPerPage(); + $total = $this->toBase()->getCountForPagination(); - $results = ($total = $this->toBase()->getCountForPagination()) - ? $this->forPage($page, $perPage)->get($columns) - : $this->model->newCollection(); + $perPage = ($perPage instanceof Closure + ? $perPage($total) + : $perPage + ) ?: $this->model->getPerPage(); + + $results = $total + ? $this->forPage($page, $perPage)->get($columns) + : $this->model->newCollection(); return $this->paginator($results, $total, $perPage, $page, [ 'path' => Paginator::resolveCurrentPath(), @@ -867,7 +909,7 @@ class Builder implements BuilderContract * Paginate the given query into a simple paginator. * * @param int|null $perPage - * @param array $columns + * @param array|string $columns * @param string $pageName * @param int|null $page * @return \Illuminate\Contracts\Pagination\Paginator @@ -893,7 +935,7 @@ class Builder implements BuilderContract * Paginate the given query into a cursor paginator. * * @param int|null $perPage - * @param array $columns + * @param array|string $columns * @param string $cursorName * @param \Illuminate\Pagination\Cursor|string|null $cursor * @return \Illuminate\Contracts\Pagination\CursorPaginator @@ -998,6 +1040,29 @@ class Builder implements BuilderContract ); } + /** + * Update the column's update timestamp. + * + * @param string|null $column + * @return int|false + */ + public function touch($column = null) + { + $time = $this->model->freshTimestamp(); + + if ($column) { + return $this->toBase()->update([$column => $time]); + } + + $column = $this->model->getUpdatedAtColumn(); + + if (! $this->model->usesTimestamps() || is_null($column)) { + return false; + } + + return $this->toBase()->update([$column => $time]); + } + /** * Increment a column's value by a given amount. * @@ -1244,7 +1309,7 @@ class Builder implements BuilderContract $originalWhereCount = is_null($query->wheres) ? 0 : count($query->wheres); - $result = $scope(...array_values($parameters)) ?? $this; + $result = $scope(...$parameters) ?? $this; if (count((array) $query->wheres) > $originalWhereCount) { $this->addNewWheresWithinGroup($query, $originalWhereCount); @@ -1400,22 +1465,13 @@ class Builder implements BuilderContract */ protected function parseWithRelations(array $relations) { + if ($relations === []) { + return []; + } + $results = []; - foreach ($relations as $name => $constraints) { - // If the "name" value is a numeric key, we can assume that no constraints - // have been specified. We will just put an empty Closure there so that - // we can treat these all the same while we are looping through them. - if (is_numeric($name)) { - $name = $constraints; - - [$name, $constraints] = str_contains($name, ':') - ? $this->createSelectWithConstraint($name) - : [$name, static function () { - // - }]; - } - + foreach ($this->prepareNestedWithRelationships($relations) as $name => $constraints) { // We need to separate out any nested includes, which allows the developers // to load deep relationships using "dots" without stating each level of // the relationship with its own key in the array of eager-load names. @@ -1427,6 +1483,91 @@ class Builder implements BuilderContract return $results; } + /** + * Prepare nested with relationships. + * + * @param array $relations + * @param string $prefix + * @return array + */ + protected function prepareNestedWithRelationships($relations, $prefix = '') + { + $preparedRelationships = []; + + if ($prefix !== '') { + $prefix .= '.'; + } + + // If any of the relationships are formatted with the [$attribute => array()] + // syntax, we shall loop over the nested relations and prepend each key of + // this array while flattening into the traditional dot notation format. + foreach ($relations as $key => $value) { + if (! is_string($key) || ! is_array($value)) { + continue; + } + + [$attribute, $attributeSelectConstraint] = $this->parseNameAndAttributeSelectionConstraint($key); + + $preparedRelationships = array_merge( + $preparedRelationships, + ["{$prefix}{$attribute}" => $attributeSelectConstraint], + $this->prepareNestedWithRelationships($value, "{$prefix}{$attribute}"), + ); + + unset($relations[$key]); + } + + // We now know that the remaining relationships are in a dot notation format + // and may be a string or Closure. We'll loop over them and ensure all of + // the present Closures are merged + strings are made into constraints. + foreach ($relations as $key => $value) { + if (is_numeric($key) && is_string($value)) { + [$key, $value] = $this->parseNameAndAttributeSelectionConstraint($value); + } + + $preparedRelationships[$prefix.$key] = $this->combineConstraints([ + $value, + $preparedRelationships[$prefix.$key] ?? static function () { + // + }, + ]); + } + + return $preparedRelationships; + } + + /** + * Combine an array of constraints into a single constraint. + * + * @param array $constraints + * @return \Closure + */ + protected function combineConstraints(array $constraints) + { + return function ($builder) use ($constraints) { + foreach ($constraints as $constraint) { + $builder = $constraint($builder) ?? $builder; + } + + return $builder; + }; + } + + /** + * Parse the attribute select constraints from the name. + * + * @param string $name + * @return array + */ + protected function parseNameAndAttributeSelectionConstraint($name) + { + return str_contains($name, ':') + ? $this->createSelectWithConstraint($name) + : [$name, static function () { + // + }]; + } + /** * Create a constraint to select the given columns for the relation. * @@ -1544,6 +1685,29 @@ class Builder implements BuilderContract return $this; } + /** + * Indicate that the given relationships should not be eagerly loaded. + * + * @param array $relations + * @return $this + */ + public function withoutEagerLoad(array $relations) + { + $relations = array_diff(array_keys($this->model->getRelations()), $relations); + + return $this->with($relations); + } + + /** + * Flush the relationships being eagerly loaded. + * + * @return $this + */ + public function withoutEagerLoads() + { + return $this->setEagerLoads([]); + } + /** * Get the default key name of the table. * @@ -1655,7 +1819,7 @@ class Builder implements BuilderContract */ public function __get($key) { - if ($key === 'orWhere') { + if (in_array($key, ['orWhere', 'whereNot', 'orWhereNot'])) { return new HigherOrderBuilderProxy($this, $key); } @@ -1754,8 +1918,8 @@ class Builder implements BuilderContract protected static function registerMixin($mixin, $replace) { $methods = (new ReflectionClass($mixin))->getMethods( - ReflectionMethod::IS_PUBLIC | ReflectionMethod::IS_PROTECTED - ); + ReflectionMethod::IS_PUBLIC | ReflectionMethod::IS_PROTECTED + ); foreach ($methods as $method) { if ($replace || ! static::hasGlobalMacro($method->name)) { diff --git a/vendor/illuminate/database/Eloquent/Casts/ArrayObject.php b/vendor/illuminate/database/Eloquent/Casts/ArrayObject.php index 2da92c3..896445e 100644 --- a/vendor/illuminate/database/Eloquent/Casts/ArrayObject.php +++ b/vendor/illuminate/database/Eloquent/Casts/ArrayObject.php @@ -6,6 +6,11 @@ use ArrayObject as BaseArrayObject; use Illuminate\Contracts\Support\Arrayable; use JsonSerializable; +/** + * @template TKey of array-key + * @template TItem + * @extends \ArrayObject + */ class ArrayObject extends BaseArrayObject implements Arrayable, JsonSerializable { /** diff --git a/vendor/illuminate/database/Eloquent/Casts/AsArrayObject.php b/vendor/illuminate/database/Eloquent/Casts/AsArrayObject.php index db9a21b..23543ba 100644 --- a/vendor/illuminate/database/Eloquent/Casts/AsArrayObject.php +++ b/vendor/illuminate/database/Eloquent/Casts/AsArrayObject.php @@ -11,7 +11,7 @@ class AsArrayObject implements Castable * Get the caster class to use when casting from / to this cast target. * * @param array $arguments - * @return object|string + * @return CastsAttributes, iterable> */ public static function castUsing(array $arguments) { @@ -19,7 +19,13 @@ class AsArrayObject implements Castable { public function get($model, $key, $value, $attributes) { - return isset($attributes[$key]) ? new ArrayObject(json_decode($attributes[$key], true)) : null; + if (! isset($attributes[$key])) { + return; + } + + $data = json_decode($attributes[$key], true); + + return is_array($data) ? new ArrayObject($data) : null; } public function set($model, $key, $value, $attributes) diff --git a/vendor/illuminate/database/Eloquent/Casts/AsCollection.php b/vendor/illuminate/database/Eloquent/Casts/AsCollection.php index 585b6cf..1a0dd83 100644 --- a/vendor/illuminate/database/Eloquent/Casts/AsCollection.php +++ b/vendor/illuminate/database/Eloquent/Casts/AsCollection.php @@ -12,7 +12,7 @@ class AsCollection implements Castable * Get the caster class to use when casting from / to this cast target. * * @param array $arguments - * @return object|string + * @return CastsAttributes<\Illuminate\Support\Collection, iterable> */ public static function castUsing(array $arguments) { @@ -20,7 +20,13 @@ class AsCollection implements Castable { public function get($model, $key, $value, $attributes) { - return isset($attributes[$key]) ? new Collection(json_decode($attributes[$key], true)) : null; + if (! isset($attributes[$key])) { + return; + } + + $data = json_decode($attributes[$key], true); + + return is_array($data) ? new Collection($data) : null; } public function set($model, $key, $value, $attributes) diff --git a/vendor/illuminate/database/Eloquent/Casts/AsEncryptedArrayObject.php b/vendor/illuminate/database/Eloquent/Casts/AsEncryptedArrayObject.php index cd65624..ce2b663 100644 --- a/vendor/illuminate/database/Eloquent/Casts/AsEncryptedArrayObject.php +++ b/vendor/illuminate/database/Eloquent/Casts/AsEncryptedArrayObject.php @@ -12,7 +12,7 @@ class AsEncryptedArrayObject implements Castable * Get the caster class to use when casting from / to this cast target. * * @param array $arguments - * @return object|string + * @return CastsAttributes, iterable> */ public static function castUsing(array $arguments) { diff --git a/vendor/illuminate/database/Eloquent/Casts/AsEncryptedCollection.php b/vendor/illuminate/database/Eloquent/Casts/AsEncryptedCollection.php index 4d9fee7..64cdf00 100644 --- a/vendor/illuminate/database/Eloquent/Casts/AsEncryptedCollection.php +++ b/vendor/illuminate/database/Eloquent/Casts/AsEncryptedCollection.php @@ -13,7 +13,7 @@ class AsEncryptedCollection implements Castable * Get the caster class to use when casting from / to this cast target. * * @param array $arguments - * @return object|string + * @return CastsAttributes<\Illuminate\Support\Collection, iterable> */ public static function castUsing(array $arguments) { diff --git a/vendor/illuminate/database/Eloquent/Casts/AsEnumArrayObject.php b/vendor/illuminate/database/Eloquent/Casts/AsEnumArrayObject.php new file mode 100644 index 0000000..5b47785 --- /dev/null +++ b/vendor/illuminate/database/Eloquent/Casts/AsEnumArrayObject.php @@ -0,0 +1,84 @@ +} $arguments + * @return CastsAttributes, iterable> + */ + public static function castUsing(array $arguments) + { + return new class($arguments) implements CastsAttributes + { + protected $arguments; + + public function __construct(array $arguments) + { + $this->arguments = $arguments; + } + + public function get($model, $key, $value, $attributes) + { + if (! isset($attributes[$key]) || is_null($attributes[$key])) { + return; + } + + $data = json_decode($attributes[$key], true); + + if (! is_array($data)) { + return; + } + + $enumClass = $this->arguments[0]; + + return new ArrayObject((new Collection($data))->map(function ($value) use ($enumClass) { + return is_subclass_of($enumClass, BackedEnum::class) + ? $enumClass::from($value) + : constant($enumClass.'::'.$value); + })->toArray()); + } + + public function set($model, $key, $value, $attributes) + { + if ($value === null) { + return [$key => null]; + } + + $storable = []; + + foreach ($value as $enum) { + $storable[] = $this->getStorableEnumValue($enum); + } + + return [$key => json_encode($storable)]; + } + + public function serialize($model, string $key, $value, array $attributes) + { + return (new Collection($value->getArrayCopy()))->map(function ($enum) { + return $this->getStorableEnumValue($enum); + })->toArray(); + } + + protected function getStorableEnumValue($enum) + { + if (is_string($enum) || is_int($enum)) { + return $enum; + } + + return $enum instanceof BackedEnum ? $enum->value : $enum->name; + } + }; + } +} diff --git a/vendor/illuminate/database/Eloquent/Casts/AsEnumCollection.php b/vendor/illuminate/database/Eloquent/Casts/AsEnumCollection.php new file mode 100644 index 0000000..ca1feb5 --- /dev/null +++ b/vendor/illuminate/database/Eloquent/Casts/AsEnumCollection.php @@ -0,0 +1,80 @@ +} $arguments + * @return CastsAttributes, iterable> + */ + public static function castUsing(array $arguments) + { + return new class($arguments) implements CastsAttributes + { + protected $arguments; + + public function __construct(array $arguments) + { + $this->arguments = $arguments; + } + + public function get($model, $key, $value, $attributes) + { + if (! isset($attributes[$key]) || is_null($attributes[$key])) { + return; + } + + $data = json_decode($attributes[$key], true); + + if (! is_array($data)) { + return; + } + + $enumClass = $this->arguments[0]; + + return (new Collection($data))->map(function ($value) use ($enumClass) { + return is_subclass_of($enumClass, BackedEnum::class) + ? $enumClass::from($value) + : constant($enumClass.'::'.$value); + }); + } + + public function set($model, $key, $value, $attributes) + { + $value = $value !== null + ? (new Collection($value))->map(function ($enum) { + return $this->getStorableEnumValue($enum); + })->toJson() + : null; + + return [$key => $value]; + } + + public function serialize($model, string $key, $value, array $attributes) + { + return (new Collection($value))->map(function ($enum) { + return $this->getStorableEnumValue($enum); + })->toArray(); + } + + protected function getStorableEnumValue($enum) + { + if (is_string($enum) || is_int($enum)) { + return $enum; + } + + return $enum instanceof BackedEnum ? $enum->value : $enum->name; + } + }; + } +} diff --git a/vendor/illuminate/database/Eloquent/Casts/AsStringable.php b/vendor/illuminate/database/Eloquent/Casts/AsStringable.php index 912659f..c2927d2 100644 --- a/vendor/illuminate/database/Eloquent/Casts/AsStringable.php +++ b/vendor/illuminate/database/Eloquent/Casts/AsStringable.php @@ -12,7 +12,7 @@ class AsStringable implements Castable * Get the caster class to use when casting from / to this cast target. * * @param array $arguments - * @return object|string + * @return CastsAttributes<\Illuminate\Support\Stringable, string|\Stringable> */ public static function castUsing(array $arguments) { diff --git a/vendor/illuminate/database/Eloquent/Casts/Attribute.php b/vendor/illuminate/database/Eloquent/Casts/Attribute.php index 819f230..3f9fd19 100644 --- a/vendor/illuminate/database/Eloquent/Casts/Attribute.php +++ b/vendor/illuminate/database/Eloquent/Casts/Attribute.php @@ -18,6 +18,13 @@ class Attribute */ public $set; + /** + * Indicates if caching is enabled for this attribute. + * + * @var bool + */ + public $withCaching = false; + /** * Indicates if caching of objects is enabled for this attribute. * @@ -83,4 +90,16 @@ class Attribute return $this; } + + /** + * Enable caching for the attribute. + * + * @return static + */ + public function shouldCache() + { + $this->withCaching = true; + + return $this; + } } diff --git a/vendor/illuminate/database/Eloquent/Collection.php b/vendor/illuminate/database/Eloquent/Collection.php index efdd507..79785c6 100755 --- a/vendor/illuminate/database/Eloquent/Collection.php +++ b/vendor/illuminate/database/Eloquent/Collection.php @@ -24,7 +24,7 @@ class Collection extends BaseCollection implements QueueableCollection * * @param mixed $key * @param TFindDefault $default - * @return static|TModel|TFindDefault + * @return static|TModel|TFindDefault */ public function find($key, $default = null) { @@ -44,9 +44,7 @@ class Collection extends BaseCollection implements QueueableCollection return $this->whereIn($this->first()->getKeyName(), $key); } - return Arr::first($this->items, function ($model) use ($key) { - return $model->getKey() == $key; - }, $default); + return Arr::first($this->items, fn ($model) => $model->getKey() == $key, $default); } /** @@ -233,9 +231,7 @@ class Collection extends BaseCollection implements QueueableCollection $relation = reset($relation); } - $models->filter(function ($model) use ($name) { - return ! is_null($model) && ! $model->relationLoaded($name); - })->load($relation); + $models->filter(fn ($model) => ! is_null($model) && ! $model->relationLoaded($name))->load($relation); if (empty($path)) { return; @@ -261,12 +257,8 @@ class Collection extends BaseCollection implements QueueableCollection { $this->pluck($relation) ->filter() - ->groupBy(function ($model) { - return get_class($model); - }) - ->each(function ($models, $className) use ($relations) { - static::make($models)->load($relations[$className] ?? []); - }); + ->groupBy(fn ($model) => get_class($model)) + ->each(fn ($models, $className) => static::make($models)->load($relations[$className] ?? [])); return $this; } @@ -282,12 +274,8 @@ class Collection extends BaseCollection implements QueueableCollection { $this->pluck($relation) ->filter() - ->groupBy(function ($model) { - return get_class($model); - }) - ->each(function ($models, $className) use ($relations) { - static::make($models)->loadCount($relations[$className] ?? []); - }); + ->groupBy(fn ($model) => get_class($model)) + ->each(fn ($models, $className) => static::make($models)->loadCount($relations[$className] ?? [])); return $this; } @@ -295,7 +283,7 @@ class Collection extends BaseCollection implements QueueableCollection /** * Determine if a key exists in the collection. * - * @param (callable(TModel, TKey): bool)|TModel|string $key + * @param (callable(TModel, TKey): bool)|TModel|string|int $key * @param mixed $operator * @param mixed $value * @return bool @@ -307,14 +295,10 @@ class Collection extends BaseCollection implements QueueableCollection } if ($key instanceof Model) { - return parent::contains(function ($model) use ($key) { - return $model->is($key); - }); + return parent::contains(fn ($model) => $model->is($key)); } - return parent::contains(function ($model) use ($key) { - return $model->getKey() == $key; - }); + return parent::contains(fn ($model) => $model->getKey() == $key); } /** @@ -324,9 +308,7 @@ class Collection extends BaseCollection implements QueueableCollection */ public function modelKeys() { - return array_map(function ($model) { - return $model->getKey(); - }, $this->items); + return array_map(fn ($model) => $model->getKey(), $this->items); } /** @@ -358,9 +340,7 @@ class Collection extends BaseCollection implements QueueableCollection { $result = parent::map($callback); - return $result->contains(function ($item) { - return ! $item instanceof Model; - }) ? $result->toBase() : $result; + return $result->contains(fn ($item) => ! $item instanceof Model) ? $result->toBase() : $result; } /** @@ -378,9 +358,7 @@ class Collection extends BaseCollection implements QueueableCollection { $result = parent::mapWithKeys($callback); - return $result->contains(function ($item) { - return ! $item instanceof Model; - }) ? $result->toBase() : $result; + return $result->contains(fn ($item) => ! $item instanceof Model) ? $result->toBase() : $result; } /** @@ -403,12 +381,8 @@ class Collection extends BaseCollection implements QueueableCollection ->get() ->getDictionary(); - return $this->filter(function ($model) use ($freshModels) { - return $model->exists && isset($freshModels[$model->getKey()]); - }) - ->map(function ($model) use ($freshModels) { - return $freshModels[$model->getKey()]; - }); + return $this->filter(fn ($model) => $model->exists && isset($freshModels[$model->getKey()])) + ->map(fn ($model) => $freshModels[$model->getKey()]); } /** @@ -525,6 +499,28 @@ class Collection extends BaseCollection implements QueueableCollection return $this->each->makeVisible($attributes); } + /** + * Set the visible attributes across the entire collection. + * + * @param array $visible + * @return $this + */ + public function setVisible($visible) + { + return $this->each->setVisible($visible); + } + + /** + * Set the hidden attributes across the entire collection. + * + * @param array $hidden + * @return $this + */ + public function setHidden($hidden) + { + return $this->each->setHidden($hidden); + } + /** * Append an attribute across the entire collection. * @@ -560,38 +556,14 @@ class Collection extends BaseCollection implements QueueableCollection */ /** - * Get an array with the values of a given key. + * Count the number of items in the collection by a field or using a callback. * - * @param string|array $value - * @param string|null $key - * @return \Illuminate\Support\Collection + * @param (callable(TModel, TKey): array-key)|string|null $countBy + * @return \Illuminate\Support\Collection */ - public function pluck($value, $key = null) + public function countBy($countBy = null) { - return $this->toBase()->pluck($value, $key); - } - - /** - * Get the keys of the collection items. - * - * @return \Illuminate\Support\Collection - */ - public function keys() - { - return $this->toBase()->keys(); - } - - /** - * Zip the collection together with one or more arrays. - * - * @template TZipValue - * - * @param \Illuminate\Contracts\Support\Arrayable|iterable ...$items - * @return \Illuminate\Support\Collection> - */ - public function zip($items) - { - return $this->toBase()->zip(...func_get_args()); + return $this->toBase()->countBy($countBy); } /** @@ -625,6 +597,16 @@ class Collection extends BaseCollection implements QueueableCollection return $this->toBase()->flip(); } + /** + * Get the keys of the collection items. + * + * @return \Illuminate\Support\Collection + */ + public function keys() + { + return $this->toBase()->keys(); + } + /** * Pad collection to the specified length with a value. * @@ -639,17 +621,40 @@ class Collection extends BaseCollection implements QueueableCollection return $this->toBase()->pad($size, $value); } + /** + * Get an array with the values of a given key. + * + * @param string|array $value + * @param string|null $key + * @return \Illuminate\Support\Collection + */ + public function pluck($value, $key = null) + { + return $this->toBase()->pluck($value, $key); + } + + /** + * Zip the collection together with one or more arrays. + * + * @template TZipValue + * + * @param \Illuminate\Contracts\Support\Arrayable|iterable ...$items + * @return \Illuminate\Support\Collection> + */ + public function zip($items) + { + return $this->toBase()->zip(...func_get_args()); + } + /** * Get the comparison function to detect duplicates. * * @param bool $strict - * @return callable(TValue, TValue): bool + * @return callable(TModel, TModel): bool */ protected function duplicateComparator($strict) { - return function ($a, $b) { - return $a->is($b); - }; + return fn ($a, $b) => $a->is($b); } /** @@ -665,10 +670,10 @@ class Collection extends BaseCollection implements QueueableCollection return; } - $class = get_class($this->first()); + $class = $this->getQueueableModelClass($this->first()); $this->each(function ($model) use ($class) { - if (get_class($model) !== $class) { + if ($this->getQueueableModelClass($model) !== $class) { throw new LogicException('Queueing collections with multiple model types is not supported.'); } }); @@ -676,6 +681,19 @@ class Collection extends BaseCollection implements QueueableCollection return $class; } + /** + * Get the queueable class name for the given model. + * + * @param \Illuminate\Database\Eloquent\Model $model + * @return string + */ + protected function getQueueableModelClass($model) + { + return method_exists($model, 'getQueueableClassName') + ? $model->getQueueableClassName() + : get_class($model); + } + /** * Get the identifiers for all of the entities. * @@ -755,9 +773,7 @@ class Collection extends BaseCollection implements QueueableCollection $class = get_class($model); - if ($this->filter(function ($model) use ($class) { - return ! $model instanceof $class; - })->isNotEmpty()) { + if ($this->filter(fn ($model) => ! $model instanceof $class)->isNotEmpty()) { throw new LogicException('Unable to create query for collection with mixed types.'); } diff --git a/vendor/illuminate/database/Eloquent/Concerns/GuardsAttributes.php b/vendor/illuminate/database/Eloquent/Concerns/GuardsAttributes.php index b2e6651..bfb6775 100644 --- a/vendor/illuminate/database/Eloquent/Concerns/GuardsAttributes.php +++ b/vendor/illuminate/database/Eloquent/Concerns/GuardsAttributes.php @@ -7,14 +7,14 @@ trait GuardsAttributes /** * The attributes that are mass assignable. * - * @var string[] + * @var array */ protected $fillable = []; /** * The attributes that aren't mass assignable. * - * @var string[]|bool + * @var array|bool */ protected $guarded = ['*']; @@ -28,14 +28,14 @@ trait GuardsAttributes /** * The actual columns that exist on the database and can be guarded. * - * @var array + * @var array */ protected static $guardableColumns = []; /** * Get the fillable attributes for the model. * - * @return array + * @return array */ public function getFillable() { @@ -45,7 +45,7 @@ trait GuardsAttributes /** * Set the fillable attributes for the model. * - * @param array $fillable + * @param array $fillable * @return $this */ public function fillable(array $fillable) @@ -58,7 +58,7 @@ trait GuardsAttributes /** * Merge new fillable attributes with existing fillable attributes on the model. * - * @param array $fillable + * @param array $fillable * @return $this */ public function mergeFillable(array $fillable) @@ -71,7 +71,7 @@ trait GuardsAttributes /** * Get the guarded attributes for the model. * - * @return array + * @return array */ public function getGuarded() { @@ -83,7 +83,7 @@ trait GuardsAttributes /** * Set the guarded attributes for the model. * - * @param array $guarded + * @param array $guarded * @return $this */ public function guard(array $guarded) @@ -96,7 +96,7 @@ trait GuardsAttributes /** * Merge new guarded attributes with existing guarded attributes on the model. * - * @param array $guarded + * @param array $guarded * @return $this */ public function mergeGuarded(array $guarded) @@ -202,7 +202,7 @@ trait GuardsAttributes } return $this->getGuarded() == ['*'] || - ! empty(preg_grep('/^'.preg_quote($key).'$/i', $this->getGuarded())) || + ! empty(preg_grep('/^'.preg_quote($key, '/').'$/i', $this->getGuarded())) || ! $this->isGuardableColumn($key); } diff --git a/vendor/illuminate/database/Eloquent/Concerns/HasAttributes.php b/vendor/illuminate/database/Eloquent/Concerns/HasAttributes.php index 2046258..2b1b7ca 100644 --- a/vendor/illuminate/database/Eloquent/Concerns/HasAttributes.php +++ b/vendor/illuminate/database/Eloquent/Concerns/HasAttributes.php @@ -2,6 +2,10 @@ namespace Illuminate\Database\Eloquent\Concerns; +use BackedEnum; +use Brick\Math\BigDecimal; +use Brick\Math\Exception\MathException as BrickMathException; +use Brick\Math\RoundingMode; use Carbon\CarbonImmutable; use Carbon\CarbonInterface; use DateTimeImmutable; @@ -11,14 +15,18 @@ use Illuminate\Contracts\Database\Eloquent\CastsInboundAttributes; use Illuminate\Contracts\Support\Arrayable; use Illuminate\Database\Eloquent\Casts\AsArrayObject; use Illuminate\Database\Eloquent\Casts\AsCollection; +use Illuminate\Database\Eloquent\Casts\AsEncryptedArrayObject; +use Illuminate\Database\Eloquent\Casts\AsEncryptedCollection; use Illuminate\Database\Eloquent\Casts\Attribute; use Illuminate\Database\Eloquent\InvalidCastException; use Illuminate\Database\Eloquent\JsonEncodingException; +use Illuminate\Database\Eloquent\MissingAttributeException; use Illuminate\Database\Eloquent\Relations\Relation; use Illuminate\Database\LazyLoadingViolationException; use Illuminate\Support\Arr; use Illuminate\Support\Carbon; use Illuminate\Support\Collection as BaseCollection; +use Illuminate\Support\Exceptions\MathException; use Illuminate\Support\Facades\Crypt; use Illuminate\Support\Facades\Date; use Illuminate\Support\Str; @@ -163,10 +171,17 @@ trait HasAttributes */ protected static $setAttributeMutatorCache = []; + /** + * The cache of the converted cast types. + * + * @var array + */ + protected static $castTypeCache = []; + /** * The encrypter instance that is used to encrypt attributes. * - * @var \Illuminate\Contracts\Encryption\Encrypter + * @var \Illuminate\Contracts\Encryption\Encrypter|null */ public static $encrypter; @@ -279,11 +294,11 @@ trait HasAttributes // If the attribute cast was a date or a datetime, we will serialize the date as // a string. This allows the developers to customize how dates are serialized // into an array without affecting how they are persisted into the storage. - if ($attributes[$key] && in_array($value, ['date', 'datetime', 'immutable_date', 'immutable_datetime'])) { + if (isset($attributes[$key]) && in_array($value, ['date', 'datetime', 'immutable_date', 'immutable_datetime'])) { $attributes[$key] = $this->serializeDate($attributes[$key]); } - if ($attributes[$key] && ($this->isCustomDateTimeCast($value) || + if (isset($attributes[$key]) && ($this->isCustomDateTimeCast($value) || $this->isImmutableCustomDateTimeCast($value))) { $attributes[$key] = $attributes[$key]->format(explode(':', $value, 2)[1]); } @@ -293,12 +308,12 @@ trait HasAttributes $attributes[$key] = $this->serializeDate($attributes[$key]); } - if ($attributes[$key] && $this->isClassSerializable($key)) { + if (isset($attributes[$key]) && $this->isClassSerializable($key)) { $attributes[$key] = $this->serializeClassCastableAttribute($key, $attributes[$key]); } if ($this->isEnumCastable($key) && (! ($attributes[$key] ?? null) instanceof Arrayable)) { - $attributes[$key] = isset($attributes[$key]) ? $attributes[$key]->value : null; + $attributes[$key] = isset($attributes[$key]) ? $this->getStorableEnumValue($attributes[$key]) : null; } if ($attributes[$key] instanceof Arrayable) { @@ -345,7 +360,7 @@ trait HasAttributes $attributes = []; foreach ($this->getArrayableRelations() as $key => $value) { - // If the values implements the Arrayable interface we can just call this + // If the values implement the Arrayable interface we can just call this // toArray method on the instances which will convert both models and // collections to their proper array form and we'll set the values. if ($value instanceof Arrayable) { @@ -353,8 +368,8 @@ trait HasAttributes } // If the value is null, we'll still go ahead and set it in this list of - // attributes since null is used to represent empty relationships if - // if it a has one or belongs to type relationships on the models. + // attributes, since null is used to represent empty relationships if + // it has a has one or belongs to type relationships on the models. elseif (is_null($value)) { $relation = $value; } @@ -435,10 +450,35 @@ trait HasAttributes // since we don't want to treat any of those methods as relationships because // they are all intended as helper methods and none of these are relations. if (method_exists(self::class, $key)) { - return; + return $this->throwMissingAttributeExceptionIfApplicable($key); } - return $this->getRelationValue($key); + return $this->isRelation($key) || $this->relationLoaded($key) + ? $this->getRelationValue($key) + : $this->throwMissingAttributeExceptionIfApplicable($key); + } + + /** + * Either throw a missing attribute exception or return null depending on Eloquent's configuration. + * + * @param string $key + * @return null + * + * @throws \Illuminate\Database\Eloquent\MissingAttributeException + */ + protected function throwMissingAttributeExceptionIfApplicable($key) + { + if ($this->exists && + ! $this->wasRecentlyCreated && + static::preventsAccessingMissingAttributes()) { + if (isset(static::$missingAttributeViolationCallback)) { + return call_user_func(static::$missingAttributeViolationCallback, $this, $key); + } + + throw new MissingAttributeException($this, $key); + } + + return null; } /** @@ -505,7 +545,7 @@ trait HasAttributes } return method_exists($this, $key) || - (static::$relationResolvers[get_class($this)][$key] ?? null); + $this->relationResolver(static::class, $key); } /** @@ -520,6 +560,10 @@ trait HasAttributes return call_user_func(static::$lazyLoadingViolationCallback, $this, $key); } + if (! $this->exists || $this->wasRecentlyCreated) { + return; + } + throw new LazyLoadingViolationException($this, $key); } @@ -626,7 +670,7 @@ trait HasAttributes */ protected function mutateAttributeMarkedAttribute($key, $value) { - if (isset($this->attributeCastCache[$key])) { + if (array_key_exists($key, $this->attributeCastCache)) { return $this->attributeCastCache[$key]; } @@ -636,10 +680,10 @@ trait HasAttributes return $value; }, $value, $this->attributes); - if (! is_object($value) || ! $attribute->withObjectCaching) { - unset($this->attributeCastCache[$key]); - } else { + if ($attribute->withCaching || (is_object($value) && $attribute->withObjectCaching)) { $this->attributeCastCache[$key] = $value; + } else { + unset($this->attributeCastCache[$key]); } return $value; @@ -801,7 +845,7 @@ trait HasAttributes return $value; } - return $castType::from($value); + return $this->getEnumCaseFromValue($castType, $value); } /** @@ -812,19 +856,23 @@ trait HasAttributes */ protected function getCastType($key) { - if ($this->isCustomDateTimeCast($this->getCasts()[$key])) { - return 'custom_datetime'; + $castType = $this->getCasts()[$key]; + + if (isset(static::$castTypeCache[$castType])) { + return static::$castTypeCache[$castType]; } - if ($this->isImmutableCustomDateTimeCast($this->getCasts()[$key])) { - return 'immutable_custom_datetime'; + if ($this->isCustomDateTimeCast($castType)) { + $convertedCastType = 'custom_datetime'; + } elseif ($this->isImmutableCustomDateTimeCast($castType)) { + $convertedCastType = 'immutable_custom_datetime'; + } elseif ($this->isDecimalCast($castType)) { + $convertedCastType = 'decimal'; + } else { + $convertedCastType = trim(strtolower($castType)); } - if ($this->isDecimalCast($this->getCasts()[$key])) { - return 'decimal'; - } - - return trim(strtolower($this->getCasts()[$key])); + return static::$castTypeCache[$castType] = $convertedCastType; } /** @@ -876,8 +924,8 @@ trait HasAttributes */ protected function isImmutableCustomDateTimeCast($cast) { - return strncmp($cast, 'immutable_date:', 15) === 0 || - strncmp($cast, 'immutable_datetime:', 19) === 0; + return str_starts_with($cast, 'immutable_date:') || + str_starts_with($cast, 'immutable_datetime:'); } /** @@ -912,7 +960,7 @@ trait HasAttributes // If an attribute is listed as a "date", we'll convert it from a DateTime // instance into a form proper for storage on the database tables using // the connection grammar's date format. We will auto set the values. - elseif ($value && $this->isDateAttribute($key)) { + elseif (! is_null($value) && $this->isDateAttribute($key)) { $value = $this->fromDateTime($value); } @@ -1019,11 +1067,13 @@ trait HasAttributes ) ); - if (! is_object($value) || ! $attribute->withObjectCaching) { - unset($this->attributeCastCache[$key]); - } else { + if ($attribute->withCaching || (is_object($value) && $attribute->withObjectCaching)) { $this->attributeCastCache[$key] = $value; + } else { + unset($this->attributeCastCache[$key]); } + + return $this; } /** @@ -1057,6 +1107,10 @@ trait HasAttributes ? $this->castAttributeAsEncryptedString($key, $value) : $value; + if ($this->isClassCastable($key)) { + unset($this->classCastCache[$key]); + } + return $this; } @@ -1071,7 +1125,7 @@ trait HasAttributes { $caster = $this->resolveCasterClass($key); - $this->attributes = array_merge( + $this->attributes = array_replace( $this->attributes, $this->normalizeCastClassResponse($key, $caster->set( $this, $key, $value, $this->attributes @@ -1089,7 +1143,7 @@ trait HasAttributes * Set the value of an enum castable attribute. * * @param string $key - * @param \BackedEnum $value + * @param \UnitEnum|string|int $value * @return void */ protected function setEnumCastableAttribute($key, $value) @@ -1098,13 +1152,42 @@ trait HasAttributes if (! isset($value)) { $this->attributes[$key] = null; - } elseif ($value instanceof $enumClass) { - $this->attributes[$key] = $value->value; + } elseif (is_object($value)) { + $this->attributes[$key] = $this->getStorableEnumValue($value); } else { - $this->attributes[$key] = $enumClass::from($value)->value; + $this->attributes[$key] = $this->getStorableEnumValue( + $this->getEnumCaseFromValue($enumClass, $value) + ); } } + /** + * Get an enum case instance from a given class and value. + * + * @param string $enumClass + * @param string|int $value + * @return \UnitEnum|\BackedEnum + */ + protected function getEnumCaseFromValue($enumClass, $value) + { + return is_subclass_of($enumClass, BackedEnum::class) + ? $enumClass::from($value) + : constant($enumClass.'::'.$value); + } + + /** + * Get the storable value from the given enum. + * + * @param \UnitEnum|\BackedEnum $value + * @return string|int + */ + protected function getStorableEnumValue($value) + { + return $value instanceof BackedEnum + ? $value->value + : $value->name; + } + /** * Get an array attribute with the given key and value set. * @@ -1179,7 +1262,7 @@ trait HasAttributes */ public function fromJson($value, $asObject = false) { - return json_decode($value, ! $asObject); + return json_decode($value ?? '', ! $asObject); } /** @@ -1208,7 +1291,7 @@ trait HasAttributes /** * Set the encrypter instance that will be used to encrypt attributes. * - * @param \Illuminate\Contracts\Encryption\Encrypter $encrypter + * @param \Illuminate\Contracts\Encryption\Encrypter|null $encrypter * @return void */ public static function encryptUsing($encrypter) @@ -1235,13 +1318,17 @@ trait HasAttributes /** * Return a decimal as string. * - * @param float $value + * @param float|string $value * @param int $decimals * @return string */ protected function asDecimal($value, $decimals) { - return number_format($value, $decimals, '.', ''); + try { + return (string) BigDecimal::of($value)->toScale($decimals, RoundingMode::HALF_UP); + } catch (BrickMathException $e) { + throw new MathException('Unable to cast value to a decimal.', previous: $e); + } } /** @@ -1481,11 +1568,13 @@ trait HasAttributes */ protected function isClassCastable($key) { - if (! array_key_exists($key, $this->getCasts())) { + $casts = $this->getCasts(); + + if (! array_key_exists($key, $casts)) { return false; } - $castType = $this->parseCasterClass($this->getCasts()[$key]); + $castType = $this->parseCasterClass($casts[$key]); if (in_array($castType, static::$primitiveCastTypes)) { return false; @@ -1506,11 +1595,13 @@ trait HasAttributes */ protected function isEnumCastable($key) { - if (! array_key_exists($key, $this->getCasts())) { + $casts = $this->getCasts(); + + if (! array_key_exists($key, $casts)) { return false; } - $castType = $this->getCasts()[$key]; + $castType = $casts[$key]; if (in_array($castType, static::$primitiveCastTypes)) { return false; @@ -1531,9 +1622,13 @@ trait HasAttributes */ protected function isClassDeviable($key) { - return $this->isClassCastable($key) && - method_exists($castType = $this->parseCasterClass($this->getCasts()[$key]), 'increment') && - method_exists($castType, 'decrement'); + if (! $this->isClassCastable($key)) { + return false; + } + + $castType = $this->resolveCasterClass($key); + + return method_exists($castType::class, 'increment') && method_exists($castType::class, 'decrement'); } /** @@ -1848,7 +1943,19 @@ trait HasAttributes } /** - * Determine if the model or any of the given attribute(s) have been modified. + * Discard attribute changes and reset the attributes to their original state. + * + * @return $this + */ + public function discardChanges() + { + [$this->attributes, $this->changes] = [$this->original, []]; + + return $this; + } + + /** + * Determine if the model or any of the given attribute(s) were changed when the model was last saved. * * @param array|string|null $attributes * @return bool @@ -1861,7 +1968,7 @@ trait HasAttributes } /** - * Determine if any of the given attributes were changed. + * Determine if any of the given attributes were changed when the model was last saved. * * @param array $changes * @param array|string|null $attributes @@ -1907,7 +2014,7 @@ trait HasAttributes } /** - * Get the attributes that were changed. + * Get the attributes that were changed when the model was last saved. * * @return array */ @@ -1939,8 +2046,8 @@ trait HasAttributes return $this->fromDateTime($attribute) === $this->fromDateTime($original); } elseif ($this->hasCast($key, ['object', 'collection'])) { - return $this->castAttribute($key, $attribute) == - $this->castAttribute($key, $original); + return $this->fromJson($attribute) === + $this->fromJson($original); } elseif ($this->hasCast($key, ['real', 'float', 'double'])) { if ($original === null) { return false; @@ -1952,6 +2059,8 @@ trait HasAttributes $this->castAttribute($key, $original); } elseif ($this->isClassCastable($key) && in_array($this->getCasts()[$key], [AsArrayObject::class, AsCollection::class])) { return $this->fromJson($attribute) === $this->fromJson($original); + } elseif ($this->isClassCastable($key) && $original !== null && in_array($this->getCasts()[$key], [AsEncryptedArrayObject::class, AsEncryptedCollection::class])) { + return $this->fromEncryptedString($attribute) === $this->fromEncryptedString($original); } return is_numeric($attribute) && is_numeric($original) @@ -2009,6 +2118,16 @@ trait HasAttributes return $this; } + /** + * Get the accessors that are being appended to model arrays. + * + * @return array + */ + public function getAppends() + { + return $this->appends; + } + /** * Set the accessors to append to model arrays. * @@ -2040,25 +2159,27 @@ trait HasAttributes */ public function getMutatedAttributes() { - $class = static::class; - - if (! isset(static::$mutatorCache[$class])) { - static::cacheMutatedAttributes($class); + if (! isset(static::$mutatorCache[static::class])) { + static::cacheMutatedAttributes($this); } - return static::$mutatorCache[$class]; + return static::$mutatorCache[static::class]; } /** * Extract and cache all the mutated attributes of a class. * - * @param string $class + * @param object|string $classOrInstance * @return void */ - public static function cacheMutatedAttributes($class) + public static function cacheMutatedAttributes($classOrInstance) { + $reflection = new ReflectionClass($classOrInstance); + + $class = $reflection->getName(); + static::$getAttributeMutatorCache[$class] = - collect($attributeMutatorMethods = static::getAttributeMarkedMutatorMethods($class)) + collect($attributeMutatorMethods = static::getAttributeMarkedMutatorMethods($classOrInstance)) ->mapWithKeys(function ($match) { return [lcfirst(static::$snakeAttributes ? Str::snake($match) : $match) => true]; })->all(); diff --git a/vendor/illuminate/database/Eloquent/Concerns/HasEvents.php b/vendor/illuminate/database/Eloquent/Concerns/HasEvents.php index eb6a970..37bc063 100644 --- a/vendor/illuminate/database/Eloquent/Concerns/HasEvents.php +++ b/vendor/illuminate/database/Eloquent/Concerns/HasEvents.php @@ -98,7 +98,7 @@ trait HasEvents [ 'retrieved', 'creating', 'created', 'updating', 'updated', 'saving', 'saved', 'restoring', 'restored', 'replicating', - 'deleting', 'deleted', 'forceDeleted', + 'deleting', 'deleted', 'forceDeleting', 'forceDeleted', ], $this->observables ); @@ -147,7 +147,7 @@ trait HasEvents * Register a model event with the dispatcher. * * @param string $event - * @param \Illuminate\Events\QueuedClosure|\Closure|string $callback + * @param \Illuminate\Events\QueuedClosure|\Closure|string|array $callback * @return void */ protected static function registerModelEvent($event, $callback) @@ -230,7 +230,7 @@ trait HasEvents /** * Register a retrieved model event with the dispatcher. * - * @param \Illuminate\Events\QueuedClosure|\Closure|string $callback + * @param \Illuminate\Events\QueuedClosure|\Closure|string|array $callback * @return void */ public static function retrieved($callback) @@ -241,7 +241,7 @@ trait HasEvents /** * Register a saving model event with the dispatcher. * - * @param \Illuminate\Events\QueuedClosure|\Closure|string $callback + * @param \Illuminate\Events\QueuedClosure|\Closure|string|array $callback * @return void */ public static function saving($callback) @@ -252,7 +252,7 @@ trait HasEvents /** * Register a saved model event with the dispatcher. * - * @param \Illuminate\Events\QueuedClosure|\Closure|string $callback + * @param \Illuminate\Events\QueuedClosure|\Closure|string|array $callback * @return void */ public static function saved($callback) @@ -263,7 +263,7 @@ trait HasEvents /** * Register an updating model event with the dispatcher. * - * @param \Illuminate\Events\QueuedClosure|\Closure|string $callback + * @param \Illuminate\Events\QueuedClosure|\Closure|string|array $callback * @return void */ public static function updating($callback) @@ -274,7 +274,7 @@ trait HasEvents /** * Register an updated model event with the dispatcher. * - * @param \Illuminate\Events\QueuedClosure|\Closure|string $callback + * @param \Illuminate\Events\QueuedClosure|\Closure|string|array $callback * @return void */ public static function updated($callback) @@ -285,7 +285,7 @@ trait HasEvents /** * Register a creating model event with the dispatcher. * - * @param \Illuminate\Events\QueuedClosure|\Closure|string $callback + * @param \Illuminate\Events\QueuedClosure|\Closure|string|array $callback * @return void */ public static function creating($callback) @@ -296,7 +296,7 @@ trait HasEvents /** * Register a created model event with the dispatcher. * - * @param \Illuminate\Events\QueuedClosure|\Closure|string $callback + * @param \Illuminate\Events\QueuedClosure|\Closure|string|array $callback * @return void */ public static function created($callback) @@ -307,7 +307,7 @@ trait HasEvents /** * Register a replicating model event with the dispatcher. * - * @param \Illuminate\Events\QueuedClosure|\Closure|string $callback + * @param \Illuminate\Events\QueuedClosure|\Closure|string|array $callback * @return void */ public static function replicating($callback) @@ -318,7 +318,7 @@ trait HasEvents /** * Register a deleting model event with the dispatcher. * - * @param \Illuminate\Events\QueuedClosure|\Closure|string $callback + * @param \Illuminate\Events\QueuedClosure|\Closure|string|array $callback * @return void */ public static function deleting($callback) @@ -329,7 +329,7 @@ trait HasEvents /** * Register a deleted model event with the dispatcher. * - * @param \Illuminate\Events\QueuedClosure|\Closure|string $callback + * @param \Illuminate\Events\QueuedClosure|\Closure|string|array $callback * @return void */ public static function deleted($callback) @@ -338,7 +338,7 @@ trait HasEvents } /** - * Remove all of the event listeners for the model. + * Remove all the event listeners for the model. * * @return void */ diff --git a/vendor/illuminate/database/Eloquent/Concerns/HasRelationships.php b/vendor/illuminate/database/Eloquent/Concerns/HasRelationships.php index 089390c..1c71fe1 100644 --- a/vendor/illuminate/database/Eloquent/Concerns/HasRelationships.php +++ b/vendor/illuminate/database/Eloquent/Concerns/HasRelationships.php @@ -7,6 +7,7 @@ use Illuminate\Database\ClassMorphViolationException; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Collection; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\PendingHasThroughRelationship; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Database\Eloquent\Relations\HasMany; @@ -54,6 +55,26 @@ trait HasRelationships */ protected static $relationResolvers = []; + /** + * Get the dynamic relation resolver if defined or inherited, or return null. + * + * @param string $class + * @param string $key + * @return mixed + */ + public function relationResolver($class, $key) + { + if ($resolver = static::$relationResolvers[$class][$key] ?? null) { + return $resolver; + } + + if ($parent = get_parent_class($class)) { + return $this->relationResolver($parent, $key); + } + + return null; + } + /** * Define a dynamic relation resolver. * @@ -115,7 +136,7 @@ trait HasRelationships */ public function hasOneThrough($related, $through, $firstKey = null, $secondKey = null, $localKey = null, $secondLocalKey = null) { - $through = new $through; + $through = $this->newRelatedThroughInstance($through); $firstKey = $firstKey ?: $this->getForeignKey(); @@ -210,9 +231,9 @@ trait HasRelationships $foreignKey = Str::snake($relation).'_'.$instance->getKeyName(); } - // Once we have the foreign key names, we'll just create a new Eloquent query - // for the related models and returns the relationship instance which will - // actually be responsible for retrieving and hydrating every relations. + // Once we have the foreign key names we'll just create a new Eloquent query + // for the related models and return the relationship instance which will + // actually be responsible for retrieving and hydrating every relation. $ownerKey = $ownerKey ?: $instance->getKeyName(); return $this->newBelongsTo( @@ -339,6 +360,21 @@ trait HasRelationships return $caller['function']; } + /** + * Create a pending has-many-through or has-one-through relationship. + * + * @param string|\Illuminate\Database\Eloquent\Relations\HasMany|\Illuminate\Database\Eloquent\Relations\HasOne $relationship + * @return \Illuminate\Database\Eloquent\PendingHasThroughRelationship + */ + public function through($relationship) + { + if (is_string($relationship)) { + $relationship = $this->{$relationship}(); + } + + return new PendingHasThroughRelationship($this, $relationship); + } + /** * Define a one-to-many relationship. * @@ -387,7 +423,7 @@ trait HasRelationships */ public function hasManyThrough($related, $through, $firstKey = null, $secondKey = null, $localKey = null, $secondLocalKey = null) { - $through = new $through; + $through = $this->newRelatedThroughInstance($through); $firstKey = $firstKey ?: $this->getForeignKey(); @@ -554,9 +590,9 @@ trait HasRelationships $relatedPivotKey = $relatedPivotKey ?: $instance->getForeignKey(); - // Now we're ready to create a new query builder for this related model and - // the relationship instances for this relation. This relations will set - // appropriate query constraints then entirely manages the hydrations. + // Now we're ready to create a new query builder for the related model and + // the relationship instances for this relation. This relation will set + // appropriate query constraints then entirely manage the hydrations. if (! $table) { $words = preg_split('/(_)/u', $name, -1, PREG_SPLIT_DELIM_CAPTURE); @@ -759,6 +795,17 @@ trait HasRelationships }); } + /** + * Create a new model instance for a related "through" model. + * + * @param string $class + * @return mixed + */ + protected function newRelatedThroughInstance($class) + { + return new $class; + } + /** * Get all the loaded relations for the instance. * diff --git a/vendor/illuminate/database/Eloquent/Concerns/HasTimestamps.php b/vendor/illuminate/database/Eloquent/Concerns/HasTimestamps.php index add911a..2b6dfab 100644 --- a/vendor/illuminate/database/Eloquent/Concerns/HasTimestamps.php +++ b/vendor/illuminate/database/Eloquent/Concerns/HasTimestamps.php @@ -13,6 +13,13 @@ trait HasTimestamps */ public $timestamps = true; + /** + * The list of models classes that have timestamps temporarily disabled. + * + * @var array + */ + protected static $ignoreTimestampsOn = []; + /** * Update the model's update timestamp. * @@ -36,10 +43,21 @@ trait HasTimestamps return $this->save(); } + /** + * Update the model's update timestamp without raising any events. + * + * @param string|null $attribute + * @return bool + */ + public function touchQuietly($attribute = null) + { + return static::withoutEvents(fn () => $this->touch($attribute)); + } + /** * Update the creation and update timestamps. * - * @return void + * @return $this */ public function updateTimestamps() { @@ -56,6 +74,8 @@ trait HasTimestamps if (! $this->exists && ! is_null($createdAtColumn) && ! $this->isDirty($createdAtColumn)) { $this->setCreatedAt($time); } + + return $this; } /** @@ -111,7 +131,7 @@ trait HasTimestamps */ public function usesTimestamps() { - return $this->timestamps; + return $this->timestamps && ! static::isIgnoringTimestamps($this::class); } /** @@ -153,4 +173,52 @@ trait HasTimestamps { return $this->qualifyColumn($this->getUpdatedAtColumn()); } + + /** + * Disable timestamps for the current class during the given callback scope. + * + * @param callable $callback + * @return mixed + */ + public static function withoutTimestamps(callable $callback) + { + return static::withoutTimestampsOn([static::class], $callback); + } + + /** + * Disable timestamps for the given model classes during the given callback scope. + * + * @param array $models + * @param callable $callback + * @return mixed + */ + public static function withoutTimestampsOn($models, $callback) + { + static::$ignoreTimestampsOn = array_values(array_merge(static::$ignoreTimestampsOn, $models)); + + try { + return $callback(); + } finally { + static::$ignoreTimestampsOn = array_values(array_diff(static::$ignoreTimestampsOn, $models)); + } + } + + /** + * Determine if the given model is ignoring timestamps / touches. + * + * @param string|null $class + * @return bool + */ + public static function isIgnoringTimestamps($class = null) + { + $class ??= static::class; + + foreach (static::$ignoreTimestampsOn as $ignoredClass) { + if ($class === $ignoredClass || is_subclass_of($class, $ignoredClass)) { + return true; + } + } + + return false; + } } diff --git a/vendor/illuminate/database/Eloquent/Concerns/HasUlids.php b/vendor/illuminate/database/Eloquent/Concerns/HasUlids.php new file mode 100644 index 0000000..b944c5d --- /dev/null +++ b/vendor/illuminate/database/Eloquent/Concerns/HasUlids.php @@ -0,0 +1,96 @@ +uniqueIds() as $column) { + if (empty($model->{$column})) { + $model->{$column} = $model->newUniqueId(); + } + } + }); + } + + /** + * Generate a new ULID for the model. + * + * @return string + */ + public function newUniqueId() + { + return strtolower((string) Str::ulid()); + } + + /** + * Retrieve the model for a bound value. + * + * @param \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Relations\Relation $query + * @param mixed $value + * @param string|null $field + * @return \Illuminate\Database\Eloquent\Relations\Relation + * + * @throws \Illuminate\Database\Eloquent\ModelNotFoundException + */ + public function resolveRouteBindingQuery($query, $value, $field = null) + { + if ($field && in_array($field, $this->uniqueIds()) && ! Str::isUlid($value)) { + throw (new ModelNotFoundException)->setModel(get_class($this), $value); + } + + if (! $field && in_array($this->getRouteKeyName(), $this->uniqueIds()) && ! Str::isUlid($value)) { + throw (new ModelNotFoundException)->setModel(get_class($this), $value); + } + + return parent::resolveRouteBindingQuery($query, $value, $field); + } + + /** + * Get the columns that should receive a unique identifier. + * + * @return array + */ + public function uniqueIds() + { + return [$this->getKeyName()]; + } + + /** + * Get the auto-incrementing key type. + * + * @return string + */ + public function getKeyType() + { + if (in_array($this->getKeyName(), $this->uniqueIds())) { + return 'string'; + } + + return $this->keyType; + } + + /** + * Get the value indicating whether the IDs are incrementing. + * + * @return bool + */ + public function getIncrementing() + { + if (in_array($this->getKeyName(), $this->uniqueIds())) { + return false; + } + + return $this->incrementing; + } +} diff --git a/vendor/illuminate/database/Eloquent/Concerns/HasUuids.php b/vendor/illuminate/database/Eloquent/Concerns/HasUuids.php new file mode 100644 index 0000000..96a08b6 --- /dev/null +++ b/vendor/illuminate/database/Eloquent/Concerns/HasUuids.php @@ -0,0 +1,96 @@ +uniqueIds() as $column) { + if (empty($model->{$column})) { + $model->{$column} = $model->newUniqueId(); + } + } + }); + } + + /** + * Generate a new UUID for the model. + * + * @return string + */ + public function newUniqueId() + { + return (string) Str::orderedUuid(); + } + + /** + * Get the columns that should receive a unique identifier. + * + * @return array + */ + public function uniqueIds() + { + return [$this->getKeyName()]; + } + + /** + * Retrieve the model for a bound value. + * + * @param \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Relations\Relation $query + * @param mixed $value + * @param string|null $field + * @return \Illuminate\Database\Eloquent\Relations\Relation + * + * @throws \Illuminate\Database\Eloquent\ModelNotFoundException + */ + public function resolveRouteBindingQuery($query, $value, $field = null) + { + if ($field && in_array($field, $this->uniqueIds()) && ! Str::isUuid($value)) { + throw (new ModelNotFoundException)->setModel(get_class($this), $value); + } + + if (! $field && in_array($this->getRouteKeyName(), $this->uniqueIds()) && ! Str::isUuid($value)) { + throw (new ModelNotFoundException)->setModel(get_class($this), $value); + } + + return parent::resolveRouteBindingQuery($query, $value, $field); + } + + /** + * Get the auto-incrementing key type. + * + * @return string + */ + public function getKeyType() + { + if (in_array($this->getKeyName(), $this->uniqueIds())) { + return 'string'; + } + + return $this->keyType; + } + + /** + * Get the value indicating whether the IDs are incrementing. + * + * @return bool + */ + public function getIncrementing() + { + if (in_array($this->getKeyName(), $this->uniqueIds())) { + return false; + } + + return $this->incrementing; + } +} diff --git a/vendor/illuminate/database/Eloquent/Concerns/HidesAttributes.php b/vendor/illuminate/database/Eloquent/Concerns/HidesAttributes.php index 31b8b98..5a7e3ba 100644 --- a/vendor/illuminate/database/Eloquent/Concerns/HidesAttributes.php +++ b/vendor/illuminate/database/Eloquent/Concerns/HidesAttributes.php @@ -7,21 +7,21 @@ trait HidesAttributes /** * The attributes that should be hidden for serialization. * - * @var array + * @var array */ protected $hidden = []; /** * The attributes that should be visible in serialization. * - * @var array + * @var array */ protected $visible = []; /** * Get the hidden attributes for the model. * - * @return array + * @return array */ public function getHidden() { @@ -31,7 +31,7 @@ trait HidesAttributes /** * Set the hidden attributes for the model. * - * @param array $hidden + * @param array $hidden * @return $this */ public function setHidden(array $hidden) @@ -44,7 +44,7 @@ trait HidesAttributes /** * Get the visible attributes for the model. * - * @return array + * @return array */ public function getVisible() { @@ -54,7 +54,7 @@ trait HidesAttributes /** * Set the visible attributes for the model. * - * @param array $visible + * @param array $visible * @return $this */ public function setVisible(array $visible) @@ -67,7 +67,7 @@ trait HidesAttributes /** * Make the given, typically hidden, attributes visible. * - * @param array|string|null $attributes + * @param array|string|null $attributes * @return $this */ public function makeVisible($attributes) @@ -87,7 +87,7 @@ trait HidesAttributes * Make the given, typically hidden, attributes visible if the given truth test passes. * * @param bool|\Closure $condition - * @param array|string|null $attributes + * @param array|string|null $attributes * @return $this */ public function makeVisibleIf($condition, $attributes) @@ -98,7 +98,7 @@ trait HidesAttributes /** * Make the given, typically visible, attributes hidden. * - * @param array|string|null $attributes + * @param array|string|null $attributes * @return $this */ public function makeHidden($attributes) @@ -114,7 +114,7 @@ trait HidesAttributes * Make the given, typically visible, attributes hidden if the given truth test passes. * * @param bool|\Closure $condition - * @param array|string|null $attributes + * @param array|string|null $attributes * @return $this */ public function makeHiddenIf($condition, $attributes) diff --git a/vendor/illuminate/database/Eloquent/Concerns/QueriesRelationships.php b/vendor/illuminate/database/Eloquent/Concerns/QueriesRelationships.php index 8b6f9b4..6f64884 100644 --- a/vendor/illuminate/database/Eloquent/Concerns/QueriesRelationships.php +++ b/vendor/illuminate/database/Eloquent/Concerns/QueriesRelationships.php @@ -5,6 +5,7 @@ namespace Illuminate\Database\Eloquent\Concerns; use BadMethodCallException; use Closure; use Illuminate\Database\Eloquent\Builder; +use Illuminate\Database\Eloquent\Collection; use Illuminate\Database\Eloquent\RelationNotFoundException; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\MorphTo; @@ -12,6 +13,7 @@ use Illuminate\Database\Eloquent\Relations\Relation; use Illuminate\Database\Query\Builder as QueryBuilder; use Illuminate\Database\Query\Expression; use Illuminate\Support\Str; +use InvalidArgumentException; trait QueriesRelationships { @@ -150,6 +152,23 @@ trait QueriesRelationships return $this->has($relation, $operator, $count, 'and', $callback); } + /** + * Add a relationship count / exists condition to the query with where clauses. + * + * Also load the relationship with same condition. + * + * @param string $relation + * @param \Closure|null $callback + * @param string $operator + * @param int $count + * @return \Illuminate\Database\Eloquent\Builder|static + */ + public function withWhereHas($relation, Closure $callback = null, $operator = '>=', $count = 1) + { + return $this->whereHas(Str::before($relation, ':'), $callback, $operator, $count) + ->with($callback ? [$relation => fn ($query) => $callback($query)] : $relation); + } + /** * Add a relationship count / exists condition to the query with where clauses and an "or". * @@ -363,7 +382,11 @@ trait QueriesRelationships public function whereRelation($relation, $column, $operator = null, $value = null) { return $this->whereHas($relation, function ($query) use ($column, $operator, $value) { - $query->where($column, $operator, $value); + if ($column instanceof Closure) { + $column($query); + } else { + $query->where($column, $operator, $value); + } }); } @@ -379,7 +402,11 @@ trait QueriesRelationships public function orWhereRelation($relation, $column, $operator = null, $value = null) { return $this->orWhereHas($relation, function ($query) use ($column, $operator, $value) { - $query->where($column, $operator, $value); + if ($column instanceof Closure) { + $column($query); + } else { + $query->where($column, $operator, $value); + } }); } @@ -446,6 +473,35 @@ trait QueriesRelationships }, null, null, $boolean); } + /** + * Add a not morph-to relationship condition to the query. + * + * @param \Illuminate\Database\Eloquent\Relations\MorphTo|string $relation + * @param \Illuminate\Database\Eloquent\Model|string $model + * @return \Illuminate\Database\Eloquent\Builder|static + */ + public function whereNotMorphedTo($relation, $model, $boolean = 'and') + { + if (is_string($relation)) { + $relation = $this->getRelationWithoutConstraints($relation); + } + + if (is_string($model)) { + $morphMap = Relation::morphMap(); + + if (! empty($morphMap) && in_array($model, $morphMap)) { + $model = array_search($model, $morphMap, true); + } + + return $this->whereNot($relation->getMorphType(), '<=>', $model, $boolean); + } + + return $this->whereNot(function ($query) use ($relation, $model) { + $query->where($relation->getMorphType(), '<=>', $model->getMorphClass()) + ->where($relation->getForeignKeyName(), '<=>', $model->getKey()); + }, null, null, $boolean); + } + /** * Add a morph-to relationship condition to the query with an "or where" clause. * @@ -458,10 +514,22 @@ trait QueriesRelationships return $this->whereMorphedTo($relation, $model, 'or'); } + /** + * Add a not morph-to relationship condition to the query with an "or where" clause. + * + * @param \Illuminate\Database\Eloquent\Relations\MorphTo|string $relation + * @param \Illuminate\Database\Eloquent\Model|string $model + * @return \Illuminate\Database\Eloquent\Builder|static + */ + public function orWhereNotMorphedTo($relation, $model) + { + return $this->whereNotMorphedTo($relation, $model, 'or'); + } + /** * Add a "belongs to" relationship where clause to the query. * - * @param \Illuminate\Database\Eloquent\Model $related + * @param \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Collection<\Illuminate\Database\Eloquent\Model> $related * @param string|null $relationshipName * @param string $boolean * @return $this @@ -470,6 +538,18 @@ trait QueriesRelationships */ public function whereBelongsTo($related, $relationshipName = null, $boolean = 'and') { + if (! $related instanceof Collection) { + $relatedCollection = $related->newCollection([$related]); + } else { + $relatedCollection = $related; + + $related = $relatedCollection->first(); + } + + if ($relatedCollection->isEmpty()) { + throw new InvalidArgumentException('Collection given to whereBelongsTo method may not be empty.'); + } + if ($relationshipName === null) { $relationshipName = Str::camel(class_basename($related)); } @@ -484,10 +564,9 @@ trait QueriesRelationships throw RelationNotFoundException::make($this->model, $relationshipName, BelongsTo::class); } - $this->where( + $this->whereIn( $relationship->getQualifiedForeignKeyName(), - '=', - $related->getAttributeValue($relationship->getOwnerKeyName()), + $relatedCollection->pluck($relationship->getOwnerKeyName())->toArray(), $boolean, ); @@ -543,9 +622,7 @@ trait QueriesRelationships $relation = $this->getRelationWithoutConstraints($name); if ($function) { - $hashedColumn = $this->getQuery()->from === $relation->getQuery()->getQuery()->from - ? "{$relation->getRelationCountHash(false)}.$column" - : $column; + $hashedColumn = $this->getRelationHashedColumn($column, $relation); $wrappedColumn = $this->getQuery()->getGrammar()->wrap( $column === '*' ? $column : $relation->getRelated()->qualifyColumn($hashedColumn) @@ -601,6 +678,24 @@ trait QueriesRelationships return $this; } + /** + * Get the relation hashed column name for the given column and relation. + * + * @param string $column + * @param \Illuminate\Database\Eloquent\Relations\Relationship $relation + * @return string + */ + protected function getRelationHashedColumn($column, $relation) + { + if (str_contains($column, '.')) { + return $column; + } + + return $this->getQuery()->from === $relation->getQuery()->getQuery()->from + ? "{$relation->getRelationCountHash(false)}.$column" + : $column; + } + /** * Add subselect queries to count the relations. * @@ -700,16 +795,42 @@ trait QueriesRelationships { $whereBindings = $from->getQuery()->getRawBindings()['where'] ?? []; + $wheres = $from->getQuery()->from !== $this->getQuery()->from + ? $this->requalifyWhereTables( + $from->getQuery()->wheres, + $from->getQuery()->from, + $this->getModel()->getTable() + ) : $from->getQuery()->wheres; + // Here we have some other query that we want to merge the where constraints from. We will // copy over any where constraints on the query as well as remove any global scopes the // query might have removed. Then we will return ourselves with the finished merging. return $this->withoutGlobalScopes( $from->removedScopes() )->mergeWheres( - $from->getQuery()->wheres, $whereBindings + $wheres, $whereBindings ); } + /** + * Updates the table name for any columns with a new qualified name. + * + * @param array $wheres + * @param string $from + * @param string $to + * @return array + */ + protected function requalifyWhereTables(array $wheres, string $from, string $to): array + { + return collect($wheres)->map(function ($where) use ($from, $to) { + return collect($where)->map(function ($value) use ($from, $to) { + return is_string($value) && str_starts_with($value, $from.'.') + ? $to.'.'.Str::afterLast($value, '.') + : $value; + }); + })->toArray(); + } + /** * Add a sub-query count clause to this query. * diff --git a/vendor/illuminate/database/Eloquent/Factories/BelongsToManyRelationship.php b/vendor/illuminate/database/Eloquent/Factories/BelongsToManyRelationship.php index e0c42c4..8e40261 100644 --- a/vendor/illuminate/database/Eloquent/Factories/BelongsToManyRelationship.php +++ b/vendor/illuminate/database/Eloquent/Factories/BelongsToManyRelationship.php @@ -10,7 +10,7 @@ class BelongsToManyRelationship /** * The related factory instance. * - * @var \Illuminate\Database\Eloquent\Factories\Factory|\Illuminate\Support\Collection|\Illuminate\Database\Eloquent\Model + * @var \Illuminate\Database\Eloquent\Factories\Factory|\Illuminate\Support\Collection|\Illuminate\Database\Eloquent\Model|array */ protected $factory; @@ -31,7 +31,7 @@ class BelongsToManyRelationship /** * Create a new attached relationship definition. * - * @param \Illuminate\Database\Eloquent\Factories\Factory|\Illuminate\Support\Collection|\Illuminate\Database\Eloquent\Model $factory + * @param \Illuminate\Database\Eloquent\Factories\Factory|\Illuminate\Support\Collection|\Illuminate\Database\Eloquent\Model|array $factory * @param callable|array $pivot * @param string $relationship * @return void @@ -58,4 +58,19 @@ class BelongsToManyRelationship ); }); } + + /** + * Specify the model instances to always use when creating relationships. + * + * @param \Illuminate\Support\Collection $recycle + * @return $this + */ + public function recycle($recycle) + { + if ($this->factory instanceof Factory) { + $this->factory = $this->factory->recycle($recycle); + } + + return $this; + } } diff --git a/vendor/illuminate/database/Eloquent/Factories/BelongsToRelationship.php b/vendor/illuminate/database/Eloquent/Factories/BelongsToRelationship.php index 55747fd..b2fb1b2 100644 --- a/vendor/illuminate/database/Eloquent/Factories/BelongsToRelationship.php +++ b/vendor/illuminate/database/Eloquent/Factories/BelongsToRelationship.php @@ -69,7 +69,9 @@ class BelongsToRelationship { return function () use ($key) { if (! $this->resolved) { - $instance = $this->factory instanceof Factory ? $this->factory->create() : $this->factory; + $instance = $this->factory instanceof Factory + ? ($this->factory->getRandomRecycledModel($this->factory->modelName()) ?? $this->factory->create()) + : $this->factory; return $this->resolved = $key ? $instance->{$key} : $instance->getKey(); } @@ -77,4 +79,19 @@ class BelongsToRelationship return $this->resolved; }; } + + /** + * Specify the model instances to always use when creating relationships. + * + * @param \Illuminate\Support\Collection $recycle + * @return $this + */ + public function recycle($recycle) + { + if ($this->factory instanceof Factory) { + $this->factory = $this->factory->recycle($recycle); + } + + return $this; + } } diff --git a/vendor/illuminate/database/Eloquent/Factories/CrossJoinSequence.php b/vendor/illuminate/database/Eloquent/Factories/CrossJoinSequence.php index b0efbd0..3270b30 100644 --- a/vendor/illuminate/database/Eloquent/Factories/CrossJoinSequence.php +++ b/vendor/illuminate/database/Eloquent/Factories/CrossJoinSequence.php @@ -9,7 +9,7 @@ class CrossJoinSequence extends Sequence /** * Create a new cross join sequence instance. * - * @param array $sequences + * @param array ...$sequences * @return void */ public function __construct(...$sequences) diff --git a/vendor/illuminate/database/Eloquent/Factories/Factory.php b/vendor/illuminate/database/Eloquent/Factories/Factory.php index 43d3771..4a416b8 100644 --- a/vendor/illuminate/database/Eloquent/Factories/Factory.php +++ b/vendor/illuminate/database/Eloquent/Factories/Factory.php @@ -8,7 +8,10 @@ use Illuminate\Container\Container; use Illuminate\Contracts\Foundation\Application; use Illuminate\Database\Eloquent\Collection as EloquentCollection; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\SoftDeletes; +use Illuminate\Support\Carbon; use Illuminate\Support\Collection; +use Illuminate\Support\Enumerable; use Illuminate\Support\Str; use Illuminate\Support\Traits\Conditionable; use Illuminate\Support\Traits\ForwardsCalls; @@ -17,6 +20,8 @@ use Throwable; /** * @template TModel of \Illuminate\Database\Eloquent\Model + * + * @method $this trashed() */ abstract class Factory { @@ -59,6 +64,13 @@ abstract class Factory */ protected $for; + /** + * The model instances to always use when creating relationships. + * + * @var \Illuminate\Support\Collection + */ + protected $recycle; + /** * The "after making" callbacks that will be applied to the model. * @@ -76,7 +88,7 @@ abstract class Factory /** * The name of the database connection that will be used to create the models. * - * @var string + * @var string|null */ protected $connection; @@ -118,6 +130,7 @@ abstract class Factory * @param \Illuminate\Support\Collection|null $afterMaking * @param \Illuminate\Support\Collection|null $afterCreating * @param string|null $connection + * @param \Illuminate\Support\Collection|null $recycle * @return void */ public function __construct($count = null, @@ -126,15 +139,17 @@ abstract class Factory ?Collection $for = null, ?Collection $afterMaking = null, ?Collection $afterCreating = null, - $connection = null) + $connection = null, + ?Collection $recycle = null) { $this->count = $count; - $this->states = $states ?: new Collection; - $this->has = $has ?: new Collection; - $this->for = $for ?: new Collection; - $this->afterMaking = $afterMaking ?: new Collection; - $this->afterCreating = $afterCreating ?: new Collection; + $this->states = $states ?? new Collection; + $this->has = $has ?? new Collection; + $this->for = $for ?? new Collection; + $this->afterMaking = $afterMaking ?? new Collection; + $this->afterCreating = $afterCreating ?? new Collection; $this->connection = $connection; + $this->recycle = $recycle ?? new Collection; $this->faker = $this->withFaker(); } @@ -207,7 +222,7 @@ abstract class Factory } /** - * Create a single model and persist it to the database. + * Create a single model and persist it to the database without dispatching any model events. * * @param (callable(array): array)|array $attributes * @return \Illuminate\Database\Eloquent\Model|TModel @@ -233,7 +248,7 @@ abstract class Factory } /** - * Create a collection of models and persist them to the database. + * Create a collection of models and persist them to the database without dispatching any model events. * * @param iterable> $records * @return \Illuminate\Database\Eloquent\Collection @@ -274,9 +289,9 @@ abstract class Factory } /** - * Create a collection of models and persist them to the database. + * Create a collection of models and persist them to the database without dispatching any model events. * - * @param array $attributes + * @param (callable(array): array)|array $attributes * @param \Illuminate\Database\Eloquent\Model|null $parent * @return \Illuminate\Database\Eloquent\Collection|\Illuminate\Database\Eloquent\Model|TModel */ @@ -296,9 +311,7 @@ abstract class Factory */ public function lazy(array $attributes = [], ?Model $parent = null) { - return function () use ($attributes, $parent) { - return $this->create($attributes, $parent); - }; + return fn () => $this->create($attributes, $parent); } /** @@ -316,6 +329,12 @@ abstract class Factory $model->save(); + foreach ($model->getRelations() as $name => $items) { + if ($items instanceof Enumerable && $items->isEmpty()) { + $model->unsetRelation($name); + } + } + $this->createChildren($model); }); } @@ -330,7 +349,7 @@ abstract class Factory { Model::unguarded(function () use ($model) { $this->has->each(function ($has) use ($model) { - $has->createFor($model); + $has->recycle($this->recycle)->createFor($model); }); }); } @@ -437,7 +456,7 @@ abstract class Factory $model = $this->newModel(); return $this->for->map(function (BelongsToRelationship $for) use ($model) { - return $for->attributesFor($model); + return $for->recycle($this->recycle)->attributesFor($model); })->collapse()->all(); } @@ -449,27 +468,35 @@ abstract class Factory */ protected function expandAttributes(array $definition) { - return collect($definition)->map(function ($attribute, $key) use (&$definition) { - if (is_callable($attribute) && ! is_string($attribute) && ! is_array($attribute)) { - $attribute = $attribute($definition); - } + return collect($definition) + ->map($evaluateRelations = function ($attribute) { + if ($attribute instanceof self) { + $attribute = $this->getRandomRecycledModel($attribute->modelName()) + ?? $attribute->recycle($this->recycle)->create()->getKey(); + } elseif ($attribute instanceof Model) { + $attribute = $attribute->getKey(); + } - if ($attribute instanceof self) { - $attribute = $attribute->create()->getKey(); - } elseif ($attribute instanceof Model) { - $attribute = $attribute->getKey(); - } + return $attribute; + }) + ->map(function ($attribute, $key) use (&$definition, $evaluateRelations) { + if (is_callable($attribute) && ! is_string($attribute) && ! is_array($attribute)) { + $attribute = $attribute($definition); + } - $definition[$key] = $attribute; + $attribute = $evaluateRelations($attribute); - return $attribute; - })->all(); + $definition[$key] = $attribute; + + return $attribute; + }) + ->all(); } /** * Add a new state transformation to the model definition. * - * @param (callable(array): array)|array $state + * @param (callable(array, \Illuminate\Database\Eloquent\Model|null): array)|array $state * @return static */ public function state($state) @@ -483,10 +510,22 @@ abstract class Factory ]); } + /** + * Set a single model attribute. + * + * @param string|int $key + * @param mixed $value + * @return static + */ + public function set($key, $value) + { + return $this->state([$key => $value]); + } + /** * Add a new sequenced state transformation to the model definition. * - * @param array $sequence + * @param mixed ...$sequence * @return static */ public function sequence(...$sequence) @@ -494,10 +533,21 @@ abstract class Factory return $this->state(new Sequence(...$sequence)); } + /** + * Add a new sequenced state transformation to the model definition and update the pending creation count to the size of the sequence. + * + * @param array ...$sequence + * @return static + */ + public function forEachSequence(...$sequence) + { + return $this->state(new Sequence(...$sequence))->count(count($sequence)); + } + /** * Add a new cross joined sequenced state transformation to the model definition. * - * @param array $sequence + * @param array ...$sequence * @return static */ public function crossJoinSequence(...$sequence) @@ -516,7 +566,7 @@ abstract class Factory { return $this->newInstance([ 'has' => $this->has->concat([new Relationship( - $factory, $relationship ?: $this->guessRelationship($factory->modelName()) + $factory, $relationship ?? $this->guessRelationship($factory->modelName()) )]), ]); } @@ -537,7 +587,7 @@ abstract class Factory /** * Define an attached relationship for the model. * - * @param \Illuminate\Database\Eloquent\Factories\Factory|\Illuminate\Support\Collection|\Illuminate\Database\Eloquent\Model $factory + * @param \Illuminate\Database\Eloquent\Factories\Factory|\Illuminate\Support\Collection|\Illuminate\Database\Eloquent\Model|array $factory * @param (callable(): array)|array $pivot * @param string|null $relationship * @return static @@ -548,7 +598,7 @@ abstract class Factory 'has' => $this->has->concat([new BelongsToManyRelationship( $factory, $pivot, - $relationship ?: Str::camel(Str::plural(class_basename( + $relationship ?? Str::camel(Str::plural(class_basename( $factory instanceof Factory ? $factory->modelName() : Collection::wrap($factory)->first() @@ -568,12 +618,42 @@ abstract class Factory { return $this->newInstance(['for' => $this->for->concat([new BelongsToRelationship( $factory, - $relationship ?: Str::camel(class_basename( + $relationship ?? Str::camel(class_basename( $factory instanceof Factory ? $factory->modelName() : $factory )) )])]); } + /** + * Provide model instances to use instead of any nested factory calls when creating relationships. + * + * @param \Illuminate\Database\Eloquent\Model|\Illuminate\Support\Collection|array $model + * @return static + */ + public function recycle($model) + { + // Group provided models by the type and merge them into existing recycle collection + return $this->newInstance([ + 'recycle' => $this->recycle + ->flatten() + ->merge( + Collection::wrap($model instanceof Model ? func_get_args() : $model) + ->flatten() + )->groupBy(fn ($model) => get_class($model)), + ]); + } + + /** + * Retrieve a random model of a given type from previously provided models to recycle. + * + * @param string $modelClassName + * @return \Illuminate\Database\Eloquent\Model|null + */ + public function getRandomRecycledModel($modelClassName) + { + return $this->recycle->get($modelClassName)?->random(); + } + /** * Add a new "after making" callback to the model definition. * @@ -665,6 +745,7 @@ abstract class Factory 'afterMaking' => $this->afterMaking, 'afterCreating' => $this->afterCreating, 'connection' => $this->connection, + 'recycle' => $this->recycle, ], $arguments))); } @@ -688,7 +769,7 @@ abstract class Factory */ public function modelName() { - $resolver = static::$modelNameResolver ?: function (self $factory) { + $resolver = static::$modelNameResolver ?? function (self $factory) { $namespacedFactoryBasename = Str::replaceLast( 'Factory', '', Str::replaceFirst(static::$namespace, '', get_class($factory)) ); @@ -702,7 +783,7 @@ abstract class Factory : $appNamespace.$factoryBasename; }; - return $this->model ?: $resolver($this); + return $this->model ?? $resolver($this); } /** @@ -769,7 +850,7 @@ abstract class Factory */ public static function resolveFactoryName(string $modelName) { - $resolver = static::$factoryNameResolver ?: function (string $modelName) { + $resolver = static::$factoryNameResolver ?? function (string $modelName) { $appNamespace = static::appNamespace(); $modelName = Str::startsWith($modelName, $appNamespace.'Models\\') @@ -811,6 +892,12 @@ abstract class Factory return $this->macroCall($method, $parameters); } + if ($method === 'trashed' && in_array(SoftDeletes::class, class_uses_recursive($this->modelName()))) { + return $this->state([ + $this->newModel()->getDeletedAtColumn() => $parameters[0] ?? Carbon::now()->subDay(), + ]); + } + if (! Str::startsWith($method, ['for', 'has'])) { static::throwBadMethodCallException($method); } @@ -820,7 +907,7 @@ abstract class Factory $relatedModel = get_class($this->newModel()->{$relationship}()->getRelated()); if (method_exists($relatedModel, 'newFactory')) { - $factory = $relatedModel::newFactory() ?: static::factoryForModel($relatedModel); + $factory = $relatedModel::newFactory() ?? static::factoryForModel($relatedModel); } else { $factory = static::factoryForModel($relatedModel); } diff --git a/vendor/illuminate/database/Eloquent/Factories/Relationship.php b/vendor/illuminate/database/Eloquent/Factories/Relationship.php index 788f6bc..3eb62da 100644 --- a/vendor/illuminate/database/Eloquent/Factories/Relationship.php +++ b/vendor/illuminate/database/Eloquent/Factories/Relationship.php @@ -59,4 +59,17 @@ class Relationship $relationship->attach($this->factory->create([], $parent)); } } + + /** + * Specify the model instances to always use when creating relationships. + * + * @param \Illuminate\Support\Collection $recycle + * @return $this + */ + public function recycle($recycle) + { + $this->factory = $this->factory->recycle($recycle); + + return $this; + } } diff --git a/vendor/illuminate/database/Eloquent/Factories/Sequence.php b/vendor/illuminate/database/Eloquent/Factories/Sequence.php index 064cc4a..e523fb3 100644 --- a/vendor/illuminate/database/Eloquent/Factories/Sequence.php +++ b/vendor/illuminate/database/Eloquent/Factories/Sequence.php @@ -30,7 +30,7 @@ class Sequence implements Countable /** * Create a new sequence instance. * - * @param array $sequence + * @param mixed ...$sequence * @return void */ public function __construct(...$sequence) diff --git a/vendor/illuminate/database/Eloquent/MissingAttributeException.php b/vendor/illuminate/database/Eloquent/MissingAttributeException.php new file mode 100755 index 0000000..87935c1 --- /dev/null +++ b/vendor/illuminate/database/Eloquent/MissingAttributeException.php @@ -0,0 +1,23 @@ +totallyGuarded(); - foreach ($this->fillableFromArray($attributes) as $key => $value) { + $fillable = $this->fillableFromArray($attributes); + + foreach ($fillable as $key => $value) { // The developers may choose to place some attributes in the "fillable" array // which means only those attributes may be set through mass assignment to // the model, and all others will just get ignored for security reasons. if ($this->isFillable($key)) { $this->setAttribute($key, $value); - } elseif ($totallyGuarded) { + } elseif ($totallyGuarded || static::preventsSilentlyDiscardingAttributes()) { + if (isset(static::$discardedAttributeViolationCallback)) { + call_user_func(static::$discardedAttributeViolationCallback, $this, [$key]); + } else { + throw new MassAssignmentException(sprintf( + 'Add [%s] to fillable property to allow mass assignment on [%s].', + $key, get_class($this) + )); + } + } + } + + if (count($attributes) !== count($fillable) && + static::preventsSilentlyDiscardingAttributes()) { + $keys = array_diff(array_keys($attributes), array_keys($fillable)); + + if (isset(static::$discardedAttributeViolationCallback)) { + call_user_func(static::$discardedAttributeViolationCallback, $this, $keys); + } else { throw new MassAssignmentException(sprintf( - 'Add [%s] to fillable property to allow mass assignment on [%s].', - $key, get_class($this) + 'Add fillable property [%s] to allow mass assignment on [%s].', + implode(', ', $keys), + get_class($this) )); } } @@ -448,9 +554,7 @@ abstract class Model implements Arrayable, ArrayAccess, CanBeEscapedWhenCastToSt */ public function forceFill(array $attributes) { - return static::unguarded(function () use ($attributes) { - return $this->fill($attributes); - }); + return static::unguarded(fn () => $this->fill($attributes)); } /** @@ -551,7 +655,7 @@ abstract class Model implements Arrayable, ArrayAccess, CanBeEscapedWhenCastToSt /** * Begin querying the model on the write connection. * - * @return \Illuminate\Database\Query\Builder + * @return \Illuminate\Database\Eloquent\Builder */ public static function onWriteConnection() { @@ -561,7 +665,7 @@ abstract class Model implements Arrayable, ArrayAccess, CanBeEscapedWhenCastToSt /** * Get all of the models from the database. * - * @param array|mixed $columns + * @param array|string $columns * @return \Illuminate\Database\Eloquent\Collection */ public static function all($columns = ['*']) @@ -921,6 +1025,36 @@ abstract class Model implements Arrayable, ArrayAccess, CanBeEscapedWhenCastToSt return $this->fill($attributes)->saveQuietly($options); } + /** + * Increment a column's value by a given amount without raising any events. + * + * @param string $column + * @param float|int $amount + * @param array $extra + * @return int + */ + protected function incrementQuietly($column, $amount = 1, array $extra = []) + { + return static::withoutEvents(function () use ($column, $amount, $extra) { + return $this->incrementOrDecrement($column, $amount, $extra, 'increment'); + }); + } + + /** + * Decrement a column's value by a given amount without raising any events. + * + * @param string $column + * @param float|int $amount + * @param array $extra + * @return int + */ + protected function decrementQuietly($column, $amount = 1, array $extra = []) + { + return static::withoutEvents(function () use ($column, $amount, $extra) { + return $this->incrementOrDecrement($column, $amount, $extra, 'decrement'); + }); + } + /** * Save the model and all of its relationships. * @@ -937,7 +1071,7 @@ abstract class Model implements Arrayable, ArrayAccess, CanBeEscapedWhenCastToSt // us to recurse into all of these nested relations for the model instance. foreach ($this->relations as $models) { $models = $models instanceof Collection - ? $models->all() : [$models]; + ? $models->all() : [$models]; foreach (array_filter($models) as $model) { if (! $model->push()) { @@ -949,6 +1083,16 @@ abstract class Model implements Arrayable, ArrayAccess, CanBeEscapedWhenCastToSt return true; } + /** + * Save the model and all of its relationships without raising any events to the parent model. + * + * @return bool + */ + public function pushQuietly() + { + return static::withoutEvents(fn () => $this->push()); + } + /** * Save the model to the database without raising any events. * @@ -957,9 +1101,7 @@ abstract class Model implements Arrayable, ArrayAccess, CanBeEscapedWhenCastToSt */ public function saveQuietly(array $options = []) { - return static::withoutEvents(function () use ($options) { - return $this->save($options); - }); + return static::withoutEvents(fn () => $this->save($options)); } /** @@ -986,7 +1128,7 @@ abstract class Model implements Arrayable, ArrayAccess, CanBeEscapedWhenCastToSt // clause to only update this model. Otherwise, we'll just insert them. if ($this->exists) { $saved = $this->isDirty() ? - $this->performUpdate($query) : true; + $this->performUpdate($query) : true; } // If the model is brand new, we'll insert it into our database and set the @@ -1021,9 +1163,7 @@ abstract class Model implements Arrayable, ArrayAccess, CanBeEscapedWhenCastToSt */ public function saveOrFail(array $options = []) { - return $this->getConnection()->transaction(function () use ($options) { - return $this->save($options); - }); + return $this->getConnection()->transaction(fn () => $this->save($options)); } /** @@ -1271,6 +1411,16 @@ abstract class Model implements Arrayable, ArrayAccess, CanBeEscapedWhenCastToSt return true; } + /** + * Delete the model from the database without raising any events. + * + * @return bool + */ + public function deleteQuietly() + { + return static::withoutEvents(fn () => $this->delete()); + } + /** * Delete the model from the database within a transaction. * @@ -1284,9 +1434,7 @@ abstract class Model implements Arrayable, ArrayAccess, CanBeEscapedWhenCastToSt return false; } - return $this->getConnection()->transaction(function () { - return $this->delete(); - }); + return $this->getConnection()->transaction(fn () => $this->delete()); } /** @@ -1378,8 +1526,8 @@ abstract class Model implements Arrayable, ArrayAccess, CanBeEscapedWhenCastToSt public function newQueryWithoutScopes() { return $this->newModelQuery() - ->with($this->with) - ->withCount($this->withCount); + ->with($this->with) + ->withCount($this->withCount); } /** @@ -1401,9 +1549,7 @@ abstract class Model implements Arrayable, ArrayAccess, CanBeEscapedWhenCastToSt */ public function newQueryForRestoration($ids) { - return is_array($ids) - ? $this->newQueryWithoutScopes()->whereIn($this->getQualifiedKeyName(), $ids) - : $this->newQueryWithoutScopes()->whereKey($ids); + return $this->newQueryWithoutScopes()->whereKey($ids); } /** @@ -1451,7 +1597,7 @@ abstract class Model implements Arrayable, ArrayAccess, CanBeEscapedWhenCastToSt public function newPivot(self $parent, array $attributes, $table, $exists, $using = null) { return $using ? $using::fromRawAttributes($parent, $attributes, $table, $exists) - : Pivot::fromAttributes($parent, $attributes, $table, $exists); + : Pivot::fromAttributes($parent, $attributes, $table, $exists); } /** @@ -1509,9 +1655,9 @@ abstract class Model implements Arrayable, ArrayAccess, CanBeEscapedWhenCastToSt /** * Convert the object into something JSON serializable. * - * @return array + * @return mixed */ - public function jsonSerialize(): array + public function jsonSerialize(): mixed { return $this->toArray(); } @@ -1529,9 +1675,9 @@ abstract class Model implements Arrayable, ArrayAccess, CanBeEscapedWhenCastToSt } return $this->setKeysForSelectQuery($this->newQueryWithoutScopes()) - ->useWritePdo() - ->with(is_string($with) ? func_get_args() : $with) - ->first(); + ->useWritePdo() + ->with(is_string($with) ? func_get_args() : $with) + ->first(); } /** @@ -1570,11 +1716,11 @@ abstract class Model implements Arrayable, ArrayAccess, CanBeEscapedWhenCastToSt */ public function replicate(array $except = null) { - $defaults = [ + $defaults = array_values(array_filter([ $this->getKeyName(), $this->getCreatedAtColumn(), $this->getUpdatedAtColumn(), - ]; + ])); $attributes = Arr::except( $this->getAttributes(), $except ? array_unique(array_merge($except, $defaults)) : $defaults @@ -1589,6 +1735,17 @@ abstract class Model implements Arrayable, ArrayAccess, CanBeEscapedWhenCastToSt }); } + /** + * Clone the model into a new, non-existing instance without raising any events. + * + * @param array|null $except + * @return static + */ + public function replicateQuietly(array $except = null) + { + return static::withoutEvents(fn () => $this->replicate($except)); + } + /** * Determine if two models have the same ID and belong to the same table. * @@ -1598,9 +1755,9 @@ abstract class Model implements Arrayable, ArrayAccess, CanBeEscapedWhenCastToSt public function is($model) { return ! is_null($model) && - $this->getKey() === $model->getKey() && - $this->getTable() === $model->getTable() && - $this->getConnectionName() === $model->getConnectionName(); + $this->getKey() === $model->getKey() && + $this->getTable() === $model->getTable() && + $this->getConnectionName() === $model->getConnectionName(); } /** @@ -1933,7 +2090,7 @@ abstract class Model implements Arrayable, ArrayAccess, CanBeEscapedWhenCastToSt */ protected function resolveChildRouteBindingQuery($childType, $value, $field) { - $relationship = $this->{Str::plural(Str::camel($childType))}(); + $relationship = $this->{$this->childRouteBindingRelationshipName($childType)}(); $field = $field ?: $relationship->getRelated()->getRouteKeyName(); @@ -1943,8 +2100,19 @@ abstract class Model implements Arrayable, ArrayAccess, CanBeEscapedWhenCastToSt } return $relationship instanceof Model - ? $relationship->resolveRouteBindingQuery($relationship, $value, $field) - : $relationship->getRelated()->resolveRouteBindingQuery($relationship, $value, $field); + ? $relationship->resolveRouteBindingQuery($relationship, $value, $field) + : $relationship->getRelated()->resolveRouteBindingQuery($relationship, $value, $field); + } + + /** + * Retrieve the child route model binding relationship name for the given child type. + * + * @param string $childType + * @return string + */ + protected function childRouteBindingRelationshipName($childType) + { + return Str::plural(Str::camel($childType)); } /** @@ -2003,6 +2171,26 @@ abstract class Model implements Arrayable, ArrayAccess, CanBeEscapedWhenCastToSt return static::$modelsShouldPreventLazyLoading; } + /** + * Determine if discarding guarded attribute fills is disabled. + * + * @return bool + */ + public static function preventsSilentlyDiscardingAttributes() + { + return static::$modelsShouldPreventSilentlyDiscardingAttributes; + } + + /** + * Determine if accessing missing attributes is disabled. + * + * @return bool + */ + public static function preventsAccessingMissingAttributes() + { + return static::$modelsShouldPreventAccessingMissingAttributes; + } + /** * Get the broadcast channel route definition that is associated with the given entity. * @@ -2054,7 +2242,11 @@ abstract class Model implements Arrayable, ArrayAccess, CanBeEscapedWhenCastToSt */ public function offsetExists($offset): bool { - return ! is_null($this->getAttribute($offset)); + try { + return ! is_null($this->getAttribute($offset)); + } catch (MissingAttributeException) { + return false; + } } /** @@ -2126,10 +2318,15 @@ abstract class Model implements Arrayable, ArrayAccess, CanBeEscapedWhenCastToSt return $this->$method(...$parameters); } - if ($resolver = (static::$relationResolvers[get_class($this)][$method] ?? null)) { + if ($resolver = ($this->relationResolver(static::class, $method))) { return $resolver($this); } + if (Str::startsWith($method, 'through') && + method_exists($this, $relationMethod = Str::of($method)->after('through')->lcfirst()->toString())) { + return $this->through($relationMethod); + } + return $this->forwardCallTo($this->newQuery(), $method, $parameters); } @@ -2153,8 +2350,8 @@ abstract class Model implements Arrayable, ArrayAccess, CanBeEscapedWhenCastToSt public function __toString() { return $this->escapeWhenCastingToString - ? e($this->toJson()) - : $this->toJson(); + ? e($this->toJson()) + : $this->toJson(); } /** diff --git a/vendor/illuminate/database/Eloquent/PendingHasThroughRelationship.php b/vendor/illuminate/database/Eloquent/PendingHasThroughRelationship.php new file mode 100644 index 0000000..612c51e --- /dev/null +++ b/vendor/illuminate/database/Eloquent/PendingHasThroughRelationship.php @@ -0,0 +1,90 @@ +rootModel = $rootModel; + + $this->localRelationship = $localRelationship; + } + + /** + * Define the distant relationship that this model has. + * + * @param string|(callable(\Illuminate\Database\Eloquent\Model): (\Illuminate\Database\Eloquent\Relations\HasOne|\Illuminate\Database\Eloquent\Relations\HasMany)) $callback + * @return \Illuminate\Database\Eloquent\Relations\HasManyThrough|\Illuminate\Database\Eloquent\Relations\HasOneThrough + */ + public function has($callback) + { + if (is_string($callback)) { + $callback = fn () => $this->localRelationship->getRelated()->{$callback}(); + } + + $distantRelation = $callback($this->localRelationship->getRelated()); + + if ($distantRelation instanceof HasMany) { + return $this->rootModel->hasManyThrough( + $distantRelation->getRelated()::class, + $this->localRelationship->getRelated()::class, + $this->localRelationship->getForeignKeyName(), + $distantRelation->getForeignKeyName(), + $this->localRelationship->getLocalKeyName(), + $distantRelation->getLocalKeyName(), + ); + } + + return $this->rootModel->hasOneThrough( + $distantRelation->getRelated()::class, + $this->localRelationship->getRelated()::class, + $this->localRelationship->getForeignKeyName(), + $distantRelation->getForeignKeyName(), + $this->localRelationship->getLocalKeyName(), + $distantRelation->getLocalKeyName(), + ); + } + + /** + * Handle dynamic method calls into the model. + * + * @param string $method + * @param array $parameters + * @return mixed + */ + public function __call($method, $parameters) + { + if (Str::startsWith($method, 'has')) { + return $this->has(Str::of($method)->after('has')->lcfirst()->toString()); + } + + throw new BadMethodCallException(sprintf( + 'Call to undefined method %s::%s()', static::class, $method + )); + } +} diff --git a/vendor/illuminate/database/Eloquent/Relations/BelongsToMany.php b/vendor/illuminate/database/Eloquent/Relations/BelongsToMany.php index fd62627..6a9ec9e 100755 --- a/vendor/illuminate/database/Eloquent/Relations/BelongsToMany.php +++ b/vendor/illuminate/database/Eloquent/Relations/BelongsToMany.php @@ -300,9 +300,9 @@ class BelongsToMany extends Relation */ protected function buildDictionary(Collection $results) { - // First we will build a dictionary of child models keyed by the foreign key - // of the relation so that we will easily and quickly match them to their - // parents without having a possibly slow inner loops for every models. + // First we'll build a dictionary of child models keyed by the foreign key + // of the relation so that we will easily and quickly match them to the + // parents without having a possibly slow inner loop for every model. $dictionary = []; foreach ($results as $result) { @@ -618,8 +618,12 @@ class BelongsToMany extends Relation */ public function firstOrCreate(array $attributes = [], array $values = [], array $joining = [], $touch = true) { - if (is_null($instance = $this->related->where($attributes)->first())) { - $instance = $this->create(array_merge($attributes, $values), $joining, $touch); + if (is_null($instance = (clone $this)->where($attributes)->first())) { + if (is_null($instance = $this->related->where($attributes)->first())) { + $instance = $this->create(array_merge($attributes, $values), $joining, $touch); + } else { + $this->attach($instance, $joining, $touch); + } } return $instance; @@ -636,8 +640,12 @@ class BelongsToMany extends Relation */ public function updateOrCreate(array $attributes, array $values = [], array $joining = [], $touch = true) { - if (is_null($instance = $this->related->where($attributes)->first())) { - return $this->create(array_merge($attributes, $values), $joining, $touch); + if (is_null($instance = (clone $this)->where($attributes)->first())) { + if (is_null($instance = $this->related->where($attributes)->first())) { + return $this->create(array_merge($attributes, $values), $joining, $touch); + } else { + $this->attach($instance, $joining, $touch); + } } $instance->fill($values); @@ -680,8 +688,8 @@ class BelongsToMany extends Relation return $this->getRelated()->newCollection(); } - return $this->whereIn( - $this->getRelated()->getQualifiedKeyName(), $this->parseIds($ids) + return $this->whereKey( + $this->parseIds($ids) )->get($columns); } @@ -711,6 +719,37 @@ class BelongsToMany extends Relation throw (new ModelNotFoundException)->setModel(get_class($this->related), $id); } + /** + * Find a related model by its primary key or call a callback. + * + * @param mixed $id + * @param \Closure|array $columns + * @param \Closure|null $callback + * @return \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Collection|mixed + */ + public function findOr($id, $columns = ['*'], Closure $callback = null) + { + if ($columns instanceof Closure) { + $callback = $columns; + + $columns = ['*']; + } + + $result = $this->find($id, $columns); + + $id = $id instanceof Arrayable ? $id->toArray() : $id; + + if (is_array($id)) { + if (count($result) === count(array_unique($id))) { + return $result; + } + } elseif (! is_null($result)) { + return $result; + } + + return $callback(); + } + /** * Add a basic where clause to the query, and return the first result. * @@ -838,7 +877,7 @@ class BelongsToMany extends Relation /** * Get the pivot columns for the relation. * - * "pivot_" is prefixed ot each column for easy removal later. + * "pivot_" is prefixed at each column for easy removal later. * * @return array */ @@ -1114,8 +1153,6 @@ class BelongsToMany extends Relation */ public function touch() { - $key = $this->getRelated()->getKeyName(); - $columns = [ $this->related->getUpdatedAtColumn() => $this->related->freshTimestampString(), ]; @@ -1124,7 +1161,7 @@ class BelongsToMany extends Relation // the related model's timestamps, to make sure these all reflect the changes // to the parent models. This will help us keep any caching synced up here. if (count($ids = $this->allRelatedIds()) > 0) { - $this->getRelated()->newQueryWithoutRelationships()->whereIn($key, $ids)->update($columns); + $this->getRelated()->newQueryWithoutRelationships()->whereKey($ids)->update($columns); } } @@ -1188,6 +1225,20 @@ class BelongsToMany extends Relation return $models; } + /** + * Save an array of new models without raising any events and attach them to the parent model. + * + * @param \Illuminate\Support\Collection|array $models + * @param array $pivotAttributes + * @return array + */ + public function saveManyQuietly($models, array $pivotAttributes = []) + { + return Model::withoutEvents(function () use ($models, $pivotAttributes) { + return $this->saveMany($models, $pivotAttributes); + }); + } + /** * Create a new instance of the related model. * diff --git a/vendor/illuminate/database/Eloquent/Relations/Concerns/InteractsWithDictionary.php b/vendor/illuminate/database/Eloquent/Relations/Concerns/InteractsWithDictionary.php index ba4ae9a..91b3bf5 100644 --- a/vendor/illuminate/database/Eloquent/Relations/Concerns/InteractsWithDictionary.php +++ b/vendor/illuminate/database/Eloquent/Relations/Concerns/InteractsWithDictionary.php @@ -4,6 +4,7 @@ namespace Illuminate\Database\Eloquent\Relations\Concerns; use BackedEnum; use Doctrine\Instantiator\Exception\InvalidArgumentException; +use UnitEnum; trait InteractsWithDictionary { @@ -23,8 +24,8 @@ trait InteractsWithDictionary } if (function_exists('enum_exists') && - $attribute instanceof BackedEnum) { - return $attribute->value; + $attribute instanceof UnitEnum) { + return $attribute instanceof BackedEnum ? $attribute->value : $attribute->name; } throw new InvalidArgumentException('Model attribute value is an object but does not have a __toString method.'); diff --git a/vendor/illuminate/database/Eloquent/Relations/Concerns/InteractsWithPivotTable.php b/vendor/illuminate/database/Eloquent/Relations/Concerns/InteractsWithPivotTable.php index 342a562..2241719 100644 --- a/vendor/illuminate/database/Eloquent/Relations/Concerns/InteractsWithPivotTable.php +++ b/vendor/illuminate/database/Eloquent/Relations/Concerns/InteractsWithPivotTable.php @@ -92,17 +92,19 @@ trait InteractsWithPivotTable $current = $this->getCurrentlyAttachedPivots() ->pluck($this->relatedPivotKey)->all(); - $detach = array_diff($current, array_keys( - $records = $this->formatRecordsList($this->parseIds($ids)) - )); + $records = $this->formatRecordsList($this->parseIds($ids)); // Next, we will take the differences of the currents and given IDs and detach // all of the entities that exist in the "current" array but are not in the // array of the new IDs given to the method which will complete the sync. - if ($detaching && count($detach) > 0) { - $this->detach($detach); + if ($detaching) { + $detach = array_diff($current, array_keys($records)); - $changes['detached'] = $this->castKeys($detach); + if (count($detach) > 0) { + $this->detach($detach); + + $changes['detached'] = $this->castKeys($detach); + } } // Now we are finally ready to attach the new records. Note that we'll disable diff --git a/vendor/illuminate/database/Eloquent/Relations/HasManyThrough.php b/vendor/illuminate/database/Eloquent/Relations/HasManyThrough.php index 7432695..b6ca908 100644 --- a/vendor/illuminate/database/Eloquent/Relations/HasManyThrough.php +++ b/vendor/illuminate/database/Eloquent/Relations/HasManyThrough.php @@ -388,6 +388,37 @@ class HasManyThrough extends Relation throw (new ModelNotFoundException)->setModel(get_class($this->related), $id); } + /** + * Find a related model by its primary key or call a callback. + * + * @param mixed $id + * @param \Closure|array $columns + * @param \Closure|null $callback + * @return \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Collection|mixed + */ + public function findOr($id, $columns = ['*'], Closure $callback = null) + { + if ($columns instanceof Closure) { + $callback = $columns; + + $columns = ['*']; + } + + $result = $this->find($id, $columns); + + $id = $id instanceof Arrayable ? $id->toArray() : $id; + + if (is_array($id)) { + if (count($result) === count(array_unique($id))) { + return $result; + } + } elseif (! is_null($result)) { + return $result; + } + + return $callback(); + } + /** * Get the results of the relationship. * @@ -518,7 +549,7 @@ class HasManyThrough extends Relation /** * Get a generator for the given query. * - * @return \Generator + * @return \Illuminate\Support\LazyCollection */ public function cursor() { diff --git a/vendor/illuminate/database/Eloquent/Relations/HasOneOrMany.php b/vendor/illuminate/database/Eloquent/Relations/HasOneOrMany.php index 4de0651..01f0c1e 100755 --- a/vendor/illuminate/database/Eloquent/Relations/HasOneOrMany.php +++ b/vendor/illuminate/database/Eloquent/Relations/HasOneOrMany.php @@ -295,6 +295,19 @@ abstract class HasOneOrMany extends Relation return $models; } + /** + * Attach a collection of models to the parent instance without raising any events to the parent model. + * + * @param iterable $models + * @return iterable + */ + public function saveManyQuietly($models) + { + return Model::withoutEvents(function () use ($models) { + return $this->saveMany($models); + }); + } + /** * Create a new instance of the related model. * @@ -310,6 +323,30 @@ abstract class HasOneOrMany extends Relation }); } + /** + * Create a new instance of the related model without raising any events to the parent model. + * + * @param array $attributes + * @return \Illuminate\Database\Eloquent\Model + */ + public function createQuietly(array $attributes = []) + { + return Model::withoutEvents(fn () => $this->create($attributes)); + } + + /** + * Create a new instance of the related model. Allow mass-assignment. + * + * @param array $attributes + * @return \Illuminate\Database\Eloquent\Model + */ + public function forceCreate(array $attributes = []) + { + $attributes[$this->getForeignKeyName()] = $this->getParentKey(); + + return $this->related->forceCreate($attributes); + } + /** * Create a Collection of new instances of the related model. * @@ -327,6 +364,17 @@ abstract class HasOneOrMany extends Relation return $instances; } + /** + * Create a Collection of new instances of the related model without raising any events to the parent model. + * + * @param iterable $records + * @return \Illuminate\Database\Eloquent\Collection + */ + public function createManyQuietly(iterable $records) + { + return Model::withoutEvents(fn () => $this->createMany($records)); + } + /** * Set the foreign ID for creating a related model. * diff --git a/vendor/illuminate/database/Eloquent/Relations/MorphMany.php b/vendor/illuminate/database/Eloquent/Relations/MorphMany.php index 12b0650..282ba2e 100755 --- a/vendor/illuminate/database/Eloquent/Relations/MorphMany.php +++ b/vendor/illuminate/database/Eloquent/Relations/MorphMany.php @@ -46,4 +46,17 @@ class MorphMany extends MorphOneOrMany { return $this->matchMany($models, $results, $relation); } + + /** + * Create a new instance of the related model. Allow mass-assignment. + * + * @param array $attributes + * @return \Illuminate\Database\Eloquent\Model + */ + public function forceCreate(array $attributes = []) + { + $attributes[$this->getMorphType()] = $this->morphClass; + + return parent::forceCreate($attributes); + } } diff --git a/vendor/illuminate/database/Eloquent/Relations/Relation.php b/vendor/illuminate/database/Eloquent/Relations/Relation.php index 58d6b31..6523ca0 100755 --- a/vendor/illuminate/database/Eloquent/Relations/Relation.php +++ b/vendor/illuminate/database/Eloquent/Relations/Relation.php @@ -301,13 +301,11 @@ abstract class Relation implements BuilderContract /** * Get the base query builder driving the Eloquent builder. * - * @deprecated Use toBase() instead - * * @return \Illuminate\Database\Query\Builder */ public function getBaseQuery() { - return $this->toBase(); + return $this->query->getQuery(); } /** @@ -317,7 +315,7 @@ abstract class Relation implements BuilderContract */ public function toBase() { - return $this->query->getQuery(); + return $this->query->toBase(); } /** diff --git a/vendor/illuminate/database/Eloquent/SoftDeletes.php b/vendor/illuminate/database/Eloquent/SoftDeletes.php index 78ad75e..da7a4a3 100644 --- a/vendor/illuminate/database/Eloquent/SoftDeletes.php +++ b/vendor/illuminate/database/Eloquent/SoftDeletes.php @@ -45,6 +45,10 @@ trait SoftDeletes */ public function forceDelete() { + if ($this->fireModelEvent('forceDeleting') === false) { + return false; + } + $this->forceDeleting = true; return tap($this->delete(), function ($deleted) { @@ -56,6 +60,16 @@ trait SoftDeletes }); } + /** + * Force a hard delete on a soft deleted model without raising any events. + * + * @return bool|null + */ + public function forceDeleteQuietly() + { + return static::withoutEvents(fn () => $this->forceDelete()); + } + /** * Perform the actual delete query on this model instance. * @@ -87,7 +101,7 @@ trait SoftDeletes $this->{$this->getDeletedAtColumn()} = $time; - if ($this->timestamps && ! is_null($this->getUpdatedAtColumn())) { + if ($this->usesTimestamps() && ! is_null($this->getUpdatedAtColumn())) { $this->{$this->getUpdatedAtColumn()} = $time; $columns[$this->getUpdatedAtColumn()] = $this->fromDateTime($time); @@ -103,7 +117,7 @@ trait SoftDeletes /** * Restore a soft-deleted model instance. * - * @return bool|null + * @return bool */ public function restore() { @@ -128,6 +142,16 @@ trait SoftDeletes return $result; } + /** + * Restore a soft-deleted model instance without raising any events. + * + * @return bool + */ + public function restoreQuietly() + { + return static::withoutEvents(fn () => $this->restore()); + } + /** * Determine if the model instance has been soft-deleted. * @@ -171,6 +195,17 @@ trait SoftDeletes static::registerModelEvent('restored', $callback); } + /** + * Register a "forceDeleting" model event callback with the dispatcher. + * + * @param \Closure|string $callback + * @return void + */ + public static function forceDeleting($callback) + { + static::registerModelEvent('forceDeleting', $callback); + } + /** * Register a "forceDeleted" model event callback with the dispatcher. * @@ -199,7 +234,7 @@ trait SoftDeletes */ public function getDeletedAtColumn() { - return defined('static::DELETED_AT') ? static::DELETED_AT : 'deleted_at'; + return defined(static::class.'::DELETED_AT') ? static::DELETED_AT : 'deleted_at'; } /** diff --git a/vendor/illuminate/database/Eloquent/SoftDeletingScope.php b/vendor/illuminate/database/Eloquent/SoftDeletingScope.php index 7528964..e6d91d9 100644 --- a/vendor/illuminate/database/Eloquent/SoftDeletingScope.php +++ b/vendor/illuminate/database/Eloquent/SoftDeletingScope.php @@ -9,7 +9,7 @@ class SoftDeletingScope implements Scope * * @var string[] */ - protected $extensions = ['Restore', 'WithTrashed', 'WithoutTrashed', 'OnlyTrashed']; + protected $extensions = ['Restore', 'RestoreOrCreate', 'WithTrashed', 'WithoutTrashed', 'OnlyTrashed']; /** * Apply the scope to a given Eloquent query builder. @@ -74,6 +74,23 @@ class SoftDeletingScope implements Scope }); } + /** + * Add the restore-or-create extension to the builder. + * + * @param \Illuminate\Database\Eloquent\Builder $builder + * @return void + */ + protected function addRestoreOrCreate(Builder $builder) + { + $builder->macro('restoreOrCreate', function (Builder $builder, array $attributes = [], array $values = []) { + $builder->withTrashed(); + + return tap($builder->firstOrCreate($attributes, $values), function ($instance) { + $instance->restore(); + }); + }); + } + /** * Add the with-trashed extension to the builder. * diff --git a/vendor/illuminate/database/Events/ConnectionEstablished.php b/vendor/illuminate/database/Events/ConnectionEstablished.php new file mode 100644 index 0000000..22a45b8 --- /dev/null +++ b/vendor/illuminate/database/Events/ConnectionEstablished.php @@ -0,0 +1,8 @@ +connectionName = $connectionName; + $this->connections = $connections; + } +} diff --git a/vendor/illuminate/database/Events/TransactionCommitting.php b/vendor/illuminate/database/Events/TransactionCommitting.php new file mode 100644 index 0000000..9b8179d --- /dev/null +++ b/vendor/illuminate/database/Events/TransactionCommitting.php @@ -0,0 +1,8 @@ + + */ + protected static $requiredPathCache = []; + /** * The output interface implementation. * @@ -144,7 +156,7 @@ class Migrator if (count($migrations) === 0) { $this->fireMigrationEvent(new NoPendingMigrations('up')); - $this->note('Nothing to migrate.'); + $this->write(Info::class, 'Nothing to migrate'); return; } @@ -160,6 +172,8 @@ class Migrator $this->fireMigrationEvent(new MigrationsStarted('up')); + $this->write(Info::class, 'Running migrations.'); + // Once we have the array of migrations, we will spin through them and run the // migrations "up" so the changes are made to the databases. We'll then log // that the migration was run so we don't repeat it next time we execute. @@ -172,6 +186,10 @@ class Migrator } $this->fireMigrationEvent(new MigrationsEnded('up')); + + if ($this->output) { + $this->output->writeln(''); + } } /** @@ -195,20 +213,12 @@ class Migrator return $this->pretendToRun($migration, 'up'); } - $this->note("Migrating: {$name}"); - - $startTime = microtime(true); - - $this->runMigration($migration, 'up'); - - $runTime = number_format((microtime(true) - $startTime) * 1000, 2); + $this->write(Task::class, $name, fn () => $this->runMigration($migration, 'up')); // Once we have run a migrations class, we will log that it was run in this // repository so that we don't try to run it next time we do a migration // in the application. A migration repository keeps the migrate order. $this->repository->log($name, $batch); - - $this->note("Migrated: {$name} ({$runTime}ms)"); } /** @@ -228,12 +238,16 @@ class Migrator if (count($migrations) === 0) { $this->fireMigrationEvent(new NoPendingMigrations('down')); - $this->note('Nothing to rollback.'); + $this->write(Info::class, 'Nothing to rollback.'); return []; } - return $this->rollbackMigrations($migrations, $paths, $options); + return tap($this->rollbackMigrations($migrations, $paths, $options), function () { + if ($this->output) { + $this->output->writeln(''); + } + }); } /** @@ -267,6 +281,8 @@ class Migrator $this->fireMigrationEvent(new MigrationsStarted('down')); + $this->write(Info::class, 'Rolling back migrations.'); + // Next we will run through all of the migrations and call the "down" method // which will reverse each migration in order. This getLast method on the // repository already returns these migration's names in reverse order. @@ -274,7 +290,7 @@ class Migrator $migration = (object) $migration; if (! $file = Arr::get($files, $migration->migration)) { - $this->note("Migration not found: {$migration->migration}"); + $this->write(TwoColumnDetail::class, $migration->migration, 'Migration not found'); continue; } @@ -307,12 +323,16 @@ class Migrator $migrations = array_reverse($this->repository->getRan()); if (count($migrations) === 0) { - $this->note('Nothing to rollback.'); + $this->write(Info::class, 'Nothing to rollback.'); return []; } - return $this->resetMigrations($migrations, $paths, $pretend); + return tap($this->resetMigrations($migrations, $paths, $pretend), function () { + if ($this->output) { + $this->output->writeln(''); + } + }); } /** @@ -354,24 +374,16 @@ class Migrator $name = $this->getMigrationName($file); - $this->note("Rolling back: {$name}"); - if ($pretend) { return $this->pretendToRun($instance, 'down'); } - $startTime = microtime(true); - - $this->runMigration($instance, 'down'); - - $runTime = number_format((microtime(true) - $startTime) * 1000, 2); + $this->write(Task::class, $name, fn () => $this->runMigration($instance, 'down')); // Once we have successfully run the migration "down" we will remove it from // the migration repository so it will be considered to have not been run // by the application then will be able to fire by any later operation. $this->repository->delete($migration); - - $this->note("Rolled back: {$name} ({$runTime}ms)"); } /** @@ -413,21 +425,25 @@ class Migrator protected function pretendToRun($migration, $method) { try { - foreach ($this->getQueries($migration, $method) as $query) { - $name = get_class($migration); + $name = get_class($migration); - $reflectionClass = new ReflectionClass($migration); + $reflectionClass = new ReflectionClass($migration); - if ($reflectionClass->isAnonymous()) { - $name = $this->getMigrationName($reflectionClass->getFileName()); - } - - $this->note("{$name}: {$query['query']}"); + if ($reflectionClass->isAnonymous()) { + $name = $this->getMigrationName($reflectionClass->getFileName()); } + + $this->write(TwoColumnDetail::class, $name); + $this->write(BulletList::class, collect($this->getQueries($migration, $method))->map(function ($query) { + return $query['query']; + })); } catch (SchemaException $e) { $name = get_class($migration); - $this->note("{$name}: failed to dump queries. This may be due to changing database columns using Doctrine, which is not supported while pretending to run migrations."); + $this->write(Error::class, sprintf( + '[%s] failed to dump queries. This may be due to changing database columns using Doctrine, which is not supported while pretending to run migrations.', + $name, + )); } } @@ -502,9 +518,13 @@ class Migrator return new $class; } - $migration = $this->files->getRequire($path); + $migration = static::$requiredPathCache[$path] ??= $this->files->getRequire($path); - return is_object($migration) ? $migration : new $class; + if (is_object($migration)) { + return clone $migration; + } + + return new $class; } /** @@ -717,15 +737,22 @@ class Migrator } /** - * Write a note to the console's output. + * Write to the console's output. * - * @param string $message + * @param string $component + * @param array|string ...$arguments * @return void */ - protected function note($message) + protected function write($component, ...$arguments) { - if ($this->output) { - $this->output->writeln($message); + if ($this->output && class_exists($component)) { + (new $component($this->output))->render(...$arguments); + } else { + foreach ($arguments as $argument) { + if (is_callable($argument)) { + $argument(); + } + } } } diff --git a/vendor/illuminate/database/MultipleColumnsSelectedException.php b/vendor/illuminate/database/MultipleColumnsSelectedException.php new file mode 100644 index 0000000..07c86fd --- /dev/null +++ b/vendor/illuminate/database/MultipleColumnsSelectedException.php @@ -0,0 +1,10 @@ +', '<=', '>=', '<>', '!=', '<=>', 'like', 'like binary', 'not like', 'ilike', - '&', '|', '^', '<<', '>>', '&~', + '&', '|', '^', '<<', '>>', '&~', 'is', 'is not', 'rlike', 'not rlike', 'regexp', 'not regexp', '~', '~*', '!~', '!~*', 'similar to', 'not similar to', 'not ilike', '~~*', '!~~*', @@ -301,7 +308,7 @@ class Builder implements BuilderContract /** * Makes "from" fetch from a subquery. * - * @param \Closure|\Illuminate\Database\Query\Builder|string $query + * @param \Closure|\Illuminate\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder|string $query * @param string $as * @return $this * @@ -333,7 +340,7 @@ class Builder implements BuilderContract /** * Creates a subquery and parse it. * - * @param \Closure|\Illuminate\Database\Query\Builder|string $query + * @param \Closure|\Illuminate\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder|string $query * @return array */ protected function createSub($query) @@ -411,6 +418,10 @@ class Builder implements BuilderContract $this->selectSub($column, $as); } else { + if (is_array($this->columns) && in_array($column, $this->columns, true)) { + continue; + } + $this->columns[] = $column; } } @@ -439,7 +450,7 @@ class Builder implements BuilderContract /** * Set the table which the query is targeting. * - * @param \Closure|\Illuminate\Database\Query\Builder|string $table + * @param \Closure|\Illuminate\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder|string $table * @param string|null $as * @return $this */ @@ -454,6 +465,45 @@ class Builder implements BuilderContract return $this; } + /** + * Add an index hint to suggest a query index. + * + * @param string $index + * @return $this + */ + public function useIndex($index) + { + $this->indexHint = new IndexHint('hint', $index); + + return $this; + } + + /** + * Add an index hint to force a query index. + * + * @param string $index + * @return $this + */ + public function forceIndex($index) + { + $this->indexHint = new IndexHint('force', $index); + + return $this; + } + + /** + * Add an index hint to ignore a query index. + * + * @param string $index + * @return $this + */ + public function ignoreIndex($index) + { + $this->indexHint = new IndexHint('ignore', $index); + + return $this; + } + /** * Add a join clause to the query. * @@ -643,7 +693,7 @@ class Builder implements BuilderContract /** * Add a subquery cross join to the query. * - * @param \Closure|\Illuminate\Database\Query\Builder|string $query + * @param \Closure|\Illuminate\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder|string $query * @param string $as * @return $this */ @@ -678,7 +728,7 @@ class Builder implements BuilderContract * * @param array $wheres * @param array $bindings - * @return void + * @return $this */ public function mergeWheres($wheres, $bindings) { @@ -716,9 +766,9 @@ class Builder implements BuilderContract $value, $operator, func_num_args() === 2 ); - // If the columns is actually a Closure instance, we will assume the developer - // wants to begin a nested where statement which is wrapped in parenthesis. - // We'll add that Closure to the query then return back out immediately. + // If the column is actually a Closure instance, we will assume the developer + // wants to begin a nested where statement which is wrapped in parentheses. + // We will add that Closure to the query and return back out immediately. if ($column instanceof Closure && is_null($operator)) { return $this->whereNested($column, $boolean); } @@ -800,7 +850,7 @@ class Builder implements BuilderContract if (is_numeric($key) && is_array($value)) { $query->{$method}(...array_values($value)); } else { - $query->$method($key, '=', $value, $boolean); + $query->{$method}($key, '=', $value, $boolean); } } }, $boolean); @@ -894,6 +944,12 @@ class Builder implements BuilderContract */ public function whereNot($column, $operator = null, $value = null, $boolean = 'and') { + if (is_array($column)) { + return $this->whereNested(function ($query) use ($column, $operator, $value, $boolean) { + $query->where($column, $operator, $value, $boolean); + }, $boolean.' not'); + } + return $this->where($column, $operator, $value, $boolean.' not'); } @@ -1003,7 +1059,7 @@ class Builder implements BuilderContract $type = $not ? 'NotIn' : 'In'; // If the value is a query builder instance we will assume the developer wants to - // look for any values that exists within this given query. So we will add the + // look for any values that exist within this given query. So, we will add the // query accordingly so that this query is properly executed when it is run. if ($this->isQueryable($values)) { [$query, $bindings] = $this->createSub($values); @@ -1022,7 +1078,11 @@ class Builder implements BuilderContract $this->wheres[] = compact('type', 'column', 'values', 'boolean'); - // Finally we'll add a binding for each values unless that value is an expression + if (count($values) !== count(Arr::flatten($values, 1))) { + throw new InvalidArgumentException('Nested arrays may not be passed to whereIn method.'); + } + + // Finally, we'll add a binding for each value unless that value is an expression // in which case we will just skip over it since it will be the query as a raw // string and not as a parameterized place-holder to be replaced by the PDO. $this->addBinding($this->cleanBindings($values), 'where'); @@ -1084,6 +1144,8 @@ class Builder implements BuilderContract $values = $values->toArray(); } + $values = Arr::flatten($values); + foreach ($values as &$value) { $value = (int) $value; } @@ -1386,7 +1448,7 @@ class Builder implements BuilderContract * * @param string $column * @param string $operator - * @param \DateTimeInterface|string|null $value + * @param \DateTimeInterface|string|int|null $value * @param string $boolean * @return $this */ @@ -1403,7 +1465,7 @@ class Builder implements BuilderContract } if (! $value instanceof Expression) { - $value = str_pad($value, 2, '0', STR_PAD_LEFT); + $value = sprintf('%02d', $value); } return $this->addDateBasedWhere('Day', $column, $operator, $value, $boolean); @@ -1414,7 +1476,7 @@ class Builder implements BuilderContract * * @param string $column * @param string $operator - * @param \DateTimeInterface|string|null $value + * @param \DateTimeInterface|string|int|null $value * @return $this */ public function orWhereDay($column, $operator, $value = null) @@ -1431,7 +1493,7 @@ class Builder implements BuilderContract * * @param string $column * @param string $operator - * @param \DateTimeInterface|string|null $value + * @param \DateTimeInterface|string|int|null $value * @param string $boolean * @return $this */ @@ -1448,7 +1510,7 @@ class Builder implements BuilderContract } if (! $value instanceof Expression) { - $value = str_pad($value, 2, '0', STR_PAD_LEFT); + $value = sprintf('%02d', $value); } return $this->addDateBasedWhere('Month', $column, $operator, $value, $boolean); @@ -1459,7 +1521,7 @@ class Builder implements BuilderContract * * @param string $column * @param string $operator - * @param \DateTimeInterface|string|null $value + * @param \DateTimeInterface|string|int|null $value * @return $this */ public function orWhereMonth($column, $operator, $value = null) @@ -1776,6 +1838,57 @@ class Builder implements BuilderContract return $this->whereJsonDoesntContain($column, $value, 'or'); } + /** + * Add a clause that determines if a JSON path exists to the query. + * + * @param string $column + * @param string $boolean + * @param bool $not + * @return $this + */ + public function whereJsonContainsKey($column, $boolean = 'and', $not = false) + { + $type = 'JsonContainsKey'; + + $this->wheres[] = compact('type', 'column', 'boolean', 'not'); + + return $this; + } + + /** + * Add an "or" clause that determines if a JSON path exists to the query. + * + * @param string $column + * @return $this + */ + public function orWhereJsonContainsKey($column) + { + return $this->whereJsonContainsKey($column, 'or'); + } + + /** + * Add a clause that determines if a JSON path does not exist to the query. + * + * @param string $column + * @param string $boolean + * @return $this + */ + public function whereJsonDoesntContainKey($column, $boolean = 'and') + { + return $this->whereJsonContainsKey($column, $boolean, true); + } + + /** + * Add an "or" clause that determines if a JSON path does not exist to the query. + * + * @param string $column + * @return $this + */ + public function orWhereJsonDoesntContainKey($column) + { + return $this->whereJsonDoesntContainKey($column, 'or'); + } + /** * Add a "where JSON length" clause to the query. * @@ -1952,8 +2065,8 @@ class Builder implements BuilderContract * Add a "having" clause to the query. * * @param \Closure|string $column - * @param string|null $operator - * @param string|null $value + * @param string|int|float|null $operator + * @param string|int|float|null $value * @param string $boolean * @return $this */ @@ -1996,8 +2109,8 @@ class Builder implements BuilderContract * Add an "or having" clause to the query. * * @param \Closure|string $column - * @param string|null $operator - * @param string|null $value + * @param string|int|float|null $operator + * @param string|int|float|null $value * @return $this */ public function orHaving($column, $operator = null, $value = null) @@ -2150,7 +2263,7 @@ class Builder implements BuilderContract /** * Add an "order by" clause to the query. * - * @param \Closure|\Illuminate\Database\Query\Builder|\Illuminate\Database\Query\Expression|string $column + * @param \Closure|\Illuminate\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Expression|string $column * @param string $direction * @return $this * @@ -2183,7 +2296,7 @@ class Builder implements BuilderContract /** * Add a descending "order by" clause to the query. * - * @param \Closure|\Illuminate\Database\Query\Builder|\Illuminate\Database\Query\Expression|string $column + * @param \Closure|\Illuminate\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Expression|string $column * @return $this */ public function orderByDesc($column) @@ -2216,7 +2329,7 @@ class Builder implements BuilderContract /** * Put the query's results in random order. * - * @param string $seed + * @param string|int $seed * @return $this */ public function inRandomOrder($seed = '') @@ -2387,7 +2500,7 @@ class Builder implements BuilderContract /** * Add a union statement to the query. * - * @param \Illuminate\Database\Query\Builder|\Closure $query + * @param \Closure|\Illuminate\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder $query * @param bool $all * @return $this */ @@ -2407,7 +2520,7 @@ class Builder implements BuilderContract /** * Add a union all statement to the query. * - * @param \Illuminate\Database\Query\Builder|\Closure $query + * @param \Closure|\Illuminate\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder $query * @return $this */ public function unionAll($query) @@ -2435,7 +2548,7 @@ class Builder implements BuilderContract /** * Lock the selected rows in the table for updating. * - * @return \Illuminate\Database\Query\Builder + * @return $this */ public function lockForUpdate() { @@ -2445,7 +2558,7 @@ class Builder implements BuilderContract /** * Share lock the selected rows in the table. * - * @return \Illuminate\Database\Query\Builder + * @return $this */ public function sharedLock() { @@ -2495,7 +2608,7 @@ class Builder implements BuilderContract * Execute a query for a single record by ID. * * @param int|string $id - * @param array $columns + * @param array|string $columns * @return mixed|static */ public function find($id, $columns = ['*']) @@ -2503,6 +2616,29 @@ class Builder implements BuilderContract return $this->where('id', '=', $id)->first($columns); } + /** + * Execute a query for a single record by ID or call a callback. + * + * @param mixed $id + * @param \Closure|array|string $columns + * @param \Closure|null $callback + * @return mixed|static + */ + public function findOr($id, $columns = ['*'], Closure $callback = null) + { + if ($columns instanceof Closure) { + $callback = $columns; + + $columns = ['*']; + } + + if (! is_null($data = $this->find($id, $columns))) { + return $data; + } + + return $callback(); + } + /** * Get a single column's value from the first result of a query. * @@ -2516,6 +2652,20 @@ class Builder implements BuilderContract return count($result) > 0 ? reset($result) : null; } + /** + * Get a single expression value from the first result of a query. + * + * @param string $expression + * @param array $bindings + * @return mixed + */ + public function rawValue(string $expression, array $bindings = []) + { + $result = (array) $this->selectRaw($expression, $bindings)->first(); + + return count($result) > 0 ? reset($result) : null; + } + /** * Get a single column's value from the first result of a query if it's the sole matching record. * @@ -2560,8 +2710,8 @@ class Builder implements BuilderContract /** * Paginate the given query into a simple paginator. * - * @param int $perPage - * @param array $columns + * @param int|\Closure $perPage + * @param array|string $columns * @param string $pageName * @param int|null $page * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator @@ -2572,6 +2722,8 @@ class Builder implements BuilderContract $total = $this->getCountForPagination(); + $perPage = $perPage instanceof Closure ? $perPage($total) : $perPage; + $results = $total ? $this->forPage($page, $perPage)->get($columns) : collect(); return $this->paginator($results, $total, $perPage, $page, [ @@ -2586,7 +2738,7 @@ class Builder implements BuilderContract * This is more efficient on larger data-sets, etc. * * @param int $perPage - * @param array $columns + * @param array|string $columns * @param string $pageName * @param int|null $page * @return \Illuminate\Contracts\Pagination\Paginator @@ -2609,7 +2761,7 @@ class Builder implements BuilderContract * This is more efficient on larger data-sets, etc. * * @param int|null $perPage - * @param array $columns + * @param array|string $columns * @param string $cursorName * @param \Illuminate\Pagination\Cursor|string|null $cursor * @return \Illuminate\Contracts\Pagination\CursorPaginator @@ -2629,15 +2781,15 @@ class Builder implements BuilderContract { $this->enforceOrderBy(); - if ($shouldReverse) { - $this->orders = collect($this->orders)->map(function ($order) { + return collect($this->orders ?? $this->unionOrders ?? [])->filter(function ($order) { + return Arr::has($order, 'direction'); + })->when($shouldReverse, function (Collection $orders) { + return $orders->map(function ($order) { $order['direction'] = $order['direction'] === 'asc' ? 'desc' : 'asc'; return $order; - })->toArray(); - } - - return collect($this->orders); + }); + })->values(); } /** @@ -2878,9 +3030,9 @@ class Builder implements BuilderContract $this->grammar->compileExists($this), $this->getBindings(), ! $this->useWritePdo ); - // If the results has rows, we will get the row and see if the exists column is a - // boolean true. If there is no results for this query we will return false as - // there are no rows for this query at all and we can return that info here. + // If the results have rows, we will get the row and see if the exists column is a + // boolean true. If there are no results for this query we will return false as + // there are no rows for this query at all, and we can return that info here. if (isset($results[0])) { $results = (array) $results[0]; @@ -3174,7 +3326,7 @@ class Builder implements BuilderContract * Insert new records into the table using a subquery. * * @param array $columns - * @param \Closure|\Illuminate\Database\Query\Builder|string $query + * @param \Closure|\Illuminate\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder|string $query * @return int */ public function insertUsing(array $columns, $query) @@ -3308,11 +3460,31 @@ class Builder implements BuilderContract throw new InvalidArgumentException('Non-numeric value passed to increment method.'); } - $wrapped = $this->grammar->wrap($column); + return $this->incrementEach([$column => $amount], $extra); + } - $columns = array_merge([$column => $this->raw("$wrapped + $amount")], $extra); + /** + * Increment the given column's values by the given amounts. + * + * @param array $columns + * @param array $extra + * @return int + * + * @throws \InvalidArgumentException + */ + public function incrementEach(array $columns, array $extra = []) + { + foreach ($columns as $column => $amount) { + if (! is_numeric($amount)) { + throw new InvalidArgumentException("Non-numeric value passed as increment amount for column: '$column'."); + } elseif (! is_string($column)) { + throw new InvalidArgumentException('Non-associative array passed to incrementEach method.'); + } - return $this->update($columns); + $columns[$column] = $this->raw("{$this->grammar->wrap($column)} + $amount"); + } + + return $this->update(array_merge($columns, $extra)); } /** @@ -3331,11 +3503,31 @@ class Builder implements BuilderContract throw new InvalidArgumentException('Non-numeric value passed to decrement method.'); } - $wrapped = $this->grammar->wrap($column); + return $this->decrementEach([$column => $amount], $extra); + } - $columns = array_merge([$column => $this->raw("$wrapped - $amount")], $extra); + /** + * Decrement the given column's values by the given amounts. + * + * @param array $columns + * @param array $extra + * @return int + * + * @throws \InvalidArgumentException + */ + public function decrementEach(array $columns, array $extra = []) + { + foreach ($columns as $column => $amount) { + if (! is_numeric($amount)) { + throw new InvalidArgumentException("Non-numeric value passed as decrement amount for column: '$column'."); + } elseif (! is_string($column)) { + throw new InvalidArgumentException('Non-associative array passed to decrementEach method.'); + } - return $this->update($columns); + $columns[$column] = $this->raw("{$this->grammar->wrap($column)} - $amount"); + } + + return $this->update(array_merge($columns, $extra)); } /** diff --git a/vendor/illuminate/database/Query/Grammars/Grammar.php b/vendor/illuminate/database/Query/Grammars/Grammar.php index 91b8af7..e15c556 100755 --- a/vendor/illuminate/database/Query/Grammars/Grammar.php +++ b/vendor/illuminate/database/Query/Grammars/Grammar.php @@ -2,15 +2,17 @@ namespace Illuminate\Database\Query\Grammars; +use Illuminate\Database\Concerns\CompilesJsonPaths; use Illuminate\Database\Grammar as BaseGrammar; use Illuminate\Database\Query\Builder; use Illuminate\Database\Query\JoinClause; use Illuminate\Support\Arr; -use Illuminate\Support\Str; use RuntimeException; class Grammar extends BaseGrammar { + use CompilesJsonPaths; + /** * The grammar specific operators. * @@ -34,6 +36,7 @@ class Grammar extends BaseGrammar 'aggregate', 'columns', 'from', + 'indexHint', 'joins', 'wheres', 'groups', @@ -190,7 +193,7 @@ class Grammar extends BaseGrammar */ public function compileWheres(Builder $query) { - // Each type of where clauses has its own compiler function which is responsible + // Each type of where clause has its own compiler function, which is responsible // for actually creating the where clauses SQL. This helps keep the code nice // and maintainable since each clause has a very small method that it uses. if (is_null($query->wheres)) { @@ -620,6 +623,35 @@ class Grammar extends BaseGrammar return json_encode($binding); } + /** + * Compile a "where JSON contains key" clause. + * + * @param \Illuminate\Database\Query\Builder $query + * @param array $where + * @return string + */ + protected function whereJsonContainsKey(Builder $query, $where) + { + $not = $where['not'] ? 'not ' : ''; + + return $not.$this->compileJsonContainsKey( + $where['column'] + ); + } + + /** + * Compile a "JSON contains key" statement into SQL. + * + * @param string $column + * @return string + * + * @throws \RuntimeException + */ + protected function compileJsonContainsKey($column) + { + throw new RuntimeException('This database engine does not support JSON contains key operations.'); + } + /** * Compile a "where JSON length" clause. * @@ -651,6 +683,17 @@ class Grammar extends BaseGrammar throw new RuntimeException('This database engine does not support JSON length operations.'); } + /** + * Compile a "JSON value cast" statement into SQL. + * + * @param string $value + * @return string + */ + public function compileJsonValueCast($value) + { + return $value; + } + /** * Compile a "where fulltext" clause. * @@ -835,7 +878,7 @@ class Grammar extends BaseGrammar /** * Compile the random statement into SQL. * - * @param string $seed + * @param string|int $seed * @return string */ public function compileRandom($seed) @@ -973,7 +1016,7 @@ class Grammar extends BaseGrammar $columns = $this->columnize(array_keys(reset($values))); // We need to build a list of parameter place-holders of values that are bound - // to the query. Each insert should have the exact same amount of parameter + // to the query. Each insert should have the exact same number of parameter // bindings so we will loop through the record and parameterize them all. $parameters = collect($values)->map(function ($record) { return '('.$this->parameterize($record).')'; @@ -1259,64 +1302,6 @@ class Grammar extends BaseGrammar return $value; } - /** - * Split the given JSON selector into the field and the optional path and wrap them separately. - * - * @param string $column - * @return array - */ - protected function wrapJsonFieldAndPath($column) - { - $parts = explode('->', $column, 2); - - $field = $this->wrap($parts[0]); - - $path = count($parts) > 1 ? ', '.$this->wrapJsonPath($parts[1], '->') : ''; - - return [$field, $path]; - } - - /** - * Wrap the given JSON path. - * - * @param string $value - * @param string $delimiter - * @return string - */ - protected function wrapJsonPath($value, $delimiter = '->') - { - $value = preg_replace("/([\\\\]+)?\\'/", "''", $value); - - $jsonPath = collect(explode($delimiter, $value)) - ->map(function ($segment) { - return $this->wrapJsonPathSegment($segment); - }) - ->join('.'); - - return "'$".(str_starts_with($jsonPath, '[') ? '' : '.').$jsonPath."'"; - } - - /** - * Wrap the given JSON path segment. - * - * @param string $segment - * @return string - */ - protected function wrapJsonPathSegment($segment) - { - if (preg_match('/(\[[^\]]+\])+$/', $segment, $parts)) { - $key = Str::beforeLast($segment, $parts[0]); - - if (! empty($key)) { - return '"'.$key.'"'.$parts[0]; - } - - return $parts[0]; - } - - return '"'.$segment.'"'; - } - /** * Concatenate an array of segments, removing empties. * diff --git a/vendor/illuminate/database/Query/Grammars/MySqlGrammar.php b/vendor/illuminate/database/Query/Grammars/MySqlGrammar.php index 404b3d5..131f8af 100755 --- a/vendor/illuminate/database/Query/Grammars/MySqlGrammar.php +++ b/vendor/illuminate/database/Query/Grammars/MySqlGrammar.php @@ -74,6 +74,22 @@ class MySqlGrammar extends Grammar return "match ({$columns}) against (".$value."{$mode}{$expanded})"; } + /** + * Compile the index hints for the query. + * + * @param \Illuminate\Database\Query\Builder $query + * @param \Illuminate\Database\Query\IndexHint $indexHint + * @return string + */ + protected function compileIndexHint(Builder $query, $indexHint) + { + return match ($indexHint->type) { + 'hint' => "use index ({$indexHint->index})", + 'force' => "force index ({$indexHint->index})", + default => "ignore index ({$indexHint->index})", + }; + } + /** * Compile an insert ignore statement into SQL. * @@ -100,6 +116,19 @@ class MySqlGrammar extends Grammar return 'json_contains('.$field.', '.$value.$path.')'; } + /** + * Compile a "JSON contains key" statement into SQL. + * + * @param string $column + * @return string + */ + protected function compileJsonContainsKey($column) + { + [$field, $path] = $this->wrapJsonFieldAndPath($column); + + return 'ifnull(json_contains_path('.$field.', \'one\''.$path.'), 0)'; + } + /** * Compile a "JSON length" statement into SQL. * @@ -115,10 +144,21 @@ class MySqlGrammar extends Grammar return 'json_length('.$field.$path.') '.$operator.' '.$value; } + /** + * Compile a "JSON value cast" statement into SQL. + * + * @param string $value + * @return string + */ + public function compileJsonValueCast($value) + { + return 'cast('.$value.' as json)'; + } + /** * Compile the random statement into SQL. * - * @param string $seed + * @param string|int $seed * @return string */ public function compileRandom($seed) @@ -187,12 +227,24 @@ class MySqlGrammar extends Grammar */ public function compileUpsert(Builder $query, array $values, array $uniqueBy, array $update) { - $sql = $this->compileInsert($query, $values).' on duplicate key update '; + $useUpsertAlias = $query->connection->getConfig('use_upsert_alias'); - $columns = collect($update)->map(function ($value, $key) { - return is_numeric($key) - ? $this->wrap($value).' = values('.$this->wrap($value).')' - : $this->wrap($key).' = '.$this->parameter($value); + $sql = $this->compileInsert($query, $values); + + if ($useUpsertAlias) { + $sql .= ' as laravel_upsert_alias'; + } + + $sql .= ' on duplicate key update '; + + $columns = collect($update)->map(function ($value, $key) use ($useUpsertAlias) { + if (! is_numeric($key)) { + return $this->wrap($key).' = '.$this->parameter($value); + } + + return $useUpsertAlias + ? $this->wrap($value).' = '.$this->wrap('laravel_upsert_alias').'.'.$this->wrap($value) + : $this->wrap($value).' = values('.$this->wrap($value).')'; })->implode(', '); return $sql.$columns; diff --git a/vendor/illuminate/database/Query/Grammars/PostgresGrammar.php b/vendor/illuminate/database/Query/Grammars/PostgresGrammar.php index 6683e14..ad4678b 100755 --- a/vendor/illuminate/database/Query/Grammars/PostgresGrammar.php +++ b/vendor/illuminate/database/Query/Grammars/PostgresGrammar.php @@ -4,6 +4,7 @@ namespace Illuminate\Database\Query\Grammars; use Illuminate\Database\Query\Builder; use Illuminate\Support\Arr; +use Illuminate\Support\Str; class PostgresGrammar extends Grammar { @@ -215,6 +216,40 @@ class PostgresGrammar extends Grammar return '('.$column.')::jsonb @> '.$value; } + /** + * Compile a "JSON contains key" statement into SQL. + * + * @param string $column + * @return string + */ + protected function compileJsonContainsKey($column) + { + $segments = explode('->', $column); + + $lastSegment = array_pop($segments); + + if (filter_var($lastSegment, FILTER_VALIDATE_INT) !== false) { + $i = $lastSegment; + } elseif (preg_match('/\[(-?[0-9]+)\]$/', $lastSegment, $matches)) { + $segments[] = Str::beforeLast($lastSegment, $matches[0]); + + $i = $matches[1]; + } + + $column = str_replace('->>', '->', $this->wrap(implode('->', $segments))); + + if (isset($i)) { + return vsprintf('case when %s then %s else false end', [ + 'jsonb_typeof(('.$column.")::jsonb) = 'array'", + 'jsonb_array_length(('.$column.')::jsonb) >= '.($i < 0 ? abs($i) : $i + 1), + ]); + } + + $key = "'".str_replace("'", "''", $lastSegment)."'"; + + return 'coalesce(('.$column.')::jsonb ?? '.$key.', false)'; + } + /** * Compile a "JSON length" statement into SQL. * @@ -374,7 +409,7 @@ class PostgresGrammar extends Grammar $field = $this->wrap(array_shift($segments)); - $path = '\'{"'.implode('","', $segments).'"}\''; + $path = "'{".implode(',', $this->wrapJsonPathAttributes($segments, '"'))."}'"; return "{$field} = jsonb_set({$field}::jsonb, {$path}, {$this->parameter($value)})"; } @@ -623,17 +658,44 @@ class PostgresGrammar extends Grammar } /** - * Wrap the attributes of the give JSON path. + * Wrap the attributes of the given JSON path. * * @param array $path * @return array */ protected function wrapJsonPathAttributes($path) { - return array_map(function ($attribute) { + $quote = func_num_args() === 2 ? func_get_arg(1) : "'"; + + return collect($path)->map(function ($attribute) { + return $this->parseJsonPathArrayKeys($attribute); + })->collapse()->map(function ($attribute) use ($quote) { return filter_var($attribute, FILTER_VALIDATE_INT) !== false ? $attribute - : "'$attribute'"; - }, $path); + : $quote.$attribute.$quote; + })->all(); + } + + /** + * Parse the given JSON path attribute for array keys. + * + * @param string $attribute + * @return array + */ + protected function parseJsonPathArrayKeys($attribute) + { + if (preg_match('/(\[[^\]]+\])+$/', $attribute, $parts)) { + $key = Str::beforeLast($attribute, $parts[0]); + + preg_match_all('/\[([^\]]+)\]/', $parts[0], $keys); + + return collect([$key]) + ->merge($keys[1]) + ->diff('') + ->values() + ->all(); + } + + return [$attribute]; } } diff --git a/vendor/illuminate/database/Query/Grammars/SQLiteGrammar.php b/vendor/illuminate/database/Query/Grammars/SQLiteGrammar.php index 29a3796..8bf7d39 100755 --- a/vendor/illuminate/database/Query/Grammars/SQLiteGrammar.php +++ b/vendor/illuminate/database/Query/Grammars/SQLiteGrammar.php @@ -117,6 +117,20 @@ class SQLiteGrammar extends Grammar return "strftime('{$type}', {$this->wrap($where['column'])}) {$where['operator']} cast({$value} as text)"; } + /** + * Compile the index hints for the query. + * + * @param \Illuminate\Database\Query\Builder $query + * @param \Illuminate\Database\Query\IndexHint $indexHint + * @return string + */ + protected function compileIndexHint(Builder $query, $indexHint) + { + return $indexHint->type === 'force' + ? "indexed by {$indexHint->index}" + : ''; + } + /** * Compile a "JSON length" statement into SQL. * @@ -132,6 +146,19 @@ class SQLiteGrammar extends Grammar return 'json_array_length('.$field.$path.') '.$operator.' '.$value; } + /** + * Compile a "JSON contains key" statement into SQL. + * + * @param string $column + * @return string + */ + protected function compileJsonContainsKey($column) + { + [$field, $path] = $this->wrapJsonFieldAndPath($column); + + return 'json_type('.$field.$path.') is not null'; + } + /** * Compile an update statement into SQL. * diff --git a/vendor/illuminate/database/Query/Grammars/SqlServerGrammar.php b/vendor/illuminate/database/Query/Grammars/SqlServerGrammar.php index e717051..baebb93 100755 --- a/vendor/illuminate/database/Query/Grammars/SqlServerGrammar.php +++ b/vendor/illuminate/database/Query/Grammars/SqlServerGrammar.php @@ -96,6 +96,20 @@ class SqlServerGrammar extends Grammar return $from; } + /** + * Compile the index hints for the query. + * + * @param \Illuminate\Database\Query\Builder $query + * @param \Illuminate\Database\Query\IndexHint $indexHint + * @return string + */ + protected function compileIndexHint(Builder $query, $indexHint) + { + return $indexHint->type === 'force' + ? "with (index({$indexHint->index}))" + : ''; + } + /** * {@inheritdoc} * @@ -165,6 +179,31 @@ class SqlServerGrammar extends Grammar return is_bool($binding) ? json_encode($binding) : $binding; } + /** + * Compile a "JSON contains key" statement into SQL. + * + * @param string $column + * @return string + */ + protected function compileJsonContainsKey($column) + { + $segments = explode('->', $column); + + $lastSegment = array_pop($segments); + + if (preg_match('/\[([0-9]+)\]$/', $lastSegment, $matches)) { + $segments[] = Str::beforeLast($lastSegment, $matches[0]); + + $key = $matches[1]; + } else { + $key = "'".str_replace("'", "''", $lastSegment)."'"; + } + + [$field, $path] = $this->wrapJsonFieldAndPath(implode('->', $segments)); + + return $key.' in (select [key] from openjson('.$field.$path.'))'; + } + /** * Compile a "JSON length" statement into SQL. * @@ -180,6 +219,17 @@ class SqlServerGrammar extends Grammar return '(select count(*) from openjson('.$field.$path.')) '.$operator.' '.$value; } + /** + * Compile a "JSON value cast" statement into SQL. + * + * @param string $value + * @return string + */ + public function compileJsonValueCast($value) + { + return 'json_query('.$value.')'; + } + /** * Compile a single having clause. * @@ -339,7 +389,7 @@ class SqlServerGrammar extends Grammar /** * Compile the random statement into SQL. * - * @param string $seed + * @param string|int $seed * @return string */ public function compileRandom($seed) diff --git a/vendor/illuminate/database/Query/IndexHint.php b/vendor/illuminate/database/Query/IndexHint.php new file mode 100755 index 0000000..2a720a2 --- /dev/null +++ b/vendor/illuminate/database/Query/IndexHint.php @@ -0,0 +1,33 @@ +type = $type; + $this->index = $index; + } +} diff --git a/vendor/illuminate/database/SQLiteDatabaseDoesNotExistException.php b/vendor/illuminate/database/SQLiteDatabaseDoesNotExistException.php new file mode 100644 index 0000000..f93cfe4 --- /dev/null +++ b/vendor/illuminate/database/SQLiteDatabaseDoesNotExistException.php @@ -0,0 +1,28 @@ +path = $path; + } +} diff --git a/vendor/illuminate/database/Schema/Blueprint.php b/vendor/illuminate/database/Schema/Blueprint.php index 7d1f059..3ea7d15 100755 --- a/vendor/illuminate/database/Schema/Blueprint.php +++ b/vendor/illuminate/database/Schema/Blueprint.php @@ -152,7 +152,8 @@ class Blueprint protected function ensureCommandsAreValid(Connection $connection) { if ($connection instanceof SQLiteConnection) { - if ($this->commandsNamed(['dropColumn', 'renameColumn'])->count() > 1) { + if ($this->commandsNamed(['dropColumn', 'renameColumn'])->count() > 1 + && ! $connection->usingNativeSchemaOperations()) { throw new BadMethodCallException( "SQLite doesn't support multiple calls to dropColumn / renameColumn in a single modification." ); @@ -214,7 +215,17 @@ class Blueprint // index method can be called without a name and it will generate one. if ($column->{$index} === true) { $this->{$index}($column->name); - $column->{$index} = false; + $column->{$index} = null; + + continue 2; + } + + // If the index has been specified on the given column, but it equals false + // and the column is supposed to be changed, we will call the drop index + // method with an array of column to drop it by its conventional name. + elseif ($column->{$index} === false && $column->change) { + $this->{'drop'.ucfirst($index)}([$column->name]); + $column->{$index} = null; continue 2; } @@ -224,7 +235,7 @@ class Blueprint // the index since the developer specified the explicit name for this. elseif (isset($column->{$index})) { $this->{$index}($column->name, $column->{$index}); - $column->{$index} = false; + $column->{$index} = null; continue 2; } @@ -540,7 +551,7 @@ class Blueprint * @param string|array $columns * @param string|null $name * @param string|null $algorithm - * @return \Illuminate\Support\Fluent + * @return \Illuminate\Database\Schema\IndexDefinition */ public function primary($columns, $name = null, $algorithm = null) { @@ -553,7 +564,7 @@ class Blueprint * @param string|array $columns * @param string|null $name * @param string|null $algorithm - * @return \Illuminate\Support\Fluent + * @return \Illuminate\Database\Schema\IndexDefinition */ public function unique($columns, $name = null, $algorithm = null) { @@ -566,7 +577,7 @@ class Blueprint * @param string|array $columns * @param string|null $name * @param string|null $algorithm - * @return \Illuminate\Support\Fluent + * @return \Illuminate\Database\Schema\IndexDefinition */ public function index($columns, $name = null, $algorithm = null) { @@ -579,7 +590,7 @@ class Blueprint * @param string|array $columns * @param string|null $name * @param string|null $algorithm - * @return \Illuminate\Support\Fluent + * @return \Illuminate\Database\Schema\IndexDefinition */ public function fullText($columns, $name = null, $algorithm = null) { @@ -591,7 +602,7 @@ class Blueprint * * @param string|array $columns * @param string|null $name - * @return \Illuminate\Support\Fluent + * @return \Illuminate\Database\Schema\IndexDefinition */ public function spatialIndex($columns, $name = null) { @@ -603,7 +614,7 @@ class Blueprint * * @param string $expression * @param string $name - * @return \Illuminate\Support\Fluent + * @return \Illuminate\Database\Schema\IndexDefinition */ public function rawIndex($expression, $name) { @@ -1089,7 +1100,7 @@ class Blueprint * Create a new date-time column on the table. * * @param string $column - * @param int $precision + * @param int|null $precision * @return \Illuminate\Database\Schema\ColumnDefinition */ public function dateTime($column, $precision = 0) @@ -1101,7 +1112,7 @@ class Blueprint * Create a new date-time column (with time zone) on the table. * * @param string $column - * @param int $precision + * @param int|null $precision * @return \Illuminate\Database\Schema\ColumnDefinition */ public function dateTimeTz($column, $precision = 0) @@ -1113,7 +1124,7 @@ class Blueprint * Create a new time column on the table. * * @param string $column - * @param int $precision + * @param int|null $precision * @return \Illuminate\Database\Schema\ColumnDefinition */ public function time($column, $precision = 0) @@ -1125,7 +1136,7 @@ class Blueprint * Create a new time column (with time zone) on the table. * * @param string $column - * @param int $precision + * @param int|null $precision * @return \Illuminate\Database\Schema\ColumnDefinition */ public function timeTz($column, $precision = 0) @@ -1137,7 +1148,7 @@ class Blueprint * Create a new timestamp column on the table. * * @param string $column - * @param int $precision + * @param int|null $precision * @return \Illuminate\Database\Schema\ColumnDefinition */ public function timestamp($column, $precision = 0) @@ -1149,7 +1160,7 @@ class Blueprint * Create a new timestamp (with time zone) column on the table. * * @param string $column - * @param int $precision + * @param int|null $precision * @return \Illuminate\Database\Schema\ColumnDefinition */ public function timestampTz($column, $precision = 0) @@ -1160,7 +1171,7 @@ class Blueprint /** * Add nullable creation and update timestamps to the table. * - * @param int $precision + * @param int|null $precision * @return void */ public function timestamps($precision = 0) @@ -1175,7 +1186,7 @@ class Blueprint * * Alias for self::timestamps(). * - * @param int $precision + * @param int|null $precision * @return void */ public function nullableTimestamps($precision = 0) @@ -1186,7 +1197,7 @@ class Blueprint /** * Add creation and update timestampTz columns to the table. * - * @param int $precision + * @param int|null $precision * @return void */ public function timestampsTz($precision = 0) @@ -1200,7 +1211,7 @@ class Blueprint * Add a "deleted at" timestamp for the table. * * @param string $column - * @param int $precision + * @param int|null $precision * @return \Illuminate\Database\Schema\ColumnDefinition */ public function softDeletes($column = 'deleted_at', $precision = 0) @@ -1212,7 +1223,7 @@ class Blueprint * Add a "deleted at" timestampTz for the table. * * @param string $column - * @param int $precision + * @param int|null $precision * @return \Illuminate\Database\Schema\ColumnDefinition */ public function softDeletesTz($column = 'deleted_at', $precision = 0) @@ -1243,7 +1254,7 @@ class Blueprint } /** - * Create a new uuid column on the table. + * Create a new UUID column on the table. * * @param string $column * @return \Illuminate\Database\Schema\ColumnDefinition @@ -1267,6 +1278,34 @@ class Blueprint ])); } + /** + * Create a new ULID column on the table. + * + * @param string $column + * @param int|null $length + * @return \Illuminate\Database\Schema\ColumnDefinition + */ + public function ulid($column = 'uuid', $length = 26) + { + return $this->char($column, $length); + } + + /** + * Create a new ULID column on the table with a foreign key constraint. + * + * @param string $column + * @param int|null $length + * @return \Illuminate\Database\Schema\ForeignIdColumnDefinition + */ + public function foreignUlid($column, $length = 26) + { + return $this->addColumnDefinition(new ForeignIdColumnDefinition($this, [ + 'type' => 'char', + 'name' => $column, + 'length' => $length, + ])); + } + /** * Create a new IP address column on the table. * @@ -1412,6 +1451,8 @@ class Blueprint { if (Builder::$defaultMorphKeyType === 'uuid') { $this->uuidMorphs($name, $indexName); + } elseif (Builder::$defaultMorphKeyType === 'ulid') { + $this->ulidMorphs($name, $indexName); } else { $this->numericMorphs($name, $indexName); } @@ -1428,6 +1469,8 @@ class Blueprint { if (Builder::$defaultMorphKeyType === 'uuid') { $this->nullableUuidMorphs($name, $indexName); + } elseif (Builder::$defaultMorphKeyType === 'ulid') { + $this->nullableUlidMorphs($name, $indexName); } else { $this->nullableNumericMorphs($name, $indexName); } @@ -1497,6 +1540,38 @@ class Blueprint $this->index(["{$name}_type", "{$name}_id"], $indexName); } + /** + * Add the proper columns for a polymorphic table using ULIDs. + * + * @param string $name + * @param string|null $indexName + * @return void + */ + public function ulidMorphs($name, $indexName = null) + { + $this->string("{$name}_type"); + + $this->ulid("{$name}_id"); + + $this->index(["{$name}_type", "{$name}_id"], $indexName); + } + + /** + * Add nullable columns for a polymorphic table using ULIDs. + * + * @param string $name + * @param string|null $indexName + * @return void + */ + public function nullableUlidMorphs($name, $indexName = null) + { + $this->string("{$name}_type")->nullable(); + + $this->ulid("{$name}_id")->nullable(); + + $this->index(["{$name}_type", "{$name}_id"], $indexName); + } + /** * Adds the `remember_token` column to the table. * @@ -1507,6 +1582,17 @@ class Blueprint return $this->string('remember_token', 100)->nullable(); } + /** + * Add a comment to the table. + * + * @param string $comment + * @return \Illuminate\Support\Fluent + */ + public function comment($comment) + { + return $this->addCommand('tableComment', compact('comment')); + } + /** * Add a new index command to the blueprint. * diff --git a/vendor/illuminate/database/Schema/Builder.php b/vendor/illuminate/database/Schema/Builder.php index dd4290a..88cd965 100755 --- a/vendor/illuminate/database/Schema/Builder.php +++ b/vendor/illuminate/database/Schema/Builder.php @@ -34,7 +34,7 @@ class Builder /** * The default string length for migrations. * - * @var int + * @var int|null */ public static $defaultStringLength = 255; @@ -45,6 +45,13 @@ class Builder */ public static $defaultMorphKeyType = 'int'; + /** + * Indicates whether Doctrine DBAL usage will be prevented if possible when dropping and renaming columns. + * + * @var bool + */ + public static $alwaysUsesNativeSchemaOperationsIfPossible = false; + /** * Create a new database Schema manager. * @@ -78,8 +85,8 @@ class Builder */ public static function defaultMorphKeyType(string $type) { - if (! in_array($type, ['int', 'uuid'])) { - throw new InvalidArgumentException("Morph key type must be 'int' or 'uuid'."); + if (! in_array($type, ['int', 'uuid', 'ulid'])) { + throw new InvalidArgumentException("Morph key type must be 'int', 'uuid', or 'ulid'."); } static::$defaultMorphKeyType = $type; @@ -95,6 +102,27 @@ class Builder return static::defaultMorphKeyType('uuid'); } + /** + * Set the default morph key type for migrations to ULIDs. + * + * @return void + */ + public static function morphUsingUlids() + { + return static::defaultMorphKeyType('ulid'); + } + + /** + * Attempt to use native schema operations for dropping and renaming columns, even if Doctrine DBAL is installed. + * + * @param bool $value + * @return void + */ + public static function useNativeSchemaOperationsIfPossible(bool $value = true) + { + static::$alwaysUsesNativeSchemaOperationsIfPossible = $value; + } + /** * Create a database in the schema. * @@ -170,6 +198,36 @@ class Builder return true; } + /** + * Execute a table builder callback if the given table has a given column. + * + * @param string $table + * @param string $column + * @param \Closure $callback + * @return void + */ + public function whenTableHasColumn(string $table, string $column, Closure $callback) + { + if ($this->hasColumn($table, $column)) { + $this->table($table, fn (Blueprint $table) => $callback($table)); + } + } + + /** + * Execute a table builder callback if the given table doesn't have a given column. + * + * @param string $table + * @param string $column + * @param \Closure $callback + * @return void + */ + public function whenTableDoesntHaveColumn(string $table, string $column, Closure $callback) + { + if (! $this->hasColumn($table, $column)) { + $this->table($table, fn (Blueprint $table) => $callback($table)); + } + } + /** * Get the data type for the given column name. * @@ -353,6 +411,23 @@ class Builder ); } + /** + * Disable foreign key constraints during the execution of a callback. + * + * @param \Closure $callback + * @return mixed + */ + public function withoutForeignKeyConstraints(Closure $callback) + { + $this->disableForeignKeyConstraints(); + + $result = $callback(); + + $this->enableForeignKeyConstraints(); + + return $result; + } + /** * Execute the blueprint to build / modify the table. * diff --git a/vendor/illuminate/database/Schema/ColumnDefinition.php b/vendor/illuminate/database/Schema/ColumnDefinition.php index 85f8ba3..51265ac 100644 --- a/vendor/illuminate/database/Schema/ColumnDefinition.php +++ b/vendor/illuminate/database/Schema/ColumnDefinition.php @@ -6,7 +6,7 @@ use Illuminate\Support\Fluent; /** * @method $this after(string $column) Place the column "after" another column (MySQL) - * @method $this always() Used as a modifier for generatedAs() (PostgreSQL) + * @method $this always(bool $value = true) Used as a modifier for generatedAs() (PostgreSQL) * @method $this autoIncrement() Set INTEGER columns as auto-increment (primary key) * @method $this change() Change the column * @method $this charset(string $charset) Specify a character set for the column (MySQL) diff --git a/vendor/illuminate/database/Schema/ForeignIdColumnDefinition.php b/vendor/illuminate/database/Schema/ForeignIdColumnDefinition.php index 1a2059e..354b248 100644 --- a/vendor/illuminate/database/Schema/ForeignIdColumnDefinition.php +++ b/vendor/illuminate/database/Schema/ForeignIdColumnDefinition.php @@ -36,7 +36,7 @@ class ForeignIdColumnDefinition extends ColumnDefinition */ public function constrained($table = null, $column = 'id') { - return $this->references($column)->on($table ?? Str::plural(Str::beforeLast($this->name, '_'.$column))); + return $this->references($column)->on($table ?? Str::of($this->name)->beforeLast('_'.$column)->plural()); } /** diff --git a/vendor/illuminate/database/Schema/ForeignKeyDefinition.php b/vendor/illuminate/database/Schema/ForeignKeyDefinition.php index a03fcff..3bb8b71 100644 --- a/vendor/illuminate/database/Schema/ForeignKeyDefinition.php +++ b/vendor/illuminate/database/Schema/ForeignKeyDefinition.php @@ -63,4 +63,14 @@ class ForeignKeyDefinition extends Fluent { return $this->onDelete('set null'); } + + /** + * Indicate that deletes should have "no action". + * + * @return $this + */ + public function noActionOnDelete() + { + return $this->onDelete('no action'); + } } diff --git a/vendor/illuminate/database/Schema/Grammars/ChangeColumn.php b/vendor/illuminate/database/Schema/Grammars/ChangeColumn.php index 70ec666..9579222 100644 --- a/vendor/illuminate/database/Schema/Grammars/ChangeColumn.php +++ b/vendor/illuminate/database/Schema/Grammars/ChangeColumn.php @@ -121,7 +121,7 @@ class ChangeColumn { $options = ['type' => static::getDoctrineColumnType($fluent['type'])]; - if (in_array($fluent['type'], ['text', 'mediumText', 'longText'])) { + if (in_array($fluent['type'], ['tinyText', 'text', 'mediumText', 'longText'])) { $options['length'] = static::calculateDoctrineTextLength($fluent['type']); } @@ -152,10 +152,11 @@ class ChangeColumn return Type::getType(match ($type) { 'biginteger' => 'bigint', 'smallinteger' => 'smallint', - 'mediumtext', 'longtext' => 'text', + 'tinytext', 'mediumtext', 'longtext' => 'text', 'binary' => 'blob', 'uuid' => 'guid', 'char' => 'string', + 'double' => 'float', default => $type, }); } @@ -169,6 +170,7 @@ class ChangeColumn protected static function calculateDoctrineTextLength($type) { return match ($type) { + 'tinyText' => 1, 'mediumText' => 65535 + 1, 'longText' => 16777215 + 1, default => 255 + 1, @@ -197,6 +199,7 @@ class ChangeColumn 'mediumInteger', 'smallInteger', 'time', + 'timestamp', 'tinyInteger', ]); } diff --git a/vendor/illuminate/database/Schema/Grammars/Grammar.php b/vendor/illuminate/database/Schema/Grammars/Grammar.php index ff2c455..ea8333e 100755 --- a/vendor/illuminate/database/Schema/Grammars/Grammar.php +++ b/vendor/illuminate/database/Schema/Grammars/Grammar.php @@ -4,6 +4,7 @@ namespace Illuminate\Database\Schema\Grammars; use Doctrine\DBAL\Schema\AbstractSchemaManager as SchemaManager; use Doctrine\DBAL\Schema\TableDiff; +use Illuminate\Database\Concerns\CompilesJsonPaths; use Illuminate\Database\Connection; use Illuminate\Database\Grammar as BaseGrammar; use Illuminate\Database\Query\Expression; @@ -14,6 +15,8 @@ use RuntimeException; abstract class Grammar extends BaseGrammar { + use CompilesJsonPaths; + /** * If this Grammar supports schema changes wrapped in a transaction. * @@ -61,7 +64,7 @@ abstract class Grammar extends BaseGrammar * @param \Illuminate\Database\Schema\Blueprint $blueprint * @param \Illuminate\Support\Fluent $command * @param \Illuminate\Database\Connection $connection - * @return array + * @return array|string */ public function compileRenameColumn(Blueprint $blueprint, Fluent $command, Connection $connection) { @@ -162,7 +165,7 @@ abstract class Grammar extends BaseGrammar $columns = []; foreach ($blueprint->getAddedColumns() as $column) { - // Each of the column types have their own compiler functions which are tasked + // Each of the column types has their own compiler functions, which are tasked // with turning the column definition into its SQL format for this platform // used by the connection. The column's modifiers are compiled and added. $sql = $this->wrap($column).' '.$this->getType($column); @@ -273,37 +276,6 @@ abstract class Grammar extends BaseGrammar ); } - /** - * Split the given JSON selector into the field and the optional path and wrap them separately. - * - * @param string $column - * @return array - */ - protected function wrapJsonFieldAndPath($column) - { - $parts = explode('->', $column, 2); - - $field = $this->wrap($parts[0]); - - $path = count($parts) > 1 ? ', '.$this->wrapJsonPath($parts[1], '->') : ''; - - return [$field, $path]; - } - - /** - * Wrap the given JSON path. - * - * @param string $value - * @param string $delimiter - * @return string - */ - protected function wrapJsonPath($value, $delimiter = '->') - { - $value = preg_replace("/([\\\\]+)?\\'/", "''", $value); - - return '\'$."'.str_replace($delimiter, '"."', $value).'"\''; - } - /** * Wrap a value in keyword identifiers. * diff --git a/vendor/illuminate/database/Schema/Grammars/MySqlGrammar.php b/vendor/illuminate/database/Schema/Grammars/MySqlGrammar.php index 78f5a9c..f87acfd 100755 --- a/vendor/illuminate/database/Schema/Grammars/MySqlGrammar.php +++ b/vendor/illuminate/database/Schema/Grammars/MySqlGrammar.php @@ -203,6 +203,25 @@ class MySqlGrammar extends Grammar })->all(); } + /** + * Compile a rename column command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @param \Illuminate\Database\Connection $connection + * @return array|string + */ + public function compileRenameColumn(Blueprint $blueprint, Fluent $command, Connection $connection) + { + return $connection->usingNativeSchemaOperations() + ? sprintf('alter table %s rename column %s to %s', + $this->wrapTable($blueprint), + $this->wrap($command->from), + $this->wrap($command->to) + ) + : parent::compileRenameColumn($blueprint, $command, $connection); + } + /** * Compile a primary key command. * @@ -212,9 +231,11 @@ class MySqlGrammar extends Grammar */ public function compilePrimary(Blueprint $blueprint, Fluent $command) { - $command->name(null); - - return $this->compileKey($blueprint, $command, 'primary key'); + return sprintf('alter table %s add primary key %s(%s)', + $this->wrapTable($blueprint), + $command->algorithm ? 'using '.$command->algorithm : '', + $this->columnize($command->columns) + ); } /** @@ -492,6 +513,21 @@ class MySqlGrammar extends Grammar return 'SET FOREIGN_KEY_CHECKS=0;'; } + /** + * Compile a table comment command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @return string + */ + public function compileTableComment(Blueprint $blueprint, Fluent $command) + { + return sprintf('alter table %s comment = %s', + $this->wrapTable($blueprint), + "'".str_replace("'", "''", $command->comment)."'" + ); + } + /** * Create the column definition for a char type. * diff --git a/vendor/illuminate/database/Schema/Grammars/PostgresGrammar.php b/vendor/illuminate/database/Schema/Grammars/PostgresGrammar.php index 603eb24..ef60d0f 100755 --- a/vendor/illuminate/database/Schema/Grammars/PostgresGrammar.php +++ b/vendor/illuminate/database/Schema/Grammars/PostgresGrammar.php @@ -2,6 +2,7 @@ namespace Illuminate\Database\Schema\Grammars; +use Illuminate\Database\Connection; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Fluent; @@ -129,6 +130,25 @@ class PostgresGrammar extends Grammar })->all(); } + /** + * Compile a rename column command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @param \Illuminate\Database\Connection $connection + * @return array|string + */ + public function compileRenameColumn(Blueprint $blueprint, Fluent $command, Connection $connection) + { + return $connection->usingNativeSchemaOperations() + ? sprintf('alter table %s rename column %s to %s', + $this->wrapTable($blueprint), + $this->wrap($command->from), + $this->wrap($command->to) + ) + : parent::compileRenameColumn($blueprint, $command, $connection); + } + /** * Compile a primary key command. * @@ -152,11 +172,21 @@ class PostgresGrammar extends Grammar */ public function compileUnique(Blueprint $blueprint, Fluent $command) { - return sprintf('alter table %s add constraint %s unique (%s)', + $sql = sprintf('alter table %s add constraint %s unique (%s)', $this->wrapTable($blueprint), $this->wrap($command->index), $this->columnize($command->columns) ); + + if (! is_null($command->deferrable)) { + $sql .= $command->deferrable ? ' deferrable' : ' not deferrable'; + } + + if ($command->deferrable && ! is_null($command->initiallyImmediate)) { + $sql .= $command->initiallyImmediate ? ' initially immediate' : ' initially deferred'; + } + + return $sql; } /** @@ -272,7 +302,7 @@ class PostgresGrammar extends Grammar */ public function compileDropAllTables($tables) { - return 'drop table "'.implode('","', $tables).'" cascade'; + return 'drop table '.implode(',', $this->escapeNames($tables)).' cascade'; } /** @@ -283,7 +313,7 @@ class PostgresGrammar extends Grammar */ public function compileDropAllViews($views) { - return 'drop view "'.implode('","', $views).'" cascade'; + return 'drop view '.implode(',', $this->escapeNames($views)).' cascade'; } /** @@ -294,7 +324,7 @@ class PostgresGrammar extends Grammar */ public function compileDropAllTypes($types) { - return 'drop type "'.implode('","', $types).'" cascade'; + return 'drop type '.implode(',', $this->escapeNames($types)).' cascade'; } /** @@ -305,7 +335,7 @@ class PostgresGrammar extends Grammar */ public function compileGetAllTables($searchPath) { - return "select tablename from pg_catalog.pg_tables where schemaname in ('".implode("','", (array) $searchPath)."')"; + return "select tablename, concat('\"', schemaname, '\".\"', tablename, '\"') as qualifiedname from pg_catalog.pg_tables where schemaname in ('".implode("','", (array) $searchPath)."')"; } /** @@ -316,7 +346,7 @@ class PostgresGrammar extends Grammar */ public function compileGetAllViews($searchPath) { - return "select viewname from pg_catalog.pg_views where schemaname in ('".implode("','", (array) $searchPath)."')"; + return "select viewname, concat('\"', schemaname, '\".\"', viewname, '\"') as qualifiedname from pg_catalog.pg_views where schemaname in ('".implode("','", (array) $searchPath)."')"; } /** @@ -486,6 +516,36 @@ class PostgresGrammar extends Grammar ); } + /** + * Compile a table comment command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @return string + */ + public function compileTableComment(Blueprint $blueprint, Fluent $command) + { + return sprintf('comment on table %s is %s', + $this->wrapTable($blueprint), + "'".str_replace("'", "''", $command->comment)."'" + ); + } + + /** + * Quote-escape the given tables, views, or types. + * + * @param array $names + * @return array + */ + public function escapeNames($names) + { + return array_map(static function ($name) { + return '"'.collect(explode('.', $name)) + ->map(fn ($segment) => trim($segment, '\'"')) + ->implode('"."').'"'; + }, $names); + } + /** * Create the column definition for a char type. * @@ -494,7 +554,11 @@ class PostgresGrammar extends Grammar */ protected function typeChar(Fluent $column) { - return "char({$column->length})"; + if ($column->length) { + return "char({$column->length})"; + } + + return 'char'; } /** @@ -505,7 +569,11 @@ class PostgresGrammar extends Grammar */ protected function typeString(Fluent $column) { - return "varchar({$column->length})"; + if ($column->length) { + return "varchar({$column->length})"; + } + + return 'varchar'; } /** diff --git a/vendor/illuminate/database/Schema/Grammars/SQLiteGrammar.php b/vendor/illuminate/database/Schema/Grammars/SQLiteGrammar.php index 4abdf65..c9d1c55 100755 --- a/vendor/illuminate/database/Schema/Grammars/SQLiteGrammar.php +++ b/vendor/illuminate/database/Schema/Grammars/SQLiteGrammar.php @@ -144,6 +144,25 @@ class SQLiteGrammar extends Grammar })->all(); } + /** + * Compile a rename column command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @param \Illuminate\Database\Connection $connection + * @return array|string + */ + public function compileRenameColumn(Blueprint $blueprint, Fluent $command, Connection $connection) + { + return $connection->usingNativeSchemaOperations() + ? sprintf('alter table %s rename column %s to %s', + $this->wrapTable($blueprint), + $this->wrap($command->from), + $this->wrap($command->to) + ) + : parent::compileRenameColumn($blueprint, $command, $connection); + } + /** * Compile a unique key command. * @@ -246,6 +265,26 @@ class SQLiteGrammar extends Grammar return "delete from sqlite_master where type in ('view')"; } + /** + * Compile the SQL needed to retrieve all table names. + * + * @return string + */ + public function compileGetAllTables() + { + return 'select type, name from sqlite_master where type = \'table\' and name not like \'sqlite_%\''; + } + + /** + * Compile the SQL needed to retrieve all view names. + * + * @return string + */ + public function compileGetAllViews() + { + return 'select type, name from sqlite_master where type = \'view\''; + } + /** * Compile the SQL needed to rebuild the database. * @@ -266,17 +305,26 @@ class SQLiteGrammar extends Grammar */ public function compileDropColumn(Blueprint $blueprint, Fluent $command, Connection $connection) { - $tableDiff = $this->getDoctrineTableDiff( - $blueprint, $schema = $connection->getDoctrineSchemaManager() - ); + if ($connection->usingNativeSchemaOperations()) { + $table = $this->wrapTable($blueprint); - foreach ($command->columns as $name) { - $tableDiff->removedColumns[$name] = $connection->getDoctrineColumn( - $this->getTablePrefix().$blueprint->getTable(), $name + $columns = $this->prefixArray('drop column', $this->wrapArray($command->columns)); + + return collect($columns)->map(fn ($column) => 'alter table '.$table.' '.$column + )->all(); + } else { + $tableDiff = $this->getDoctrineTableDiff( + $blueprint, $schema = $connection->getDoctrineSchemaManager() ); - } - return (array) $schema->getDatabasePlatform()->getAlterTableSQL($tableDiff); + foreach ($command->columns as $name) { + $tableDiff->removedColumns[$name] = $connection->getDoctrineColumn( + $this->getTablePrefix().$blueprint->getTable(), $name + ); + } + + return (array) $schema->getDatabasePlatform()->getAlterTableSQL($tableDiff); + } } /** diff --git a/vendor/illuminate/database/Schema/Grammars/SqlServerGrammar.php b/vendor/illuminate/database/Schema/Grammars/SqlServerGrammar.php index e594cfd..4d7271c 100755 --- a/vendor/illuminate/database/Schema/Grammars/SqlServerGrammar.php +++ b/vendor/illuminate/database/Schema/Grammars/SqlServerGrammar.php @@ -2,6 +2,7 @@ namespace Illuminate\Database\Schema\Grammars; +use Illuminate\Database\Connection; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Fluent; @@ -107,6 +108,24 @@ class SqlServerGrammar extends Grammar ); } + /** + * Compile a rename column command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @param \Illuminate\Database\Connection $connection + * @return array|string + */ + public function compileRenameColumn(Blueprint $blueprint, Fluent $command, Connection $connection) + { + return $connection->usingNativeSchemaOperations() + ? sprintf("sp_rename '%s', %s, 'COLUMN'", + $this->wrap($blueprint->getTable().'.'.$command->from), + $this->wrap($command->to) + ) + : parent::compileRenameColumn($blueprint, $command, $connection); + } + /** * Compile a primary key command. * @@ -393,6 +412,26 @@ class SqlServerGrammar extends Grammar EXEC sp_executesql @sql;"; } + /** + * Compile the SQL needed to retrieve all table names. + * + * @return string + */ + public function compileGetAllTables() + { + return "select name, type from sys.tables where type = 'U'"; + } + + /** + * Compile the SQL needed to retrieve all view names. + * + * @return string + */ + public function compileGetAllViews() + { + return "select name, type from sys.objects where type = 'V'"; + } + /** * Create the column definition for a char type. * diff --git a/vendor/illuminate/database/Schema/IndexDefinition.php b/vendor/illuminate/database/Schema/IndexDefinition.php new file mode 100644 index 0000000..fc5d78e --- /dev/null +++ b/vendor/illuminate/database/Schema/IndexDefinition.php @@ -0,0 +1,16 @@ +connection->getTablePrefix().$table; - return count($this->connection->select( + return count($this->connection->selectFromWriteConnection( $this->grammar->compileTableExists(), [$this->connection->getDatabaseName(), $table] )) > 0; } @@ -55,7 +55,7 @@ class MySqlBuilder extends Builder { $table = $this->connection->getTablePrefix().$table; - $results = $this->connection->select( + $results = $this->connection->selectFromWriteConnection( $this->grammar->compileColumnListing(), [$this->connection->getDatabaseName(), $table] ); diff --git a/vendor/illuminate/database/Schema/MySqlSchemaState.php b/vendor/illuminate/database/Schema/MySqlSchemaState.php index d28ab10..0cd3486 100644 --- a/vendor/illuminate/database/Schema/MySqlSchemaState.php +++ b/vendor/illuminate/database/Schema/MySqlSchemaState.php @@ -85,10 +85,10 @@ class MySqlSchemaState extends SchemaState */ protected function baseDumpCommand() { - $command = 'mysqldump '.$this->connectionString().' --no-tablespaces --skip-add-locks --skip-comments --skip-set-charset --tz-utc'; + $command = 'mysqldump '.$this->connectionString().' --no-tablespaces --skip-add-locks --skip-comments --skip-set-charset --tz-utc --column-statistics=0'; if (! $this->connection->isMaria()) { - $command .= ' --column-statistics=0 --set-gtid-purged=OFF'; + $command .= ' --set-gtid-purged=OFF'; } return $command.' "${:LARAVEL_LOAD_DATABASE}"'; diff --git a/vendor/illuminate/database/Schema/PostgresBuilder.php b/vendor/illuminate/database/Schema/PostgresBuilder.php index f0f8662..adfbd68 100755 --- a/vendor/illuminate/database/Schema/PostgresBuilder.php +++ b/vendor/illuminate/database/Schema/PostgresBuilder.php @@ -48,7 +48,7 @@ class PostgresBuilder extends Builder $table = $this->connection->getTablePrefix().$table; - return count($this->connection->select( + return count($this->connection->selectFromWriteConnection( $this->grammar->compileTableExists(), [$database, $schema, $table] )) > 0; } @@ -62,15 +62,15 @@ class PostgresBuilder extends Builder { $tables = []; - $excludedTables = $this->connection->getConfig('dont_drop') ?? ['spatial_ref_sys']; + $excludedTables = $this->grammar->escapeNames( + $this->connection->getConfig('dont_drop') ?? ['spatial_ref_sys'] + ); foreach ($this->getAllTables() as $row) { $row = (array) $row; - $table = reset($row); - - if (! in_array($table, $excludedTables)) { - $tables[] = $table; + if (empty(array_intersect($this->grammar->escapeNames($row), $excludedTables))) { + $tables[] = $row['qualifiedname'] ?? reset($row); } } @@ -95,7 +95,7 @@ class PostgresBuilder extends Builder foreach ($this->getAllViews() as $row) { $row = (array) $row; - $views[] = reset($row); + $views[] = $row['qualifiedname'] ?? reset($row); } if (empty($views)) { @@ -187,7 +187,7 @@ class PostgresBuilder extends Builder $table = $this->connection->getTablePrefix().$table; - $results = $this->connection->select( + $results = $this->connection->selectFromWriteConnection( $this->grammar->compileColumnListing(), [$database, $schema, $table] ); @@ -239,14 +239,10 @@ class PostgresBuilder extends Builder */ protected function parseSearchPath($searchPath) { - $searchPath = $this->baseParseSearchPath($searchPath); - - array_walk($searchPath, function (&$schema) { - $schema = $schema === '$user' + return array_map(function ($schema) { + return $schema === '$user' ? $this->connection->getConfig('username') : $schema; - }); - - return $searchPath; + }, $this->baseParseSearchPath($searchPath)); } } diff --git a/vendor/illuminate/database/Schema/PostgresSchemaState.php b/vendor/illuminate/database/Schema/PostgresSchemaState.php index b6d4273..cfb100d 100644 --- a/vendor/illuminate/database/Schema/PostgresSchemaState.php +++ b/vendor/illuminate/database/Schema/PostgresSchemaState.php @@ -15,19 +15,16 @@ class PostgresSchemaState extends SchemaState */ public function dump(Connection $connection, $path) { - $excludedTables = collect($connection->getSchemaBuilder()->getAllTables()) - ->map->tablename - ->reject(function ($table) { - return $table === $this->migrationTable; - })->map(function ($table) { - return '--exclude-table-data="*.'.$table.'"'; - })->implode(' '); + $commands = collect([ + $this->baseDumpCommand().' --schema-only > '.$path, + $this->baseDumpCommand().' -t '.$this->migrationTable.' --data-only >> '.$path, + ]); - $this->makeProcess( - $this->baseDumpCommand().' --file="${:LARAVEL_LOAD_PATH}" '.$excludedTables - )->mustRun($this->output, array_merge($this->baseVariables($this->connection->getConfig()), [ - 'LARAVEL_LOAD_PATH' => $path, - ])); + $commands->map(function ($command, $path) { + $this->makeProcess($command)->mustRun($this->output, array_merge($this->baseVariables($this->connection->getConfig()), [ + 'LARAVEL_LOAD_PATH' => $path, + ])); + }); } /** @@ -58,7 +55,7 @@ class PostgresSchemaState extends SchemaState */ protected function baseDumpCommand() { - return 'pg_dump --no-owner --no-acl -Fc --host="${:LARAVEL_LOAD_HOST}" --port="${:LARAVEL_LOAD_PORT}" --username="${:LARAVEL_LOAD_USER}" --dbname="${:LARAVEL_LOAD_DATABASE}"'; + return 'pg_dump --no-owner --no-acl --host="${:LARAVEL_LOAD_HOST}" --port="${:LARAVEL_LOAD_PORT}" --username="${:LARAVEL_LOAD_USER}" --dbname="${:LARAVEL_LOAD_DATABASE}"'; } /** diff --git a/vendor/illuminate/database/Schema/SQLiteBuilder.php b/vendor/illuminate/database/Schema/SQLiteBuilder.php index 3bc1275..4e74f92 100644 --- a/vendor/illuminate/database/Schema/SQLiteBuilder.php +++ b/vendor/illuminate/database/Schema/SQLiteBuilder.php @@ -66,6 +66,30 @@ class SQLiteBuilder extends Builder $this->connection->select($this->grammar->compileRebuild()); } + /** + * Get all of the table names for the database. + * + * @return array + */ + public function getAllTables() + { + return $this->connection->select( + $this->grammar->compileGetAllTables() + ); + } + + /** + * Get all of the view names for the database. + * + * @return array + */ + public function getAllViews() + { + return $this->connection->select( + $this->grammar->compileGetAllViews() + ); + } + /** * Empty the database file. * diff --git a/vendor/illuminate/database/Schema/SchemaState.php b/vendor/illuminate/database/Schema/SchemaState.php index e6f35ab..58d9c3a 100644 --- a/vendor/illuminate/database/Schema/SchemaState.php +++ b/vendor/illuminate/database/Schema/SchemaState.php @@ -86,7 +86,7 @@ abstract class SchemaState /** * Create a new process instance. * - * @param array $arguments + * @param mixed ...$arguments * @return \Symfony\Component\Process\Process */ public function makeProcess(...$arguments) diff --git a/vendor/illuminate/database/Schema/SqlServerBuilder.php b/vendor/illuminate/database/Schema/SqlServerBuilder.php index 93da1cb..c323e12 100644 --- a/vendor/illuminate/database/Schema/SqlServerBuilder.php +++ b/vendor/illuminate/database/Schema/SqlServerBuilder.php @@ -51,4 +51,28 @@ class SqlServerBuilder extends Builder { $this->connection->statement($this->grammar->compileDropAllViews()); } + + /** + * Drop all tables from the database. + * + * @return array + */ + public function getAllTables() + { + return $this->connection->select( + $this->grammar->compileGetAllTables() + ); + } + + /** + * Get all of the view names for the database. + * + * @return array + */ + public function getAllViews() + { + return $this->connection->select( + $this->grammar->compileGetAllViews() + ); + } } diff --git a/vendor/illuminate/database/Schema/SqliteSchemaState.php b/vendor/illuminate/database/Schema/SqliteSchemaState.php index 9a98b63..10efc7c 100644 --- a/vendor/illuminate/database/Schema/SqliteSchemaState.php +++ b/vendor/illuminate/database/Schema/SqliteSchemaState.php @@ -61,6 +61,12 @@ class SqliteSchemaState extends SchemaState */ public function load($path) { + if ($this->connection->getDatabaseName() === ':memory:') { + $this->connection->getPdo()->exec($this->files->get($path)); + + return; + } + $process = $this->makeProcess($this->baseCommand().' < "${:LARAVEL_LOAD_PATH}"'); $process->mustRun(null, array_merge($this->baseVariables($this->connection->getConfig()), [ diff --git a/vendor/illuminate/database/Seeder.php b/vendor/illuminate/database/Seeder.php index 1a7a12e..ba4cd4a 100755 --- a/vendor/illuminate/database/Seeder.php +++ b/vendor/illuminate/database/Seeder.php @@ -3,7 +3,8 @@ namespace Illuminate\Database; use Illuminate\Console\Command; -use Illuminate\Container\Container; +use Illuminate\Console\View\Components\TwoColumnDetail; +use Illuminate\Contracts\Container\Container; use Illuminate\Database\Console\Seeds\WithoutModelEvents; use Illuminate\Support\Arr; use InvalidArgumentException; @@ -13,7 +14,7 @@ abstract class Seeder /** * The container instance. * - * @var \Illuminate\Container\Container + * @var \Illuminate\Contracts\Container\Container */ protected $container; @@ -49,17 +50,25 @@ abstract class Seeder $name = get_class($seeder); if ($silent === false && isset($this->command)) { - $this->command->getOutput()->writeln("Seeding: {$name}"); + with(new TwoColumnDetail($this->command->getOutput()))->render( + $name, + 'RUNNING' + ); } $startTime = microtime(true); $seeder->__invoke($parameters); - $runTime = number_format((microtime(true) - $startTime) * 1000, 2); - if ($silent === false && isset($this->command)) { - $this->command->getOutput()->writeln("Seeded: {$name} ({$runTime}ms)"); + $runTime = number_format((microtime(true) - $startTime) * 1000, 2); + + with(new TwoColumnDetail($this->command->getOutput()))->render( + $name, + "$runTime ms DONE" + ); + + $this->command->getOutput()->writeln(''); } static::$called[] = $class; @@ -134,7 +143,7 @@ abstract class Seeder /** * Set the IoC container instance. * - * @param \Illuminate\Container\Container $container + * @param \Illuminate\Contracts\Container\Container $container * @return $this */ public function setContainer(Container $container) diff --git a/vendor/illuminate/database/SqlServerConnection.php b/vendor/illuminate/database/SqlServerConnection.php index ab8983d..feb4577 100755 --- a/vendor/illuminate/database/SqlServerConnection.php +++ b/vendor/illuminate/database/SqlServerConnection.php @@ -27,7 +27,7 @@ class SqlServerConnection extends Connection { for ($a = 1; $a <= $attempts; $a++) { if ($this->getDriverName() === 'sqlsrv') { - return parent::transaction($callback); + return parent::transaction($callback, $attempts); } $this->getPdo()->exec('BEGIN TRAN'); diff --git a/vendor/illuminate/database/composer.json b/vendor/illuminate/database/composer.json index df3d06c..ba2dc30 100644 --- a/vendor/illuminate/database/composer.json +++ b/vendor/illuminate/database/composer.json @@ -16,13 +16,14 @@ ], "require": { "php": "^8.0.2", - "ext-json": "*", + "ext-pdo": "*", + "brick/math": "^0.9.3|^0.10.2|^0.11", "illuminate/collections": "^9.0", "illuminate/container": "^9.0", "illuminate/contracts": "^9.0", "illuminate/macroable": "^9.0", "illuminate/support": "^9.0", - "symfony/console": "^6.0" + "symfony/console": "^6.0.9" }, "autoload": { "psr-4": { @@ -35,8 +36,9 @@ } }, "suggest": { + "ext-filter": "Required to use the Postgres database driver.", "doctrine/dbal": "Required to rename columns and drop SQLite columns (^2.13.3|^3.1.4).", - "fakerphp/faker": "Required to use the eloquent factory builder (^1.9.1).", + "fakerphp/faker": "Required to use the eloquent factory builder (^1.21).", "illuminate/console": "Required to use the database commands (^9.0).", "illuminate/events": "Required to use the observers with Eloquent (^9.0).", "illuminate/filesystem": "Required to use the migrations (^9.0).", diff --git a/vendor/illuminate/support/Benchmark.php b/vendor/illuminate/support/Benchmark.php new file mode 100644 index 0000000..3a09d59 --- /dev/null +++ b/vendor/illuminate/support/Benchmark.php @@ -0,0 +1,50 @@ +map(function ($callback) use ($iterations) { + return collect(range(1, $iterations))->map(function () use ($callback) { + gc_collect_cycles(); + + $start = hrtime(true); + + $callback(); + + return (hrtime(true) - $start) / 1000000; + })->average(); + })->when( + $benchmarkables instanceof Closure, + fn ($c) => $c->first(), + fn ($c) => $c->all(), + ); + } + + /** + * Measure a callable or array of callables over the given number of iterations, then dump and die. + * + * @param \Closure|array $benchmarkables + * @param int $iterations + * @return never + */ + public static function dd(Closure|array $benchmarkables, int $iterations = 1): void + { + $result = collect(static::measure(Arr::wrap($benchmarkables), $iterations)) + ->map(fn ($average) => number_format($average, 3).'ms') + ->when($benchmarkables instanceof Closure, fn ($c) => $c->first(), fn ($c) => $c->all()); + + dd($result); + } +} diff --git a/vendor/illuminate/support/Carbon.php b/vendor/illuminate/support/Carbon.php index 004b27b..972d7eb 100644 --- a/vendor/illuminate/support/Carbon.php +++ b/vendor/illuminate/support/Carbon.php @@ -4,9 +4,12 @@ namespace Illuminate\Support; use Carbon\Carbon as BaseCarbon; use Carbon\CarbonImmutable as BaseCarbonImmutable; +use Illuminate\Support\Traits\Conditionable; class Carbon extends BaseCarbon { + use Conditionable; + /** * {@inheritdoc} */ diff --git a/vendor/illuminate/support/Composer.php b/vendor/illuminate/support/Composer.php index 623e916..9933615 100644 --- a/vendor/illuminate/support/Composer.php +++ b/vendor/illuminate/support/Composer.php @@ -65,7 +65,7 @@ class Composer * * @return array */ - protected function findComposer() + public function findComposer() { if ($this->files->exists($this->workingPath.'/composer.phar')) { return [$this->phpBinary(), 'composer.phar']; @@ -107,4 +107,26 @@ class Composer return $this; } + + /** + * Get the version of Composer. + * + * @return string|null + */ + public function getVersion() + { + $command = array_merge($this->findComposer(), ['-V', '--no-ansi']); + + $process = $this->getProcess($command); + + $process->run(); + + $output = $process->getOutput(); + + if (preg_match('/(\d+(\.\d+){2})/', $output, $version)) { + return $version[1]; + } + + return explode(' ', $output)[2] ?? null; + } } diff --git a/vendor/illuminate/support/ConfigurationUrlParser.php b/vendor/illuminate/support/ConfigurationUrlParser.php index be54b9a..a1b9337 100644 --- a/vendor/illuminate/support/ConfigurationUrlParser.php +++ b/vendor/illuminate/support/ConfigurationUrlParser.php @@ -67,9 +67,7 @@ class ConfigurationUrlParser 'port' => $url['port'] ?? null, 'username' => $url['user'] ?? null, 'password' => $url['pass'] ?? null, - ], function ($value) { - return ! is_null($value); - }); + ], fn ($value) => ! is_null($value)); } /** diff --git a/vendor/illuminate/support/DateFactory.php b/vendor/illuminate/support/DateFactory.php index f36cb46..3d0cd04 100644 --- a/vendor/illuminate/support/DateFactory.php +++ b/vendor/illuminate/support/DateFactory.php @@ -9,77 +9,77 @@ use InvalidArgumentException; * @see https://carbon.nesbot.com/docs/ * @see https://github.com/briannesbitt/Carbon/blob/master/src/Carbon/Factory.php * - * @method static Carbon create($year = 0, $month = 1, $day = 1, $hour = 0, $minute = 0, $second = 0, $tz = null) - * @method static Carbon createFromDate($year = null, $month = null, $day = null, $tz = null) - * @method static Carbon|false createFromFormat($format, $time, $tz = null) - * @method static Carbon createFromTime($hour = 0, $minute = 0, $second = 0, $tz = null) - * @method static Carbon createFromTimeString($time, $tz = null) - * @method static Carbon createFromTimestamp($timestamp, $tz = null) - * @method static Carbon createFromTimestampMs($timestamp, $tz = null) - * @method static Carbon createFromTimestampUTC($timestamp) - * @method static Carbon createMidnightDate($year = null, $month = null, $day = null, $tz = null) - * @method static Carbon|false createSafe($year = null, $month = null, $day = null, $hour = null, $minute = null, $second = null, $tz = null) - * @method static Carbon disableHumanDiffOption($humanDiffOption) - * @method static Carbon enableHumanDiffOption($humanDiffOption) - * @method static mixed executeWithLocale($locale, $func) - * @method static Carbon fromSerialized($value) - * @method static array getAvailableLocales() - * @method static array getDays() - * @method static int getHumanDiffOptions() - * @method static array getIsoUnits() - * @method static Carbon getLastErrors() - * @method static string getLocale() - * @method static int getMidDayAt() - * @method static Carbon getTestNow() - * @method static \Symfony\Component\Translation\TranslatorInterface getTranslator() - * @method static int getWeekEndsAt() - * @method static int getWeekStartsAt() - * @method static array getWeekendDays() - * @method static bool hasFormat($date, $format) - * @method static bool hasMacro($name) - * @method static bool hasRelativeKeywords($time) - * @method static bool hasTestNow() - * @method static Carbon instance($date) - * @method static bool isImmutable() - * @method static bool isModifiableUnit($unit) - * @method static Carbon isMutable() - * @method static bool isStrictModeEnabled() - * @method static bool localeHasDiffOneDayWords($locale) - * @method static bool localeHasDiffSyntax($locale) - * @method static bool localeHasDiffTwoDayWords($locale) - * @method static bool localeHasPeriodSyntax($locale) - * @method static bool localeHasShortUnits($locale) - * @method static void macro($name, $macro) - * @method static Carbon|null make($var) - * @method static Carbon maxValue() - * @method static Carbon minValue() - * @method static void mixin($mixin) - * @method static Carbon now($tz = null) - * @method static Carbon parse($time = null, $tz = null) - * @method static string pluralUnit(string $unit) - * @method static void resetMonthsOverflow() - * @method static void resetToStringFormat() - * @method static void resetYearsOverflow() - * @method static void serializeUsing($callback) - * @method static Carbon setHumanDiffOptions($humanDiffOptions) - * @method static bool setLocale($locale) - * @method static void setMidDayAt($hour) - * @method static void setTestNow($testNow = null) - * @method static void setToStringFormat($format) - * @method static void setTranslator(\Symfony\Component\Translation\TranslatorInterface $translator) - * @method static Carbon setUtf8($utf8) - * @method static void setWeekEndsAt($day) - * @method static void setWeekStartsAt($day) - * @method static void setWeekendDays($days) - * @method static bool shouldOverflowMonths() - * @method static bool shouldOverflowYears() - * @method static string singularUnit(string $unit) - * @method static Carbon today($tz = null) - * @method static Carbon tomorrow($tz = null) - * @method static void useMonthsOverflow($monthsOverflow = true) - * @method static Carbon useStrictMode($strictModeEnabled = true) - * @method static void useYearsOverflow($yearsOverflow = true) - * @method static Carbon yesterday($tz = null) + * @method \Illuminate\Support\Carbon create($year = 0, $month = 1, $day = 1, $hour = 0, $minute = 0, $second = 0, $tz = null) + * @method \Illuminate\Support\Carbon createFromDate($year = null, $month = null, $day = null, $tz = null) + * @method \Illuminate\Support\Carbon|false createFromFormat($format, $time, $tz = null) + * @method \Illuminate\Support\Carbon createFromTime($hour = 0, $minute = 0, $second = 0, $tz = null) + * @method \Illuminate\Support\Carbon createFromTimeString($time, $tz = null) + * @method \Illuminate\Support\Carbon createFromTimestamp($timestamp, $tz = null) + * @method \Illuminate\Support\Carbon createFromTimestampMs($timestamp, $tz = null) + * @method \Illuminate\Support\Carbon createFromTimestampUTC($timestamp) + * @method \Illuminate\Support\Carbon createMidnightDate($year = null, $month = null, $day = null, $tz = null) + * @method \Illuminate\Support\Carbon|false createSafe($year = null, $month = null, $day = null, $hour = null, $minute = null, $second = null, $tz = null) + * @method void disableHumanDiffOption($humanDiffOption) + * @method void enableHumanDiffOption($humanDiffOption) + * @method mixed executeWithLocale($locale, $func) + * @method \Illuminate\Support\Carbon fromSerialized($value) + * @method array getAvailableLocales() + * @method array getDays() + * @method int getHumanDiffOptions() + * @method array getIsoUnits() + * @method array getLastErrors() + * @method string getLocale() + * @method int getMidDayAt() + * @method \Illuminate\Support\Carbon|null getTestNow() + * @method \Symfony\Component\Translation\TranslatorInterface getTranslator() + * @method int getWeekEndsAt() + * @method int getWeekStartsAt() + * @method array getWeekendDays() + * @method bool hasFormat($date, $format) + * @method bool hasMacro($name) + * @method bool hasRelativeKeywords($time) + * @method bool hasTestNow() + * @method \Illuminate\Support\Carbon instance($date) + * @method bool isImmutable() + * @method bool isModifiableUnit($unit) + * @method bool isMutable() + * @method bool isStrictModeEnabled() + * @method bool localeHasDiffOneDayWords($locale) + * @method bool localeHasDiffSyntax($locale) + * @method bool localeHasDiffTwoDayWords($locale) + * @method bool localeHasPeriodSyntax($locale) + * @method bool localeHasShortUnits($locale) + * @method void macro($name, $macro) + * @method \Illuminate\Support\Carbon|null make($var) + * @method \Illuminate\Support\Carbon maxValue() + * @method \Illuminate\Support\Carbon minValue() + * @method void mixin($mixin) + * @method \Illuminate\Support\Carbon now($tz = null) + * @method \Illuminate\Support\Carbon parse($time = null, $tz = null) + * @method string pluralUnit(string $unit) + * @method void resetMonthsOverflow() + * @method void resetToStringFormat() + * @method void resetYearsOverflow() + * @method void serializeUsing($callback) + * @method void setHumanDiffOptions($humanDiffOptions) + * @method bool setLocale($locale) + * @method void setMidDayAt($hour) + * @method void setTestNow($testNow = null) + * @method void setToStringFormat($format) + * @method void setTranslator(\Symfony\Component\Translation\TranslatorInterface $translator) + * @method void setUtf8($utf8) + * @method void setWeekEndsAt($day) + * @method void setWeekStartsAt($day) + * @method void setWeekendDays($days) + * @method bool shouldOverflowMonths() + * @method bool shouldOverflowYears() + * @method string singularUnit(string $unit) + * @method \Illuminate\Support\Carbon today($tz = null) + * @method \Illuminate\Support\Carbon tomorrow($tz = null) + * @method void useMonthsOverflow($monthsOverflow = true) + * @method void useStrictMode($strictModeEnabled = true) + * @method void useYearsOverflow($yearsOverflow = true) + * @method \Illuminate\Support\Carbon yesterday($tz = null) */ class DateFactory { @@ -211,7 +211,7 @@ class DateFactory $dateClass = static::$dateClass ?: $defaultClassName; - // Check if date can be created using public class method... + // Check if the date can be created using the public class method... if (method_exists($dateClass, $method) || method_exists($dateClass, 'hasMacro') && $dateClass::hasMacro($method)) { return $dateClass::$method(...$parameters); diff --git a/vendor/illuminate/support/Env.php b/vendor/illuminate/support/Env.php index b310073..4d5747a 100644 --- a/vendor/illuminate/support/Env.php +++ b/vendor/illuminate/support/Env.php @@ -96,8 +96,6 @@ class Env return $value; }) - ->getOrCall(function () use ($default) { - return value($default); - }); + ->getOrCall(fn () => value($default)); } } diff --git a/vendor/illuminate/support/Exceptions/MathException.php b/vendor/illuminate/support/Exceptions/MathException.php new file mode 100644 index 0000000..6f9158d --- /dev/null +++ b/vendor/illuminate/support/Exceptions/MathException.php @@ -0,0 +1,10 @@ + URL::class, 'Validator' => Validator::class, 'View' => View::class, + 'Vite' => Vite::class, ]); } diff --git a/vendor/illuminate/support/Facades/File.php b/vendor/illuminate/support/Facades/File.php index c22d363..7063fef 100755 --- a/vendor/illuminate/support/Facades/File.php +++ b/vendor/illuminate/support/Facades/File.php @@ -3,48 +3,57 @@ namespace Illuminate\Support\Facades; /** - * @method static \Symfony\Component\Finder\SplFileInfo[] allFiles(string $directory, bool $hidden = false) - * @method static \Symfony\Component\Finder\SplFileInfo[] files(string $directory, bool $hidden = false) - * @method static array directories(string $directory) - * @method static array glob(string $pattern, int $flags = 0) - * @method static bool cleanDirectory(string $directory) - * @method static bool copy(string $path, string $target) - * @method static bool copyDirectory(string $directory, string $destination, int|null $options = null) - * @method static bool delete(string|array $paths) - * @method static bool deleteDirectories(string $directory) - * @method static bool deleteDirectory(string $directory, bool $preserve = false) * @method static bool exists(string $path) - * @method static bool isDirectory(string $directory) - * @method static bool isFile(string $file) - * @method static bool isReadable(string $path) - * @method static bool isWritable(string $path) - * @method static bool makeDirectory(string $path, int $mode = 0755, bool $recursive = false, bool $force = false) * @method static bool missing(string $path) - * @method static bool move(string $path, string $target) - * @method static bool moveDirectory(string $from, string $to, bool $overwrite = false) - * @method static int append(string $path, string $data) - * @method static int lastModified(string $path) - * @method static int prepend(string $path, string $data) - * @method static int size(string $path) - * @method static int|bool put(string $path, string $contents, bool $lock = false) - * @method static mixed chmod(string $path, int|null $mode = null) + * @method static string get(string $path, bool $lock = false) + * @method static string sharedGet(string $path) * @method static mixed getRequire(string $path, array $data = []) - * @method static mixed requireOnce(string $file, array $data = []) + * @method static mixed requireOnce(string $path, array $data = []) + * @method static \Illuminate\Support\LazyCollection lines(string $path) + * @method static string hash(string $path, string $algorithm = 'md5') + * @method static int|bool put(string $path, string $contents, bool $lock = false) + * @method static void replace(string $path, string $content, int|null $mode = null) + * @method static void replaceInFile(array|string $search, array|string $replace, string $path) + * @method static int prepend(string $path, string $data) + * @method static int append(string $path, string $data) + * @method static mixed chmod(string $path, int|null $mode = null) + * @method static bool delete(string|array $paths) + * @method static bool move(string $path, string $target) + * @method static bool copy(string $path, string $target) + * @method static void link(string $target, string $link) + * @method static void relativeLink(string $target, string $link) + * @method static string name(string $path) * @method static string basename(string $path) * @method static string dirname(string $path) * @method static string extension(string $path) - * @method static string get(string $path, bool $lock = false) - * @method static string hash(string $path) - * @method static string name(string $path) - * @method static string sharedGet(string $path) + * @method static string|null guessExtension(string $path) * @method static string type(string $path) * @method static string|false mimeType(string $path) - * @method static string|null guessExtension(string $path) + * @method static int size(string $path) + * @method static int lastModified(string $path) + * @method static bool isDirectory(string $directory) + * @method static bool isEmptyDirectory(string $directory, bool $ignoreDotFiles = false) + * @method static bool isReadable(string $path) + * @method static bool isWritable(string $path) + * @method static bool hasSameHash(string $firstFile, string $secondFile) + * @method static bool isFile(string $file) + * @method static array glob(string $pattern, int $flags = 0) + * @method static \Symfony\Component\Finder\SplFileInfo[] files(string $directory, bool $hidden = false) + * @method static \Symfony\Component\Finder\SplFileInfo[] allFiles(string $directory, bool $hidden = false) + * @method static array directories(string $directory) * @method static void ensureDirectoryExists(string $path, int $mode = 0755, bool $recursive = true) - * @method static void link(string $target, string $link) - * @method static \Illuminate\Support\LazyCollection lines(string $path) - * @method static void relativeLink(string $target, string $link) - * @method static void replace(string $path, string $content) + * @method static bool makeDirectory(string $path, int $mode = 0755, bool $recursive = false, bool $force = false) + * @method static bool moveDirectory(string $from, string $to, bool $overwrite = false) + * @method static bool copyDirectory(string $directory, string $destination, int|null $options = null) + * @method static bool deleteDirectory(string $directory, bool $preserve = false) + * @method static bool deleteDirectories(string $directory) + * @method static bool cleanDirectory(string $directory) + * @method static \Illuminate\Filesystem\Filesystem|mixed when(\Closure|mixed|null $value = null, callable|null $callback = null, callable|null $default = null) + * @method static \Illuminate\Filesystem\Filesystem|mixed unless(\Closure|mixed|null $value = null, callable|null $callback = null, callable|null $default = null) + * @method static void macro(string $name, object|callable $macro) + * @method static void mixin(object $mixin, bool $replace = true) + * @method static bool hasMacro(string $name) + * @method static void flushMacros() * * @see \Illuminate\Filesystem\Filesystem */ diff --git a/vendor/illuminate/support/Facades/Gate.php b/vendor/illuminate/support/Facades/Gate.php index 49d8b66..7cb4a52 100644 --- a/vendor/illuminate/support/Facades/Gate.php +++ b/vendor/illuminate/support/Facades/Gate.php @@ -5,26 +5,33 @@ namespace Illuminate\Support\Facades; use Illuminate\Contracts\Auth\Access\Gate as GateContract; /** - * @method static \Illuminate\Auth\Access\Gate guessPolicyNamesUsing(callable $callback) + * @method static bool has(string|array $ability) + * @method static \Illuminate\Auth\Access\Response allowIf(\Illuminate\Auth\Access\Response|\Closure|bool $condition, string|null $message = null, string|null $code = null) + * @method static \Illuminate\Auth\Access\Response denyIf(\Illuminate\Auth\Access\Response|\Closure|bool $condition, string|null $message = null, string|null $code = null) + * @method static \Illuminate\Auth\Access\Gate define(string $ability, callable|array|string $callback) + * @method static \Illuminate\Auth\Access\Gate resource(string $name, string $class, array|null $abilities = null) + * @method static \Illuminate\Auth\Access\Gate policy(string $class, string $policy) + * @method static \Illuminate\Auth\Access\Gate before(callable $callback) + * @method static \Illuminate\Auth\Access\Gate after(callable $callback) + * @method static bool allows(string $ability, array|mixed $arguments = []) + * @method static bool denies(string $ability, array|mixed $arguments = []) + * @method static bool check(iterable|string $abilities, array|mixed $arguments = []) + * @method static bool any(iterable|string $abilities, array|mixed $arguments = []) + * @method static bool none(iterable|string $abilities, array|mixed $arguments = []) * @method static \Illuminate\Auth\Access\Response authorize(string $ability, array|mixed $arguments = []) * @method static \Illuminate\Auth\Access\Response inspect(string $ability, array|mixed $arguments = []) - * @method static \Illuminate\Auth\Access\Response allowIf(\Closure|bool $condition, string|null $message = null, mixed $code = null) - * @method static \Illuminate\Auth\Access\Response denyIf(\Closure|bool $condition, string|null $message = null, mixed $code = null) - * @method static \Illuminate\Contracts\Auth\Access\Gate after(callable $callback) - * @method static \Illuminate\Contracts\Auth\Access\Gate before(callable $callback) - * @method static \Illuminate\Contracts\Auth\Access\Gate define(string $ability, callable|string $callback) - * @method static \Illuminate\Contracts\Auth\Access\Gate forUser(\Illuminate\Contracts\Auth\Authenticatable|mixed $user) - * @method static \Illuminate\Contracts\Auth\Access\Gate policy(string $class, string $policy) - * @method static array abilities() - * @method static bool allows(string $ability, array|mixed $arguments = []) - * @method static bool any(iterable|string $abilities, array|mixed $arguments = []) - * @method static bool check(iterable|string $abilities, array|mixed $arguments = []) - * @method static bool denies(string $ability, array|mixed $arguments = []) - * @method static bool has(string $ability) - * @method static mixed getPolicyFor(object|string $class) * @method static mixed raw(string $ability, array|mixed $arguments = []) + * @method static mixed getPolicyFor(object|string $class) + * @method static \Illuminate\Auth\Access\Gate guessPolicyNamesUsing(callable $callback) + * @method static mixed resolvePolicy(object|string $class) + * @method static \Illuminate\Auth\Access\Gate forUser(\Illuminate\Contracts\Auth\Authenticatable|mixed $user) + * @method static array abilities() + * @method static array policies() + * @method static \Illuminate\Auth\Access\Gate setContainer(\Illuminate\Contracts\Container\Container $container) + * @method static \Illuminate\Auth\Access\Response denyWithStatus(int $status, string|null $message = null, int|null $code = null) + * @method static \Illuminate\Auth\Access\Response denyAsNotFound(string|null $message = null, int|null $code = null) * - * @see \Illuminate\Contracts\Auth\Access\Gate + * @see \Illuminate\Auth\Access\Gate */ class Gate extends Facade { diff --git a/vendor/illuminate/support/Facades/Hash.php b/vendor/illuminate/support/Facades/Hash.php index b9855fd..1cfe561 100755 --- a/vendor/illuminate/support/Facades/Hash.php +++ b/vendor/illuminate/support/Facades/Hash.php @@ -3,13 +3,23 @@ namespace Illuminate\Support\Facades; /** + * @method static \Illuminate\Hashing\BcryptHasher createBcryptDriver() + * @method static \Illuminate\Hashing\ArgonHasher createArgonDriver() + * @method static \Illuminate\Hashing\Argon2IdHasher createArgon2idDriver() * @method static array info(string $hashedValue) + * @method static string make(string $value, array $options = []) * @method static bool check(string $value, string $hashedValue, array $options = []) * @method static bool needsRehash(string $hashedValue, array $options = []) - * @method static string make(string $value, array $options = []) - * @method static \Illuminate\Hashing\HashManager extend($driver, \Closure $callback) + * @method static string getDefaultDriver() + * @method static mixed driver(string|null $driver = null) + * @method static \Illuminate\Hashing\HashManager extend(string $driver, \Closure $callback) + * @method static array getDrivers() + * @method static \Illuminate\Contracts\Container\Container getContainer() + * @method static \Illuminate\Hashing\HashManager setContainer(\Illuminate\Contracts\Container\Container $container) + * @method static \Illuminate\Hashing\HashManager forgetDrivers() * * @see \Illuminate\Hashing\HashManager + * @see \Illuminate\Hashing\AbstractHasher */ class Hash extends Facade { diff --git a/vendor/illuminate/support/Facades/Http.php b/vendor/illuminate/support/Facades/Http.php index 72f8769..4aab841 100644 --- a/vendor/illuminate/support/Facades/Http.php +++ b/vendor/illuminate/support/Facades/Http.php @@ -5,49 +5,80 @@ namespace Illuminate\Support\Facades; use Illuminate\Http\Client\Factory; /** - * @method static \GuzzleHttp\Promise\PromiseInterface response($body = null, $status = 200, $headers = []) - * @method static \Illuminate\Http\Client\PendingRequest accept(string $contentType) - * @method static \Illuminate\Http\Client\PendingRequest acceptJson() - * @method static \Illuminate\Http\Client\PendingRequest asForm() - * @method static \Illuminate\Http\Client\PendingRequest asJson() - * @method static \Illuminate\Http\Client\PendingRequest asMultipart() - * @method static \Illuminate\Http\Client\PendingRequest async() - * @method static \Illuminate\Http\Client\PendingRequest attach(string|array $name, string $contents = '', string|null $filename = null, array $headers = []) - * @method static \Illuminate\Http\Client\PendingRequest baseUrl(string $url) - * @method static \Illuminate\Http\Client\PendingRequest beforeSending(callable $callback) - * @method static \Illuminate\Http\Client\PendingRequest bodyFormat(string $format) - * @method static \Illuminate\Http\Client\PendingRequest contentType(string $contentType) - * @method static \Illuminate\Http\Client\PendingRequest dd() - * @method static \Illuminate\Http\Client\PendingRequest dump() - * @method static \Illuminate\Http\Client\PendingRequest retry(int $times, int $sleep = 0, ?callable $when = null, bool $throw = true) - * @method static \Illuminate\Http\Client\PendingRequest sink(string|resource $to) - * @method static \Illuminate\Http\Client\PendingRequest stub(callable $callback) - * @method static \Illuminate\Http\Client\PendingRequest timeout(int $seconds) - * @method static \Illuminate\Http\Client\PendingRequest withBasicAuth(string $username, string $password) - * @method static \Illuminate\Http\Client\PendingRequest withBody(resource|string $content, string $contentType) - * @method static \Illuminate\Http\Client\PendingRequest withCookies(array $cookies, string $domain) - * @method static \Illuminate\Http\Client\PendingRequest withDigestAuth(string $username, string $password) - * @method static \Illuminate\Http\Client\PendingRequest withHeaders(array $headers) - * @method static \Illuminate\Http\Client\PendingRequest withMiddleware(callable $middleware) - * @method static \Illuminate\Http\Client\PendingRequest withOptions(array $options) - * @method static \Illuminate\Http\Client\PendingRequest withToken(string $token, string $type = 'Bearer') - * @method static \Illuminate\Http\Client\PendingRequest withUserAgent(string $userAgent) - * @method static \Illuminate\Http\Client\PendingRequest withoutRedirecting() - * @method static \Illuminate\Http\Client\PendingRequest withoutVerifying() - * @method static array pool(callable $callback) - * @method static \Illuminate\Http\Client\Response delete(string $url, array $data = []) - * @method static \Illuminate\Http\Client\Response get(string $url, array|string|null $query = null) - * @method static \Illuminate\Http\Client\Response head(string $url, array|string|null $query = null) - * @method static \Illuminate\Http\Client\Response patch(string $url, array $data = []) - * @method static \Illuminate\Http\Client\Response post(string $url, array $data = []) - * @method static \Illuminate\Http\Client\Response put(string $url, array $data = []) - * @method static \Illuminate\Http\Client\Response send(string $method, string $url, array $options = []) + * @method static \GuzzleHttp\Promise\PromiseInterface response(array|string|null $body = null, int $status = 200, array $headers = []) + * @method static \Illuminate\Http\Client\ResponseSequence sequence(array $responses = []) + * @method static \Illuminate\Http\Client\Factory allowStrayRequests() + * @method static void recordRequestResponsePair(\Illuminate\Http\Client\Request $request, \Illuminate\Http\Client\Response $response) * @method static void assertSent(callable $callback) * @method static void assertSentInOrder(array $callbacks) * @method static void assertNotSent(callable $callback) * @method static void assertNothingSent() * @method static void assertSentCount(int $count) * @method static void assertSequencesAreEmpty() + * @method static \Illuminate\Support\Collection recorded(callable $callback = null) + * @method static \Illuminate\Contracts\Events\Dispatcher|null getDispatcher() + * @method static void macro(string $name, object|callable $macro) + * @method static void mixin(object $mixin, bool $replace = true) + * @method static bool hasMacro(string $name) + * @method static void flushMacros() + * @method static mixed macroCall(string $method, array $parameters) + * @method static \Illuminate\Http\Client\PendingRequest baseUrl(string $url) + * @method static \Illuminate\Http\Client\PendingRequest withBody(string $content, string $contentType) + * @method static \Illuminate\Http\Client\PendingRequest asJson() + * @method static \Illuminate\Http\Client\PendingRequest asForm() + * @method static \Illuminate\Http\Client\PendingRequest attach(string|array $name, string|resource $contents = '', string|null $filename = null, array $headers = []) + * @method static \Illuminate\Http\Client\PendingRequest asMultipart() + * @method static \Illuminate\Http\Client\PendingRequest bodyFormat(string $format) + * @method static \Illuminate\Http\Client\PendingRequest contentType(string $contentType) + * @method static \Illuminate\Http\Client\PendingRequest acceptJson() + * @method static \Illuminate\Http\Client\PendingRequest accept(string $contentType) + * @method static \Illuminate\Http\Client\PendingRequest withHeaders(array $headers) + * @method static \Illuminate\Http\Client\PendingRequest withBasicAuth(string $username, string $password) + * @method static \Illuminate\Http\Client\PendingRequest withDigestAuth(string $username, string $password) + * @method static \Illuminate\Http\Client\PendingRequest withToken(string $token, string $type = 'Bearer') + * @method static \Illuminate\Http\Client\PendingRequest withUserAgent(string $userAgent) + * @method static \Illuminate\Http\Client\PendingRequest withUrlParameters(array $parameters = []) + * @method static \Illuminate\Http\Client\PendingRequest withCookies(array $cookies, string $domain) + * @method static \Illuminate\Http\Client\PendingRequest maxRedirects(int $max) + * @method static \Illuminate\Http\Client\PendingRequest withoutRedirecting() + * @method static \Illuminate\Http\Client\PendingRequest withoutVerifying() + * @method static \Illuminate\Http\Client\PendingRequest sink(string|resource $to) + * @method static \Illuminate\Http\Client\PendingRequest timeout(int $seconds) + * @method static \Illuminate\Http\Client\PendingRequest connectTimeout(int $seconds) + * @method static \Illuminate\Http\Client\PendingRequest retry(int $times, int $sleepMilliseconds = 0, callable|null $when = null, bool $throw = true) + * @method static \Illuminate\Http\Client\PendingRequest withOptions(array $options) + * @method static \Illuminate\Http\Client\PendingRequest withMiddleware(callable $middleware) + * @method static \Illuminate\Http\Client\PendingRequest beforeSending(callable $callback) + * @method static \Illuminate\Http\Client\PendingRequest throw(callable|null $callback = null) + * @method static \Illuminate\Http\Client\PendingRequest throwIf(callable|bool $condition, callable|null $throwCallback = null) + * @method static \Illuminate\Http\Client\PendingRequest throwUnless(bool $condition) + * @method static \Illuminate\Http\Client\PendingRequest dump() + * @method static \Illuminate\Http\Client\PendingRequest dd() + * @method static \Illuminate\Http\Client\Response get(string $url, array|string|null $query = null) + * @method static \Illuminate\Http\Client\Response head(string $url, array|string|null $query = null) + * @method static \Illuminate\Http\Client\Response post(string $url, array $data = []) + * @method static \Illuminate\Http\Client\Response patch(string $url, array $data = []) + * @method static \Illuminate\Http\Client\Response put(string $url, array $data = []) + * @method static \Illuminate\Http\Client\Response delete(string $url, array $data = []) + * @method static array pool(callable $callback) + * @method static \Illuminate\Http\Client\Response send(string $method, string $url, array $options = []) + * @method static \GuzzleHttp\Client buildClient() + * @method static \GuzzleHttp\Client createClient(\GuzzleHttp\HandlerStack $handlerStack) + * @method static \GuzzleHttp\HandlerStack buildHandlerStack() + * @method static \GuzzleHttp\HandlerStack pushHandlers(\GuzzleHttp\HandlerStack $handlerStack) + * @method static \Closure buildBeforeSendingHandler() + * @method static \Closure buildRecorderHandler() + * @method static \Closure buildStubHandler() + * @method static \GuzzleHttp\Psr7\RequestInterface runBeforeSendingCallbacks(\GuzzleHttp\Psr7\RequestInterface $request, array $options) + * @method static array mergeOptions(array ...$options) + * @method static \Illuminate\Http\Client\PendingRequest stub(callable $callback) + * @method static \Illuminate\Http\Client\PendingRequest async(bool $async = true) + * @method static \GuzzleHttp\Promise\PromiseInterface|null getPromise() + * @method static \Illuminate\Http\Client\PendingRequest setClient(\GuzzleHttp\Client $client) + * @method static \Illuminate\Http\Client\PendingRequest setHandler(callable $handler) + * @method static array getOptions() + * @method static \Illuminate\Http\Client\PendingRequest|mixed when(\Closure|mixed|null $value = null, callable|null $callback = null, callable|null $default = null) + * @method static \Illuminate\Http\Client\PendingRequest|mixed unless(\Closure|mixed|null $value = null, callable|null $callback = null, callable|null $default = null) * * @see \Illuminate\Http\Client\Factory */ @@ -91,6 +122,18 @@ class Http extends Facade return $fake->fakeSequence($urlPattern); } + /** + * Indicate that an exception should be thrown if any request is not faked. + * + * @return \Illuminate\Http\Client\Factory + */ + public static function preventStrayRequests() + { + return tap(static::getFacadeRoot(), function ($fake) { + static::swap($fake->preventStrayRequests()); + }); + } + /** * Stub the given URL using the given callback. * diff --git a/vendor/illuminate/support/Facades/Lang.php b/vendor/illuminate/support/Facades/Lang.php index 3e7ece4..992282c 100755 --- a/vendor/illuminate/support/Facades/Lang.php +++ b/vendor/illuminate/support/Facades/Lang.php @@ -3,12 +3,32 @@ namespace Illuminate\Support\Facades; /** - * @method static bool hasForLocale(string $key, string $locale = null) - * @method static bool has(string $key, string $locale = null, bool $fallback = true) - * @method static mixed get(string $key, array $replace = [], string $locale = null, bool $fallback = true) - * @method static string choice(string $key, \Countable|int|array $number, array $replace = [], string $locale = null) + * @method static bool hasForLocale(string $key, string|null $locale = null) + * @method static bool has(string $key, string|null $locale = null, bool $fallback = true) + * @method static string|array get(string $key, array $replace = [], string|null $locale = null, bool $fallback = true) + * @method static string choice(string $key, \Countable|int|array $number, array $replace = [], string|null $locale = null) + * @method static void addLines(array $lines, string $locale, string $namespace = '*') + * @method static void load(string $namespace, string $group, string $locale) + * @method static void addNamespace(string $namespace, string $hint) + * @method static void addJsonPath(string $path) + * @method static array parseKey(string $key) + * @method static void determineLocalesUsing(callable $callback) + * @method static \Illuminate\Translation\MessageSelector getSelector() + * @method static void setSelector(\Illuminate\Translation\MessageSelector $selector) + * @method static \Illuminate\Contracts\Translation\Loader getLoader() + * @method static string locale() * @method static string getLocale() * @method static void setLocale(string $locale) + * @method static string getFallback() + * @method static void setFallback(string $fallback) + * @method static void setLoaded(array $loaded) + * @method static void stringable(callable|string $class, callable|null $handler = null) + * @method static void setParsedKey(string $key, array $parsed) + * @method static void flushParsedKeys() + * @method static void macro(string $name, object|callable $macro) + * @method static void mixin(object $mixin, bool $replace = true) + * @method static bool hasMacro(string $name) + * @method static void flushMacros() * * @see \Illuminate\Translation\Translator */ diff --git a/vendor/illuminate/support/Facades/Log.php b/vendor/illuminate/support/Facades/Log.php index 68493fd..48cd340 100755 --- a/vendor/illuminate/support/Facades/Log.php +++ b/vendor/illuminate/support/Facades/Log.php @@ -3,24 +3,36 @@ namespace Illuminate\Support\Facades; /** - * @method static \Psr\Log\LoggerInterface channel(string $channel = null) - * @method static \Psr\Log\LoggerInterface stack(array $channels, string $channel = null) * @method static \Psr\Log\LoggerInterface build(array $config) - * @method static \Illuminate\Log\Logger withContext(array $context = []) - * @method static \Illuminate\Log\Logger withoutContext() + * @method static \Psr\Log\LoggerInterface stack(array $channels, string|null $channel = null) + * @method static \Psr\Log\LoggerInterface channel(string|null $channel = null) + * @method static \Psr\Log\LoggerInterface driver(string|null $driver = null) + * @method static \Illuminate\Log\LogManager shareContext(array $context) + * @method static array sharedContext() + * @method static \Illuminate\Log\LogManager flushSharedContext() + * @method static string|null getDefaultDriver() + * @method static void setDefaultDriver(string $name) + * @method static \Illuminate\Log\LogManager extend(string $driver, \Closure $callback) + * @method static void forgetChannel(string|null $driver = null) + * @method static array getChannels() + * @method static void emergency(string $message, array $context = []) * @method static void alert(string $message, array $context = []) * @method static void critical(string $message, array $context = []) - * @method static void debug(string $message, array $context = []) - * @method static void emergency(string $message, array $context = []) * @method static void error(string $message, array $context = []) - * @method static void info(string $message, array $context = []) - * @method static void log($level, string $message, array $context = []) - * @method static void notice(string $message, array $context = []) * @method static void warning(string $message, array $context = []) - * @method static void write(string $level, string $message, array $context = []) + * @method static void notice(string $message, array $context = []) + * @method static void info(string $message, array $context = []) + * @method static void debug(string $message, array $context = []) + * @method static void log(mixed $level, string $message, array $context = []) + * @method static void write(string $level, \Illuminate\Contracts\Support\Arrayable|\Illuminate\Contracts\Support\Jsonable|\Illuminate\Support\Stringable|array|string $message, array $context = []) + * @method static \Illuminate\Log\Logger withContext(array $context = []) + * @method static \Illuminate\Log\Logger withoutContext() * @method static void listen(\Closure $callback) + * @method static \Psr\Log\LoggerInterface getLogger() + * @method static \Illuminate\Contracts\Events\Dispatcher getEventDispatcher() + * @method static void setEventDispatcher(\Illuminate\Contracts\Events\Dispatcher $dispatcher) * - * @see \Illuminate\Log\Logger + * @see \Illuminate\Log\LogManager */ class Log extends Facade { diff --git a/vendor/illuminate/support/Facades/Mail.php b/vendor/illuminate/support/Facades/Mail.php index 0097834..a6544a3 100755 --- a/vendor/illuminate/support/Facades/Mail.php +++ b/vendor/illuminate/support/Facades/Mail.php @@ -5,34 +5,56 @@ namespace Illuminate\Support\Facades; use Illuminate\Support\Testing\Fakes\MailFake; /** - * @method static \Illuminate\Mail\Mailer mailer(string|null $name = null) + * @method static \Illuminate\Contracts\Mail\Mailer mailer(string|null $name = null) + * @method static \Illuminate\Mail\Mailer driver(string|null $driver = null) + * @method static \Symfony\Component\Mailer\Transport\TransportInterface createSymfonyTransport(array $config) + * @method static string getDefaultDriver() + * @method static void setDefaultDriver(string $name) + * @method static void purge(string|null $name = null) + * @method static \Illuminate\Mail\MailManager extend(string $driver, \Closure $callback) + * @method static \Illuminate\Contracts\Foundation\Application getApplication() + * @method static \Illuminate\Mail\MailManager setApplication(\Illuminate\Contracts\Foundation\Application $app) + * @method static \Illuminate\Mail\MailManager forgetMailers() * @method static void alwaysFrom(string $address, string|null $name = null) * @method static void alwaysReplyTo(string $address, string|null $name = null) * @method static void alwaysReturnPath(string $address) * @method static void alwaysTo(string $address, string|null $name = null) - * @method static \Illuminate\Mail\PendingMail bcc($users) - * @method static \Illuminate\Mail\PendingMail to($users) - * @method static \Illuminate\Support\Collection queued(string $mailable, \Closure|string $callback = null) - * @method static \Illuminate\Support\Collection sent(string $mailable, \Closure|string $callback = null) - * @method static \Illuminate\Mail\SentMessage|null raw(string $text, $callback) - * @method static \Illuminate\Mail\SentMessage|null plain(string $view, array $data, $callback) - * @method static \Illuminate\Mail\SentMessage|null html(string $html, $callback) - * @method static \Illuminate\Mail\SentMessage|null send(\Illuminate\Contracts\Mail\Mailable|string|array $view, array $data = [], \Closure|string $callback = null) - * @method static array failures() - * @method static bool hasQueued(string $mailable) - * @method static bool hasSent(string $mailable) - * @method static mixed later(\DateTimeInterface|\DateInterval|int $delay, \Illuminate\Contracts\Mail\Mailable|string|array $view, string $queue = null) - * @method static mixed laterOn(string $queue, \DateTimeInterface|\DateInterval|int $delay, \Illuminate\Contracts\Mail\Mailable|string|array $view) - * @method static mixed queue(\Illuminate\Contracts\Mail\Mailable|string|array $view, string $queue = null) - * @method static mixed queueOn(string $queue, \Illuminate\Contracts\Mail\Mailable|string|array $view) - * @method static void assertNotQueued(string $mailable, callable $callback = null) - * @method static void assertNotSent(string $mailable, callable|int $callback = null) - * @method static void assertNothingQueued() + * @method static \Illuminate\Mail\PendingMail to(mixed $users) + * @method static \Illuminate\Mail\PendingMail cc(mixed $users) + * @method static \Illuminate\Mail\PendingMail bcc(mixed $users) + * @method static \Illuminate\Mail\SentMessage|null html(string $html, mixed $callback) + * @method static \Illuminate\Mail\SentMessage|null raw(string $text, mixed $callback) + * @method static \Illuminate\Mail\SentMessage|null plain(string $view, array $data, mixed $callback) + * @method static string render(string|array $view, array $data = []) + * @method static \Illuminate\Mail\SentMessage|null send(\Illuminate\Contracts\Mail\Mailable|string|array $view, array $data = [], \Closure|string|null $callback = null) + * @method static mixed queue(\Illuminate\Contracts\Mail\Mailable|string|array $view, string|null $queue = null) + * @method static mixed onQueue(string $queue, \Illuminate\Contracts\Mail\Mailable $view) + * @method static mixed queueOn(string $queue, \Illuminate\Contracts\Mail\Mailable $view) + * @method static mixed later(\DateTimeInterface|\DateInterval|int $delay, \Illuminate\Contracts\Mail\Mailable $view, string|null $queue = null) + * @method static mixed laterOn(string $queue, \DateTimeInterface|\DateInterval|int $delay, \Illuminate\Contracts\Mail\Mailable $view) + * @method static \Symfony\Component\Mailer\Transport\TransportInterface getSymfonyTransport() + * @method static \Illuminate\Contracts\View\Factory getViewFactory() + * @method static void setSymfonyTransport(\Symfony\Component\Mailer\Transport\TransportInterface $transport) + * @method static \Illuminate\Mail\Mailer setQueue(\Illuminate\Contracts\Queue\Factory $queue) + * @method static void macro(string $name, object|callable $macro) + * @method static void mixin(object $mixin, bool $replace = true) + * @method static bool hasMacro(string $name) + * @method static void flushMacros() + * @method static void assertSent(string|\Closure $mailable, callable|int|null $callback = null) + * @method static void assertNotOutgoing(string|\Closure $mailable, callable|null $callback = null) + * @method static void assertNotSent(string|\Closure $mailable, callable|null $callback = null) + * @method static void assertNothingOutgoing() * @method static void assertNothingSent() - * @method static void assertQueued(string|\Closure $mailable, callable|int $callback = null) - * @method static void assertSent(string|\Closure $mailable, callable|int $callback = null) + * @method static void assertQueued(string|\Closure $mailable, callable|int|null $callback = null) + * @method static void assertNotQueued(string|\Closure $mailable, callable|null $callback = null) + * @method static void assertNothingQueued() + * @method static \Illuminate\Support\Collection sent(string|\Closure $mailable, callable|null $callback = null) + * @method static bool hasSent(string $mailable) + * @method static \Illuminate\Support\Collection queued(string|\Closure $mailable, callable|null $callback = null) + * @method static bool hasQueued(string $mailable) + * @method static array failures() * - * @see \Illuminate\Mail\Mailer + * @see \Illuminate\Mail\MailManager * @see \Illuminate\Support\Testing\Fakes\MailFake */ class Mail extends Facade diff --git a/vendor/illuminate/support/Facades/Notification.php b/vendor/illuminate/support/Facades/Notification.php index 68f7201..74d5647 100644 --- a/vendor/illuminate/support/Facades/Notification.php +++ b/vendor/illuminate/support/Facades/Notification.php @@ -7,22 +7,38 @@ use Illuminate\Notifications\ChannelManager; use Illuminate\Support\Testing\Fakes\NotificationFake; /** - * @method static \Illuminate\Notifications\ChannelManager locale(string|null $locale) - * @method static \Illuminate\Support\Collection sent(mixed $notifiable, string $notification, callable $callback = null) - * @method static bool hasSent(mixed $notifiable, string $notification) + * @method static void send(\Illuminate\Support\Collection|array|mixed $notifiables, mixed $notification) + * @method static void sendNow(\Illuminate\Support\Collection|array|mixed $notifiables, mixed $notification, array|null $channels = null) * @method static mixed channel(string|null $name = null) - * @method static void assertNotSentTo(mixed $notifiable, string|\Closure $notification, callable $callback = null) - * @method static void assertNothingSent() - * @method static void assertNothingSentTo(mixed $notifiable) - * @method static void assertSentOnDemand(string|\Closure $notification, callable $callback = null) - * @method static void assertSentTo(mixed $notifiable, string|\Closure $notification, callable $callback = null) + * @method static string getDefaultDriver() + * @method static string deliversVia() + * @method static void deliverVia(string $channel) + * @method static \Illuminate\Notifications\ChannelManager locale(string $locale) + * @method static mixed driver(string|null $driver = null) + * @method static \Illuminate\Notifications\ChannelManager extend(string $driver, \Closure $callback) + * @method static array getDrivers() + * @method static \Illuminate\Contracts\Container\Container getContainer() + * @method static \Illuminate\Notifications\ChannelManager setContainer(\Illuminate\Contracts\Container\Container $container) + * @method static \Illuminate\Notifications\ChannelManager forgetDrivers() + * @method static void assertSentOnDemand(string|\Closure $notification, callable|null $callback = null) + * @method static void assertSentTo(mixed $notifiable, string|\Closure $notification, callable|null $callback = null) * @method static void assertSentOnDemandTimes(string $notification, int $times = 1) * @method static void assertSentToTimes(mixed $notifiable, string $notification, int $times = 1) - * @method static void assertTimesSent(int $expectedCount, string $notification) - * @method static void send(\Illuminate\Support\Collection|array|mixed $notifiables, $notification) - * @method static void sendNow(\Illuminate\Support\Collection|array|mixed $notifiables, $notification) + * @method static void assertNotSentTo(mixed $notifiable, string|\Closure $notification, callable|null $callback = null) + * @method static void assertNothingSent() + * @method static void assertNothingSentTo(mixed $notifiable) + * @method static void assertSentTimes(string $notification, int $expectedCount) + * @method static void assertCount(int $expectedCount) + * @method static \Illuminate\Support\Collection sent(mixed $notifiable, string $notification, callable|null $callback = null) + * @method static bool hasSent(mixed $notifiable, string $notification) + * @method static array sentNotifications() + * @method static void macro(string $name, object|callable $macro) + * @method static void mixin(object $mixin, bool $replace = true) + * @method static bool hasMacro(string $name) + * @method static void flushMacros() * * @see \Illuminate\Notifications\ChannelManager + * @see \Illuminate\Support\Testing\Fakes\NotificationFake */ class Notification extends Facade { diff --git a/vendor/illuminate/support/Facades/ParallelTesting.php b/vendor/illuminate/support/Facades/ParallelTesting.php index c397611..d91558c 100644 --- a/vendor/illuminate/support/Facades/ParallelTesting.php +++ b/vendor/illuminate/support/Facades/ParallelTesting.php @@ -3,12 +3,20 @@ namespace Illuminate\Support\Facades; /** + * @method static void resolveOptionsUsing(\Closure|null $resolver) + * @method static void resolveTokenUsing(\Closure|null $resolver) * @method static void setUpProcess(callable $callback) * @method static void setUpTestCase(callable $callback) * @method static void setUpTestDatabase(callable $callback) * @method static void tearDownProcess(callable $callback) * @method static void tearDownTestCase(callable $callback) - * @method static int|false token() + * @method static void callSetUpProcessCallbacks() + * @method static void callSetUpTestCaseCallbacks(\Illuminate\Foundation\Testing\TestCase $testCase) + * @method static void callSetUpTestDatabaseCallbacks(string $database) + * @method static void callTearDownProcessCallbacks() + * @method static void callTearDownTestCaseCallbacks(\Illuminate\Foundation\Testing\TestCase $testCase) + * @method static mixed option(string $option) + * @method static string|false token() * * @see \Illuminate\Testing\ParallelTesting */ diff --git a/vendor/illuminate/support/Facades/Password.php b/vendor/illuminate/support/Facades/Password.php index 4ff371f..87d9daf 100755 --- a/vendor/illuminate/support/Facades/Password.php +++ b/vendor/illuminate/support/Facades/Password.php @@ -5,15 +5,18 @@ namespace Illuminate\Support\Facades; use Illuminate\Contracts\Auth\PasswordBroker; /** + * @method static \Illuminate\Contracts\Auth\PasswordBroker broker(string|null $name = null) + * @method static string getDefaultDriver() + * @method static void setDefaultDriver(string $name) + * @method static string sendResetLink(array $credentials, \Closure|null $callback = null) * @method static mixed reset(array $credentials, \Closure $callback) - * @method static string sendResetLink(array $credentials, \Closure $callback = null) - * @method static \Illuminate\Contracts\Auth\CanResetPassword getUser(array $credentials) + * @method static \Illuminate\Contracts\Auth\CanResetPassword|null getUser(array $credentials) * @method static string createToken(\Illuminate\Contracts\Auth\CanResetPassword $user) * @method static void deleteToken(\Illuminate\Contracts\Auth\CanResetPassword $user) * @method static bool tokenExists(\Illuminate\Contracts\Auth\CanResetPassword $user, string $token) * @method static \Illuminate\Auth\Passwords\TokenRepositoryInterface getRepository() - * @method static \Illuminate\Contracts\Auth\PasswordBroker broker(string|null $name = null) * + * @see \Illuminate\Auth\Passwords\PasswordBrokerManager * @see \Illuminate\Auth\Passwords\PasswordBroker */ class Password extends Facade diff --git a/vendor/illuminate/support/Facades/Queue.php b/vendor/illuminate/support/Facades/Queue.php index 5af1329..60fc5fe 100755 --- a/vendor/illuminate/support/Facades/Queue.php +++ b/vendor/illuminate/support/Facades/Queue.php @@ -6,24 +6,51 @@ use Illuminate\Queue\Worker; use Illuminate\Support\Testing\Fakes\QueueFake; /** - * @method static \Illuminate\Contracts\Queue\Job|null pop(string $queue = null) - * @method static \Illuminate\Contracts\Queue\Queue setConnectionName(string $name) - * @method static int size(string $queue = null) - * @method static mixed bulk(array $jobs, mixed $data = '', string $queue = null) - * @method static mixed later(\DateTimeInterface|\DateInterval|int $delay, string|object $job, mixed $data = '', string $queue = null) - * @method static mixed laterOn(string $queue, \DateTimeInterface|\DateInterval|int $delay, string|object $job, mixed $data = '') - * @method static mixed push(string|object $job, mixed $data = '', $queue = null) + * @method static void before(mixed $callback) + * @method static void after(mixed $callback) + * @method static void exceptionOccurred(mixed $callback) + * @method static void looping(mixed $callback) + * @method static void failing(mixed $callback) + * @method static void stopping(mixed $callback) + * @method static bool connected(string|null $name = null) + * @method static \Illuminate\Contracts\Queue\Queue connection(string|null $name = null) + * @method static void extend(string $driver, \Closure $resolver) + * @method static void addConnector(string $driver, \Closure $resolver) + * @method static string getDefaultDriver() + * @method static void setDefaultDriver(string $name) + * @method static string getName(string|null $connection = null) + * @method static \Illuminate\Contracts\Foundation\Application getApplication() + * @method static \Illuminate\Queue\QueueManager setApplication(\Illuminate\Contracts\Foundation\Application $app) + * @method static int size(string|null $queue = null) + * @method static mixed push(string|object $job, mixed $data = '', string|null $queue = null) * @method static mixed pushOn(string $queue, string|object $job, mixed $data = '') - * @method static mixed pushRaw(string $payload, string $queue = null, array $options = []) + * @method static mixed pushRaw(string $payload, string|null $queue = null, array $options = []) + * @method static mixed later(\DateTimeInterface|\DateInterval|int $delay, string|object $job, mixed $data = '', string|null $queue = null) + * @method static mixed laterOn(string $queue, \DateTimeInterface|\DateInterval|int $delay, string|object $job, mixed $data = '') + * @method static mixed bulk(array $jobs, mixed $data = '', string|null $queue = null) + * @method static \Illuminate\Contracts\Queue\Job|null pop(string|null $queue = null) * @method static string getConnectionName() - * @method static void assertNotPushed(string|\Closure $job, callable $callback = null) + * @method static \Illuminate\Contracts\Queue\Queue setConnectionName(string $name) + * @method static mixed getJobBackoff(mixed $job) + * @method static mixed getJobExpiration(mixed $job) + * @method static void createPayloadUsing(callable|null $callback) + * @method static \Illuminate\Container\Container getContainer() + * @method static void setContainer(\Illuminate\Container\Container $container) + * @method static \Illuminate\Support\Testing\Fakes\QueueFake except(array|string $jobsToBeQueued) + * @method static void assertPushed(string|\Closure $job, callable|int|null $callback = null) + * @method static void assertPushedOn(string $queue, string|\Closure $job, callable|null $callback = null) + * @method static void assertPushedWithChain(string $job, array $expectedChain = [], callable|null $callback = null) + * @method static void assertPushedWithoutChain(string $job, callable|null $callback = null) + * @method static void assertNotPushed(string|\Closure $job, callable|null $callback = null) * @method static void assertNothingPushed() - * @method static void assertPushed(string|\Closure $job, callable|int $callback = null) - * @method static void assertPushedOn(string $queue, string|\Closure $job, callable $callback = null) - * @method static void assertPushedWithChain(string $job, array $expectedChain = [], callable $callback = null) + * @method static \Illuminate\Support\Collection pushed(string $job, callable|null $callback = null) + * @method static bool hasPushed(string $job) + * @method static bool shouldFakeJob(object $job) + * @method static array pushedJobs() * * @see \Illuminate\Queue\QueueManager * @see \Illuminate\Queue\Queue + * @see \Illuminate\Support\Testing\Fakes\QueueFake */ class Queue extends Facade { @@ -42,11 +69,12 @@ class Queue extends Facade /** * Replace the bound instance with a fake. * + * @param array|string $jobsToFake * @return \Illuminate\Support\Testing\Fakes\QueueFake */ - public static function fake() + public static function fake($jobsToFake = []) { - static::swap($fake = new QueueFake(static::getFacadeApplication())); + static::swap($fake = new QueueFake(static::getFacadeApplication(), $jobsToFake, static::getFacadeRoot())); return $fake; } diff --git a/vendor/illuminate/support/Facades/RateLimiter.php b/vendor/illuminate/support/Facades/RateLimiter.php index 3c33eb2..1a7f082 100644 --- a/vendor/illuminate/support/Facades/RateLimiter.php +++ b/vendor/illuminate/support/Facades/RateLimiter.php @@ -5,14 +5,16 @@ namespace Illuminate\Support\Facades; /** * @method static \Illuminate\Cache\RateLimiter for(string $name, \Closure $callback) * @method static \Closure limiter(string $name) - * @method static bool tooManyAttempts($key, $maxAttempts) - * @method static int hit($key, $decaySeconds = 60) - * @method static mixed attempts($key) - * @method static mixed resetAttempts($key) - * @method static int retriesLeft($key, $maxAttempts) - * @method static void clear($key) - * @method static int availableIn($key) - * @method static bool attempt($key, $maxAttempts, \Closure $callback, $decaySeconds = 60) + * @method static mixed attempt(string $key, int $maxAttempts, \Closure $callback, int $decaySeconds = 60) + * @method static bool tooManyAttempts(string $key, int $maxAttempts) + * @method static int hit(string $key, int $decaySeconds = 60) + * @method static mixed attempts(string $key) + * @method static mixed resetAttempts(string $key) + * @method static int remaining(string $key, int $maxAttempts) + * @method static int retriesLeft(string $key, int $maxAttempts) + * @method static void clear(string $key) + * @method static int availableIn(string $key) + * @method static string cleanRateLimiterKey(string $key) * * @see \Illuminate\Cache\RateLimiter */ diff --git a/vendor/illuminate/support/Facades/Redirect.php b/vendor/illuminate/support/Facades/Redirect.php index c8569b3..ce96f7e 100755 --- a/vendor/illuminate/support/Facades/Redirect.php +++ b/vendor/illuminate/support/Facades/Redirect.php @@ -3,21 +3,25 @@ namespace Illuminate\Support\Facades; /** - * @method static \Illuminate\Http\RedirectResponse action(string $action, mixed $parameters = [], int $status = 302, array $headers = []) - * @method static \Illuminate\Http\RedirectResponse away(string $path, int $status = 302, array $headers = []) - * @method static \Illuminate\Http\RedirectResponse back(int $status = 302, array $headers = [], $fallback = false) - * @method static \Illuminate\Http\RedirectResponse guest(string $path, int $status = 302, array $headers = [], bool $secure = null) - * @method static \Illuminate\Http\RedirectResponse home(int $status = 302) - * @method static \Illuminate\Http\RedirectResponse intended(string $default = '/', int $status = 302, array $headers = [], bool $secure = null) + * @method static \Illuminate\Http\RedirectResponse back(int $status = 302, array $headers = [], mixed $fallback = false) * @method static \Illuminate\Http\RedirectResponse refresh(int $status = 302, array $headers = []) - * @method static \Illuminate\Http\RedirectResponse route(string $route, mixed $parameters = [], int $status = 302, array $headers = []) + * @method static \Illuminate\Http\RedirectResponse guest(string $path, int $status = 302, array $headers = [], bool|null $secure = null) + * @method static \Illuminate\Http\RedirectResponse intended(mixed $default = '/', int $status = 302, array $headers = [], bool|null $secure = null) + * @method static \Illuminate\Http\RedirectResponse to(string $path, int $status = 302, array $headers = [], bool|null $secure = null) + * @method static \Illuminate\Http\RedirectResponse away(string $path, int $status = 302, array $headers = []) * @method static \Illuminate\Http\RedirectResponse secure(string $path, int $status = 302, array $headers = []) - * @method static \Illuminate\Http\RedirectResponse signedRoute(string $name, mixed $parameters = [], \DateTimeInterface|\DateInterval|int $expiration = null, int $status = 302, array $headers = []) - * @method static \Illuminate\Http\RedirectResponse temporarySignedRoute(string $name, \DateTimeInterface|\DateInterval|int $expiration, mixed $parameters = [], int $status = 302, array $headers = []) - * @method static \Illuminate\Http\RedirectResponse to(string $path, int $status = 302, array $headers = [], bool $secure = null) + * @method static \Illuminate\Http\RedirectResponse route(string $route, mixed $parameters = [], int $status = 302, array $headers = []) + * @method static \Illuminate\Http\RedirectResponse signedRoute(string $route, mixed $parameters = [], \DateTimeInterface|\DateInterval|int|null $expiration = null, int $status = 302, array $headers = []) + * @method static \Illuminate\Http\RedirectResponse temporarySignedRoute(string $route, \DateTimeInterface|\DateInterval|int|null $expiration, mixed $parameters = [], int $status = 302, array $headers = []) + * @method static \Illuminate\Http\RedirectResponse action(string|array $action, mixed $parameters = [], int $status = 302, array $headers = []) * @method static \Illuminate\Routing\UrlGenerator getUrlGenerator() * @method static void setSession(\Illuminate\Session\Store $session) - * @method static void setIntendedUrl(string $url) + * @method static string|null getIntendedUrl() + * @method static \Illuminate\Routing\Redirector setIntendedUrl(string $url) + * @method static void macro(string $name, object|callable $macro) + * @method static void mixin(object $mixin, bool $replace = true) + * @method static bool hasMacro(string $name) + * @method static void flushMacros() * * @see \Illuminate\Routing\Redirector */ diff --git a/vendor/illuminate/support/Facades/Redis.php b/vendor/illuminate/support/Facades/Redis.php index 5073020..b796ad0 100755 --- a/vendor/illuminate/support/Facades/Redis.php +++ b/vendor/illuminate/support/Facades/Redis.php @@ -3,12 +3,34 @@ namespace Illuminate\Support\Facades; /** - * @method static \Illuminate\Redis\Connections\Connection connection(string $name = null) + * @method static \Illuminate\Redis\Connections\Connection connection(string|null $name = null) + * @method static \Illuminate\Redis\Connections\Connection resolve(string|null $name = null) + * @method static array connections() + * @method static void enableEvents() + * @method static void disableEvents() + * @method static void setDriver(string $driver) + * @method static void purge(string|null $name = null) + * @method static \Illuminate\Redis\RedisManager extend(string $driver, \Closure $callback) + * @method static void createSubscription(array|string $channels, \Closure $callback, string $method = 'subscribe') * @method static \Illuminate\Redis\Limiters\ConcurrencyLimiterBuilder funnel(string $name) * @method static \Illuminate\Redis\Limiters\DurationLimiterBuilder throttle(string $name) + * @method static mixed client() + * @method static void subscribe(array|string $channels, \Closure $callback) + * @method static void psubscribe(array|string $channels, \Closure $callback) + * @method static mixed command(string $method, array $parameters = []) + * @method static void listen(\Closure $callback) + * @method static string|null getName() + * @method static \Illuminate\Redis\Connections\Connection setName(string $name) + * @method static \Illuminate\Contracts\Events\Dispatcher getEventDispatcher() + * @method static void setEventDispatcher(\Illuminate\Contracts\Events\Dispatcher $events) + * @method static void unsetEventDispatcher() + * @method static void macro(string $name, object|callable $macro) + * @method static void mixin(object $mixin, bool $replace = true) + * @method static bool hasMacro(string $name) + * @method static void flushMacros() + * @method static mixed macroCall(string $method, array $parameters) * * @see \Illuminate\Redis\RedisManager - * @see \Illuminate\Contracts\Redis\Factory */ class Redis extends Facade { diff --git a/vendor/illuminate/support/Facades/Request.php b/vendor/illuminate/support/Facades/Request.php index 05496d9..b62435d 100755 --- a/vendor/illuminate/support/Facades/Request.php +++ b/vendor/illuminate/support/Facades/Request.php @@ -3,89 +3,181 @@ namespace Illuminate\Support\Facades; /** - * @method static \Closure getRouteResolver() - * @method static \Closure getUserResolver() * @method static \Illuminate\Http\Request capture() - * @method static \Illuminate\Http\Request createFrom(\Illuminate\Http\Request $from, \Illuminate\Http\Request|null $to = null) - * @method static \Illuminate\Http\Request createFromBase(\Symfony\Component\HttpFoundation\Request $request) - * @method static \Illuminate\Http\Request duplicate(array|null $query = null, array|null $request = null, array|null $attributes = null, array|null $cookies = null, array|null $files = null, array|null $server = null) * @method static \Illuminate\Http\Request instance() - * @method static \Illuminate\Http\Request merge(array $input) - * @method static \Illuminate\Http\Request replace(array $input) - * @method static \Illuminate\Http\Request setJson(\Symfony\Component\HttpFoundation\ParameterBag $json) - * @method static \Illuminate\Http\Request setRouteResolver(\Closure $callback) - * @method static \Illuminate\Http\Request setUserResolver(\Closure $callback) - * @method static \Illuminate\Http\UploadedFile|\Illuminate\Http\UploadedFile[]|array|null file(string|null $key = null, mixed $default = null) - * @method static \Illuminate\Routing\Route|object|string route(string|null $param = null, string|null $default = null) - * @method static \Illuminate\Session\Store session() - * @method static \Illuminate\Session\Store|null getSession() - * @method static \Symfony\Component\HttpFoundation\ParameterBag|mixed json(string|null $key = null, mixed $default = null) - * @method static array all(array|mixed|null $keys = null) - * @method static array allFiles() - * @method static array except(array|mixed $keys) - * @method static array ips() - * @method static array keys() - * @method static array only(array|mixed $keys) - * @method static array segments() - * @method static array toArray() - * @method static array validate(array $rules, ...$params) - * @method static array validateWithBag(string $errorBag, array $rules, ...$params) - * @method static bool accepts(string|array $contentTypes) - * @method static bool acceptsAnyContentType() - * @method static bool acceptsHtml() - * @method static bool acceptsJson() - * @method static bool ajax() - * @method static bool anyFilled(string|array $key) - * @method static bool exists(string|array $key) - * @method static bool expectsJson() - * @method static bool filled(string|array $key) - * @method static bool fullUrlIs(mixed ...$patterns) - * @method static bool has(string|array $key) - * @method static bool hasAny(string|array $key) - * @method static bool hasCookie(string $key) - * @method static bool hasFile(string $key) - * @method static bool hasHeader(string $key) - * @method static bool hasValidSignature(bool $absolute = true) - * @method static bool is(mixed ...$patterns) - * @method static bool isJson() - * @method static bool matchesType(string $actual, string $type) - * @method static bool offsetExists(string $offset) - * @method static bool pjax() - * @method static bool prefers(string|array $contentTypes) - * @method static bool prefetch() - * @method static bool routeIs(mixed ...$patterns) - * @method static bool secure() - * @method static bool wantsJson() - * @method static mixed filterFiles(mixed $files) - * @method static mixed offsetGet(string $offset) - * @method static mixed user(string|null $guard = null) - * @method static string decodedPath() - * @method static string fingerprint() - * @method static string format($default = 'html') - * @method static string fullUrl() - * @method static string fullUrlWithQuery(array $query) * @method static string method() - * @method static string path() * @method static string root() * @method static string url() - * @method static string userAgent() - * @method static string|array old(string|null $key = null, string|array|null $default = null) - * @method static string|array|null cookie(string|null $key = null, string|array|null $default = null) - * @method static string|array|null header(string|null $key = null, string|array|null $default = null) - * @method static string|array|null input(string|null $key = null, string|array|null $default = null) - * @method static string|array|null post(string|null $key = null, string|array|null $default = null) - * @method static string|array|null query(string|null $key = null, string|array|null $default = null) - * @method static string|array|null server(string|null $key = null, string|array|null $default = null) - * @method static string|null bearerToken() - * @method static string|null ip() + * @method static string fullUrl() + * @method static string fullUrlWithQuery(array $query) + * @method static string fullUrlWithoutQuery(array|string $keys) + * @method static string path() + * @method static string decodedPath() * @method static string|null segment(int $index, string|null $default = null) - * @method static void flash() - * @method static void flashExcept(array|mixed $keys) - * @method static void flashOnly(array|mixed $keys) - * @method static void flush() - * @method static void offsetSet(string $offset, mixed $value) - * @method static void offsetUnset(string $offset) + * @method static array segments() + * @method static bool is(mixed ...$patterns) + * @method static bool routeIs(mixed ...$patterns) + * @method static bool fullUrlIs(mixed ...$patterns) + * @method static string host() + * @method static string httpHost() + * @method static string schemeAndHttpHost() + * @method static bool ajax() + * @method static bool pjax() + * @method static bool prefetch() + * @method static bool secure() + * @method static string|null ip() + * @method static array ips() + * @method static string|null userAgent() + * @method static \Illuminate\Http\Request merge(array $input) + * @method static \Illuminate\Http\Request mergeIfMissing(array $input) + * @method static \Illuminate\Http\Request replace(array $input) + * @method static mixed get(string $key, mixed $default = null) + * @method static \Symfony\Component\HttpFoundation\ParameterBag|mixed json(string|null $key = null, mixed $default = null) + * @method static \Illuminate\Http\Request createFrom(\Illuminate\Http\Request $from, \Illuminate\Http\Request|null $to = null) + * @method static \Illuminate\Http\Request createFromBase(\Symfony\Component\HttpFoundation\Request $request) + * @method static \Illuminate\Http\Request duplicate(array $query = null, array $request = null, array $attributes = null, array $cookies = null, array $files = null, array $server = null) + * @method static bool hasSession(bool $skipIfUninitialized = false) + * @method static \Symfony\Component\HttpFoundation\Session\SessionInterface getSession() + * @method static \Illuminate\Contracts\Session\Session session() * @method static void setLaravelSession(\Illuminate\Contracts\Session\Session $session) + * @method static void setRequestLocale(string $locale) + * @method static void setDefaultRequestLocale(string $locale) + * @method static mixed user(string|null $guard = null) + * @method static \Illuminate\Routing\Route|object|string|null route(string|null $param = null, mixed $default = null) + * @method static string fingerprint() + * @method static \Illuminate\Http\Request setJson(\Symfony\Component\HttpFoundation\ParameterBag $json) + * @method static \Closure getUserResolver() + * @method static \Illuminate\Http\Request setUserResolver(\Closure $callback) + * @method static \Closure getRouteResolver() + * @method static \Illuminate\Http\Request setRouteResolver(\Closure $callback) + * @method static array toArray() + * @method static void initialize(array $query = [], array $request = [], array $attributes = [], array $cookies = [], array $files = [], array $server = [], string|resource|null $content = null) + * @method static \static createFromGlobals() + * @method static \static create(string $uri, string $method = 'GET', array $parameters = [], array $cookies = [], array $files = [], array $server = [], string|resource|null $content = null) + * @method static void setFactory(callable|null $callable) + * @method static void overrideGlobals() + * @method static void setTrustedProxies(array $proxies, int $trustedHeaderSet) + * @method static string[] getTrustedProxies() + * @method static int getTrustedHeaderSet() + * @method static void setTrustedHosts(array $hostPatterns) + * @method static string[] getTrustedHosts() + * @method static string normalizeQueryString(string|null $qs) + * @method static void enableHttpMethodParameterOverride() + * @method static bool getHttpMethodParameterOverride() + * @method static bool hasPreviousSession() + * @method static void setSession(\Symfony\Component\HttpFoundation\Session\SessionInterface $session) + * @method static array getClientIps() + * @method static string|null getClientIp() + * @method static string getScriptName() + * @method static string getPathInfo() + * @method static string getBasePath() + * @method static string getBaseUrl() + * @method static string getScheme() + * @method static int|string|null getPort() + * @method static string|null getUser() + * @method static string|null getPassword() + * @method static string|null getUserInfo() + * @method static string getHttpHost() + * @method static string getRequestUri() + * @method static string getSchemeAndHttpHost() + * @method static string getUri() + * @method static string getUriForPath(string $path) + * @method static string getRelativeUriForPath(string $path) + * @method static string|null getQueryString() + * @method static bool isSecure() + * @method static string getHost() + * @method static void setMethod(string $method) + * @method static string getMethod() + * @method static string getRealMethod() + * @method static string|null getMimeType(string $format) + * @method static string[] getMimeTypes(string $format) + * @method static string|null getFormat(string|null $mimeType) + * @method static void setFormat(string|null $format, string|string[] $mimeTypes) + * @method static string|null getRequestFormat(string|null $default = 'html') + * @method static void setRequestFormat(string|null $format) + * @method static string|null getContentTypeFormat() + * @method static void setDefaultLocale(string $locale) + * @method static string getDefaultLocale() + * @method static void setLocale(string $locale) + * @method static string getLocale() + * @method static bool isMethod(string $method) + * @method static bool isMethodSafe() + * @method static bool isMethodIdempotent() + * @method static bool isMethodCacheable() + * @method static string|null getProtocolVersion() + * @method static string|resource getContent(bool $asResource = false) + * @method static array getETags() + * @method static bool isNoCache() + * @method static string|null getPreferredFormat(string|null $default = 'html') + * @method static string|null getPreferredLanguage(string[] $locales = null) + * @method static string[] getLanguages() + * @method static string[] getCharsets() + * @method static string[] getEncodings() + * @method static string[] getAcceptableContentTypes() + * @method static bool isXmlHttpRequest() + * @method static bool preferSafeContent() + * @method static bool isFromTrustedProxy() + * @method static array filterPrecognitiveRules(array $rules) + * @method static bool isAttemptingPrecognition() + * @method static bool isPrecognitive() + * @method static bool isJson() + * @method static bool expectsJson() + * @method static bool wantsJson() + * @method static bool accepts(string|array $contentTypes) + * @method static string|null prefers(string|array $contentTypes) + * @method static bool acceptsAnyContentType() + * @method static bool acceptsJson() + * @method static bool acceptsHtml() + * @method static bool matchesType(string $actual, string $type) + * @method static string format(string $default = 'html') + * @method static string|array|null old(string|null $key = null, \Illuminate\Database\Eloquent\Model|string|array|null $default = null) + * @method static void flash() + * @method static void flashOnly(array|mixed $keys) + * @method static void flashExcept(array|mixed $keys) + * @method static void flush() + * @method static string|array|null server(string|null $key = null, string|array|null $default = null) + * @method static bool hasHeader(string $key) + * @method static string|array|null header(string|null $key = null, string|array|null $default = null) + * @method static string|null bearerToken() + * @method static bool exists(string|array $key) + * @method static bool has(string|array $key) + * @method static bool hasAny(string|array $keys) + * @method static \Illuminate\Http\Request|mixed whenHas(string $key, callable $callback, callable|null $default = null) + * @method static bool filled(string|array $key) + * @method static bool isNotFilled(string|array $key) + * @method static bool anyFilled(string|array $keys) + * @method static \Illuminate\Http\Request|mixed whenFilled(string $key, callable $callback, callable|null $default = null) + * @method static bool missing(string|array $key) + * @method static \Illuminate\Http\Request|mixed whenMissing(string $key, callable $callback, callable|null $default = null) + * @method static array keys() + * @method static array all(array|mixed|null $keys = null) + * @method static mixed input(string|null $key = null, mixed $default = null) + * @method static \Illuminate\Support\Stringable str(string $key, mixed $default = null) + * @method static \Illuminate\Support\Stringable string(string $key, mixed $default = null) + * @method static bool boolean(string|null $key = null, bool $default = false) + * @method static int integer(string $key, int $default = 0) + * @method static float float(string $key, float $default = 0) + * @method static \Illuminate\Support\Carbon|null date(string $key, string|null $format = null, string|null $tz = null) + * @method static object|null enum(string $key, string $enumClass) + * @method static \Illuminate\Support\Collection collect(array|string|null $key = null) + * @method static array only(array|mixed $keys) + * @method static array except(array|mixed $keys) + * @method static string|array|null query(string|null $key = null, string|array|null $default = null) + * @method static string|array|null post(string|null $key = null, string|array|null $default = null) + * @method static bool hasCookie(string $key) + * @method static string|array|null cookie(string|null $key = null, string|array|null $default = null) + * @method static array allFiles() + * @method static bool hasFile(string $key) + * @method static \Illuminate\Http\UploadedFile|\Illuminate\Http\UploadedFile[]|array|null file(string|null $key = null, mixed $default = null) + * @method static never dd(mixed ...$keys) + * @method static \Illuminate\Http\Request dump(mixed $keys = []) + * @method static void macro(string $name, object|callable $macro) + * @method static void mixin(object $mixin, bool $replace = true) + * @method static bool hasMacro(string $name) + * @method static void flushMacros() + * @method static array validate(array $rules, ...$params) + * @method static array validateWithBag(string $errorBag, array $rules, ...$params) + * @method static bool hasValidSignature(bool $absolute = true) * * @see \Illuminate\Http\Request */ diff --git a/vendor/illuminate/support/Facades/Response.php b/vendor/illuminate/support/Facades/Response.php index 6f31960..6a9d46f 100755 --- a/vendor/illuminate/support/Facades/Response.php +++ b/vendor/illuminate/support/Facades/Response.php @@ -5,22 +5,26 @@ namespace Illuminate\Support\Facades; use Illuminate\Contracts\Routing\ResponseFactory as ResponseFactoryContract; /** - * @method static \Illuminate\Http\JsonResponse json(string|array $data = [], int $status = 200, array $headers = [], int $options = 0) - * @method static \Illuminate\Http\JsonResponse jsonp(string $callback, string|array $data = [], int $status = 200, array $headers = [], int $options = 0) - * @method static \Illuminate\Http\RedirectResponse redirectGuest(string $path, int $status = 302, array $headers = [], bool|null $secure = null) - * @method static \Illuminate\Http\RedirectResponse redirectTo(string $path, int $status = 302, array $headers = [], bool|null $secure = null) - * @method static \Illuminate\Http\RedirectResponse redirectToAction(string $action, mixed $parameters = [], int $status = 302, array $headers = []) - * @method static \Illuminate\Http\RedirectResponse redirectToIntended(string $default = '/', int $status = 302, array $headers = [], bool|null $secure = null) - * @method static \Illuminate\Http\RedirectResponse redirectToRoute(string $route, mixed $parameters = [], int $status = 302, array $headers = []) - * @method static \Illuminate\Http\Response make(array|string $content = '', int $status = 200, array $headers = []) - * @method static \Illuminate\Http\Response noContent($status = 204, array $headers = []) - * @method static \Illuminate\Http\Response view(string $view, array $data = [], int $status = 200, array $headers = []) + * @method static \Illuminate\Http\Response make(mixed $content = '', int $status = 200, array $headers = []) + * @method static \Illuminate\Http\Response noContent(int $status = 204, array $headers = []) + * @method static \Illuminate\Http\Response view(string|array $view, array $data = [], int $status = 200, array $headers = []) + * @method static \Illuminate\Http\JsonResponse json(mixed $data = [], int $status = 200, array $headers = [], int $options = 0) + * @method static \Illuminate\Http\JsonResponse jsonp(string $callback, mixed $data = [], int $status = 200, array $headers = [], int $options = 0) + * @method static \Symfony\Component\HttpFoundation\StreamedResponse stream(callable $callback, int $status = 200, array $headers = []) + * @method static \Symfony\Component\HttpFoundation\StreamedResponse streamDownload(callable $callback, string|null $name = null, array $headers = [], string|null $disposition = 'attachment') * @method static \Symfony\Component\HttpFoundation\BinaryFileResponse download(\SplFileInfo|string $file, string|null $name = null, array $headers = [], string|null $disposition = 'attachment') - * @method static \Symfony\Component\HttpFoundation\BinaryFileResponse file($file, array $headers = []) - * @method static \Symfony\Component\HttpFoundation\StreamedResponse stream(\Closure $callback, int $status = 200, array $headers = []) - * @method static \Symfony\Component\HttpFoundation\StreamedResponse streamDownload(\Closure $callback, string|null $name = null, array $headers = [], string|null $disposition = 'attachment') + * @method static \Symfony\Component\HttpFoundation\BinaryFileResponse file(\SplFileInfo|string $file, array $headers = []) + * @method static \Illuminate\Http\RedirectResponse redirectTo(string $path, int $status = 302, array $headers = [], bool|null $secure = null) + * @method static \Illuminate\Http\RedirectResponse redirectToRoute(string $route, mixed $parameters = [], int $status = 302, array $headers = []) + * @method static \Illuminate\Http\RedirectResponse redirectToAction(string $action, mixed $parameters = [], int $status = 302, array $headers = []) + * @method static \Illuminate\Http\RedirectResponse redirectGuest(string $path, int $status = 302, array $headers = [], bool|null $secure = null) + * @method static \Illuminate\Http\RedirectResponse redirectToIntended(string $default = '/', int $status = 302, array $headers = [], bool|null $secure = null) + * @method static void macro(string $name, object|callable $macro) + * @method static void mixin(object $mixin, bool $replace = true) + * @method static bool hasMacro(string $name) + * @method static void flushMacros() * - * @see \Illuminate\Contracts\Routing\ResponseFactory + * @see \Illuminate\Routing\ResponseFactory */ class Response extends Facade { diff --git a/vendor/illuminate/support/Facades/Route.php b/vendor/illuminate/support/Facades/Route.php index bc956c1..6fdaf6e 100755 --- a/vendor/illuminate/support/Facades/Route.php +++ b/vendor/illuminate/support/Facades/Route.php @@ -3,24 +3,89 @@ namespace Illuminate\Support\Facades; /** - * @method static \Illuminate\Routing\PendingResourceRegistration apiResource(string $name, string $controller, array $options = []) - * @method static \Illuminate\Routing\PendingResourceRegistration resource(string $name, string $controller, array $options = []) - * @method static \Illuminate\Routing\Route any(string $uri, array|string|callable|null $action = null) - * @method static \Illuminate\Routing\Route|null current() - * @method static \Illuminate\Routing\Route delete(string $uri, array|string|callable|null $action = null) - * @method static \Illuminate\Routing\Route fallback(array|string|callable|null $action = null) * @method static \Illuminate\Routing\Route get(string $uri, array|string|callable|null $action = null) - * @method static \Illuminate\Routing\Route|null getCurrentRoute() - * @method static \Illuminate\Routing\RouteCollectionInterface getRoutes() - * @method static \Illuminate\Routing\Route match(array|string $methods, string $uri, array|string|callable|null $action = null) - * @method static \Illuminate\Routing\Route options(string $uri, array|string|callable|null $action = null) - * @method static \Illuminate\Routing\Route patch(string $uri, array|string|callable|null $action = null) - * @method static \Illuminate\Routing\Route permanentRedirect(string $uri, string $destination) * @method static \Illuminate\Routing\Route post(string $uri, array|string|callable|null $action = null) * @method static \Illuminate\Routing\Route put(string $uri, array|string|callable|null $action = null) + * @method static \Illuminate\Routing\Route patch(string $uri, array|string|callable|null $action = null) + * @method static \Illuminate\Routing\Route delete(string $uri, array|string|callable|null $action = null) + * @method static \Illuminate\Routing\Route options(string $uri, array|string|callable|null $action = null) + * @method static \Illuminate\Routing\Route any(string $uri, array|string|callable|null $action = null) + * @method static \Illuminate\Routing\Route fallback(array|string|callable|null $action) * @method static \Illuminate\Routing\Route redirect(string $uri, string $destination, int $status = 302) - * @method static \Illuminate\Routing\Route substituteBindings(\Illuminate\Support\Facades\Route $route) + * @method static \Illuminate\Routing\Route permanentRedirect(string $uri, string $destination) * @method static \Illuminate\Routing\Route view(string $uri, string $view, array $data = [], int|array $status = 200, array $headers = []) + * @method static \Illuminate\Routing\Route match(array|string $methods, string $uri, array|string|callable|null $action = null) + * @method static void resources(array $resources, array $options = []) + * @method static \Illuminate\Routing\PendingResourceRegistration resource(string $name, string $controller, array $options = []) + * @method static void apiResources(array $resources, array $options = []) + * @method static \Illuminate\Routing\PendingResourceRegistration apiResource(string $name, string $controller, array $options = []) + * @method static void singletons(array $singletons, array $options = []) + * @method static \Illuminate\Routing\PendingSingletonResourceRegistration singleton(string $name, string $controller, array $options = []) + * @method static void apiSingletons(array $singletons, array $options = []) + * @method static \Illuminate\Routing\PendingSingletonResourceRegistration apiSingleton(string $name, string $controller, array $options = []) + * @method static \Illuminate\Routing\Router group(array $attributes, \Closure|array|string $routes) + * @method static array mergeWithLastGroup(array $new, bool $prependExistingPrefix = true) + * @method static string getLastGroupPrefix() + * @method static \Illuminate\Routing\Route addRoute(array|string $methods, string $uri, array|string|callable|null $action) + * @method static \Illuminate\Routing\Route newRoute(array|string $methods, string $uri, mixed $action) + * @method static \Symfony\Component\HttpFoundation\Response respondWithRoute(string $name) + * @method static \Symfony\Component\HttpFoundation\Response dispatch(\Illuminate\Http\Request $request) + * @method static \Symfony\Component\HttpFoundation\Response dispatchToRoute(\Illuminate\Http\Request $request) + * @method static array gatherRouteMiddleware(\Illuminate\Routing\Route $route) + * @method static array resolveMiddleware(array $middleware, array $excluded = []) + * @method static \Symfony\Component\HttpFoundation\Response prepareResponse(\Symfony\Component\HttpFoundation\Request $request, mixed $response) + * @method static \Symfony\Component\HttpFoundation\Response toResponse(\Symfony\Component\HttpFoundation\Request $request, mixed $response) + * @method static \Illuminate\Routing\Route substituteBindings(\Illuminate\Routing\Route $route) + * @method static void substituteImplicitBindings(\Illuminate\Routing\Route $route) + * @method static void matched(string|callable $callback) + * @method static array getMiddleware() + * @method static \Illuminate\Routing\Router aliasMiddleware(string $name, string $class) + * @method static bool hasMiddlewareGroup(string $name) + * @method static array getMiddlewareGroups() + * @method static \Illuminate\Routing\Router middlewareGroup(string $name, array $middleware) + * @method static \Illuminate\Routing\Router prependMiddlewareToGroup(string $group, string $middleware) + * @method static \Illuminate\Routing\Router pushMiddlewareToGroup(string $group, string $middleware) + * @method static \Illuminate\Routing\Router removeMiddlewareFromGroup(string $group, string $middleware) + * @method static \Illuminate\Routing\Router flushMiddlewareGroups() + * @method static void bind(string $key, string|callable $binder) + * @method static void model(string $key, string $class, \Closure|null $callback = null) + * @method static \Closure|null getBindingCallback(string $key) + * @method static array getPatterns() + * @method static void pattern(string $key, string $pattern) + * @method static void patterns(array $patterns) + * @method static bool hasGroupStack() + * @method static array getGroupStack() + * @method static mixed input(string $key, string|null $default = null) + * @method static \Illuminate\Http\Request getCurrentRequest() + * @method static \Illuminate\Routing\Route|null getCurrentRoute() + * @method static \Illuminate\Routing\Route|null current() + * @method static bool has(string|array $name) + * @method static string|null currentRouteName() + * @method static bool is(mixed ...$patterns) + * @method static bool currentRouteNamed(mixed ...$patterns) + * @method static string|null currentRouteAction() + * @method static bool uses(array ...$patterns) + * @method static bool currentRouteUses(string $action) + * @method static void singularResourceParameters(bool $singular = true) + * @method static void resourceParameters(array $parameters = []) + * @method static array|null resourceVerbs(array $verbs = []) + * @method static \Illuminate\Routing\RouteCollectionInterface getRoutes() + * @method static void setRoutes(\Illuminate\Routing\RouteCollection $routes) + * @method static void setCompiledRoutes(array $routes) + * @method static array uniqueMiddleware(array $middleware) + * @method static \Illuminate\Routing\Router setContainer(\Illuminate\Container\Container $container) + * @method static void macro(string $name, object|callable $macro) + * @method static void mixin(object $mixin, bool $replace = true) + * @method static bool hasMacro(string $name) + * @method static void flushMacros() + * @method static mixed macroCall(string $method, array $parameters) + * @method static \Illuminate\Routing\RouteRegistrar attribute(string $key, mixed $value) + * @method static \Illuminate\Routing\RouteRegistrar whereAlpha(array|string $parameters) + * @method static \Illuminate\Routing\RouteRegistrar whereAlphaNumeric(array|string $parameters) + * @method static \Illuminate\Routing\RouteRegistrar whereNumber(array|string $parameters) + * @method static \Illuminate\Routing\RouteRegistrar whereUlid(array|string $parameters) + * @method static \Illuminate\Routing\RouteRegistrar whereUuid(array|string $parameters) + * @method static \Illuminate\Routing\RouteRegistrar whereIn(array|string $parameters, array $values) * @method static \Illuminate\Routing\RouteRegistrar as(string $value) * @method static \Illuminate\Routing\RouteRegistrar controller(string $controller) * @method static \Illuminate\Routing\RouteRegistrar domain(string $value) @@ -30,20 +95,8 @@ namespace Illuminate\Support\Facades; * @method static \Illuminate\Routing\RouteRegistrar prefix(string $prefix) * @method static \Illuminate\Routing\RouteRegistrar scopeBindings() * @method static \Illuminate\Routing\RouteRegistrar where(array $where) - * @method static \Illuminate\Routing\Router|\Illuminate\Routing\RouteRegistrar group(\Closure|string|array $attributes, \Closure|string $routes) - * @method static \Illuminate\Routing\ResourceRegistrar resourceVerbs(array $verbs = []) - * @method static string|null currentRouteAction() - * @method static string|null currentRouteName() - * @method static void apiResources(array $resources, array $options = []) - * @method static void bind(string $key, string|callable $binder) - * @method static void model(string $key, string $class, \Closure|null $callback = null) - * @method static void pattern(string $key, string $pattern) - * @method static void resources(array $resources, array $options = []) - * @method static void substituteImplicitBindings(\Illuminate\Support\Facades\Route $route) - * @method static boolean uses(...$patterns) - * @method static boolean is(...$patterns) - * @method static boolean has(string $name) - * @method static mixed input(string $key, string|null $default = null) + * @method static \Illuminate\Routing\RouteRegistrar withoutMiddleware(array|string $middleware) + * @method static \Illuminate\Routing\RouteRegistrar withoutScopedBindings() * * @see \Illuminate\Routing\Router */ diff --git a/vendor/illuminate/support/Facades/Schema.php b/vendor/illuminate/support/Facades/Schema.php index 2b0584d..f3084d0 100755 --- a/vendor/illuminate/support/Facades/Schema.php +++ b/vendor/illuminate/support/Facades/Schema.php @@ -3,25 +3,36 @@ namespace Illuminate\Support\Facades; /** - * @method static \Illuminate\Database\Schema\Builder create(string $table, \Closure $callback) - * @method static \Illuminate\Database\Schema\Builder createDatabase(string $name) - * @method static \Illuminate\Database\Schema\Builder disableForeignKeyConstraints() - * @method static \Illuminate\Database\Schema\Builder drop(string $table) - * @method static \Illuminate\Database\Schema\Builder dropDatabaseIfExists(string $name) - * @method static \Illuminate\Database\Schema\Builder dropIfExists(string $table) - * @method static \Illuminate\Database\Schema\Builder enableForeignKeyConstraints() - * @method static \Illuminate\Database\Schema\Builder rename(string $from, string $to) - * @method static \Illuminate\Database\Schema\Builder table(string $table, \Closure $callback) + * @method static void defaultStringLength(int $length) + * @method static void defaultMorphKeyType(string $type) + * @method static void morphUsingUuids() + * @method static void morphUsingUlids() + * @method static void useNativeSchemaOperationsIfPossible(bool $value = true) + * @method static bool createDatabase(string $name) + * @method static bool dropDatabaseIfExists(string $name) + * @method static bool hasTable(string $table) * @method static bool hasColumn(string $table, string $column) * @method static bool hasColumns(string $table, array $columns) - * @method static bool dropColumns(string $table, array $columns) - * @method static bool hasTable(string $table) - * @method static void defaultStringLength(int $length) - * @method static array getColumnListing(string $table) + * @method static void whenTableHasColumn(string $table, string $column, \Closure $callback) + * @method static void whenTableDoesntHaveColumn(string $table, string $column, \Closure $callback) * @method static string getColumnType(string $table, string $column) - * @method static void morphUsingUuids() + * @method static array getColumnListing(string $table) + * @method static void table(string $table, \Closure $callback) + * @method static void create(string $table, \Closure $callback) + * @method static void drop(string $table) + * @method static void dropIfExists(string $table) + * @method static void dropColumns(string $table, string|array $columns) + * @method static void dropAllTables() + * @method static void dropAllViews() + * @method static void dropAllTypes() + * @method static void getAllTables() + * @method static void rename(string $from, string $to) + * @method static bool enableForeignKeyConstraints() + * @method static bool disableForeignKeyConstraints() + * @method static mixed withoutForeignKeyConstraints(\Closure $callback) * @method static \Illuminate\Database\Connection getConnection() * @method static \Illuminate\Database\Schema\Builder setConnection(\Illuminate\Database\Connection $connection) + * @method static void blueprintResolver(\Closure $resolver) * * @see \Illuminate\Database\Schema\Builder */ diff --git a/vendor/illuminate/support/Facades/Session.php b/vendor/illuminate/support/Facades/Session.php index a072321..e1ea753 100755 --- a/vendor/illuminate/support/Facades/Session.php +++ b/vendor/illuminate/support/Facades/Session.php @@ -3,33 +3,68 @@ namespace Illuminate\Support\Facades; /** - * @method static \SessionHandlerInterface getHandler() - * @method static array all() - * @method static bool exists(string|array $key) - * @method static bool handlerNeedsRequest() - * @method static bool has(string|array $key) - * @method static bool isStarted() - * @method static bool migrate(bool $destroy = false) - * @method static bool save() + * @method static bool shouldBlock() + * @method static string|null blockDriver() + * @method static array getSessionConfig() + * @method static string getDefaultDriver() + * @method static void setDefaultDriver(string $name) + * @method static mixed driver(string|null $driver = null) + * @method static \Illuminate\Session\SessionManager extend(string $driver, \Closure $callback) + * @method static array getDrivers() + * @method static \Illuminate\Contracts\Container\Container getContainer() + * @method static \Illuminate\Session\SessionManager setContainer(\Illuminate\Contracts\Container\Container $container) + * @method static \Illuminate\Session\SessionManager forgetDrivers() * @method static bool start() - * @method static mixed get(string $key, $default = null) - * @method static mixed flash(string $key, $value = true) - * @method static mixed pull(string $key, $default = null) - * @method static mixed remove(string $key) - * @method static string getId() - * @method static string getName() - * @method static string token() - * @method static string|null previousUrl() - * @method static void flush() - * @method static void forget(string|array $keys) + * @method static void save() + * @method static void ageFlashData() + * @method static array all() + * @method static array only(array $keys) + * @method static bool exists(string|array $key) + * @method static bool missing(string|array $key) + * @method static bool has(string|array $key) + * @method static mixed get(string $key, mixed $default = null) + * @method static mixed pull(string $key, mixed $default = null) + * @method static bool hasOldInput(string|null $key = null) + * @method static mixed getOldInput(string|null $key = null, mixed $default = null) + * @method static void replace(array $attributes) + * @method static void put(string|array $key, mixed $value = null) + * @method static mixed remember(string $key, \Closure $callback) * @method static void push(string $key, mixed $value) - * @method static void put(string|array $key, $value = null) - * @method static void setId(string $id) + * @method static mixed increment(string $key, int $amount = 1) + * @method static int decrement(string $key, int $amount = 1) + * @method static void flash(string $key, mixed $value = true) + * @method static void now(string $key, mixed $value) + * @method static void reflash() + * @method static void keep(array|mixed $keys = null) + * @method static void flashInput(array $value) + * @method static mixed remove(string $key) + * @method static void forget(string|array $keys) + * @method static void flush() + * @method static bool invalidate() + * @method static bool regenerate(bool $destroy = false) + * @method static bool migrate(bool $destroy = false) + * @method static bool isStarted() + * @method static string getName() + * @method static void setName(string $name) + * @method static string getId() + * @method static void setId(string|null $id) + * @method static bool isValidId(string|null $id) + * @method static void setExists(bool $value) + * @method static string token() + * @method static void regenerateToken() + * @method static string|null previousUrl() * @method static void setPreviousUrl(string $url) + * @method static void passwordConfirmed() + * @method static \SessionHandlerInterface getHandler() + * @method static \SessionHandlerInterface setHandler(\SessionHandlerInterface $handler) + * @method static bool handlerNeedsRequest() * @method static void setRequestOnHandler(\Illuminate\Http\Request $request) + * @method static void macro(string $name, object|callable $macro) + * @method static void mixin(object $mixin, bool $replace = true) + * @method static bool hasMacro(string $name) + * @method static void flushMacros() * * @see \Illuminate\Session\SessionManager - * @see \Illuminate\Session\Store */ class Session extends Facade { diff --git a/vendor/illuminate/support/Facades/Storage.php b/vendor/illuminate/support/Facades/Storage.php index 581183f..f8fcddd 100644 --- a/vendor/illuminate/support/Facades/Storage.php +++ b/vendor/illuminate/support/Facades/Storage.php @@ -5,43 +5,79 @@ namespace Illuminate\Support\Facades; use Illuminate\Filesystem\Filesystem; /** - * @method static \Illuminate\Contracts\Filesystem\Filesystem assertExists(string|array $path) - * @method static \Illuminate\Contracts\Filesystem\Filesystem assertMissing(string|array $path) - * @method static \Illuminate\Contracts\Filesystem\Filesystem cloud() - * @method static \Illuminate\Contracts\Filesystem\Filesystem build(string|array $root) + * @method static \Illuminate\Contracts\Filesystem\Filesystem drive(string|null $name = null) * @method static \Illuminate\Contracts\Filesystem\Filesystem disk(string|null $name = null) + * @method static \Illuminate\Contracts\Filesystem\Filesystem cloud() + * @method static \Illuminate\Contracts\Filesystem\Filesystem build(string|array $config) + * @method static \Illuminate\Contracts\Filesystem\Filesystem createLocalDriver(array $config) + * @method static \Illuminate\Contracts\Filesystem\Filesystem createFtpDriver(array $config) + * @method static \Illuminate\Contracts\Filesystem\Filesystem createSftpDriver(array $config) + * @method static \Illuminate\Contracts\Filesystem\Cloud createS3Driver(array $config) + * @method static \Illuminate\Contracts\Filesystem\Filesystem createScopedDriver(array $config) + * @method static \Illuminate\Filesystem\FilesystemManager set(string $name, mixed $disk) + * @method static string getDefaultDriver() + * @method static string getDefaultCloudDriver() + * @method static \Illuminate\Filesystem\FilesystemManager forgetDisk(array|string $disk) + * @method static void purge(string|null $name = null) * @method static \Illuminate\Filesystem\FilesystemManager extend(string $driver, \Closure $callback) - * @method static \Symfony\Component\HttpFoundation\StreamedResponse download(string $path, string|null $name = null, array|null $headers = []) - * @method static \Symfony\Component\HttpFoundation\StreamedResponse response(string $path, string|null $name = null, array|null $headers = [], string|null $disposition = 'inline') - * @method static array allDirectories(string|null $directory = null) + * @method static \Illuminate\Filesystem\FilesystemManager setApplication(\Illuminate\Contracts\Foundation\Application $app) + * @method static bool exists(string $path) + * @method static string|null get(string $path) + * @method static resource|null readStream(string $path) + * @method static bool put(string $path, string|resource $contents, mixed $options = []) + * @method static bool writeStream(string $path, resource $resource, array $options = []) + * @method static string getVisibility(string $path) + * @method static bool setVisibility(string $path, string $visibility) + * @method static bool prepend(string $path, string $data) + * @method static bool append(string $path, string $data) + * @method static bool delete(string|array $paths) + * @method static bool copy(string $from, string $to) + * @method static bool move(string $from, string $to) + * @method static int size(string $path) + * @method static int lastModified(string $path) + * @method static array files(string|null $directory = null, bool $recursive = false) * @method static array allFiles(string|null $directory = null) * @method static array directories(string|null $directory = null, bool $recursive = false) - * @method static array files(string|null $directory = null, bool $recursive = false) - * @method static bool append(string $path, string $data) - * @method static bool copy(string $from, string $to) - * @method static bool delete(string|array $paths) - * @method static bool deleteDirectory(string $directory) - * @method static bool exists(string $path) + * @method static array allDirectories(string|null $directory = null) * @method static bool makeDirectory(string $path) + * @method static bool deleteDirectory(string $directory) + * @method static \Illuminate\Filesystem\FilesystemAdapter assertExists(string|array $path, string|null $content = null) + * @method static \Illuminate\Filesystem\FilesystemAdapter assertMissing(string|array $path) + * @method static \Illuminate\Filesystem\FilesystemAdapter assertDirectoryEmpty(string $path) * @method static bool missing(string $path) - * @method static bool move(string $from, string $to) - * @method static bool prepend(string $path, string $data) - * @method static bool put(string $path, \Psr\Http\Message\StreamInterface|\Illuminate\Http\File|\Illuminate\Http\UploadedFile|string|resource $contents, mixed $options = []) - * @method static bool setVisibility(string $path, string $visibility) - * @method static bool writeStream(string $path, resource $resource, array $options = []) - * @method static int lastModified(string $path) - * @method static int size(string $path) - * @method static resource|null readStream(string $path) - * @method static string get(string $path) - * @method static string getVisibility(string $path) + * @method static bool fileExists(string $path) + * @method static bool fileMissing(string $path) + * @method static bool directoryExists(string $path) + * @method static bool directoryMissing(string $path) * @method static string path(string $path) - * @method static string temporaryUrl(string $path, \DateTimeInterface $expiration, array $options = []) - * @method static string url(string $path) - * @method static string|false mimeType(string $path) + * @method static \Symfony\Component\HttpFoundation\StreamedResponse response(string $path, string|null $name = null, array $headers = [], string|null $disposition = 'inline') + * @method static \Symfony\Component\HttpFoundation\StreamedResponse download(string $path, string|null $name = null, array $headers = []) * @method static string|false putFile(string $path, \Illuminate\Http\File|\Illuminate\Http\UploadedFile|string $file, mixed $options = []) * @method static string|false putFileAs(string $path, \Illuminate\Http\File|\Illuminate\Http\UploadedFile|string $file, string $name, mixed $options = []) - * @method static void macro(string $name, object|callable $macro) + * @method static string|false checksum(string $path, array $options = []) + * @method static string|false mimeType(string $path) + * @method static string url(string $path) + * @method static bool providesTemporaryUrls() + * @method static string temporaryUrl(string $path, \DateTimeInterface $expiration, array $options = []) + * @method static array temporaryUploadUrl(string $path, \DateTimeInterface $expiration, array $options = []) + * @method static \League\Flysystem\FilesystemOperator getDriver() + * @method static \League\Flysystem\FilesystemAdapter getAdapter() + * @method static array getConfig() * @method static void buildTemporaryUrlsUsing(\Closure $callback) + * @method static \Illuminate\Filesystem\FilesystemAdapter|mixed when(\Closure|mixed|null $value = null, callable|null $callback = null, callable|null $default = null) + * @method static \Illuminate\Filesystem\FilesystemAdapter|mixed unless(\Closure|mixed|null $value = null, callable|null $callback = null, callable|null $default = null) + * @method static void macro(string $name, object|callable $macro) + * @method static void mixin(object $mixin, bool $replace = true) + * @method static bool hasMacro(string $name) + * @method static void flushMacros() + * @method static mixed macroCall(string $method, array $parameters) + * @method static bool has(string $location) + * @method static string read(string $location) + * @method static \League\Flysystem\DirectoryListing listContents(string $location, bool $deep = false) + * @method static int fileSize(string $path) + * @method static string visibility(string $path) + * @method static void write(string $location, string $contents, array $config = []) + * @method static void createDirectory(string $location, array $config = []) * * @see \Illuminate\Filesystem\FilesystemManager */ diff --git a/vendor/illuminate/support/Facades/URL.php b/vendor/illuminate/support/Facades/URL.php index 7d9941d..8da96f4 100755 --- a/vendor/illuminate/support/Facades/URL.php +++ b/vendor/illuminate/support/Facades/URL.php @@ -3,24 +3,48 @@ namespace Illuminate\Support\Facades; /** - * @method static \Illuminate\Contracts\Routing\UrlGenerator setRootControllerNamespace(string $rootNamespace) - * @method static bool hasValidSignature(\Illuminate\Http\Request $request, bool $absolute = true) - * @method static string action(string|array $action, $parameters = [], bool $absolute = true) - * @method static string asset(string $path, bool $secure = null) - * @method static string secureAsset(string $path) - * @method static string current() * @method static string full() + * @method static string current() + * @method static string previous(mixed $fallback = false) + * @method static string previousPath(mixed $fallback = false) + * @method static string to(string $path, mixed $extra = [], bool|null $secure = null) + * @method static string secure(string $path, array $parameters = []) + * @method static string asset(string $path, bool|null $secure = null) + * @method static string secureAsset(string $path) + * @method static string assetFrom(string $root, string $path, bool|null $secure = null) + * @method static string formatScheme(bool|null $secure = null) + * @method static string signedRoute(string $name, mixed $parameters = [], \DateTimeInterface|\DateInterval|int|null $expiration = null, bool $absolute = true) + * @method static string temporarySignedRoute(string $name, \DateTimeInterface|\DateInterval|int $expiration, array $parameters = [], bool $absolute = true) + * @method static bool hasValidSignature(\Illuminate\Http\Request $request, bool $absolute = true, array $ignoreQuery = []) + * @method static bool hasValidRelativeSignature(\Illuminate\Http\Request $request, array $ignoreQuery = []) + * @method static bool hasCorrectSignature(\Illuminate\Http\Request $request, bool $absolute = true, array $ignoreQuery = []) + * @method static bool signatureHasNotExpired(\Illuminate\Http\Request $request) + * @method static string route(string $name, mixed $parameters = [], bool $absolute = true) + * @method static string toRoute(\Illuminate\Routing\Route $route, mixed $parameters, bool $absolute) + * @method static string action(string|array $action, mixed $parameters = [], bool $absolute = true) + * @method static array formatParameters(mixed|array $parameters) + * @method static string formatRoot(string $scheme, string|null $root = null) + * @method static string format(string $root, string $path, \Illuminate\Routing\Route|null $route = null) + * @method static bool isValidUrl(string $path) + * @method static void defaults(array $defaults) + * @method static array getDefaultParameters() + * @method static void forceScheme(string|null $scheme) + * @method static void forceRootUrl(string|null $root) + * @method static \Illuminate\Routing\UrlGenerator formatHostUsing(\Closure $callback) + * @method static \Illuminate\Routing\UrlGenerator formatPathUsing(\Closure $callback) + * @method static \Closure pathFormatter() + * @method static \Illuminate\Http\Request getRequest() + * @method static void setRequest(\Illuminate\Http\Request $request) + * @method static \Illuminate\Routing\UrlGenerator setRoutes(\Illuminate\Routing\RouteCollectionInterface $routes) + * @method static \Illuminate\Routing\UrlGenerator setSessionResolver(callable $sessionResolver) + * @method static \Illuminate\Routing\UrlGenerator setKeyResolver(callable $keyResolver) + * @method static \Illuminate\Routing\UrlGenerator withKeyResolver(callable $keyResolver) + * @method static string getRootControllerNamespace() + * @method static \Illuminate\Routing\UrlGenerator setRootControllerNamespace(string $rootNamespace) * @method static void macro(string $name, object|callable $macro) * @method static void mixin(object $mixin, bool $replace = true) - * @method static string previous($fallback = false) - * @method static string route(string $name, $parameters = [], bool $absolute = true) - * @method static string secure(string $path, array $parameters = []) - * @method static string signedRoute(string $name, array $parameters = [], \DateTimeInterface|\DateInterval|int $expiration = null, bool $absolute = true) - * @method static string temporarySignedRoute(string $name, \DateTimeInterface|\DateInterval|int $expiration, array $parameters = [], bool $absolute = true) - * @method static string to(string $path, $extra = [], bool $secure = null) - * @method static void defaults(array $defaults) - * @method static void forceScheme(string $scheme) - * @method static bool isValidUrl(string $path) + * @method static bool hasMacro(string $name) + * @method static void flushMacros() * * @see \Illuminate\Routing\UrlGenerator */ diff --git a/vendor/illuminate/support/Facades/Validator.php b/vendor/illuminate/support/Facades/Validator.php index 0141277..4d7002b 100755 --- a/vendor/illuminate/support/Facades/Validator.php +++ b/vendor/illuminate/support/Facades/Validator.php @@ -3,13 +3,20 @@ namespace Illuminate\Support\Facades; /** - * @method static \Illuminate\Contracts\Validation\Validator make(array $data, array $rules, array $messages = [], array $customAttributes = []) + * @method static \Illuminate\Validation\Validator make(array $data, array $rules, array $messages = [], array $customAttributes = []) + * @method static array validate(array $data, array $rules, array $messages = [], array $customAttributes = []) + * @method static void extend(string $rule, \Closure|string $extension, string|null $message = null) + * @method static void extendImplicit(string $rule, \Closure|string $extension, string|null $message = null) + * @method static void extendDependent(string $rule, \Closure|string $extension, string|null $message = null) + * @method static void replacer(string $rule, \Closure|string $replacer) * @method static void includeUnvalidatedArrayKeys() * @method static void excludeUnvalidatedArrayKeys() - * @method static void extend(string $rule, \Closure|string $extension, string $message = null) - * @method static void extendImplicit(string $rule, \Closure|string $extension, string $message = null) - * @method static void replacer(string $rule, \Closure|string $replacer) - * @method static array validate(array $data, array $rules, array $messages = [], array $customAttributes = []) + * @method static void resolver(\Closure $resolver) + * @method static \Illuminate\Contracts\Translation\Translator getTranslator() + * @method static \Illuminate\Validation\PresenceVerifierInterface getPresenceVerifier() + * @method static void setPresenceVerifier(\Illuminate\Validation\PresenceVerifierInterface $presenceVerifier) + * @method static \Illuminate\Contracts\Container\Container|null getContainer() + * @method static \Illuminate\Validation\Factory setContainer(\Illuminate\Contracts\Container\Container $container) * * @see \Illuminate\Validation\Factory */ diff --git a/vendor/illuminate/support/Facades/View.php b/vendor/illuminate/support/Facades/View.php index 4988ee9..10eaa64 100755 --- a/vendor/illuminate/support/Facades/View.php +++ b/vendor/illuminate/support/Facades/View.php @@ -3,16 +3,83 @@ namespace Illuminate\Support\Facades; /** - * @method static \Illuminate\Contracts\View\Factory addNamespace(string $namespace, string|array $hints) + * @method static \Illuminate\Contracts\View\View file(string $path, \Illuminate\Contracts\Support\Arrayable|array $data = [], array $mergeData = []) + * @method static \Illuminate\Contracts\View\View make(string $view, \Illuminate\Contracts\Support\Arrayable|array $data = [], array $mergeData = []) * @method static \Illuminate\Contracts\View\View first(array $views, \Illuminate\Contracts\Support\Arrayable|array $data = [], array $mergeData = []) - * @method static \Illuminate\Contracts\View\Factory replaceNamespace(string $namespace, string|array $hints) - * @method static \Illuminate\Contracts\View\Factory addExtension(string $extension, string $engine, \Closure|null $resolver = null) - * @method static \Illuminate\Contracts\View\View file(string $path, array $data = [], array $mergeData = []) - * @method static \Illuminate\Contracts\View\View make(string $view, array $data = [], array $mergeData = []) - * @method static array composer(array|string $views, \Closure|string $callback) - * @method static array creator(array|string $views, \Closure|string $callback) + * @method static string renderWhen(bool $condition, string $view, \Illuminate\Contracts\Support\Arrayable|array $data = [], array $mergeData = []) + * @method static string renderUnless(bool $condition, string $view, \Illuminate\Contracts\Support\Arrayable|array $data = [], array $mergeData = []) + * @method static string renderEach(string $view, array $data, string $iterator, string $empty = 'raw|') * @method static bool exists(string $view) - * @method static mixed share(array|string $key, $value = null) + * @method static \Illuminate\Contracts\View\Engine getEngineFromPath(string $path) + * @method static mixed share(array|string $key, mixed|null $value = null) + * @method static void incrementRender() + * @method static void decrementRender() + * @method static bool doneRendering() + * @method static bool hasRenderedOnce(string $id) + * @method static void markAsRenderedOnce(string $id) + * @method static void addLocation(string $location) + * @method static \Illuminate\View\Factory addNamespace(string $namespace, string|array $hints) + * @method static \Illuminate\View\Factory prependNamespace(string $namespace, string|array $hints) + * @method static \Illuminate\View\Factory replaceNamespace(string $namespace, string|array $hints) + * @method static void addExtension(string $extension, string $engine, \Closure|null $resolver = null) + * @method static void flushState() + * @method static void flushStateIfDoneRendering() + * @method static array getExtensions() + * @method static \Illuminate\View\Engines\EngineResolver getEngineResolver() + * @method static \Illuminate\View\ViewFinderInterface getFinder() + * @method static void setFinder(\Illuminate\View\ViewFinderInterface $finder) + * @method static void flushFinderCache() + * @method static \Illuminate\Contracts\Events\Dispatcher getDispatcher() + * @method static void setDispatcher(\Illuminate\Contracts\Events\Dispatcher $events) + * @method static \Illuminate\Contracts\Container\Container getContainer() + * @method static void setContainer(\Illuminate\Contracts\Container\Container $container) + * @method static mixed shared(string $key, mixed $default = null) + * @method static array getShared() + * @method static void macro(string $name, object|callable $macro) + * @method static void mixin(object $mixin, bool $replace = true) + * @method static bool hasMacro(string $name) + * @method static void flushMacros() + * @method static void startComponent(\Illuminate\Contracts\View\View|\Illuminate\Contracts\Support\Htmlable|\Closure|string $view, array $data = []) + * @method static void startComponentFirst(array $names, array $data = []) + * @method static string renderComponent() + * @method static mixed|null getConsumableComponentData(string $key, mixed $default = null) + * @method static void slot(string $name, string|null $content = null, array $attributes = []) + * @method static void endSlot() + * @method static array creator(array|string $views, \Closure|string $callback) + * @method static array composers(array $composers) + * @method static array composer(array|string $views, \Closure|string $callback) + * @method static void callComposer(\Illuminate\Contracts\View\View $view) + * @method static void callCreator(\Illuminate\Contracts\View\View $view) + * @method static void startFragment(string $fragment) + * @method static string stopFragment() + * @method static mixed getFragment(string $name, string|null $default = null) + * @method static array getFragments() + * @method static void flushFragments() + * @method static void startSection(string $section, string|null $content = null) + * @method static void inject(string $section, string $content) + * @method static string yieldSection() + * @method static string stopSection(bool $overwrite = false) + * @method static string appendSection() + * @method static string yieldContent(string $section, string $default = '') + * @method static string parentPlaceholder(string $section = '') + * @method static bool hasSection(string $name) + * @method static bool sectionMissing(string $name) + * @method static mixed getSection(string $name, string|null $default = null) + * @method static array getSections() + * @method static void flushSections() + * @method static void addLoop(\Countable|array $data) + * @method static void incrementLoopIndices() + * @method static void popLoop() + * @method static \stdClass|null getLastLoop() + * @method static array getLoopStack() + * @method static void startPush(string $section, string $content = '') + * @method static string stopPush() + * @method static void startPrepend(string $section, string $content = '') + * @method static string stopPrepend() + * @method static string yieldPushContent(string $section, string $default = '') + * @method static void flushStacks() + * @method static void startTranslation(array $replacements = []) + * @method static string renderTranslation() * * @see \Illuminate\View\Factory */ diff --git a/vendor/illuminate/support/Facades/Vite.php b/vendor/illuminate/support/Facades/Vite.php new file mode 100644 index 0000000..f7b4f02 --- /dev/null +++ b/vendor/illuminate/support/Facades/Vite.php @@ -0,0 +1,41 @@ +attributes[$method] = count($parameters) > 0 ? $parameters[0] : true; + $this->attributes[$method] = count($parameters) > 0 ? reset($parameters) : true; return $this; } diff --git a/vendor/illuminate/support/Js.php b/vendor/illuminate/support/Js.php index 5a1d23a..69e9a76 100644 --- a/vendor/illuminate/support/Js.php +++ b/vendor/illuminate/support/Js.php @@ -2,6 +2,7 @@ namespace Illuminate\Support; +use BackedEnum; use Illuminate\Contracts\Support\Arrayable; use Illuminate\Contracts\Support\Htmlable; use Illuminate\Contracts\Support\Jsonable; @@ -69,6 +70,10 @@ class Js implements Htmlable return $data->toHtml(); } + if ($data instanceof BackedEnum) { + $data = $data->value; + } + $json = $this->jsonEncode($data, $flags, $depth); if (is_string($data)) { diff --git a/vendor/illuminate/support/Lottery.php b/vendor/illuminate/support/Lottery.php new file mode 100644 index 0000000..9bf3b47 --- /dev/null +++ b/vendor/illuminate/support/Lottery.php @@ -0,0 +1,271 @@ + 1) { + throw new RuntimeException('Float must not be greater than 1.'); + } + + $this->chances = $chances; + + $this->outOf = $outOf; + } + + /** + * Create a new Lottery instance. + * + * @param int|float $chances + * @param int|null $outOf + * @return static + */ + public static function odds($chances, $outOf = null) + { + return new static($chances, $outOf); + } + + /** + * Set the winner callback. + * + * @param callable $callback + * @return $this + */ + public function winner($callback) + { + $this->winner = $callback; + + return $this; + } + + /** + * Set the loser callback. + * + * @param callable $callback + * @return $this + */ + public function loser($callback) + { + $this->loser = $callback; + + return $this; + } + + /** + * Run the lottery. + * + * @param mixed ...$args + * @return mixed + */ + public function __invoke(...$args) + { + return $this->runCallback(...$args); + } + + /** + * Run the lottery. + * + * @param null|int $times + * @return mixed + */ + public function choose($times = null) + { + if ($times === null) { + return $this->runCallback(); + } + + $results = []; + + for ($i = 0; $i < $times; $i++) { + $results[] = $this->runCallback(); + } + + return $results; + } + + /** + * Run the winner or loser callback, randomly. + * + * @param mixed ...$args + * @return callable + */ + protected function runCallback(...$args) + { + return $this->wins() + ? ($this->winner ?? fn () => true)(...$args) + : ($this->loser ?? fn () => false)(...$args); + } + + /** + * Determine if the lottery "wins" or "loses". + * + * @return bool + */ + protected function wins() + { + return static::resultFactory()($this->chances, $this->outOf); + } + + /** + * The factory that determines the lottery result. + * + * @return callable + */ + protected static function resultFactory() + { + return static::$resultFactory ?? fn ($chances, $outOf) => $outOf === null + ? random_int(0, PHP_INT_MAX) / PHP_INT_MAX <= $chances + : random_int(1, $outOf) <= $chances; + } + + /** + * Force the lottery to always result in a win. + * + * @param callable|null $callback + * @return void + */ + public static function alwaysWin($callback = null) + { + self::setResultFactory(fn () => true); + + if ($callback === null) { + return; + } + + $callback(); + + static::determineResultNormally(); + } + + /** + * Force the lottery to always result in a lose. + * + * @param callable|null $callback + * @return void + */ + public static function alwaysLose($callback = null) + { + self::setResultFactory(fn () => false); + + if ($callback === null) { + return; + } + + $callback(); + + static::determineResultNormally(); + } + + /** + * Set the sequence that will be used to determine lottery results. + * + * @param array $sequence + * @param callable|null $whenMissing + * @return void + */ + public static function fix($sequence, $whenMissing = null) + { + return static::forceResultWithSequence($sequence, $whenMissing); + } + + /** + * Set the sequence that will be used to determine lottery results. + * + * @param array $sequence + * @param callable|null $whenMissing + * @return void + */ + public static function forceResultWithSequence($sequence, $whenMissing = null) + { + $next = 0; + + $whenMissing ??= function ($chances, $outOf) use (&$next) { + $factoryCache = static::$resultFactory; + + static::$resultFactory = null; + + $result = static::resultFactory()($chances, $outOf); + + static::$resultFactory = $factoryCache; + + $next++; + + return $result; + }; + + static::setResultFactory(function ($chances, $outOf) use (&$next, $sequence, $whenMissing) { + if (array_key_exists($next, $sequence)) { + return $sequence[$next++]; + } + + return $whenMissing($chances, $outOf); + }); + } + + /** + * Indicate that the lottery results should be determined normally. + * + * @return void + */ + public static function determineResultNormally() + { + static::$resultFactory = null; + } + + /** + * Set the factory that should be used to determine the lottery results. + * + * @param callable $factory + * @return void + */ + public static function setResultFactory($factory) + { + self::$resultFactory = $factory; + } +} diff --git a/vendor/illuminate/support/MessageBag.php b/vendor/illuminate/support/MessageBag.php index cfc6d88..88ebfb0 100755 --- a/vendor/illuminate/support/MessageBag.php +++ b/vendor/illuminate/support/MessageBag.php @@ -139,7 +139,7 @@ class MessageBag implements Jsonable, JsonSerializable, MessageBagContract, Mess /** * Determine if messages exist for any of the given keys. * - * @param array|string $keys + * @param array|string|null $keys * @return bool */ public function hasAny($keys = []) @@ -260,6 +260,10 @@ class MessageBag implements Jsonable, JsonSerializable, MessageBagContract, Mess */ protected function transform($messages, $format, $messageKey) { + if ($format == ':message') { + return (array) $messages; + } + return collect((array) $messages) ->map(function ($message) use ($format, $messageKey) { // We will simply spin through the given messages and transform each one diff --git a/vendor/illuminate/support/Pluralizer.php b/vendor/illuminate/support/Pluralizer.php index fbe5182..0d909de 100755 --- a/vendor/illuminate/support/Pluralizer.php +++ b/vendor/illuminate/support/Pluralizer.php @@ -7,54 +7,29 @@ use Doctrine\Inflector\InflectorFactory; class Pluralizer { /** - * Uncountable word forms. + * The cached inflector instance. + * + * @var static + */ + protected static $inflector; + + /** + * The language that should be used by the inflector. + * + * @var string + */ + protected static $language = 'english'; + + /** + * Uncountable non-nouns word forms. + * + * Contains words supported by Doctrine/Inflector/Rules/English/Uninflected.php * * @var string[] */ public static $uncountable = [ - 'audio', - 'bison', - 'cattle', - 'chassis', - 'compensation', - 'coreopsis', - 'data', - 'deer', - 'education', - 'emoji', - 'equipment', - 'evidence', - 'feedback', - 'firmware', - 'fish', - 'furniture', - 'gold', - 'hardware', - 'information', - 'jedi', - 'kin', - 'knowledge', - 'love', - 'metadata', - 'money', - 'moose', - 'news', - 'nutrition', - 'offspring', - 'plankton', - 'pokemon', - 'police', - 'rain', 'recommended', 'related', - 'rice', - 'series', - 'sheep', - 'software', - 'species', - 'swine', - 'traffic', - 'wheat', ]; /** @@ -130,12 +105,23 @@ class Pluralizer */ public static function inflector() { - static $inflector; - - if (is_null($inflector)) { - $inflector = InflectorFactory::createForLanguage('english')->build(); + if (is_null(static::$inflector)) { + static::$inflector = InflectorFactory::createForLanguage(static::$language)->build(); } - return $inflector; + return static::$inflector; + } + + /** + * Specify the language that should be used by the inflector. + * + * @param string $language + * @return void + */ + public static function useLanguage(string $language) + { + static::$language = $language; + + static::$inflector = null; } } diff --git a/vendor/illuminate/support/Str.php b/vendor/illuminate/support/Str.php index a87afe9..2c7912e 100644 --- a/vendor/illuminate/support/Str.php +++ b/vendor/illuminate/support/Str.php @@ -2,12 +2,20 @@ namespace Illuminate\Support; +use Closure; use Illuminate\Support\Traits\Macroable; +use JsonException; +use League\CommonMark\Environment\Environment; +use League\CommonMark\Extension\GithubFlavoredMarkdownExtension; +use League\CommonMark\Extension\InlinesOnly\InlinesOnlyExtension; use League\CommonMark\GithubFlavoredMarkdownConverter; +use League\CommonMark\MarkdownConverter; use Ramsey\Uuid\Codec\TimestampFirstCombCodec; use Ramsey\Uuid\Generator\CombGenerator; use Ramsey\Uuid\Uuid; use Ramsey\Uuid\UuidFactory; +use Symfony\Component\Uid\Ulid; +use Traversable; use voku\helper\ASCII; class Str @@ -38,10 +46,17 @@ class Str /** * The callback that should be used to generate UUIDs. * - * @var callable + * @var callable|null */ protected static $uuidFactory; + /** + * The callback that should be used to generate random strings. + * + * @var callable|null + */ + protected static $randomStringFactory; + /** * Get a new stringable object from the given string. * @@ -205,7 +220,7 @@ class Str * Determine if a given string contains a given substring. * * @param string $haystack - * @param string|string[] $needles + * @param string|iterable $needles * @param bool $ignoreCase * @return bool */ @@ -213,10 +228,17 @@ class Str { if ($ignoreCase) { $haystack = mb_strtolower($haystack); - $needles = array_map('mb_strtolower', (array) $needles); } - foreach ((array) $needles as $needle) { + if (! is_iterable($needles)) { + $needles = (array) $needles; + } + + foreach ($needles as $needle) { + if ($ignoreCase) { + $needle = mb_strtolower($needle); + } + if ($needle !== '' && str_contains($haystack, $needle)) { return true; } @@ -229,19 +251,14 @@ class Str * Determine if a given string contains all array values. * * @param string $haystack - * @param string[] $needles + * @param iterable $needles * @param bool $ignoreCase * @return bool */ - public static function containsAll($haystack, array $needles, $ignoreCase = false) + public static function containsAll($haystack, $needles, $ignoreCase = false) { - if ($ignoreCase) { - $haystack = mb_strtolower($haystack); - $needles = array_map('mb_strtolower', $needles); - } - foreach ($needles as $needle) { - if (! static::contains($haystack, $needle)) { + if (! static::contains($haystack, $needle, $ignoreCase)) { return false; } } @@ -253,16 +270,17 @@ class Str * Determine if a given string ends with a given substring. * * @param string $haystack - * @param string|string[] $needles + * @param string|iterable $needles * @return bool */ public static function endsWith($haystack, $needles) { - foreach ((array) $needles as $needle) { - if ( - $needle !== '' && $needle !== null - && str_ends_with($haystack, $needle) - ) { + if (! is_iterable($needles)) { + $needles = (array) $needles; + } + + foreach ($needles as $needle) { + if ((string) $needle !== '' && str_ends_with($haystack, $needle)) { return true; } } @@ -320,24 +338,35 @@ class Str return preg_replace('/(?:'.$quoted.')+$/u', '', $value).$cap; } + /** + * Wrap the string with the given strings. + * + * @param string $value + * @param string $before + * @param string|null $after + * @return string + */ + public static function wrap($value, $before, $after = null) + { + return $before.$value.($after ??= $before); + } + /** * Determine if a given string matches a given pattern. * - * @param string|array $pattern + * @param string|iterable $pattern * @param string $value * @return bool */ public static function is($pattern, $value) { - $patterns = Arr::wrap($pattern); - $value = (string) $value; - if (empty($patterns)) { - return false; + if (! is_iterable($pattern)) { + $pattern = [$pattern]; } - foreach ($patterns as $pattern) { + foreach ($pattern as $pattern) { $pattern = (string) $pattern; // If the given value is an exact match we can of course return true right @@ -373,6 +402,27 @@ class Str return ASCII::is_ascii((string) $value); } + /** + * Determine if a given string is valid JSON. + * + * @param string $value + * @return bool + */ + public static function isJson($value) + { + if (! is_string($value)) { + return false; + } + + try { + json_decode($value, true, 512, JSON_THROW_ON_ERROR); + } catch (JsonException) { + return false; + } + + return true; + } + /** * Determine if a given string is a valid UUID. * @@ -388,6 +438,21 @@ class Str return preg_match('/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iD', $value) > 0; } + /** + * Determine if a given string is a valid ULID. + * + * @param string $value + * @return bool + */ + public static function isUlid($value) + { + if (! is_string($value)) { + return false; + } + + return Ulid::isValid($value); + } + /** * Convert a string to kebab case. * @@ -476,6 +541,25 @@ class Str return (string) $converter->convert($string); } + /** + * Converts inline Markdown into HTML. + * + * @param string $string + * @param array $options + * @return string + */ + public static function inlineMarkdown($string, array $options = []) + { + $environment = new Environment($options); + + $environment->addExtension(new GithubFlavoredMarkdownExtension()); + $environment->addExtension(new InlinesOnlyExtension()); + + $converter = new MarkdownConverter($environment); + + return (string) $converter->convert($string); + } + /** * Masks a portion of a string with a repeated character. * @@ -492,20 +576,24 @@ class Str return $string; } - if (is_null($length) && PHP_MAJOR_VERSION < 8) { - $length = mb_strlen($string, $encoding); - } - $segment = mb_substr($string, $index, $length, $encoding); if ($segment === '') { return $string; } - $start = mb_substr($string, 0, mb_strpos($string, $segment, 0, $encoding), $encoding); - $end = mb_substr($string, mb_strpos($string, $segment, 0, $encoding) + mb_strlen($segment, $encoding)); + $strlen = mb_strlen($string, $encoding); + $startIndex = $index; - return $start.str_repeat(mb_substr($character, 0, 1, $encoding), mb_strlen($segment, $encoding)).$end; + if ($index < 0) { + $startIndex = $index < -$strlen ? 0 : $strlen + $index; + } + + $start = mb_substr($string, 0, $startIndex, $encoding); + $segmentLen = mb_strlen($segment, $encoding); + $end = mb_substr($string, $startIndex + $segmentLen); + + return $start.str_repeat(mb_substr($character, 0, 1, $encoding), $segmentLen).$end; } /** @@ -554,7 +642,13 @@ class Str */ public static function padBoth($value, $length, $pad = ' ') { - return str_pad($value, $length, $pad, STR_PAD_BOTH); + $short = max(0, $length - mb_strlen($value)); + $shortLeft = floor($short / 2); + $shortRight = ceil($short / 2); + + return mb_substr(str_repeat($pad, $shortLeft), 0, $shortLeft). + $value. + mb_substr(str_repeat($pad, $shortRight), 0, $shortRight); } /** @@ -567,7 +661,9 @@ class Str */ public static function padLeft($value, $length, $pad = ' ') { - return str_pad($value, $length, $pad, STR_PAD_LEFT); + $short = max(0, $length - mb_strlen($value)); + + return mb_substr(str_repeat($pad, $short), 0, $short).$value; } /** @@ -580,7 +676,9 @@ class Str */ public static function padRight($value, $length, $pad = ' ') { - return str_pad($value, $length, $pad, STR_PAD_RIGHT); + $short = max(0, $length - mb_strlen($value)); + + return $value.mb_substr(str_repeat($pad, $short), 0, $short); } /** @@ -631,17 +729,76 @@ class Str */ public static function random($length = 16) { - $string = ''; + return (static::$randomStringFactory ?? function ($length) { + $string = ''; - while (($len = strlen($string)) < $length) { - $size = $length - $len; + while (($len = strlen($string)) < $length) { + $size = $length - $len; - $bytes = random_bytes($size); + $bytesSize = (int) ceil(($size) / 3) * 3; - $string .= substr(str_replace(['/', '+', '='], '', base64_encode($bytes)), 0, $size); - } + $bytes = random_bytes($bytesSize); - return $string; + $string .= substr(str_replace(['/', '+', '='], '', base64_encode($bytes)), 0, $size); + } + + return $string; + })($length); + } + + /** + * Set the callable that will be used to generate random strings. + * + * @param callable|null $factory + * @return void + */ + public static function createRandomStringsUsing(callable $factory = null) + { + static::$randomStringFactory = $factory; + } + + /** + * Set the sequence that will be used to generate random strings. + * + * @param array $sequence + * @param callable|null $whenMissing + * @return void + */ + public static function createRandomStringsUsingSequence(array $sequence, $whenMissing = null) + { + $next = 0; + + $whenMissing ??= function ($length) use (&$next) { + $factoryCache = static::$randomStringFactory; + + static::$randomStringFactory = null; + + $randomString = static::random($length); + + static::$randomStringFactory = $factoryCache; + + $next++; + + return $randomString; + }; + + static::createRandomStringsUsing(function ($length) use (&$next, $sequence, $whenMissing) { + if (array_key_exists($next, $sequence)) { + return $sequence[$next++]; + } + + return $whenMissing($length); + }); + } + + /** + * Indicate that random strings should be created normally and not using a custom factory. + * + * @return void + */ + public static function createRandomStringsNormally() + { + static::$randomStringFactory = null; } /** @@ -660,12 +817,16 @@ class Str * Replace a given value in the string sequentially with an array. * * @param string $search - * @param array $replace + * @param iterable $replace * @param string $subject * @return string */ - public static function replaceArray($search, array $replace, $subject) + public static function replaceArray($search, $replace, $subject) { + if ($replace instanceof Traversable) { + $replace = collect($replace)->all(); + } + $segments = explode($search, $subject); $result = array_shift($segments); @@ -680,13 +841,25 @@ class Str /** * Replace the given value in the given string. * - * @param string|string[] $search - * @param string|string[] $replace - * @param string|string[] $subject + * @param string|iterable $search + * @param string|iterable $replace + * @param string|iterable $subject * @return string */ public static function replace($search, $replace, $subject) { + if ($search instanceof Traversable) { + $search = collect($search)->all(); + } + + if ($replace instanceof Traversable) { + $replace = collect($replace)->all(); + } + + if ($subject instanceof Traversable) { + $subject = collect($subject)->all(); + } + return str_replace($search, $replace, $subject); } @@ -741,13 +914,17 @@ class Str /** * Remove any occurrence of the given string in the subject. * - * @param string|array $search + * @param string|iterable $search * @param string $subject * @param bool $caseSensitive * @return string */ public static function remove($search, $subject, $caseSensitive = true) { + if ($search instanceof Traversable) { + $search = collect($search)->all(); + } + $subject = $caseSensitive ? str_replace($search, '', $subject) : str_ireplace($search, '', $subject); @@ -838,9 +1015,10 @@ class Str * @param string $title * @param string $separator * @param string|null $language + * @param array $dictionary * @return string */ - public static function slug($title, $separator = '-', $language = 'en') + public static function slug($title, $separator = '-', $language = 'en', $dictionary = ['@' => 'at']) { $title = $language ? static::ascii($title, $language) : $title; @@ -849,10 +1027,14 @@ class Str $title = preg_replace('!['.preg_quote($flip).']+!u', $separator, $title); - // Replace @ with the word 'at' - $title = str_replace('@', $separator.'at'.$separator, $title); + // Replace dictionary words + foreach ($dictionary as $key => $value) { + $dictionary[$key] = $separator.$value.$separator; + } - // Remove all characters that are not the separator, letters, numbers, or whitespace. + $title = str_replace(array_keys($dictionary), array_values($dictionary), $title); + + // Remove all characters that are not the separator, letters, numbers, or whitespace $title = preg_replace('![^'.preg_quote($separator).'\pL\pN\s]+!u', '', static::lower($title)); // Replace all separator characters and whitespace by a single separator @@ -885,16 +1067,31 @@ class Str return static::$snakeCache[$key][$delimiter] = $value; } + /** + * Remove all "extra" blank space from the given string. + * + * @param string $value + * @return string + */ + public static function squish($value) + { + return preg_replace('~(\s|\x{3164})+~u', ' ', preg_replace('~^[\s\x{FEFF}]+|[\s\x{FEFF}]+$~u', '', $value)); + } + /** * Determine if a given string starts with a given substring. * * @param string $haystack - * @param string|string[] $needles + * @param string|iterable $needles * @return bool */ public static function startsWith($haystack, $needles) { - foreach ((array) $needles as $needle) { + if (! is_iterable($needles)) { + $needles = [$needles]; + } + + foreach ($needles as $needle) { if ((string) $needle !== '' && str_starts_with($haystack, $needle)) { return true; } @@ -919,9 +1116,7 @@ class Str $words = explode(' ', static::replace(['-', '_'], ' ', $value)); - $studlyWords = array_map(function ($word) { - return static::ucfirst($word); - }, $words); + $studlyWords = array_map(fn ($word) => static::ucfirst($word), $words); return static::$studlyCache[$key] = implode($studlyWords); } @@ -932,11 +1127,12 @@ class Str * @param string $string * @param int $start * @param int|null $length + * @param string $encoding * @return string */ - public static function substr($string, $start, $length = null) + public static function substr($string, $start, $length = null, $encoding = 'UTF-8') { - return mb_substr($string, $start, $length, 'UTF-8'); + return mb_substr($string, $start, $length, $encoding); } /** @@ -952,19 +1148,19 @@ class Str { if (! is_null($length)) { return substr_count($haystack, $needle, $offset, $length); - } else { - return substr_count($haystack, $needle, $offset); } + + return substr_count($haystack, $needle, $offset); } /** * Replace text within a portion of a string. * - * @param string|array $string - * @param string|array $replace - * @param array|int $offset - * @param array|int|null $length - * @return string|array + * @param string|string[] $string + * @param string|string[] $replace + * @param int|int[] $offset + * @param int|int[]|null $length + * @return string|string[] */ public static function substrReplace($string, $replace, $offset = 0, $length = null) { @@ -1013,7 +1209,7 @@ class Str * Split a string into pieces by uppercase characters. * * @param string $string - * @return array + * @return string[] */ public static function ucsplit($string) { @@ -1024,11 +1220,12 @@ class Str * Get the number of words a string contains. * * @param string $string + * @param string|null $characters * @return int */ - public static function wordCount($string) + public static function wordCount($string, $characters = null) { - return str_word_count($string); + return str_word_count($string, 0, $characters); } /** @@ -1079,6 +1276,63 @@ class Str static::$uuidFactory = $factory; } + /** + * Set the sequence that will be used to generate UUIDs. + * + * @param array $sequence + * @param callable|null $whenMissing + * @return void + */ + public static function createUuidsUsingSequence(array $sequence, $whenMissing = null) + { + $next = 0; + + $whenMissing ??= function () use (&$next) { + $factoryCache = static::$uuidFactory; + + static::$uuidFactory = null; + + $uuid = static::uuid(); + + static::$uuidFactory = $factoryCache; + + $next++; + + return $uuid; + }; + + static::createUuidsUsing(function () use (&$next, $sequence, $whenMissing) { + if (array_key_exists($next, $sequence)) { + return $sequence[$next++]; + } + + return $whenMissing(); + }); + } + + /** + * Always return the same UUID when generating new UUIDs. + * + * @param \Closure|null $callback + * @return \Ramsey\Uuid\UuidInterface + */ + public static function freezeUuids(Closure $callback = null) + { + $uuid = Str::uuid(); + + Str::createUuidsUsing(fn () => $uuid); + + if ($callback !== null) { + try { + $callback($uuid); + } finally { + Str::createUuidsNormally(); + } + } + + return $uuid; + } + /** * Indicate that UUIDs should be created normally and not using a custom factory. * @@ -1089,6 +1343,16 @@ class Str static::$uuidFactory = null; } + /** + * Generate a ULID. + * + * @return \Symfony\Component\Uid\Ulid + */ + public static function ulid() + { + return new Ulid(); + } + /** * Remove all strings from the casing caches. * diff --git a/vendor/illuminate/support/Stringable.php b/vendor/illuminate/support/Stringable.php index 90177d5..7453570 100644 --- a/vendor/illuminate/support/Stringable.php +++ b/vendor/illuminate/support/Stringable.php @@ -3,6 +3,7 @@ namespace Illuminate\Support; use Closure; +use Illuminate\Support\Facades\Date; use Illuminate\Support\Traits\Conditionable; use Illuminate\Support\Traits\Macroable; use Illuminate\Support\Traits\Tappable; @@ -56,7 +57,7 @@ class Stringable implements JsonSerializable /** * Append the given values to the string. * - * @param array $values + * @param string ...$values * @return static */ public function append(...$values) @@ -64,6 +65,17 @@ class Stringable implements JsonSerializable return new static($this->value.implode('', $values)); } + /** + * Append a new line to the string. + * + * @param int $count + * @return $this + */ + public function newLine($count = 1) + { + return $this->append(str_repeat(PHP_EOL, $count)); + } + /** * Transliterate a UTF-8 value to ASCII. * @@ -155,23 +167,25 @@ class Stringable implements JsonSerializable /** * Determine if a given string contains a given substring. * - * @param string|string[] $needles + * @param string|iterable $needles + * @param bool $ignoreCase * @return bool */ - public function contains($needles) + public function contains($needles, $ignoreCase = false) { - return Str::contains($this->value, $needles); + return Str::contains($this->value, $needles, $ignoreCase); } /** * Determine if a given string contains all array values. * - * @param array $needles + * @param iterable $needles + * @param bool $ignoreCase * @return bool */ - public function containsAll(array $needles) + public function containsAll($needles, $ignoreCase = false) { - return Str::containsAll($this->value, $needles); + return Str::containsAll($this->value, $needles, $ignoreCase); } /** @@ -188,7 +202,7 @@ class Stringable implements JsonSerializable /** * Determine if a given string ends with a given substring. * - * @param string|string[] $needles + * @param string|iterable $needles * @return bool */ public function endsWith($needles) @@ -199,11 +213,15 @@ class Stringable implements JsonSerializable /** * Determine if the string is an exact match with the given value. * - * @param string $value + * @param \Illuminate\Support\Stringable|string $value * @return bool */ public function exactly($value) { + if ($value instanceof Stringable) { + $value = $value->toString(); + } + return $this->value === $value; } @@ -264,7 +282,7 @@ class Stringable implements JsonSerializable /** * Determine if a given string matches a given pattern. * - * @param string|array $pattern + * @param string|iterable $pattern * @return bool */ public function is($pattern) @@ -282,6 +300,16 @@ class Stringable implements JsonSerializable return Str::isAscii($this->value); } + /** + * Determine if a given string is valid JSON. + * + * @return bool + */ + public function isJson() + { + return Str::isJson($this->value); + } + /** * Determine if a given string is a valid UUID. * @@ -292,6 +320,16 @@ class Stringable implements JsonSerializable return Str::isUuid($this->value); } + /** + * Determine if a given string is a valid ULID. + * + * @return bool + */ + public function isUlid() + { + return Str::isUlid($this->value); + } + /** * Determine if the given string is empty. * @@ -325,7 +363,7 @@ class Stringable implements JsonSerializable /** * Return the length of the given string. * - * @param string $encoding + * @param string|null $encoding * @return int */ public function length($encoding = null) @@ -366,6 +404,17 @@ class Stringable implements JsonSerializable return new static(Str::markdown($this->value, $options)); } + /** + * Convert inline Markdown into HTML. + * + * @param array $options + * @return static + */ + public function inlineMarkdown(array $options = []) + { + return new static(Str::inlineMarkdown($this->value, $options)); + } + /** * Masks a portion of a string with a repeated character. * @@ -453,7 +502,7 @@ class Stringable implements JsonSerializable * Parse a Class@method style callback into class and method. * * @param string|null $default - * @return array + * @return array */ public function parseCallback($default = null) { @@ -474,7 +523,7 @@ class Stringable implements JsonSerializable /** * Get the plural form of an English word. * - * @param int $count + * @param int|array|\Countable $count * @return static */ public function plural($count = 2) @@ -485,7 +534,7 @@ class Stringable implements JsonSerializable /** * Pluralize the last word of an English, studly caps case string. * - * @param int $count + * @param int|array|\Countable $count * @return static */ public function pluralStudly($count = 2) @@ -496,7 +545,7 @@ class Stringable implements JsonSerializable /** * Prepend the given values to the string. * - * @param array $values + * @param string ...$values * @return static */ public function prepend(...$values) @@ -507,7 +556,7 @@ class Stringable implements JsonSerializable /** * Remove any occurrence of the given string in the subject. * - * @param string|array $search + * @param string|iterable $search * @param bool $caseSensitive * @return static */ @@ -540,23 +589,23 @@ class Stringable implements JsonSerializable /** * Replace the given value in the given string. * - * @param string|string[] $search - * @param string|string[] $replace + * @param string|iterable $search + * @param string|iterable $replace * @return static */ public function replace($search, $replace) { - return new static(str_replace($search, $replace, $this->value)); + return new static(Str::replace($search, $replace, $this->value)); } /** * Replace a given value in the string sequentially with an array. * * @param string $search - * @param array $replace + * @param iterable $replace * @return static */ - public function replaceArray($search, array $replace) + public function replaceArray($search, $replace) { return new static(Str::replaceArray($search, $replace, $this->value)); } @@ -613,6 +662,16 @@ class Stringable implements JsonSerializable return collect(sscanf($this->value, $format)); } + /** + * Remove all "extra" blank space from the given string. + * + * @return static + */ + public function squish() + { + return new static(Str::squish($this->value)); + } + /** * Begin a string with a single instance of a given value. * @@ -680,11 +739,12 @@ class Stringable implements JsonSerializable * * @param string $separator * @param string|null $language + * @param array $dictionary * @return static */ - public function slug($separator = '-', $language = 'en') + public function slug($separator = '-', $language = 'en', $dictionary = ['@' => 'at']) { - return new static(Str::slug($this->value, $separator, $language)); + return new static(Str::slug($this->value, $separator, $language, $dictionary)); } /** @@ -701,7 +761,7 @@ class Stringable implements JsonSerializable /** * Determine if a given string starts with a given substring. * - * @param string|string[] $needles + * @param string|iterable $needles * @return bool */ public function startsWith($needles) @@ -724,32 +784,33 @@ class Stringable implements JsonSerializable * * @param int $start * @param int|null $length + * @param string $encoding * @return static */ - public function substr($start, $length = null) + public function substr($start, $length = null, $encoding = 'UTF-8') { - return new static(Str::substr($this->value, $start, $length)); + return new static(Str::substr($this->value, $start, $length, $encoding)); } /** * Returns the number of substring occurrences. * * @param string $needle - * @param int|null $offset + * @param int $offset * @param int|null $length * @return int */ - public function substrCount($needle, $offset = null, $length = null) + public function substrCount($needle, $offset = 0, $length = null) { - return Str::substrCount($this->value, $needle, $offset ?? 0, $length); + return Str::substrCount($this->value, $needle, $offset, $length); } /** * Replace text within a portion of a string. * - * @param string|array $replace - * @param array|int $offset - * @param array|int|null $length + * @param string|string[] $replace + * @param int|int[] $offset + * @param int|int[]|null $length * @return static */ public function substrReplace($replace, $offset = 0, $length = null) @@ -834,7 +895,7 @@ class Stringable implements JsonSerializable /** * Execute the given callback if the string contains a given substring. * - * @param string|string[] $needles + * @param string|iterable $needles * @param callable $callback * @param callable|null $default * @return static @@ -847,7 +908,7 @@ class Stringable implements JsonSerializable /** * Execute the given callback if the string contains all array values. * - * @param array $needles + * @param iterable $needles * @param callable $callback * @param callable|null $default * @return static @@ -884,7 +945,7 @@ class Stringable implements JsonSerializable /** * Execute the given callback if the string ends with a given substring. * - * @param string|string[] $needles + * @param string|iterable $needles * @param callable $callback * @param callable|null $default * @return static @@ -907,10 +968,23 @@ class Stringable implements JsonSerializable return $this->when($this->exactly($value), $callback, $default); } + /** + * Execute the given callback if the string is not an exact match with the given value. + * + * @param string $value + * @param callable $callback + * @param callable|null $default + * @return static + */ + public function whenNotExactly($value, $callback, $default = null) + { + return $this->when(! $this->exactly($value), $callback, $default); + } + /** * Execute the given callback if the string matches a given pattern. * - * @param string|array $pattern + * @param string|iterable $pattern * @param callable $callback * @param callable|null $default * @return static @@ -944,10 +1018,22 @@ class Stringable implements JsonSerializable return $this->when($this->isUuid(), $callback, $default); } + /** + * Execute the given callback if the string is a valid ULID. + * + * @param callable $callback + * @param callable|null $default + * @return static + */ + public function whenIsUlid($callback, $default = null) + { + return $this->when($this->isUlid(), $callback, $default); + } + /** * Execute the given callback if the string starts with a given substring. * - * @param string|string[] $needles + * @param string|iterable $needles * @param callable $callback * @param callable|null $default * @return static @@ -985,11 +1071,24 @@ class Stringable implements JsonSerializable /** * Get the number of words a string contains. * + * @param string|null $characters * @return int */ - public function wordCount() + public function wordCount($characters = null) { - return str_word_count($this->value); + return Str::wordCount($this->value, $characters); + } + + /** + * Wrap the string with the given strings. + * + * @param string $before + * @param string|null $after + * @return static + */ + public function wrap($before, $after = null) + { + return new static(Str::wrap($this->value, $before, $after)); } /** @@ -1046,6 +1145,56 @@ class Stringable implements JsonSerializable return $this->value; } + /** + * Get the underlying string value as an integer. + * + * @return int + */ + public function toInteger() + { + return intval($this->value); + } + + /** + * Get the underlying string value as a float. + * + * @return float + */ + public function toFloat() + { + return floatval($this->value); + } + + /** + * Get the underlying string value as a boolean. + * + * Returns true when value is "1", "true", "on", and "yes". Otherwise, returns false. + * + * @return bool + */ + public function toBoolean() + { + return filter_var($this->value, FILTER_VALIDATE_BOOLEAN); + } + + /** + * Get the underlying string value as a Carbon instance. + * + * @param string|null $format + * @param string|null $tz + * @return \Illuminate\Support\Carbon + * + * @throws \Carbon\Exceptions\InvalidFormatException + */ + public function toDate($format = null, $tz = null) + { + if (is_null($format)) { + return Date::parse($this->value, $tz); + } + + return Date::createFromFormat($format, $this->value, $tz); + } + /** * Convert the object to a string when JSON encoded. * diff --git a/vendor/illuminate/support/Testing/Fakes/BatchFake.php b/vendor/illuminate/support/Testing/Fakes/BatchFake.php new file mode 100644 index 0000000..607168b --- /dev/null +++ b/vendor/illuminate/support/Testing/Fakes/BatchFake.php @@ -0,0 +1,163 @@ +id = $id; + $this->name = $name; + $this->totalJobs = $totalJobs; + $this->pendingJobs = $pendingJobs; + $this->failedJobs = $failedJobs; + $this->failedJobIds = $failedJobIds; + $this->options = $options; + $this->createdAt = $createdAt; + $this->cancelledAt = $cancelledAt; + $this->finishedAt = $finishedAt; + } + + /** + * Get a fresh instance of the batch represented by this ID. + * + * @return self + */ + public function fresh() + { + return $this; + } + + /** + * Add additional jobs to the batch. + * + * @param \Illuminate\Support\Enumerable|object|array $jobs + * @return self + */ + public function add($jobs) + { + foreach ($jobs as $job) { + $this->added[] = $job; + } + + return $this; + } + + /** + * Record that a job within the batch finished successfully, executing any callbacks if necessary. + * + * @param string $jobId + * @return void + */ + public function recordSuccessfulJob(string $jobId) + { + // + } + + /** + * Decrement the pending jobs for the batch. + * + * @param string $jobId + * @return \Illuminate\Bus\UpdatedBatchJobCounts + */ + public function decrementPendingJobs(string $jobId) + { + // + } + + /** + * Record that a job within the batch failed to finish successfully, executing any callbacks if necessary. + * + * @param string $jobId + * @param \Throwable $e + * @return void + */ + public function recordFailedJob(string $jobId, $e) + { + // + } + + /** + * Increment the failed jobs for the batch. + * + * @param string $jobId + * @return \Illuminate\Bus\UpdatedBatchJobCounts + */ + public function incrementFailedJobs(string $jobId) + { + return new UpdatedBatchJobCounts; + } + + /** + * Cancel the batch. + * + * @return void + */ + public function cancel() + { + $this->cancelledAt = Carbon::now(); + } + + /** + * Delete the batch from storage. + * + * @return void + */ + public function delete() + { + $this->deleted = true; + } + + /** + * Determine if the batch has been deleted. + * + * @return bool + */ + public function deleted() + { + return $this->deleted; + } +} diff --git a/vendor/illuminate/support/Testing/Fakes/BatchRepositoryFake.php b/vendor/illuminate/support/Testing/Fakes/BatchRepositoryFake.php index d966133..021c73f 100644 --- a/vendor/illuminate/support/Testing/Fakes/BatchRepositoryFake.php +++ b/vendor/illuminate/support/Testing/Fakes/BatchRepositoryFake.php @@ -4,15 +4,20 @@ namespace Illuminate\Support\Testing\Fakes; use Carbon\CarbonImmutable; use Closure; -use Illuminate\Bus\Batch; use Illuminate\Bus\BatchRepository; use Illuminate\Bus\PendingBatch; use Illuminate\Bus\UpdatedBatchJobCounts; -use Illuminate\Support\Facades\Facade; use Illuminate\Support\Str; class BatchRepositoryFake implements BatchRepository { + /** + * The batches stored in the repository. + * + * @var \Illuminate\Bus\Batch[] + */ + protected $batches = []; + /** * Retrieve a list of batches. * @@ -22,7 +27,7 @@ class BatchRepositoryFake implements BatchRepository */ public function get($limit, $before) { - return []; + return $this->batches; } /** @@ -33,7 +38,7 @@ class BatchRepositoryFake implements BatchRepository */ public function find(string $batchId) { - // + return $this->batches[$batchId] ?? null; } /** @@ -44,10 +49,10 @@ class BatchRepositoryFake implements BatchRepository */ public function store(PendingBatch $batch) { - return new Batch( - new QueueFake(Facade::getFacadeApplication()), - $this, - (string) Str::orderedUuid(), + $id = (string) Str::orderedUuid(); + + $this->batches[$id] = new BatchFake( + $id, $batch->name, count($batch->jobs), count($batch->jobs), @@ -58,6 +63,8 @@ class BatchRepositoryFake implements BatchRepository null, null ); + + return $this->batches[$id]; } /** @@ -104,7 +111,9 @@ class BatchRepositoryFake implements BatchRepository */ public function markAsFinished(string $batchId) { - // + if (isset($this->batches[$batchId])) { + $this->batches[$batchId]->finishedAt = now(); + } } /** @@ -115,7 +124,9 @@ class BatchRepositoryFake implements BatchRepository */ public function cancel(string $batchId) { - // + if (isset($this->batches[$batchId])) { + $this->batches[$batchId]->cancel(); + } } /** @@ -126,7 +137,7 @@ class BatchRepositoryFake implements BatchRepository */ public function delete(string $batchId) { - // + unset($this->batches[$batchId]); } /** diff --git a/vendor/illuminate/support/Testing/Fakes/BusFake.php b/vendor/illuminate/support/Testing/Fakes/BusFake.php index 122252d..9da1fac 100644 --- a/vendor/illuminate/support/Testing/Fakes/BusFake.php +++ b/vendor/illuminate/support/Testing/Fakes/BusFake.php @@ -3,6 +3,7 @@ namespace Illuminate\Support\Testing\Fakes; use Closure; +use Illuminate\Bus\BatchRepository; use Illuminate\Bus\PendingBatch; use Illuminate\Contracts\Bus\QueueingDispatcher; use Illuminate\Support\Arr; @@ -26,7 +27,21 @@ class BusFake implements QueueingDispatcher * * @var array */ - protected $jobsToFake; + protected $jobsToFake = []; + + /** + * The job types that should be dispatched instead of faked. + * + * @var array + */ + protected $jobsToDispatch = []; + + /** + * The fake repository to track batched jobs. + * + * @var \Illuminate\Bus\BatchRepository + */ + protected $batchRepository; /** * The commands that have been dispatched. @@ -61,13 +76,27 @@ class BusFake implements QueueingDispatcher * * @param \Illuminate\Contracts\Bus\QueueingDispatcher $dispatcher * @param array|string $jobsToFake + * @param \Illuminate\Bus\BatchRepository|null $batchRepository * @return void */ - public function __construct(QueueingDispatcher $dispatcher, $jobsToFake = []) + public function __construct(QueueingDispatcher $dispatcher, $jobsToFake = [], BatchRepository $batchRepository = null) { $this->dispatcher = $dispatcher; - $this->jobsToFake = Arr::wrap($jobsToFake); + $this->batchRepository = $batchRepository ?: new BatchRepositoryFake; + } + + /** + * Specify the jobs that should be dispatched instead of faked. + * + * @param array|string $jobsToDispatch + * @return void + */ + public function except($jobsToDispatch) + { + $this->jobsToDispatch = array_merge($this->jobsToDispatch, Arr::wrap($jobsToDispatch)); + + return $this; } /** @@ -98,15 +127,21 @@ class BusFake implements QueueingDispatcher /** * Assert if a job was pushed a number of times. * - * @param string $command + * @param string|\Closure $command * @param int $times * @return void */ public function assertDispatchedTimes($command, $times = 1) { - $count = $this->dispatched($command)->count() + - $this->dispatchedAfterResponse($command)->count() + - $this->dispatchedSync($command)->count(); + $callback = null; + + if ($command instanceof Closure) { + [$command, $callback] = [$this->firstClosureParameterType($command), $command]; + } + + $count = $this->dispatched($command, $callback)->count() + + $this->dispatchedAfterResponse($command, $callback)->count() + + $this->dispatchedSync($command, $callback)->count(); PHPUnit::assertSame( $times, $count, @@ -171,13 +206,19 @@ class BusFake implements QueueingDispatcher /** * Assert if a job was pushed synchronously a number of times. * - * @param string $command + * @param string|\Closure $command * @param int $times * @return void */ public function assertDispatchedSyncTimes($command, $times = 1) { - $count = $this->dispatchedSync($command)->count(); + $callback = null; + + if ($command instanceof Closure) { + [$command, $callback] = [$this->firstClosureParameterType($command), $command]; + } + + $count = $this->dispatchedSync($command, $callback)->count(); PHPUnit::assertSame( $times, $count, @@ -230,13 +271,19 @@ class BusFake implements QueueingDispatcher /** * Assert if a job was pushed after the response was sent a number of times. * - * @param string $command + * @param string|\Closure $command * @param int $times * @return void */ public function assertDispatchedAfterResponseTimes($command, $times = 1) { - $count = $this->dispatchedAfterResponse($command)->count(); + $callback = null; + + if ($command instanceof Closure) { + [$command, $callback] = [$this->firstClosureParameterType($command), $command]; + } + + $count = $this->dispatchedAfterResponse($command, $callback)->count(); PHPUnit::assertSame( $times, $count, @@ -351,14 +398,12 @@ class BusFake implements QueueingDispatcher */ protected function assertDispatchedWithChainOfObjects($command, $expectedChain, $callback) { - $chain = collect($expectedChain)->map(function ($job) { - return serialize($job); - })->all(); + $chain = collect($expectedChain)->map(fn ($job) => serialize($job))->all(); PHPUnit::assertTrue( - $this->dispatched($command, $callback)->filter(function ($job) use ($chain) { - return $job->chained == $chain; - })->isNotEmpty(), + $this->dispatched($command, $callback)->filter( + fn ($job) => $job->chained == $chain + )->isNotEmpty(), 'The expected chain was not dispatched.' ); } @@ -374,12 +419,12 @@ class BusFake implements QueueingDispatcher protected function assertDispatchedWithChainOfClasses($command, $expectedChain, $callback) { $matching = $this->dispatched($command, $callback)->map->chained->map(function ($chain) { - return collect($chain)->map(function ($job) { - return get_class(unserialize($job)); - }); - })->filter(function ($chain) use ($expectedChain) { - return $chain->all() === $expectedChain; - }); + return collect($chain)->map( + fn ($job) => get_class(unserialize($job)) + ); + })->filter( + fn ($chain) => $chain->all() === $expectedChain + ); PHPUnit::assertTrue( $matching->isNotEmpty(), 'The expected chain was not dispatched.' @@ -394,9 +439,7 @@ class BusFake implements QueueingDispatcher */ protected function isChainOfObjects($chain) { - return ! collect($chain)->contains(function ($job) { - return ! is_object($job); - }); + return ! collect($chain)->contains(fn ($job) => ! is_object($job)); } /** @@ -426,6 +469,16 @@ class BusFake implements QueueingDispatcher ); } + /** + * Assert that no batched jobs were dispatched. + * + * @return void + */ + public function assertNothingBatched() + { + PHPUnit::assertEmpty($this->batches, 'Batched jobs were dispatched unexpectedly.'); + } + /** * Get all of the jobs matching a truth-test callback. * @@ -439,13 +492,9 @@ class BusFake implements QueueingDispatcher return collect(); } - $callback = $callback ?: function () { - return true; - }; + $callback = $callback ?: fn () => true; - return collect($this->commands[$command])->filter(function ($command) use ($callback) { - return $callback($command); - }); + return collect($this->commands[$command])->filter(fn ($command) => $callback($command)); } /** @@ -461,13 +510,9 @@ class BusFake implements QueueingDispatcher return collect(); } - $callback = $callback ?: function () { - return true; - }; + $callback = $callback ?: fn () => true; - return collect($this->commandsSync[$command])->filter(function ($command) use ($callback) { - return $callback($command); - }); + return collect($this->commandsSync[$command])->filter(fn ($command) => $callback($command)); } /** @@ -483,13 +528,9 @@ class BusFake implements QueueingDispatcher return collect(); } - $callback = $callback ?: function () { - return true; - }; + $callback = $callback ?: fn () => true; - return collect($this->commandsAfterResponse[$command])->filter(function ($command) use ($callback) { - return $callback($command); - }); + return collect($this->commandsAfterResponse[$command])->filter(fn ($command) => $callback($command)); } /** @@ -504,9 +545,7 @@ class BusFake implements QueueingDispatcher return collect(); } - return collect($this->batches)->filter(function ($batch) use ($callback) { - return $callback($batch); - }); + return collect($this->batches)->filter(fn ($batch) => $callback($batch)); } /** @@ -642,7 +681,7 @@ class BusFake implements QueueingDispatcher */ public function findBatch(string $batchId) { - // + return $this->batchRepository->find($batchId); } /** @@ -656,6 +695,17 @@ class BusFake implements QueueingDispatcher return new PendingBatchFake($this, Collection::wrap($jobs)); } + /** + * Dispatch an empty job batch for testing. + * + * @param string $name + * @return \Illuminate\Bus\Batch + */ + public function dispatchFakeBatch($name = '') + { + return $this->batch([])->name($name)->dispatch(); + } + /** * Record the fake pending batch dispatch. * @@ -666,7 +716,7 @@ class BusFake implements QueueingDispatcher { $this->batches[] = $pendingBatch; - return (new BatchRepositoryFake)->store($pendingBatch); + return $this->batchRepository->store($pendingBatch); } /** @@ -677,6 +727,10 @@ class BusFake implements QueueingDispatcher */ protected function shouldFakeJob($command) { + if ($this->shouldDispatchCommand($command)) { + return false; + } + if (empty($this->jobsToFake)) { return true; } @@ -689,6 +743,22 @@ class BusFake implements QueueingDispatcher })->isNotEmpty(); } + /** + * Determine if a command should be dispatched or not. + * + * @param mixed $command + * @return bool + */ + protected function shouldDispatchCommand($command) + { + return collect($this->jobsToDispatch) + ->filter(function ($job) use ($command) { + return $job instanceof Closure + ? $job($command) + : $job === get_class($command); + })->isNotEmpty(); + } + /** * Set the pipes commands should be piped through before dispatching. * diff --git a/vendor/illuminate/support/Testing/Fakes/EventFake.php b/vendor/illuminate/support/Testing/Fakes/EventFake.php index ed5014f..f1e4655 100644 --- a/vendor/illuminate/support/Testing/Fakes/EventFake.php +++ b/vendor/illuminate/support/Testing/Fakes/EventFake.php @@ -5,6 +5,7 @@ namespace Illuminate\Support\Testing\Fakes; use Closure; use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Support\Arr; +use Illuminate\Support\Str; use Illuminate\Support\Traits\ReflectsClosures; use PHPUnit\Framework\Assert as PHPUnit; use ReflectionFunction; @@ -25,7 +26,14 @@ class EventFake implements Dispatcher * * @var array */ - protected $eventsToFake; + protected $eventsToFake = []; + + /** + * The event types that should be dispatched instead of intercepted. + * + * @var array + */ + protected $eventsToDispatch = []; /** * All of the events that have been intercepted keyed by type. @@ -48,11 +56,27 @@ class EventFake implements Dispatcher $this->eventsToFake = Arr::wrap($eventsToFake); } + /** + * Specify the events that should be dispatched instead of faked. + * + * @param array|string $eventsToDispatch + * @return $this + */ + public function except($eventsToDispatch) + { + $this->eventsToDispatch = array_merge( + $this->eventsToDispatch, + Arr::wrap($eventsToDispatch) + ); + + return $this; + } + /** * Assert if an event has a listener attached to it. * * @param string $expectedEvent - * @param string $expectedListener + * @param string|array $expectedListener * @return void */ public function assertListening($expectedEvent, $expectedListener) @@ -61,9 +85,23 @@ class EventFake implements Dispatcher $actualListener = (new ReflectionFunction($listenerClosure)) ->getStaticVariables()['listener']; - if ($actualListener === $expectedListener || + $normalizedListener = $expectedListener; + + if (is_string($actualListener) && Str::contains($actualListener, '@')) { + $actualListener = Str::parseCallback($actualListener); + + if (is_string($expectedListener)) { + if (Str::contains($expectedListener, '@')) { + $normalizedListener = Str::parseCallback($expectedListener); + } else { + $normalizedListener = [$expectedListener, 'handle']; + } + } + } + + if ($actualListener === $normalizedListener || ($actualListener instanceof Closure && - $expectedListener === Closure::class)) { + $normalizedListener === Closure::class)) { PHPUnit::assertTrue(true); return; @@ -167,13 +205,11 @@ class EventFake implements Dispatcher return collect(); } - $callback = $callback ?: function () { - return true; - }; + $callback = $callback ?: fn () => true; - return collect($this->events[$event])->filter(function ($arguments) use ($callback) { - return $callback(...$arguments); - }); + return collect($this->events[$event])->filter( + fn ($arguments) => $callback(...$arguments) + ); } /** @@ -272,6 +308,10 @@ class EventFake implements Dispatcher */ protected function shouldFakeEvent($eventName, $payload) { + if ($this->shouldDispatchEvent($eventName, $payload)) { + return false; + } + if (empty($this->eventsToFake)) { return true; } @@ -285,6 +325,28 @@ class EventFake implements Dispatcher ->isNotEmpty(); } + /** + * Determine whether an event should be dispatched or not. + * + * @param string $eventName + * @param mixed $payload + * @return bool + */ + protected function shouldDispatchEvent($eventName, $payload) + { + if (empty($this->eventsToDispatch)) { + return false; + } + + return collect($this->eventsToDispatch) + ->filter(function ($event) use ($eventName, $payload) { + return $event instanceof Closure + ? $event($eventName, $payload) + : $event === $eventName; + }) + ->isNotEmpty(); + } + /** * Remove a set of listeners from the dispatcher. * diff --git a/vendor/illuminate/support/Testing/Fakes/MailFake.php b/vendor/illuminate/support/Testing/Fakes/MailFake.php index 4fea2cb..c95c15a 100644 --- a/vendor/illuminate/support/Testing/Fakes/MailFake.php +++ b/vendor/illuminate/support/Testing/Fakes/MailFake.php @@ -128,9 +128,9 @@ class MailFake implements Factory, Mailer, MailQueue */ public function assertNothingSent() { - $mailableNames = collect($this->mailables)->map(function ($mailable) { - return get_class($mailable); - })->join(', '); + $mailableNames = collect($this->mailables)->map( + fn ($mailable) => get_class($mailable) + )->join(', '); PHPUnit::assertEmpty($this->mailables, 'The following mailables were sent unexpectedly: '.$mailableNames); } @@ -197,9 +197,9 @@ class MailFake implements Factory, Mailer, MailQueue */ public function assertNothingQueued() { - $mailableNames = collect($this->queuedMailables)->map(function ($mailable) { - return get_class($mailable); - })->join(', '); + $mailableNames = collect($this->queuedMailables)->map( + fn ($mailable) => get_class($mailable) + )->join(', '); PHPUnit::assertEmpty($this->queuedMailables, 'The following mailables were queued unexpectedly: '.$mailableNames); } @@ -219,13 +219,9 @@ class MailFake implements Factory, Mailer, MailQueue return collect(); } - $callback = $callback ?: function () { - return true; - }; + $callback = $callback ?: fn () => true; - return $this->mailablesOf($mailable)->filter(function ($mailable) use ($callback) { - return $callback($mailable); - }); + return $this->mailablesOf($mailable)->filter(fn ($mailable) => $callback($mailable)); } /** @@ -254,13 +250,9 @@ class MailFake implements Factory, Mailer, MailQueue return collect(); } - $callback = $callback ?: function () { - return true; - }; + $callback = $callback ?: fn () => true; - return $this->queuedMailablesOf($mailable)->filter(function ($mailable) use ($callback) { - return $callback($mailable); - }); + return $this->queuedMailablesOf($mailable)->filter(fn ($mailable) => $callback($mailable)); } /** @@ -282,9 +274,7 @@ class MailFake implements Factory, Mailer, MailQueue */ protected function mailablesOf($type) { - return collect($this->mailables)->filter(function ($mailable) use ($type) { - return $mailable instanceof $type; - }); + return collect($this->mailables)->filter(fn ($mailable) => $mailable instanceof $type); } /** @@ -295,9 +285,7 @@ class MailFake implements Factory, Mailer, MailQueue */ protected function queuedMailablesOf($type) { - return collect($this->queuedMailables)->filter(function ($mailable) use ($type) { - return $mailable instanceof $type; - }); + return collect($this->queuedMailables)->filter(fn ($mailable) => $mailable instanceof $type); } /** @@ -324,6 +312,17 @@ class MailFake implements Factory, Mailer, MailQueue return (new PendingMailFake($this))->to($users); } + /** + * Begin the process of mailing a mailable class instance. + * + * @param mixed $users + * @return \Illuminate\Mail\PendingMail + */ + public function cc($users) + { + return (new PendingMailFake($this))->cc($users); + } + /** * Begin the process of mailing a mailable class instance. * @@ -363,12 +362,12 @@ class MailFake implements Factory, Mailer, MailQueue $view->mailer($this->currentMailer); - $this->currentMailer = null; - if ($view instanceof ShouldQueue) { return $this->queue($view, $data); } + $this->currentMailer = null; + $this->mailables[] = $view; } diff --git a/vendor/illuminate/support/Testing/Fakes/NotificationFake.php b/vendor/illuminate/support/Testing/Fakes/NotificationFake.php index 4c08911..5991420 100644 --- a/vendor/illuminate/support/Testing/Fakes/NotificationFake.php +++ b/vendor/illuminate/support/Testing/Fakes/NotificationFake.php @@ -197,9 +197,7 @@ class NotificationFake implements NotificationDispatcher, NotificationFactory { $actualCount = collect($this->notifications) ->flatten(1) - ->reduce(function ($count, $sent) use ($notification) { - return $count + count($sent[$notification] ?? []); - }, 0); + ->reduce(fn ($count, $sent) => $count + count($sent[$notification] ?? []), 0); PHPUnit::assertSame( $expectedCount, $actualCount, @@ -207,6 +205,22 @@ class NotificationFake implements NotificationDispatcher, NotificationFactory ); } + /** + * Assert the total count of notification that were sent. + * + * @param int $expectedCount + * @return void + */ + public function assertCount($expectedCount) + { + $actualCount = collect($this->notifications)->flatten(3)->count(); + + PHPUnit::assertSame( + $expectedCount, $actualCount, + "Expected {$expectedCount} notifications to be sent, but {$actualCount} were sent." + ); + } + /** * Assert the total amount of times a notification was sent. * @@ -235,15 +249,13 @@ class NotificationFake implements NotificationDispatcher, NotificationFactory return collect(); } - $callback = $callback ?: function () { - return true; - }; + $callback = $callback ?: fn () => true; $notifications = collect($this->notificationsFor($notifiable, $notification)); - return $notifications->filter(function ($arguments) use ($callback) { - return $callback(...array_values($arguments)); - })->pluck('notification'); + return $notifications->filter( + fn ($arguments) => $callback(...array_values($arguments)) + )->pluck('notification'); } /** @@ -306,9 +318,7 @@ class NotificationFake implements NotificationDispatcher, NotificationFactory if (method_exists($notification, 'shouldSend')) { $notifiableChannels = array_filter( $notifiableChannels, - function ($channel) use ($notification, $notifiable) { - return $notification->shouldSend($notifiable, $channel) !== false; - } + fn ($channel) => $notification->shouldSend($notifiable, $channel) !== false ); if (empty($notifiableChannels)) { @@ -352,4 +362,14 @@ class NotificationFake implements NotificationDispatcher, NotificationFactory return $this; } + + /** + * Get the notifications that have been sent. + * + * @return array + */ + public function sentNotifications() + { + return $this->notifications; + } } diff --git a/vendor/illuminate/support/Testing/Fakes/PendingBatchFake.php b/vendor/illuminate/support/Testing/Fakes/PendingBatchFake.php index c60b4b5..3d0f499 100644 --- a/vendor/illuminate/support/Testing/Fakes/PendingBatchFake.php +++ b/vendor/illuminate/support/Testing/Fakes/PendingBatchFake.php @@ -36,4 +36,14 @@ class PendingBatchFake extends PendingBatch { return $this->bus->recordPendingBatch($this); } + + /** + * Dispatch the batch after the response is sent to the browser. + * + * @return \Illuminate\Bus\Batch + */ + public function dispatchAfterResponse() + { + return $this->bus->recordPendingBatch($this); + } } diff --git a/vendor/illuminate/support/Testing/Fakes/QueueFake.php b/vendor/illuminate/support/Testing/Fakes/QueueFake.php index cb34915..f2caa76 100644 --- a/vendor/illuminate/support/Testing/Fakes/QueueFake.php +++ b/vendor/illuminate/support/Testing/Fakes/QueueFake.php @@ -6,6 +6,7 @@ use BadMethodCallException; use Closure; use Illuminate\Contracts\Queue\Queue; use Illuminate\Queue\QueueManager; +use Illuminate\Support\Collection; use Illuminate\Support\Traits\ReflectsClosures; use PHPUnit\Framework\Assert as PHPUnit; @@ -13,6 +14,27 @@ class QueueFake extends QueueManager implements Queue { use ReflectsClosures; + /** + * The original queue manager. + * + * @var \Illuminate\Contracts\Queue\Queue + */ + protected $queue; + + /** + * The job types that should be intercepted instead of pushed to the queue. + * + * @var \Illuminate\Support\Collection + */ + protected $jobsToFake; + + /** + * The job types that should be pushed to the queue and not intercepted. + * + * @var \Illuminate\Support\Collection + */ + protected $jobsToBeQueued; + /** * All of the jobs that have been pushed. * @@ -20,6 +42,36 @@ class QueueFake extends QueueManager implements Queue */ protected $jobs = []; + /** + * Create a new fake queue instance. + * + * @param \Illuminate\Contracts\Foundation\Application $app + * @param array $jobsToFake + * @param \Illuminate\Queue\QueueManager|null $queue + * @return void + */ + public function __construct($app, $jobsToFake = [], $queue = null) + { + parent::__construct($app); + + $this->jobsToFake = Collection::wrap($jobsToFake); + $this->jobsToBeQueued = Collection::make(); + $this->queue = $queue; + } + + /** + * Specify the jobs that should be queued instead of faked. + * + * @param array|string $jobsToBeQueued + * @return $this + */ + public function except($jobsToBeQueued) + { + $this->jobsToBeQueued = Collection::wrap($jobsToBeQueued)->merge($this->jobsToBeQueued); + + return $this; + } + /** * Assert if a job was pushed based on a truth-test callback. * @@ -135,14 +187,10 @@ class QueueFake extends QueueManager implements Queue */ protected function assertPushedWithChainOfObjects($job, $expectedChain, $callback) { - $chain = collect($expectedChain)->map(function ($job) { - return serialize($job); - })->all(); + $chain = collect($expectedChain)->map(fn ($job) => serialize($job))->all(); PHPUnit::assertTrue( - $this->pushed($job, $callback)->filter(function ($job) use ($chain) { - return $job->chained == $chain; - })->isNotEmpty(), + $this->pushed($job, $callback)->filter(fn ($job) => $job->chained == $chain)->isNotEmpty(), 'The expected chain was not pushed.' ); } @@ -178,9 +226,7 @@ class QueueFake extends QueueManager implements Queue */ protected function isChainOfObjects($chain) { - return ! collect($chain)->contains(function ($job) { - return ! is_object($job); - }); + return ! collect($chain)->contains(fn ($job) => ! is_object($job)); } /** @@ -225,13 +271,11 @@ class QueueFake extends QueueManager implements Queue return collect(); } - $callback = $callback ?: function () { - return true; - }; + $callback = $callback ?: fn () => true; - return collect($this->jobs[$job])->filter(function ($data) use ($callback) { - return $callback($data['job'], $data['queue']); - })->pluck('job'); + return collect($this->jobs[$job])->filter( + fn ($data) => $callback($data['job'], $data['queue'], $data['data']) + )->pluck('job'); } /** @@ -264,9 +308,9 @@ class QueueFake extends QueueManager implements Queue */ public function size($queue = null) { - return collect($this->jobs)->flatten(1)->filter(function ($job) use ($queue) { - return $job['queue'] === $queue; - })->count(); + return collect($this->jobs)->flatten(1)->filter( + fn ($job) => $job['queue'] === $queue + )->count(); } /** @@ -279,10 +323,55 @@ class QueueFake extends QueueManager implements Queue */ public function push($job, $data = '', $queue = null) { - $this->jobs[is_object($job) ? get_class($job) : $job][] = [ - 'job' => $job, - 'queue' => $queue, - ]; + if ($this->shouldFakeJob($job)) { + $this->jobs[is_object($job) ? get_class($job) : $job][] = [ + 'job' => $job, + 'queue' => $queue, + 'data' => $data, + ]; + } else { + is_object($job) && isset($job->connection) + ? $this->queue->connection($job->connection)->push($job, $data, $queue) + : $this->queue->push($job, $data, $queue); + } + } + + /** + * Determine if a job should be faked or actually dispatched. + * + * @param object $job + * @return bool + */ + public function shouldFakeJob($job) + { + if ($this->shouldDispatchJob($job)) { + return false; + } + + if ($this->jobsToFake->isEmpty()) { + return true; + } + + return $this->jobsToFake->contains( + fn ($jobToFake) => $job instanceof ((string) $jobToFake) + ); + } + + /** + * Determine if a job should be pushed to the queue instead of faked. + * + * @param object $job + * @return bool + */ + protected function shouldDispatchJob($job) + { + if ($this->jobsToBeQueued->isEmpty()) { + return false; + } + + return $this->jobsToBeQueued->contains( + fn ($jobToQueue) => $job instanceof ((string) $jobToQueue) + ); } /** diff --git a/vendor/illuminate/support/Timebox.php b/vendor/illuminate/support/Timebox.php new file mode 100644 index 0000000..6e2aa4d --- /dev/null +++ b/vendor/illuminate/support/Timebox.php @@ -0,0 +1,72 @@ +earlyReturn && $remainder > 0) { + $this->usleep($remainder); + } + + return $result; + } + + /** + * Indicate that the timebox can return early. + * + * @return $this + */ + public function returnEarly() + { + $this->earlyReturn = true; + + return $this; + } + + /** + * Indicate that the timebox cannot return early. + * + * @return $this + */ + public function dontReturnEarly() + { + $this->earlyReturn = false; + + return $this; + } + + /** + * Sleep for the specified number of microseconds. + * + * @param int $microseconds + * @return void + */ + protected function usleep(int $microseconds) + { + usleep($microseconds); + } +} diff --git a/vendor/illuminate/support/ValidatedInput.php b/vendor/illuminate/support/ValidatedInput.php index 084cb24..87e47b5 100644 --- a/vendor/illuminate/support/ValidatedInput.php +++ b/vendor/illuminate/support/ValidatedInput.php @@ -27,10 +27,40 @@ class ValidatedInput implements ValidatedData $this->input = $input; } + /** + * Determine if the validated input has one or more keys. + * + * @param mixed $keys + * @return bool + */ + public function has($keys) + { + $keys = is_array($keys) ? $keys : func_get_args(); + + foreach ($keys as $key) { + if (! Arr::has($this->input, $key)) { + return false; + } + } + + return true; + } + + /** + * Determine if the validated input is missing one or more keys. + * + * @param mixed $keys + * @return bool + */ + public function missing($keys) + { + return ! $this->has($keys); + } + /** * Get a subset containing the provided keys with values from the input data. * - * @param array|mixed $keys + * @param mixed $keys * @return array */ public function only($keys) @@ -55,7 +85,7 @@ class ValidatedInput implements ValidatedData /** * Get all of the input except for a specified array of items. * - * @param array|mixed $keys + * @param mixed $keys * @return array */ public function except($keys) diff --git a/vendor/illuminate/support/composer.json b/vendor/illuminate/support/composer.json index 1e1681c..61b01cf 100644 --- a/vendor/illuminate/support/composer.json +++ b/vendor/illuminate/support/composer.json @@ -15,14 +15,15 @@ ], "require": { "php": "^8.0.2", - "ext-json": "*", + "ext-ctype": "*", + "ext-filter": "*", "ext-mbstring": "*", "doctrine/inflector": "^2.0", "illuminate/collections": "^9.0", "illuminate/conditionable": "^9.0", "illuminate/contracts": "^9.0", "illuminate/macroable": "^9.0", - "nesbot/carbon": "^2.53.1", + "nesbot/carbon": "^2.62.1", "voku/portable-ascii": "^2.0" }, "conflict": { @@ -44,8 +45,9 @@ "suggest": { "illuminate/filesystem": "Required to use the composer class (^9.0).", "league/commonmark": "Required to use Str::markdown() and Stringable::markdown() (^2.0.2).", - "ramsey/uuid": "Required to use Str::uuid() (^4.2.2).", + "ramsey/uuid": "Required to use Str::uuid() (^4.7).", "symfony/process": "Required to use the composer class (^6.0).", + "symfony/uid": "Required to use Str::ulid() (^6.0).", "symfony/var-dumper": "Required to use the dd function (^6.0).", "vlucas/phpdotenv": "Required to use the Env class and env helper (^5.4.1)." }, diff --git a/vendor/illuminate/support/helpers.php b/vendor/illuminate/support/helpers.php index 6928cc3..bb8d178 100755 --- a/vendor/illuminate/support/helpers.php +++ b/vendor/illuminate/support/helpers.php @@ -102,7 +102,7 @@ if (! function_exists('e')) { /** * Encode HTML special characters in a string. * - * @param \Illuminate\Contracts\Support\DeferringDisplayableValue|\Illuminate\Contracts\Support\Htmlable|string|null $value + * @param \Illuminate\Contracts\Support\DeferringDisplayableValue|\Illuminate\Contracts\Support\Htmlable|\BackedEnum|string|null $value * @param bool $doubleEncode * @return string */ @@ -116,6 +116,10 @@ if (! function_exists('e')) { return $value->toHtml(); } + if ($value instanceof BackedEnum) { + $value = $value->value; + } + return htmlspecialchars($value ?? '', ENT_QUOTES, 'UTF-8', $doubleEncode); } } @@ -249,7 +253,7 @@ if (! function_exists('retry')) { $sleepMilliseconds = $backoff[$attempts - 1] ?? $sleepMilliseconds; if ($sleepMilliseconds) { - usleep(value($sleepMilliseconds, $attempts) * 1000); + usleep(value($sleepMilliseconds, $attempts, $e) * 1000); } goto beginning; @@ -408,10 +412,11 @@ if (! function_exists('with')) { * Return the given value, optionally passed through the given callback. * * @template TValue + * @template TReturn * * @param TValue $value - * @param (callable(TValue): TValue)|null $callback - * @return TValue + * @param (callable(TValue): (TReturn))|null $callback + * @return ($callback is null ? TValue : TReturn) */ function with($value, callable $callback = null) { diff --git a/vendor/nesbot/carbon/.phpstorm.meta.php b/vendor/nesbot/carbon/.phpstorm.meta.php new file mode 100644 index 0000000..bd7c7e0 --- /dev/null +++ b/vendor/nesbot/carbon/.phpstorm.meta.php @@ -0,0 +1,10 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Carbon\MessageFormatter; + +use Symfony\Component\Translation\Formatter\MessageFormatterInterface; + +if (!class_exists(LazyMessageFormatter::class, false)) { + abstract class LazyMessageFormatter implements MessageFormatterInterface + { + public function format(string $message, string $locale, array $parameters = []): string + { + return $this->formatter->format( + $message, + $this->transformLocale($locale), + $parameters + ); + } + } +} diff --git a/vendor/nesbot/carbon/lazy/Carbon/MessageFormatter/MessageFormatterMapperWeakType.php b/vendor/nesbot/carbon/lazy/Carbon/MessageFormatter/MessageFormatterMapperWeakType.php new file mode 100644 index 0000000..cbd890d --- /dev/null +++ b/vendor/nesbot/carbon/lazy/Carbon/MessageFormatter/MessageFormatterMapperWeakType.php @@ -0,0 +1,36 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Carbon\MessageFormatter; + +use Symfony\Component\Translation\Formatter\ChoiceMessageFormatterInterface; +use Symfony\Component\Translation\Formatter\MessageFormatterInterface; + +if (!class_exists(LazyMessageFormatter::class, false)) { + abstract class LazyMessageFormatter implements MessageFormatterInterface, ChoiceMessageFormatterInterface + { + abstract protected function transformLocale(?string $locale): ?string; + + public function format($message, $locale, array $parameters = []) + { + return $this->formatter->format( + $message, + $this->transformLocale($locale), + $parameters + ); + } + + public function choiceFormat($message, $number, $locale, array $parameters = []) + { + return $this->formatter->choiceFormat($message, $number, $locale, $parameters); + } + } +} diff --git a/vendor/nesbot/carbon/lazy/Carbon/PHPStan/AbstractMacroBuiltin.php b/vendor/nesbot/carbon/lazy/Carbon/PHPStan/AbstractMacroBuiltin.php new file mode 100644 index 0000000..ba7cf63 --- /dev/null +++ b/vendor/nesbot/carbon/lazy/Carbon/PHPStan/AbstractMacroBuiltin.php @@ -0,0 +1,36 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Carbon\PHPStan; + +use PHPStan\BetterReflection\Reflection; +use ReflectionMethod; + +if (!class_exists(AbstractReflectionMacro::class, false)) { + abstract class AbstractReflectionMacro extends AbstractMacro + { + /** + * {@inheritdoc} + */ + public function getReflection(): ?ReflectionMethod + { + if ($this->reflectionFunction instanceof Reflection\ReflectionMethod) { + return new Reflection\Adapter\ReflectionMethod($this->reflectionFunction); + } + + return $this->reflectionFunction instanceof ReflectionMethod + ? $this->reflectionFunction + : null; + } + } +} diff --git a/vendor/nesbot/carbon/lazy/Carbon/PHPStan/AbstractMacroStatic.php b/vendor/nesbot/carbon/lazy/Carbon/PHPStan/AbstractMacroStatic.php new file mode 100644 index 0000000..bd4c8e8 --- /dev/null +++ b/vendor/nesbot/carbon/lazy/Carbon/PHPStan/AbstractMacroStatic.php @@ -0,0 +1,45 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Carbon\PHPStan; + +use PHPStan\BetterReflection\Reflection; +use ReflectionMethod; + +if (!class_exists(AbstractReflectionMacro::class, false)) { + abstract class AbstractReflectionMacro extends AbstractMacro + { + /** + * {@inheritdoc} + */ + public function getReflection(): ?Reflection\Adapter\ReflectionMethod + { + if ($this->reflectionFunction instanceof Reflection\Adapter\ReflectionMethod) { + return $this->reflectionFunction; + } + + if ($this->reflectionFunction instanceof Reflection\ReflectionMethod) { + return new Reflection\Adapter\ReflectionMethod($this->reflectionFunction); + } + + return $this->reflectionFunction instanceof ReflectionMethod + ? new Reflection\Adapter\ReflectionMethod( + Reflection\ReflectionMethod::createFromName( + $this->reflectionFunction->getDeclaringClass()->getName(), + $this->reflectionFunction->getName() + ) + ) + : null; + } + } +} diff --git a/vendor/nesbot/carbon/lazy/Carbon/PHPStan/MacroStrongType.php b/vendor/nesbot/carbon/lazy/Carbon/PHPStan/MacroStrongType.php index eacd9c1..f615b3a 100644 --- a/vendor/nesbot/carbon/lazy/Carbon/PHPStan/MacroStrongType.php +++ b/vendor/nesbot/carbon/lazy/Carbon/PHPStan/MacroStrongType.php @@ -14,14 +14,16 @@ declare(strict_types=1); namespace Carbon\PHPStan; if (!class_exists(LazyMacro::class, false)) { - abstract class LazyMacro extends AbstractMacro + abstract class LazyMacro extends AbstractReflectionMacro { /** * {@inheritdoc} */ public function getFileName(): ?string { - return $this->reflectionFunction->getFileName(); + $file = $this->reflectionFunction->getFileName(); + + return (($file ? realpath($file) : null) ?: $file) ?: null; } /** diff --git a/vendor/nesbot/carbon/lazy/Carbon/PHPStan/MacroWeakType.php b/vendor/nesbot/carbon/lazy/Carbon/PHPStan/MacroWeakType.php index 3e9fcf4..bf64c1d 100644 --- a/vendor/nesbot/carbon/lazy/Carbon/PHPStan/MacroWeakType.php +++ b/vendor/nesbot/carbon/lazy/Carbon/PHPStan/MacroWeakType.php @@ -14,7 +14,7 @@ declare(strict_types=1); namespace Carbon\PHPStan; if (!class_exists(LazyMacro::class, false)) { - abstract class LazyMacro extends AbstractMacro + abstract class LazyMacro extends AbstractReflectionMacro { /** * {@inheritdoc} @@ -23,7 +23,9 @@ if (!class_exists(LazyMacro::class, false)) { */ public function getFileName() { - return $this->reflectionFunction->getFileName(); + $file = $this->reflectionFunction->getFileName(); + + return (($file ? realpath($file) : null) ?: $file) ?: null; } /** diff --git a/vendor/nesbot/carbon/readme.md b/vendor/nesbot/carbon/readme.md index 5d82721..a178c3c 100644 --- a/vendor/nesbot/carbon/readme.md +++ b/vendor/nesbot/carbon/readme.md @@ -120,12 +120,22 @@ This project exists thanks to all the people who contribute. Support this project by becoming a sponsor. Your logo will show up here with a link to your website. - + + + + + + + + + + + [[Become a sponsor](https://opencollective.com/Carbon#sponsor)] diff --git a/vendor/nesbot/carbon/src/Carbon/AbstractTranslator.php b/vendor/nesbot/carbon/src/Carbon/AbstractTranslator.php index 48441e7..8b8fe08 100644 --- a/vendor/nesbot/carbon/src/Carbon/AbstractTranslator.php +++ b/vendor/nesbot/carbon/src/Carbon/AbstractTranslator.php @@ -11,6 +11,7 @@ namespace Carbon; +use Carbon\MessageFormatter\MessageFormatterMapper; use Closure; use ReflectionException; use ReflectionFunction; @@ -51,7 +52,7 @@ abstract class AbstractTranslator extends Translation\Translator /** * List of locales aliases. * - * @var string[] + * @var array */ protected $aliases = [ 'me' => 'sr_Latn_ME', @@ -83,7 +84,7 @@ abstract class AbstractTranslator extends Translation\Translator $this->initializing = true; $this->directories = [__DIR__.'/Lang']; $this->addLoader('array', new ArrayLoader()); - parent::__construct($locale, $formatter, $cacheDir, $debug); + parent::__construct($locale, new MessageFormatterMapper($formatter), $cacheDir, $debug); $this->initializing = false; } @@ -220,8 +221,8 @@ abstract class AbstractTranslator extends Translation\Translator $catalogue = $this->getCatalogue($locale); $format = $this instanceof TranslatorStrongTypeInterface - ? $this->getFromCatalogue($catalogue, (string) $id, $domain) // @codeCoverageIgnore - : $this->getCatalogue($locale)->get((string) $id, $domain); + ? $this->getFromCatalogue($catalogue, (string) $id, $domain) + : $this->getCatalogue($locale)->get((string) $id, $domain); // @codeCoverageIgnore if ($format instanceof Closure) { // @codeCoverageIgnoreStart @@ -250,11 +251,7 @@ abstract class AbstractTranslator extends Translation\Translator */ protected function loadMessagesFromFile($locale) { - if (isset($this->messages[$locale])) { - return true; - } - - return $this->resetMessages($locale); + return isset($this->messages[$locale]) || $this->resetMessages($locale); } /** @@ -311,7 +308,7 @@ abstract class AbstractTranslator extends Translation\Translator */ public function setLocale($locale) { - $locale = preg_replace_callback('/[-_]([a-z]{2,}|[0-9]{2,})/', function ($matches) { + $locale = preg_replace_callback('/[-_]([a-z]{2,}|\d{2,})/', function ($matches) { // _2-letters or YUE is a region, _3+-letters is a variant $upper = strtoupper($matches[1]); @@ -359,13 +356,13 @@ abstract class AbstractTranslator extends Translation\Translator parent::setLocale($macroLocale); } - if ($this->loadMessagesFromFile($locale) || $this->initializing) { - parent::setLocale($locale); - - return true; + if (!$this->loadMessagesFromFile($locale) && !$this->initializing) { + return false; } - return false; + parent::setLocale($locale); + + return true; } /** diff --git a/vendor/nesbot/carbon/src/Carbon/Carbon.php b/vendor/nesbot/carbon/src/Carbon/Carbon.php index e327590..1e285aa 100644 --- a/vendor/nesbot/carbon/src/Carbon/Carbon.php +++ b/vendor/nesbot/carbon/src/Carbon/Carbon.php @@ -502,8 +502,8 @@ use DateTimeZone; * @method string longRelativeToNowDiffForHumans(DateTimeInterface $other = null, int $parts = 1) Get the difference (long format, 'RelativeToNow' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.) * @method string shortRelativeToOtherDiffForHumans(DateTimeInterface $other = null, int $parts = 1) Get the difference (short format, 'RelativeToOther' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.) * @method string longRelativeToOtherDiffForHumans(DateTimeInterface $other = null, int $parts = 1) Get the difference (long format, 'RelativeToOther' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.) - * @method static Carbon|false createFromFormat(string $format, string $time, string|DateTimeZone $timezone = null) Parse a string into a new Carbon object according to the specified format. - * @method static Carbon __set_state(array $array) https://php.net/manual/en/datetime.set-state.php + * @method static static|false createFromFormat(string $format, string $time, string|DateTimeZone $timezone = null) Parse a string into a new Carbon object according to the specified format. + * @method static static __set_state(array $array) https://php.net/manual/en/datetime.set-state.php * * */ diff --git a/vendor/nesbot/carbon/src/Carbon/CarbonImmutable.php b/vendor/nesbot/carbon/src/Carbon/CarbonImmutable.php index 6d1194e..960d66c 100644 --- a/vendor/nesbot/carbon/src/Carbon/CarbonImmutable.php +++ b/vendor/nesbot/carbon/src/Carbon/CarbonImmutable.php @@ -24,486 +24,486 @@ use DateTimeZone; * * * - * @property int $year - * @property int $yearIso - * @property int $month - * @property int $day - * @property int $hour - * @property int $minute - * @property int $second - * @property int $micro - * @property int $microsecond - * @property int|float|string $timestamp seconds since the Unix Epoch - * @property string $englishDayOfWeek the day of week in English - * @property string $shortEnglishDayOfWeek the abbreviated day of week in English - * @property string $englishMonth the month in English - * @property string $shortEnglishMonth the abbreviated month in English - * @property int $milliseconds - * @property int $millisecond - * @property int $milli - * @property int $week 1 through 53 - * @property int $isoWeek 1 through 53 - * @property int $weekYear year according to week format - * @property int $isoWeekYear year according to ISO week format - * @property int $dayOfYear 1 through 366 - * @property int $age does a diffInYears() with default parameters - * @property int $offset the timezone offset in seconds from UTC - * @property int $offsetMinutes the timezone offset in minutes from UTC - * @property int $offsetHours the timezone offset in hours from UTC - * @property CarbonTimeZone $timezone the current timezone - * @property CarbonTimeZone $tz alias of $timezone - * @property-read int $dayOfWeek 0 (for Sunday) through 6 (for Saturday) - * @property-read int $dayOfWeekIso 1 (for Monday) through 7 (for Sunday) - * @property-read int $weekOfYear ISO-8601 week number of year, weeks starting on Monday - * @property-read int $daysInMonth number of days in the given month - * @property-read string $latinMeridiem "am"/"pm" (Ante meridiem or Post meridiem latin lowercase mark) - * @property-read string $latinUpperMeridiem "AM"/"PM" (Ante meridiem or Post meridiem latin uppercase mark) - * @property-read string $timezoneAbbreviatedName the current timezone abbreviated name - * @property-read string $tzAbbrName alias of $timezoneAbbreviatedName - * @property-read string $dayName long name of weekday translated according to Carbon locale, in english if no translation available for current language - * @property-read string $shortDayName short name of weekday translated according to Carbon locale, in english if no translation available for current language - * @property-read string $minDayName very short name of weekday translated according to Carbon locale, in english if no translation available for current language - * @property-read string $monthName long name of month translated according to Carbon locale, in english if no translation available for current language - * @property-read string $shortMonthName short name of month translated according to Carbon locale, in english if no translation available for current language - * @property-read string $meridiem lowercase meridiem mark translated according to Carbon locale, in latin if no translation available for current language - * @property-read string $upperMeridiem uppercase meridiem mark translated according to Carbon locale, in latin if no translation available for current language - * @property-read int $noZeroHour current hour from 1 to 24 - * @property-read int $weeksInYear 51 through 53 - * @property-read int $isoWeeksInYear 51 through 53 - * @property-read int $weekOfMonth 1 through 5 - * @property-read int $weekNumberInMonth 1 through 5 - * @property-read int $firstWeekDay 0 through 6 - * @property-read int $lastWeekDay 0 through 6 - * @property-read int $daysInYear 365 or 366 - * @property-read int $quarter the quarter of this instance, 1 - 4 - * @property-read int $decade the decade of this instance - * @property-read int $century the century of this instance - * @property-read int $millennium the millennium of this instance - * @property-read bool $dst daylight savings time indicator, true if DST, false otherwise - * @property-read bool $local checks if the timezone is local, true if local, false otherwise - * @property-read bool $utc checks if the timezone is UTC, true if UTC, false otherwise - * @property-read string $timezoneName the current timezone name - * @property-read string $tzName alias of $timezoneName - * @property-read string $locale locale of the current instance + * @property int $year + * @property int $yearIso + * @property int $month + * @property int $day + * @property int $hour + * @property int $minute + * @property int $second + * @property int $micro + * @property int $microsecond + * @property int|float|string $timestamp seconds since the Unix Epoch + * @property string $englishDayOfWeek the day of week in English + * @property string $shortEnglishDayOfWeek the abbreviated day of week in English + * @property string $englishMonth the month in English + * @property string $shortEnglishMonth the abbreviated month in English + * @property int $milliseconds + * @property int $millisecond + * @property int $milli + * @property int $week 1 through 53 + * @property int $isoWeek 1 through 53 + * @property int $weekYear year according to week format + * @property int $isoWeekYear year according to ISO week format + * @property int $dayOfYear 1 through 366 + * @property int $age does a diffInYears() with default parameters + * @property int $offset the timezone offset in seconds from UTC + * @property int $offsetMinutes the timezone offset in minutes from UTC + * @property int $offsetHours the timezone offset in hours from UTC + * @property CarbonTimeZone $timezone the current timezone + * @property CarbonTimeZone $tz alias of $timezone + * @property-read int $dayOfWeek 0 (for Sunday) through 6 (for Saturday) + * @property-read int $dayOfWeekIso 1 (for Monday) through 7 (for Sunday) + * @property-read int $weekOfYear ISO-8601 week number of year, weeks starting on Monday + * @property-read int $daysInMonth number of days in the given month + * @property-read string $latinMeridiem "am"/"pm" (Ante meridiem or Post meridiem latin lowercase mark) + * @property-read string $latinUpperMeridiem "AM"/"PM" (Ante meridiem or Post meridiem latin uppercase mark) + * @property-read string $timezoneAbbreviatedName the current timezone abbreviated name + * @property-read string $tzAbbrName alias of $timezoneAbbreviatedName + * @property-read string $dayName long name of weekday translated according to Carbon locale, in english if no translation available for current language + * @property-read string $shortDayName short name of weekday translated according to Carbon locale, in english if no translation available for current language + * @property-read string $minDayName very short name of weekday translated according to Carbon locale, in english if no translation available for current language + * @property-read string $monthName long name of month translated according to Carbon locale, in english if no translation available for current language + * @property-read string $shortMonthName short name of month translated according to Carbon locale, in english if no translation available for current language + * @property-read string $meridiem lowercase meridiem mark translated according to Carbon locale, in latin if no translation available for current language + * @property-read string $upperMeridiem uppercase meridiem mark translated according to Carbon locale, in latin if no translation available for current language + * @property-read int $noZeroHour current hour from 1 to 24 + * @property-read int $weeksInYear 51 through 53 + * @property-read int $isoWeeksInYear 51 through 53 + * @property-read int $weekOfMonth 1 through 5 + * @property-read int $weekNumberInMonth 1 through 5 + * @property-read int $firstWeekDay 0 through 6 + * @property-read int $lastWeekDay 0 through 6 + * @property-read int $daysInYear 365 or 366 + * @property-read int $quarter the quarter of this instance, 1 - 4 + * @property-read int $decade the decade of this instance + * @property-read int $century the century of this instance + * @property-read int $millennium the millennium of this instance + * @property-read bool $dst daylight savings time indicator, true if DST, false otherwise + * @property-read bool $local checks if the timezone is local, true if local, false otherwise + * @property-read bool $utc checks if the timezone is UTC, true if UTC, false otherwise + * @property-read string $timezoneName the current timezone name + * @property-read string $tzName alias of $timezoneName + * @property-read string $locale locale of the current instance * - * @method bool isUtc() Check if the current instance has UTC timezone. (Both isUtc and isUTC cases are valid.) - * @method bool isLocal() Check if the current instance has non-UTC timezone. - * @method bool isValid() Check if the current instance is a valid date. - * @method bool isDST() Check if the current instance is in a daylight saving time. - * @method bool isSunday() Checks if the instance day is sunday. - * @method bool isMonday() Checks if the instance day is monday. - * @method bool isTuesday() Checks if the instance day is tuesday. - * @method bool isWednesday() Checks if the instance day is wednesday. - * @method bool isThursday() Checks if the instance day is thursday. - * @method bool isFriday() Checks if the instance day is friday. - * @method bool isSaturday() Checks if the instance day is saturday. - * @method bool isSameYear(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same year as the instance. If null passed, compare to now (with the same timezone). - * @method bool isCurrentYear() Checks if the instance is in the same year as the current moment. - * @method bool isNextYear() Checks if the instance is in the same year as the current moment next year. - * @method bool isLastYear() Checks if the instance is in the same year as the current moment last year. - * @method bool isSameWeek(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same week as the instance. If null passed, compare to now (with the same timezone). - * @method bool isCurrentWeek() Checks if the instance is in the same week as the current moment. - * @method bool isNextWeek() Checks if the instance is in the same week as the current moment next week. - * @method bool isLastWeek() Checks if the instance is in the same week as the current moment last week. - * @method bool isSameDay(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same day as the instance. If null passed, compare to now (with the same timezone). - * @method bool isCurrentDay() Checks if the instance is in the same day as the current moment. - * @method bool isNextDay() Checks if the instance is in the same day as the current moment next day. - * @method bool isLastDay() Checks if the instance is in the same day as the current moment last day. - * @method bool isSameHour(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same hour as the instance. If null passed, compare to now (with the same timezone). - * @method bool isCurrentHour() Checks if the instance is in the same hour as the current moment. - * @method bool isNextHour() Checks if the instance is in the same hour as the current moment next hour. - * @method bool isLastHour() Checks if the instance is in the same hour as the current moment last hour. - * @method bool isSameMinute(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same minute as the instance. If null passed, compare to now (with the same timezone). - * @method bool isCurrentMinute() Checks if the instance is in the same minute as the current moment. - * @method bool isNextMinute() Checks if the instance is in the same minute as the current moment next minute. - * @method bool isLastMinute() Checks if the instance is in the same minute as the current moment last minute. - * @method bool isSameSecond(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same second as the instance. If null passed, compare to now (with the same timezone). - * @method bool isCurrentSecond() Checks if the instance is in the same second as the current moment. - * @method bool isNextSecond() Checks if the instance is in the same second as the current moment next second. - * @method bool isLastSecond() Checks if the instance is in the same second as the current moment last second. - * @method bool isSameMicro(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same microsecond as the instance. If null passed, compare to now (with the same timezone). - * @method bool isCurrentMicro() Checks if the instance is in the same microsecond as the current moment. - * @method bool isNextMicro() Checks if the instance is in the same microsecond as the current moment next microsecond. - * @method bool isLastMicro() Checks if the instance is in the same microsecond as the current moment last microsecond. - * @method bool isSameMicrosecond(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same microsecond as the instance. If null passed, compare to now (with the same timezone). - * @method bool isCurrentMicrosecond() Checks if the instance is in the same microsecond as the current moment. - * @method bool isNextMicrosecond() Checks if the instance is in the same microsecond as the current moment next microsecond. - * @method bool isLastMicrosecond() Checks if the instance is in the same microsecond as the current moment last microsecond. - * @method bool isCurrentMonth() Checks if the instance is in the same month as the current moment. - * @method bool isNextMonth() Checks if the instance is in the same month as the current moment next month. - * @method bool isLastMonth() Checks if the instance is in the same month as the current moment last month. - * @method bool isCurrentQuarter() Checks if the instance is in the same quarter as the current moment. - * @method bool isNextQuarter() Checks if the instance is in the same quarter as the current moment next quarter. - * @method bool isLastQuarter() Checks if the instance is in the same quarter as the current moment last quarter. - * @method bool isSameDecade(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same decade as the instance. If null passed, compare to now (with the same timezone). - * @method bool isCurrentDecade() Checks if the instance is in the same decade as the current moment. - * @method bool isNextDecade() Checks if the instance is in the same decade as the current moment next decade. - * @method bool isLastDecade() Checks if the instance is in the same decade as the current moment last decade. - * @method bool isSameCentury(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same century as the instance. If null passed, compare to now (with the same timezone). - * @method bool isCurrentCentury() Checks if the instance is in the same century as the current moment. - * @method bool isNextCentury() Checks if the instance is in the same century as the current moment next century. - * @method bool isLastCentury() Checks if the instance is in the same century as the current moment last century. - * @method bool isSameMillennium(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same millennium as the instance. If null passed, compare to now (with the same timezone). - * @method bool isCurrentMillennium() Checks if the instance is in the same millennium as the current moment. - * @method bool isNextMillennium() Checks if the instance is in the same millennium as the current moment next millennium. - * @method bool isLastMillennium() Checks if the instance is in the same millennium as the current moment last millennium. - * @method CarbonImmutable years(int $value) Set current instance year to the given value. - * @method CarbonImmutable year(int $value) Set current instance year to the given value. - * @method CarbonImmutable setYears(int $value) Set current instance year to the given value. - * @method CarbonImmutable setYear(int $value) Set current instance year to the given value. - * @method CarbonImmutable months(int $value) Set current instance month to the given value. - * @method CarbonImmutable month(int $value) Set current instance month to the given value. - * @method CarbonImmutable setMonths(int $value) Set current instance month to the given value. - * @method CarbonImmutable setMonth(int $value) Set current instance month to the given value. - * @method CarbonImmutable days(int $value) Set current instance day to the given value. - * @method CarbonImmutable day(int $value) Set current instance day to the given value. - * @method CarbonImmutable setDays(int $value) Set current instance day to the given value. - * @method CarbonImmutable setDay(int $value) Set current instance day to the given value. - * @method CarbonImmutable hours(int $value) Set current instance hour to the given value. - * @method CarbonImmutable hour(int $value) Set current instance hour to the given value. - * @method CarbonImmutable setHours(int $value) Set current instance hour to the given value. - * @method CarbonImmutable setHour(int $value) Set current instance hour to the given value. - * @method CarbonImmutable minutes(int $value) Set current instance minute to the given value. - * @method CarbonImmutable minute(int $value) Set current instance minute to the given value. - * @method CarbonImmutable setMinutes(int $value) Set current instance minute to the given value. - * @method CarbonImmutable setMinute(int $value) Set current instance minute to the given value. - * @method CarbonImmutable seconds(int $value) Set current instance second to the given value. - * @method CarbonImmutable second(int $value) Set current instance second to the given value. - * @method CarbonImmutable setSeconds(int $value) Set current instance second to the given value. - * @method CarbonImmutable setSecond(int $value) Set current instance second to the given value. - * @method CarbonImmutable millis(int $value) Set current instance millisecond to the given value. - * @method CarbonImmutable milli(int $value) Set current instance millisecond to the given value. - * @method CarbonImmutable setMillis(int $value) Set current instance millisecond to the given value. - * @method CarbonImmutable setMilli(int $value) Set current instance millisecond to the given value. - * @method CarbonImmutable milliseconds(int $value) Set current instance millisecond to the given value. - * @method CarbonImmutable millisecond(int $value) Set current instance millisecond to the given value. - * @method CarbonImmutable setMilliseconds(int $value) Set current instance millisecond to the given value. - * @method CarbonImmutable setMillisecond(int $value) Set current instance millisecond to the given value. - * @method CarbonImmutable micros(int $value) Set current instance microsecond to the given value. - * @method CarbonImmutable micro(int $value) Set current instance microsecond to the given value. - * @method CarbonImmutable setMicros(int $value) Set current instance microsecond to the given value. - * @method CarbonImmutable setMicro(int $value) Set current instance microsecond to the given value. - * @method CarbonImmutable microseconds(int $value) Set current instance microsecond to the given value. - * @method CarbonImmutable microsecond(int $value) Set current instance microsecond to the given value. - * @method CarbonImmutable setMicroseconds(int $value) Set current instance microsecond to the given value. - * @method CarbonImmutable setMicrosecond(int $value) Set current instance microsecond to the given value. - * @method CarbonImmutable addYears(int $value = 1) Add years (the $value count passed in) to the instance (using date interval). - * @method CarbonImmutable addYear() Add one year to the instance (using date interval). - * @method CarbonImmutable subYears(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval). - * @method CarbonImmutable subYear() Sub one year to the instance (using date interval). - * @method CarbonImmutable addYearsWithOverflow(int $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonImmutable addYearWithOverflow() Add one year to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonImmutable subYearsWithOverflow(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonImmutable subYearWithOverflow() Sub one year to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonImmutable addYearsWithoutOverflow(int $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable addYearWithoutOverflow() Add one year to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable subYearsWithoutOverflow(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable subYearWithoutOverflow() Sub one year to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable addYearsWithNoOverflow(int $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable addYearWithNoOverflow() Add one year to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable subYearsWithNoOverflow(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable subYearWithNoOverflow() Sub one year to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable addYearsNoOverflow(int $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable addYearNoOverflow() Add one year to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable subYearsNoOverflow(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable subYearNoOverflow() Sub one year to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable addMonths(int $value = 1) Add months (the $value count passed in) to the instance (using date interval). - * @method CarbonImmutable addMonth() Add one month to the instance (using date interval). - * @method CarbonImmutable subMonths(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval). - * @method CarbonImmutable subMonth() Sub one month to the instance (using date interval). - * @method CarbonImmutable addMonthsWithOverflow(int $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonImmutable addMonthWithOverflow() Add one month to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonImmutable subMonthsWithOverflow(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonImmutable subMonthWithOverflow() Sub one month to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonImmutable addMonthsWithoutOverflow(int $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable addMonthWithoutOverflow() Add one month to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable subMonthsWithoutOverflow(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable subMonthWithoutOverflow() Sub one month to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable addMonthsWithNoOverflow(int $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable addMonthWithNoOverflow() Add one month to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable subMonthsWithNoOverflow(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable subMonthWithNoOverflow() Sub one month to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable addMonthsNoOverflow(int $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable addMonthNoOverflow() Add one month to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable subMonthsNoOverflow(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable subMonthNoOverflow() Sub one month to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable addDays(int $value = 1) Add days (the $value count passed in) to the instance (using date interval). - * @method CarbonImmutable addDay() Add one day to the instance (using date interval). - * @method CarbonImmutable subDays(int $value = 1) Sub days (the $value count passed in) to the instance (using date interval). - * @method CarbonImmutable subDay() Sub one day to the instance (using date interval). - * @method CarbonImmutable addHours(int $value = 1) Add hours (the $value count passed in) to the instance (using date interval). - * @method CarbonImmutable addHour() Add one hour to the instance (using date interval). - * @method CarbonImmutable subHours(int $value = 1) Sub hours (the $value count passed in) to the instance (using date interval). - * @method CarbonImmutable subHour() Sub one hour to the instance (using date interval). - * @method CarbonImmutable addMinutes(int $value = 1) Add minutes (the $value count passed in) to the instance (using date interval). - * @method CarbonImmutable addMinute() Add one minute to the instance (using date interval). - * @method CarbonImmutable subMinutes(int $value = 1) Sub minutes (the $value count passed in) to the instance (using date interval). - * @method CarbonImmutable subMinute() Sub one minute to the instance (using date interval). - * @method CarbonImmutable addSeconds(int $value = 1) Add seconds (the $value count passed in) to the instance (using date interval). - * @method CarbonImmutable addSecond() Add one second to the instance (using date interval). - * @method CarbonImmutable subSeconds(int $value = 1) Sub seconds (the $value count passed in) to the instance (using date interval). - * @method CarbonImmutable subSecond() Sub one second to the instance (using date interval). - * @method CarbonImmutable addMillis(int $value = 1) Add milliseconds (the $value count passed in) to the instance (using date interval). - * @method CarbonImmutable addMilli() Add one millisecond to the instance (using date interval). - * @method CarbonImmutable subMillis(int $value = 1) Sub milliseconds (the $value count passed in) to the instance (using date interval). - * @method CarbonImmutable subMilli() Sub one millisecond to the instance (using date interval). - * @method CarbonImmutable addMilliseconds(int $value = 1) Add milliseconds (the $value count passed in) to the instance (using date interval). - * @method CarbonImmutable addMillisecond() Add one millisecond to the instance (using date interval). - * @method CarbonImmutable subMilliseconds(int $value = 1) Sub milliseconds (the $value count passed in) to the instance (using date interval). - * @method CarbonImmutable subMillisecond() Sub one millisecond to the instance (using date interval). - * @method CarbonImmutable addMicros(int $value = 1) Add microseconds (the $value count passed in) to the instance (using date interval). - * @method CarbonImmutable addMicro() Add one microsecond to the instance (using date interval). - * @method CarbonImmutable subMicros(int $value = 1) Sub microseconds (the $value count passed in) to the instance (using date interval). - * @method CarbonImmutable subMicro() Sub one microsecond to the instance (using date interval). - * @method CarbonImmutable addMicroseconds(int $value = 1) Add microseconds (the $value count passed in) to the instance (using date interval). - * @method CarbonImmutable addMicrosecond() Add one microsecond to the instance (using date interval). - * @method CarbonImmutable subMicroseconds(int $value = 1) Sub microseconds (the $value count passed in) to the instance (using date interval). - * @method CarbonImmutable subMicrosecond() Sub one microsecond to the instance (using date interval). - * @method CarbonImmutable addMillennia(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval). - * @method CarbonImmutable addMillennium() Add one millennium to the instance (using date interval). - * @method CarbonImmutable subMillennia(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval). - * @method CarbonImmutable subMillennium() Sub one millennium to the instance (using date interval). - * @method CarbonImmutable addMillenniaWithOverflow(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonImmutable addMillenniumWithOverflow() Add one millennium to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonImmutable subMillenniaWithOverflow(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonImmutable subMillenniumWithOverflow() Sub one millennium to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonImmutable addMillenniaWithoutOverflow(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable addMillenniumWithoutOverflow() Add one millennium to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable subMillenniaWithoutOverflow(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable subMillenniumWithoutOverflow() Sub one millennium to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable addMillenniaWithNoOverflow(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable addMillenniumWithNoOverflow() Add one millennium to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable subMillenniaWithNoOverflow(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable subMillenniumWithNoOverflow() Sub one millennium to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable addMillenniaNoOverflow(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable addMillenniumNoOverflow() Add one millennium to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable subMillenniaNoOverflow(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable subMillenniumNoOverflow() Sub one millennium to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable addCenturies(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval). - * @method CarbonImmutable addCentury() Add one century to the instance (using date interval). - * @method CarbonImmutable subCenturies(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval). - * @method CarbonImmutable subCentury() Sub one century to the instance (using date interval). - * @method CarbonImmutable addCenturiesWithOverflow(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonImmutable addCenturyWithOverflow() Add one century to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonImmutable subCenturiesWithOverflow(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonImmutable subCenturyWithOverflow() Sub one century to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonImmutable addCenturiesWithoutOverflow(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable addCenturyWithoutOverflow() Add one century to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable subCenturiesWithoutOverflow(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable subCenturyWithoutOverflow() Sub one century to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable addCenturiesWithNoOverflow(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable addCenturyWithNoOverflow() Add one century to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable subCenturiesWithNoOverflow(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable subCenturyWithNoOverflow() Sub one century to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable addCenturiesNoOverflow(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable addCenturyNoOverflow() Add one century to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable subCenturiesNoOverflow(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable subCenturyNoOverflow() Sub one century to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable addDecades(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval). - * @method CarbonImmutable addDecade() Add one decade to the instance (using date interval). - * @method CarbonImmutable subDecades(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval). - * @method CarbonImmutable subDecade() Sub one decade to the instance (using date interval). - * @method CarbonImmutable addDecadesWithOverflow(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonImmutable addDecadeWithOverflow() Add one decade to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonImmutable subDecadesWithOverflow(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonImmutable subDecadeWithOverflow() Sub one decade to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonImmutable addDecadesWithoutOverflow(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable addDecadeWithoutOverflow() Add one decade to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable subDecadesWithoutOverflow(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable subDecadeWithoutOverflow() Sub one decade to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable addDecadesWithNoOverflow(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable addDecadeWithNoOverflow() Add one decade to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable subDecadesWithNoOverflow(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable subDecadeWithNoOverflow() Sub one decade to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable addDecadesNoOverflow(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable addDecadeNoOverflow() Add one decade to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable subDecadesNoOverflow(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable subDecadeNoOverflow() Sub one decade to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable addQuarters(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval). - * @method CarbonImmutable addQuarter() Add one quarter to the instance (using date interval). - * @method CarbonImmutable subQuarters(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval). - * @method CarbonImmutable subQuarter() Sub one quarter to the instance (using date interval). - * @method CarbonImmutable addQuartersWithOverflow(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonImmutable addQuarterWithOverflow() Add one quarter to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonImmutable subQuartersWithOverflow(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonImmutable subQuarterWithOverflow() Sub one quarter to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonImmutable addQuartersWithoutOverflow(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable addQuarterWithoutOverflow() Add one quarter to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable subQuartersWithoutOverflow(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable subQuarterWithoutOverflow() Sub one quarter to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable addQuartersWithNoOverflow(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable addQuarterWithNoOverflow() Add one quarter to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable subQuartersWithNoOverflow(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable subQuarterWithNoOverflow() Sub one quarter to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable addQuartersNoOverflow(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable addQuarterNoOverflow() Add one quarter to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable subQuartersNoOverflow(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable subQuarterNoOverflow() Sub one quarter to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable addWeeks(int $value = 1) Add weeks (the $value count passed in) to the instance (using date interval). - * @method CarbonImmutable addWeek() Add one week to the instance (using date interval). - * @method CarbonImmutable subWeeks(int $value = 1) Sub weeks (the $value count passed in) to the instance (using date interval). - * @method CarbonImmutable subWeek() Sub one week to the instance (using date interval). - * @method CarbonImmutable addWeekdays(int $value = 1) Add weekdays (the $value count passed in) to the instance (using date interval). - * @method CarbonImmutable addWeekday() Add one weekday to the instance (using date interval). - * @method CarbonImmutable subWeekdays(int $value = 1) Sub weekdays (the $value count passed in) to the instance (using date interval). - * @method CarbonImmutable subWeekday() Sub one weekday to the instance (using date interval). - * @method CarbonImmutable addRealMicros(int $value = 1) Add microseconds (the $value count passed in) to the instance (using timestamp). - * @method CarbonImmutable addRealMicro() Add one microsecond to the instance (using timestamp). - * @method CarbonImmutable subRealMicros(int $value = 1) Sub microseconds (the $value count passed in) to the instance (using timestamp). - * @method CarbonImmutable subRealMicro() Sub one microsecond to the instance (using timestamp). - * @method CarbonPeriod microsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each microsecond or every X microseconds if a factor is given. - * @method CarbonImmutable addRealMicroseconds(int $value = 1) Add microseconds (the $value count passed in) to the instance (using timestamp). - * @method CarbonImmutable addRealMicrosecond() Add one microsecond to the instance (using timestamp). - * @method CarbonImmutable subRealMicroseconds(int $value = 1) Sub microseconds (the $value count passed in) to the instance (using timestamp). - * @method CarbonImmutable subRealMicrosecond() Sub one microsecond to the instance (using timestamp). - * @method CarbonPeriod microsecondsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each microsecond or every X microseconds if a factor is given. - * @method CarbonImmutable addRealMillis(int $value = 1) Add milliseconds (the $value count passed in) to the instance (using timestamp). - * @method CarbonImmutable addRealMilli() Add one millisecond to the instance (using timestamp). - * @method CarbonImmutable subRealMillis(int $value = 1) Sub milliseconds (the $value count passed in) to the instance (using timestamp). - * @method CarbonImmutable subRealMilli() Sub one millisecond to the instance (using timestamp). - * @method CarbonPeriod millisUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each millisecond or every X milliseconds if a factor is given. - * @method CarbonImmutable addRealMilliseconds(int $value = 1) Add milliseconds (the $value count passed in) to the instance (using timestamp). - * @method CarbonImmutable addRealMillisecond() Add one millisecond to the instance (using timestamp). - * @method CarbonImmutable subRealMilliseconds(int $value = 1) Sub milliseconds (the $value count passed in) to the instance (using timestamp). - * @method CarbonImmutable subRealMillisecond() Sub one millisecond to the instance (using timestamp). - * @method CarbonPeriod millisecondsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each millisecond or every X milliseconds if a factor is given. - * @method CarbonImmutable addRealSeconds(int $value = 1) Add seconds (the $value count passed in) to the instance (using timestamp). - * @method CarbonImmutable addRealSecond() Add one second to the instance (using timestamp). - * @method CarbonImmutable subRealSeconds(int $value = 1) Sub seconds (the $value count passed in) to the instance (using timestamp). - * @method CarbonImmutable subRealSecond() Sub one second to the instance (using timestamp). - * @method CarbonPeriod secondsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each second or every X seconds if a factor is given. - * @method CarbonImmutable addRealMinutes(int $value = 1) Add minutes (the $value count passed in) to the instance (using timestamp). - * @method CarbonImmutable addRealMinute() Add one minute to the instance (using timestamp). - * @method CarbonImmutable subRealMinutes(int $value = 1) Sub minutes (the $value count passed in) to the instance (using timestamp). - * @method CarbonImmutable subRealMinute() Sub one minute to the instance (using timestamp). - * @method CarbonPeriod minutesUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each minute or every X minutes if a factor is given. - * @method CarbonImmutable addRealHours(int $value = 1) Add hours (the $value count passed in) to the instance (using timestamp). - * @method CarbonImmutable addRealHour() Add one hour to the instance (using timestamp). - * @method CarbonImmutable subRealHours(int $value = 1) Sub hours (the $value count passed in) to the instance (using timestamp). - * @method CarbonImmutable subRealHour() Sub one hour to the instance (using timestamp). - * @method CarbonPeriod hoursUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each hour or every X hours if a factor is given. - * @method CarbonImmutable addRealDays(int $value = 1) Add days (the $value count passed in) to the instance (using timestamp). - * @method CarbonImmutable addRealDay() Add one day to the instance (using timestamp). - * @method CarbonImmutable subRealDays(int $value = 1) Sub days (the $value count passed in) to the instance (using timestamp). - * @method CarbonImmutable subRealDay() Sub one day to the instance (using timestamp). - * @method CarbonPeriod daysUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each day or every X days if a factor is given. - * @method CarbonImmutable addRealWeeks(int $value = 1) Add weeks (the $value count passed in) to the instance (using timestamp). - * @method CarbonImmutable addRealWeek() Add one week to the instance (using timestamp). - * @method CarbonImmutable subRealWeeks(int $value = 1) Sub weeks (the $value count passed in) to the instance (using timestamp). - * @method CarbonImmutable subRealWeek() Sub one week to the instance (using timestamp). - * @method CarbonPeriod weeksUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each week or every X weeks if a factor is given. - * @method CarbonImmutable addRealMonths(int $value = 1) Add months (the $value count passed in) to the instance (using timestamp). - * @method CarbonImmutable addRealMonth() Add one month to the instance (using timestamp). - * @method CarbonImmutable subRealMonths(int $value = 1) Sub months (the $value count passed in) to the instance (using timestamp). - * @method CarbonImmutable subRealMonth() Sub one month to the instance (using timestamp). - * @method CarbonPeriod monthsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each month or every X months if a factor is given. - * @method CarbonImmutable addRealQuarters(int $value = 1) Add quarters (the $value count passed in) to the instance (using timestamp). - * @method CarbonImmutable addRealQuarter() Add one quarter to the instance (using timestamp). - * @method CarbonImmutable subRealQuarters(int $value = 1) Sub quarters (the $value count passed in) to the instance (using timestamp). - * @method CarbonImmutable subRealQuarter() Sub one quarter to the instance (using timestamp). - * @method CarbonPeriod quartersUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each quarter or every X quarters if a factor is given. - * @method CarbonImmutable addRealYears(int $value = 1) Add years (the $value count passed in) to the instance (using timestamp). - * @method CarbonImmutable addRealYear() Add one year to the instance (using timestamp). - * @method CarbonImmutable subRealYears(int $value = 1) Sub years (the $value count passed in) to the instance (using timestamp). - * @method CarbonImmutable subRealYear() Sub one year to the instance (using timestamp). - * @method CarbonPeriod yearsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each year or every X years if a factor is given. - * @method CarbonImmutable addRealDecades(int $value = 1) Add decades (the $value count passed in) to the instance (using timestamp). - * @method CarbonImmutable addRealDecade() Add one decade to the instance (using timestamp). - * @method CarbonImmutable subRealDecades(int $value = 1) Sub decades (the $value count passed in) to the instance (using timestamp). - * @method CarbonImmutable subRealDecade() Sub one decade to the instance (using timestamp). - * @method CarbonPeriod decadesUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each decade or every X decades if a factor is given. - * @method CarbonImmutable addRealCenturies(int $value = 1) Add centuries (the $value count passed in) to the instance (using timestamp). - * @method CarbonImmutable addRealCentury() Add one century to the instance (using timestamp). - * @method CarbonImmutable subRealCenturies(int $value = 1) Sub centuries (the $value count passed in) to the instance (using timestamp). - * @method CarbonImmutable subRealCentury() Sub one century to the instance (using timestamp). - * @method CarbonPeriod centuriesUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each century or every X centuries if a factor is given. - * @method CarbonImmutable addRealMillennia(int $value = 1) Add millennia (the $value count passed in) to the instance (using timestamp). - * @method CarbonImmutable addRealMillennium() Add one millennium to the instance (using timestamp). - * @method CarbonImmutable subRealMillennia(int $value = 1) Sub millennia (the $value count passed in) to the instance (using timestamp). - * @method CarbonImmutable subRealMillennium() Sub one millennium to the instance (using timestamp). - * @method CarbonPeriod millenniaUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each millennium or every X millennia if a factor is given. - * @method CarbonImmutable roundYear(float $precision = 1, string $function = "round") Round the current instance year with given precision using the given function. - * @method CarbonImmutable roundYears(float $precision = 1, string $function = "round") Round the current instance year with given precision using the given function. - * @method CarbonImmutable floorYear(float $precision = 1) Truncate the current instance year with given precision. - * @method CarbonImmutable floorYears(float $precision = 1) Truncate the current instance year with given precision. - * @method CarbonImmutable ceilYear(float $precision = 1) Ceil the current instance year with given precision. - * @method CarbonImmutable ceilYears(float $precision = 1) Ceil the current instance year with given precision. - * @method CarbonImmutable roundMonth(float $precision = 1, string $function = "round") Round the current instance month with given precision using the given function. - * @method CarbonImmutable roundMonths(float $precision = 1, string $function = "round") Round the current instance month with given precision using the given function. - * @method CarbonImmutable floorMonth(float $precision = 1) Truncate the current instance month with given precision. - * @method CarbonImmutable floorMonths(float $precision = 1) Truncate the current instance month with given precision. - * @method CarbonImmutable ceilMonth(float $precision = 1) Ceil the current instance month with given precision. - * @method CarbonImmutable ceilMonths(float $precision = 1) Ceil the current instance month with given precision. - * @method CarbonImmutable roundDay(float $precision = 1, string $function = "round") Round the current instance day with given precision using the given function. - * @method CarbonImmutable roundDays(float $precision = 1, string $function = "round") Round the current instance day with given precision using the given function. - * @method CarbonImmutable floorDay(float $precision = 1) Truncate the current instance day with given precision. - * @method CarbonImmutable floorDays(float $precision = 1) Truncate the current instance day with given precision. - * @method CarbonImmutable ceilDay(float $precision = 1) Ceil the current instance day with given precision. - * @method CarbonImmutable ceilDays(float $precision = 1) Ceil the current instance day with given precision. - * @method CarbonImmutable roundHour(float $precision = 1, string $function = "round") Round the current instance hour with given precision using the given function. - * @method CarbonImmutable roundHours(float $precision = 1, string $function = "round") Round the current instance hour with given precision using the given function. - * @method CarbonImmutable floorHour(float $precision = 1) Truncate the current instance hour with given precision. - * @method CarbonImmutable floorHours(float $precision = 1) Truncate the current instance hour with given precision. - * @method CarbonImmutable ceilHour(float $precision = 1) Ceil the current instance hour with given precision. - * @method CarbonImmutable ceilHours(float $precision = 1) Ceil the current instance hour with given precision. - * @method CarbonImmutable roundMinute(float $precision = 1, string $function = "round") Round the current instance minute with given precision using the given function. - * @method CarbonImmutable roundMinutes(float $precision = 1, string $function = "round") Round the current instance minute with given precision using the given function. - * @method CarbonImmutable floorMinute(float $precision = 1) Truncate the current instance minute with given precision. - * @method CarbonImmutable floorMinutes(float $precision = 1) Truncate the current instance minute with given precision. - * @method CarbonImmutable ceilMinute(float $precision = 1) Ceil the current instance minute with given precision. - * @method CarbonImmutable ceilMinutes(float $precision = 1) Ceil the current instance minute with given precision. - * @method CarbonImmutable roundSecond(float $precision = 1, string $function = "round") Round the current instance second with given precision using the given function. - * @method CarbonImmutable roundSeconds(float $precision = 1, string $function = "round") Round the current instance second with given precision using the given function. - * @method CarbonImmutable floorSecond(float $precision = 1) Truncate the current instance second with given precision. - * @method CarbonImmutable floorSeconds(float $precision = 1) Truncate the current instance second with given precision. - * @method CarbonImmutable ceilSecond(float $precision = 1) Ceil the current instance second with given precision. - * @method CarbonImmutable ceilSeconds(float $precision = 1) Ceil the current instance second with given precision. - * @method CarbonImmutable roundMillennium(float $precision = 1, string $function = "round") Round the current instance millennium with given precision using the given function. - * @method CarbonImmutable roundMillennia(float $precision = 1, string $function = "round") Round the current instance millennium with given precision using the given function. - * @method CarbonImmutable floorMillennium(float $precision = 1) Truncate the current instance millennium with given precision. - * @method CarbonImmutable floorMillennia(float $precision = 1) Truncate the current instance millennium with given precision. - * @method CarbonImmutable ceilMillennium(float $precision = 1) Ceil the current instance millennium with given precision. - * @method CarbonImmutable ceilMillennia(float $precision = 1) Ceil the current instance millennium with given precision. - * @method CarbonImmutable roundCentury(float $precision = 1, string $function = "round") Round the current instance century with given precision using the given function. - * @method CarbonImmutable roundCenturies(float $precision = 1, string $function = "round") Round the current instance century with given precision using the given function. - * @method CarbonImmutable floorCentury(float $precision = 1) Truncate the current instance century with given precision. - * @method CarbonImmutable floorCenturies(float $precision = 1) Truncate the current instance century with given precision. - * @method CarbonImmutable ceilCentury(float $precision = 1) Ceil the current instance century with given precision. - * @method CarbonImmutable ceilCenturies(float $precision = 1) Ceil the current instance century with given precision. - * @method CarbonImmutable roundDecade(float $precision = 1, string $function = "round") Round the current instance decade with given precision using the given function. - * @method CarbonImmutable roundDecades(float $precision = 1, string $function = "round") Round the current instance decade with given precision using the given function. - * @method CarbonImmutable floorDecade(float $precision = 1) Truncate the current instance decade with given precision. - * @method CarbonImmutable floorDecades(float $precision = 1) Truncate the current instance decade with given precision. - * @method CarbonImmutable ceilDecade(float $precision = 1) Ceil the current instance decade with given precision. - * @method CarbonImmutable ceilDecades(float $precision = 1) Ceil the current instance decade with given precision. - * @method CarbonImmutable roundQuarter(float $precision = 1, string $function = "round") Round the current instance quarter with given precision using the given function. - * @method CarbonImmutable roundQuarters(float $precision = 1, string $function = "round") Round the current instance quarter with given precision using the given function. - * @method CarbonImmutable floorQuarter(float $precision = 1) Truncate the current instance quarter with given precision. - * @method CarbonImmutable floorQuarters(float $precision = 1) Truncate the current instance quarter with given precision. - * @method CarbonImmutable ceilQuarter(float $precision = 1) Ceil the current instance quarter with given precision. - * @method CarbonImmutable ceilQuarters(float $precision = 1) Ceil the current instance quarter with given precision. - * @method CarbonImmutable roundMillisecond(float $precision = 1, string $function = "round") Round the current instance millisecond with given precision using the given function. - * @method CarbonImmutable roundMilliseconds(float $precision = 1, string $function = "round") Round the current instance millisecond with given precision using the given function. - * @method CarbonImmutable floorMillisecond(float $precision = 1) Truncate the current instance millisecond with given precision. - * @method CarbonImmutable floorMilliseconds(float $precision = 1) Truncate the current instance millisecond with given precision. - * @method CarbonImmutable ceilMillisecond(float $precision = 1) Ceil the current instance millisecond with given precision. - * @method CarbonImmutable ceilMilliseconds(float $precision = 1) Ceil the current instance millisecond with given precision. - * @method CarbonImmutable roundMicrosecond(float $precision = 1, string $function = "round") Round the current instance microsecond with given precision using the given function. - * @method CarbonImmutable roundMicroseconds(float $precision = 1, string $function = "round") Round the current instance microsecond with given precision using the given function. - * @method CarbonImmutable floorMicrosecond(float $precision = 1) Truncate the current instance microsecond with given precision. - * @method CarbonImmutable floorMicroseconds(float $precision = 1) Truncate the current instance microsecond with given precision. - * @method CarbonImmutable ceilMicrosecond(float $precision = 1) Ceil the current instance microsecond with given precision. - * @method CarbonImmutable ceilMicroseconds(float $precision = 1) Ceil the current instance microsecond with given precision. - * @method string shortAbsoluteDiffForHumans(DateTimeInterface $other = null, int $parts = 1) Get the difference (short format, 'Absolute' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.) - * @method string longAbsoluteDiffForHumans(DateTimeInterface $other = null, int $parts = 1) Get the difference (long format, 'Absolute' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.) - * @method string shortRelativeDiffForHumans(DateTimeInterface $other = null, int $parts = 1) Get the difference (short format, 'Relative' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.) - * @method string longRelativeDiffForHumans(DateTimeInterface $other = null, int $parts = 1) Get the difference (long format, 'Relative' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.) - * @method string shortRelativeToNowDiffForHumans(DateTimeInterface $other = null, int $parts = 1) Get the difference (short format, 'RelativeToNow' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.) - * @method string longRelativeToNowDiffForHumans(DateTimeInterface $other = null, int $parts = 1) Get the difference (long format, 'RelativeToNow' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.) - * @method string shortRelativeToOtherDiffForHumans(DateTimeInterface $other = null, int $parts = 1) Get the difference (short format, 'RelativeToOther' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.) - * @method string longRelativeToOtherDiffForHumans(DateTimeInterface $other = null, int $parts = 1) Get the difference (long format, 'RelativeToOther' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.) - * @method static CarbonImmutable|false createFromFormat(string $format, string $time, string|DateTimeZone $timezone = null) Parse a string into a new CarbonImmutable object according to the specified format. - * @method static CarbonImmutable __set_state(array $array) https://php.net/manual/en/datetime.set-state.php + * @method bool isUtc() Check if the current instance has UTC timezone. (Both isUtc and isUTC cases are valid.) + * @method bool isLocal() Check if the current instance has non-UTC timezone. + * @method bool isValid() Check if the current instance is a valid date. + * @method bool isDST() Check if the current instance is in a daylight saving time. + * @method bool isSunday() Checks if the instance day is sunday. + * @method bool isMonday() Checks if the instance day is monday. + * @method bool isTuesday() Checks if the instance day is tuesday. + * @method bool isWednesday() Checks if the instance day is wednesday. + * @method bool isThursday() Checks if the instance day is thursday. + * @method bool isFriday() Checks if the instance day is friday. + * @method bool isSaturday() Checks if the instance day is saturday. + * @method bool isSameYear(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same year as the instance. If null passed, compare to now (with the same timezone). + * @method bool isCurrentYear() Checks if the instance is in the same year as the current moment. + * @method bool isNextYear() Checks if the instance is in the same year as the current moment next year. + * @method bool isLastYear() Checks if the instance is in the same year as the current moment last year. + * @method bool isSameWeek(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same week as the instance. If null passed, compare to now (with the same timezone). + * @method bool isCurrentWeek() Checks if the instance is in the same week as the current moment. + * @method bool isNextWeek() Checks if the instance is in the same week as the current moment next week. + * @method bool isLastWeek() Checks if the instance is in the same week as the current moment last week. + * @method bool isSameDay(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same day as the instance. If null passed, compare to now (with the same timezone). + * @method bool isCurrentDay() Checks if the instance is in the same day as the current moment. + * @method bool isNextDay() Checks if the instance is in the same day as the current moment next day. + * @method bool isLastDay() Checks if the instance is in the same day as the current moment last day. + * @method bool isSameHour(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same hour as the instance. If null passed, compare to now (with the same timezone). + * @method bool isCurrentHour() Checks if the instance is in the same hour as the current moment. + * @method bool isNextHour() Checks if the instance is in the same hour as the current moment next hour. + * @method bool isLastHour() Checks if the instance is in the same hour as the current moment last hour. + * @method bool isSameMinute(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same minute as the instance. If null passed, compare to now (with the same timezone). + * @method bool isCurrentMinute() Checks if the instance is in the same minute as the current moment. + * @method bool isNextMinute() Checks if the instance is in the same minute as the current moment next minute. + * @method bool isLastMinute() Checks if the instance is in the same minute as the current moment last minute. + * @method bool isSameSecond(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same second as the instance. If null passed, compare to now (with the same timezone). + * @method bool isCurrentSecond() Checks if the instance is in the same second as the current moment. + * @method bool isNextSecond() Checks if the instance is in the same second as the current moment next second. + * @method bool isLastSecond() Checks if the instance is in the same second as the current moment last second. + * @method bool isSameMicro(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same microsecond as the instance. If null passed, compare to now (with the same timezone). + * @method bool isCurrentMicro() Checks if the instance is in the same microsecond as the current moment. + * @method bool isNextMicro() Checks if the instance is in the same microsecond as the current moment next microsecond. + * @method bool isLastMicro() Checks if the instance is in the same microsecond as the current moment last microsecond. + * @method bool isSameMicrosecond(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same microsecond as the instance. If null passed, compare to now (with the same timezone). + * @method bool isCurrentMicrosecond() Checks if the instance is in the same microsecond as the current moment. + * @method bool isNextMicrosecond() Checks if the instance is in the same microsecond as the current moment next microsecond. + * @method bool isLastMicrosecond() Checks if the instance is in the same microsecond as the current moment last microsecond. + * @method bool isCurrentMonth() Checks if the instance is in the same month as the current moment. + * @method bool isNextMonth() Checks if the instance is in the same month as the current moment next month. + * @method bool isLastMonth() Checks if the instance is in the same month as the current moment last month. + * @method bool isCurrentQuarter() Checks if the instance is in the same quarter as the current moment. + * @method bool isNextQuarter() Checks if the instance is in the same quarter as the current moment next quarter. + * @method bool isLastQuarter() Checks if the instance is in the same quarter as the current moment last quarter. + * @method bool isSameDecade(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same decade as the instance. If null passed, compare to now (with the same timezone). + * @method bool isCurrentDecade() Checks if the instance is in the same decade as the current moment. + * @method bool isNextDecade() Checks if the instance is in the same decade as the current moment next decade. + * @method bool isLastDecade() Checks if the instance is in the same decade as the current moment last decade. + * @method bool isSameCentury(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same century as the instance. If null passed, compare to now (with the same timezone). + * @method bool isCurrentCentury() Checks if the instance is in the same century as the current moment. + * @method bool isNextCentury() Checks if the instance is in the same century as the current moment next century. + * @method bool isLastCentury() Checks if the instance is in the same century as the current moment last century. + * @method bool isSameMillennium(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same millennium as the instance. If null passed, compare to now (with the same timezone). + * @method bool isCurrentMillennium() Checks if the instance is in the same millennium as the current moment. + * @method bool isNextMillennium() Checks if the instance is in the same millennium as the current moment next millennium. + * @method bool isLastMillennium() Checks if the instance is in the same millennium as the current moment last millennium. + * @method CarbonImmutable years(int $value) Set current instance year to the given value. + * @method CarbonImmutable year(int $value) Set current instance year to the given value. + * @method CarbonImmutable setYears(int $value) Set current instance year to the given value. + * @method CarbonImmutable setYear(int $value) Set current instance year to the given value. + * @method CarbonImmutable months(int $value) Set current instance month to the given value. + * @method CarbonImmutable month(int $value) Set current instance month to the given value. + * @method CarbonImmutable setMonths(int $value) Set current instance month to the given value. + * @method CarbonImmutable setMonth(int $value) Set current instance month to the given value. + * @method CarbonImmutable days(int $value) Set current instance day to the given value. + * @method CarbonImmutable day(int $value) Set current instance day to the given value. + * @method CarbonImmutable setDays(int $value) Set current instance day to the given value. + * @method CarbonImmutable setDay(int $value) Set current instance day to the given value. + * @method CarbonImmutable hours(int $value) Set current instance hour to the given value. + * @method CarbonImmutable hour(int $value) Set current instance hour to the given value. + * @method CarbonImmutable setHours(int $value) Set current instance hour to the given value. + * @method CarbonImmutable setHour(int $value) Set current instance hour to the given value. + * @method CarbonImmutable minutes(int $value) Set current instance minute to the given value. + * @method CarbonImmutable minute(int $value) Set current instance minute to the given value. + * @method CarbonImmutable setMinutes(int $value) Set current instance minute to the given value. + * @method CarbonImmutable setMinute(int $value) Set current instance minute to the given value. + * @method CarbonImmutable seconds(int $value) Set current instance second to the given value. + * @method CarbonImmutable second(int $value) Set current instance second to the given value. + * @method CarbonImmutable setSeconds(int $value) Set current instance second to the given value. + * @method CarbonImmutable setSecond(int $value) Set current instance second to the given value. + * @method CarbonImmutable millis(int $value) Set current instance millisecond to the given value. + * @method CarbonImmutable milli(int $value) Set current instance millisecond to the given value. + * @method CarbonImmutable setMillis(int $value) Set current instance millisecond to the given value. + * @method CarbonImmutable setMilli(int $value) Set current instance millisecond to the given value. + * @method CarbonImmutable milliseconds(int $value) Set current instance millisecond to the given value. + * @method CarbonImmutable millisecond(int $value) Set current instance millisecond to the given value. + * @method CarbonImmutable setMilliseconds(int $value) Set current instance millisecond to the given value. + * @method CarbonImmutable setMillisecond(int $value) Set current instance millisecond to the given value. + * @method CarbonImmutable micros(int $value) Set current instance microsecond to the given value. + * @method CarbonImmutable micro(int $value) Set current instance microsecond to the given value. + * @method CarbonImmutable setMicros(int $value) Set current instance microsecond to the given value. + * @method CarbonImmutable setMicro(int $value) Set current instance microsecond to the given value. + * @method CarbonImmutable microseconds(int $value) Set current instance microsecond to the given value. + * @method CarbonImmutable microsecond(int $value) Set current instance microsecond to the given value. + * @method CarbonImmutable setMicroseconds(int $value) Set current instance microsecond to the given value. + * @method CarbonImmutable setMicrosecond(int $value) Set current instance microsecond to the given value. + * @method CarbonImmutable addYears(int $value = 1) Add years (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable addYear() Add one year to the instance (using date interval). + * @method CarbonImmutable subYears(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable subYear() Sub one year to the instance (using date interval). + * @method CarbonImmutable addYearsWithOverflow(int $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonImmutable addYearWithOverflow() Add one year to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonImmutable subYearsWithOverflow(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonImmutable subYearWithOverflow() Sub one year to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonImmutable addYearsWithoutOverflow(int $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable addYearWithoutOverflow() Add one year to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable subYearsWithoutOverflow(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable subYearWithoutOverflow() Sub one year to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable addYearsWithNoOverflow(int $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable addYearWithNoOverflow() Add one year to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable subYearsWithNoOverflow(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable subYearWithNoOverflow() Sub one year to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable addYearsNoOverflow(int $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable addYearNoOverflow() Add one year to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable subYearsNoOverflow(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable subYearNoOverflow() Sub one year to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable addMonths(int $value = 1) Add months (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable addMonth() Add one month to the instance (using date interval). + * @method CarbonImmutable subMonths(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable subMonth() Sub one month to the instance (using date interval). + * @method CarbonImmutable addMonthsWithOverflow(int $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonImmutable addMonthWithOverflow() Add one month to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonImmutable subMonthsWithOverflow(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonImmutable subMonthWithOverflow() Sub one month to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonImmutable addMonthsWithoutOverflow(int $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable addMonthWithoutOverflow() Add one month to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable subMonthsWithoutOverflow(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable subMonthWithoutOverflow() Sub one month to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable addMonthsWithNoOverflow(int $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable addMonthWithNoOverflow() Add one month to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable subMonthsWithNoOverflow(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable subMonthWithNoOverflow() Sub one month to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable addMonthsNoOverflow(int $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable addMonthNoOverflow() Add one month to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable subMonthsNoOverflow(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable subMonthNoOverflow() Sub one month to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable addDays(int $value = 1) Add days (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable addDay() Add one day to the instance (using date interval). + * @method CarbonImmutable subDays(int $value = 1) Sub days (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable subDay() Sub one day to the instance (using date interval). + * @method CarbonImmutable addHours(int $value = 1) Add hours (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable addHour() Add one hour to the instance (using date interval). + * @method CarbonImmutable subHours(int $value = 1) Sub hours (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable subHour() Sub one hour to the instance (using date interval). + * @method CarbonImmutable addMinutes(int $value = 1) Add minutes (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable addMinute() Add one minute to the instance (using date interval). + * @method CarbonImmutable subMinutes(int $value = 1) Sub minutes (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable subMinute() Sub one minute to the instance (using date interval). + * @method CarbonImmutable addSeconds(int $value = 1) Add seconds (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable addSecond() Add one second to the instance (using date interval). + * @method CarbonImmutable subSeconds(int $value = 1) Sub seconds (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable subSecond() Sub one second to the instance (using date interval). + * @method CarbonImmutable addMillis(int $value = 1) Add milliseconds (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable addMilli() Add one millisecond to the instance (using date interval). + * @method CarbonImmutable subMillis(int $value = 1) Sub milliseconds (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable subMilli() Sub one millisecond to the instance (using date interval). + * @method CarbonImmutable addMilliseconds(int $value = 1) Add milliseconds (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable addMillisecond() Add one millisecond to the instance (using date interval). + * @method CarbonImmutable subMilliseconds(int $value = 1) Sub milliseconds (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable subMillisecond() Sub one millisecond to the instance (using date interval). + * @method CarbonImmutable addMicros(int $value = 1) Add microseconds (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable addMicro() Add one microsecond to the instance (using date interval). + * @method CarbonImmutable subMicros(int $value = 1) Sub microseconds (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable subMicro() Sub one microsecond to the instance (using date interval). + * @method CarbonImmutable addMicroseconds(int $value = 1) Add microseconds (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable addMicrosecond() Add one microsecond to the instance (using date interval). + * @method CarbonImmutable subMicroseconds(int $value = 1) Sub microseconds (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable subMicrosecond() Sub one microsecond to the instance (using date interval). + * @method CarbonImmutable addMillennia(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable addMillennium() Add one millennium to the instance (using date interval). + * @method CarbonImmutable subMillennia(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable subMillennium() Sub one millennium to the instance (using date interval). + * @method CarbonImmutable addMillenniaWithOverflow(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonImmutable addMillenniumWithOverflow() Add one millennium to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonImmutable subMillenniaWithOverflow(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonImmutable subMillenniumWithOverflow() Sub one millennium to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonImmutable addMillenniaWithoutOverflow(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable addMillenniumWithoutOverflow() Add one millennium to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable subMillenniaWithoutOverflow(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable subMillenniumWithoutOverflow() Sub one millennium to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable addMillenniaWithNoOverflow(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable addMillenniumWithNoOverflow() Add one millennium to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable subMillenniaWithNoOverflow(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable subMillenniumWithNoOverflow() Sub one millennium to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable addMillenniaNoOverflow(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable addMillenniumNoOverflow() Add one millennium to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable subMillenniaNoOverflow(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable subMillenniumNoOverflow() Sub one millennium to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable addCenturies(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable addCentury() Add one century to the instance (using date interval). + * @method CarbonImmutable subCenturies(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable subCentury() Sub one century to the instance (using date interval). + * @method CarbonImmutable addCenturiesWithOverflow(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonImmutable addCenturyWithOverflow() Add one century to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonImmutable subCenturiesWithOverflow(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonImmutable subCenturyWithOverflow() Sub one century to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonImmutable addCenturiesWithoutOverflow(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable addCenturyWithoutOverflow() Add one century to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable subCenturiesWithoutOverflow(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable subCenturyWithoutOverflow() Sub one century to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable addCenturiesWithNoOverflow(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable addCenturyWithNoOverflow() Add one century to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable subCenturiesWithNoOverflow(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable subCenturyWithNoOverflow() Sub one century to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable addCenturiesNoOverflow(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable addCenturyNoOverflow() Add one century to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable subCenturiesNoOverflow(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable subCenturyNoOverflow() Sub one century to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable addDecades(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable addDecade() Add one decade to the instance (using date interval). + * @method CarbonImmutable subDecades(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable subDecade() Sub one decade to the instance (using date interval). + * @method CarbonImmutable addDecadesWithOverflow(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonImmutable addDecadeWithOverflow() Add one decade to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonImmutable subDecadesWithOverflow(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonImmutable subDecadeWithOverflow() Sub one decade to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonImmutable addDecadesWithoutOverflow(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable addDecadeWithoutOverflow() Add one decade to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable subDecadesWithoutOverflow(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable subDecadeWithoutOverflow() Sub one decade to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable addDecadesWithNoOverflow(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable addDecadeWithNoOverflow() Add one decade to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable subDecadesWithNoOverflow(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable subDecadeWithNoOverflow() Sub one decade to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable addDecadesNoOverflow(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable addDecadeNoOverflow() Add one decade to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable subDecadesNoOverflow(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable subDecadeNoOverflow() Sub one decade to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable addQuarters(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable addQuarter() Add one quarter to the instance (using date interval). + * @method CarbonImmutable subQuarters(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable subQuarter() Sub one quarter to the instance (using date interval). + * @method CarbonImmutable addQuartersWithOverflow(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonImmutable addQuarterWithOverflow() Add one quarter to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonImmutable subQuartersWithOverflow(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonImmutable subQuarterWithOverflow() Sub one quarter to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonImmutable addQuartersWithoutOverflow(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable addQuarterWithoutOverflow() Add one quarter to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable subQuartersWithoutOverflow(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable subQuarterWithoutOverflow() Sub one quarter to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable addQuartersWithNoOverflow(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable addQuarterWithNoOverflow() Add one quarter to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable subQuartersWithNoOverflow(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable subQuarterWithNoOverflow() Sub one quarter to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable addQuartersNoOverflow(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable addQuarterNoOverflow() Add one quarter to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable subQuartersNoOverflow(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable subQuarterNoOverflow() Sub one quarter to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable addWeeks(int $value = 1) Add weeks (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable addWeek() Add one week to the instance (using date interval). + * @method CarbonImmutable subWeeks(int $value = 1) Sub weeks (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable subWeek() Sub one week to the instance (using date interval). + * @method CarbonImmutable addWeekdays(int $value = 1) Add weekdays (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable addWeekday() Add one weekday to the instance (using date interval). + * @method CarbonImmutable subWeekdays(int $value = 1) Sub weekdays (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable subWeekday() Sub one weekday to the instance (using date interval). + * @method CarbonImmutable addRealMicros(int $value = 1) Add microseconds (the $value count passed in) to the instance (using timestamp). + * @method CarbonImmutable addRealMicro() Add one microsecond to the instance (using timestamp). + * @method CarbonImmutable subRealMicros(int $value = 1) Sub microseconds (the $value count passed in) to the instance (using timestamp). + * @method CarbonImmutable subRealMicro() Sub one microsecond to the instance (using timestamp). + * @method CarbonPeriod microsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each microsecond or every X microseconds if a factor is given. + * @method CarbonImmutable addRealMicroseconds(int $value = 1) Add microseconds (the $value count passed in) to the instance (using timestamp). + * @method CarbonImmutable addRealMicrosecond() Add one microsecond to the instance (using timestamp). + * @method CarbonImmutable subRealMicroseconds(int $value = 1) Sub microseconds (the $value count passed in) to the instance (using timestamp). + * @method CarbonImmutable subRealMicrosecond() Sub one microsecond to the instance (using timestamp). + * @method CarbonPeriod microsecondsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each microsecond or every X microseconds if a factor is given. + * @method CarbonImmutable addRealMillis(int $value = 1) Add milliseconds (the $value count passed in) to the instance (using timestamp). + * @method CarbonImmutable addRealMilli() Add one millisecond to the instance (using timestamp). + * @method CarbonImmutable subRealMillis(int $value = 1) Sub milliseconds (the $value count passed in) to the instance (using timestamp). + * @method CarbonImmutable subRealMilli() Sub one millisecond to the instance (using timestamp). + * @method CarbonPeriod millisUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each millisecond or every X milliseconds if a factor is given. + * @method CarbonImmutable addRealMilliseconds(int $value = 1) Add milliseconds (the $value count passed in) to the instance (using timestamp). + * @method CarbonImmutable addRealMillisecond() Add one millisecond to the instance (using timestamp). + * @method CarbonImmutable subRealMilliseconds(int $value = 1) Sub milliseconds (the $value count passed in) to the instance (using timestamp). + * @method CarbonImmutable subRealMillisecond() Sub one millisecond to the instance (using timestamp). + * @method CarbonPeriod millisecondsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each millisecond or every X milliseconds if a factor is given. + * @method CarbonImmutable addRealSeconds(int $value = 1) Add seconds (the $value count passed in) to the instance (using timestamp). + * @method CarbonImmutable addRealSecond() Add one second to the instance (using timestamp). + * @method CarbonImmutable subRealSeconds(int $value = 1) Sub seconds (the $value count passed in) to the instance (using timestamp). + * @method CarbonImmutable subRealSecond() Sub one second to the instance (using timestamp). + * @method CarbonPeriod secondsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each second or every X seconds if a factor is given. + * @method CarbonImmutable addRealMinutes(int $value = 1) Add minutes (the $value count passed in) to the instance (using timestamp). + * @method CarbonImmutable addRealMinute() Add one minute to the instance (using timestamp). + * @method CarbonImmutable subRealMinutes(int $value = 1) Sub minutes (the $value count passed in) to the instance (using timestamp). + * @method CarbonImmutable subRealMinute() Sub one minute to the instance (using timestamp). + * @method CarbonPeriod minutesUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each minute or every X minutes if a factor is given. + * @method CarbonImmutable addRealHours(int $value = 1) Add hours (the $value count passed in) to the instance (using timestamp). + * @method CarbonImmutable addRealHour() Add one hour to the instance (using timestamp). + * @method CarbonImmutable subRealHours(int $value = 1) Sub hours (the $value count passed in) to the instance (using timestamp). + * @method CarbonImmutable subRealHour() Sub one hour to the instance (using timestamp). + * @method CarbonPeriod hoursUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each hour or every X hours if a factor is given. + * @method CarbonImmutable addRealDays(int $value = 1) Add days (the $value count passed in) to the instance (using timestamp). + * @method CarbonImmutable addRealDay() Add one day to the instance (using timestamp). + * @method CarbonImmutable subRealDays(int $value = 1) Sub days (the $value count passed in) to the instance (using timestamp). + * @method CarbonImmutable subRealDay() Sub one day to the instance (using timestamp). + * @method CarbonPeriod daysUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each day or every X days if a factor is given. + * @method CarbonImmutable addRealWeeks(int $value = 1) Add weeks (the $value count passed in) to the instance (using timestamp). + * @method CarbonImmutable addRealWeek() Add one week to the instance (using timestamp). + * @method CarbonImmutable subRealWeeks(int $value = 1) Sub weeks (the $value count passed in) to the instance (using timestamp). + * @method CarbonImmutable subRealWeek() Sub one week to the instance (using timestamp). + * @method CarbonPeriod weeksUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each week or every X weeks if a factor is given. + * @method CarbonImmutable addRealMonths(int $value = 1) Add months (the $value count passed in) to the instance (using timestamp). + * @method CarbonImmutable addRealMonth() Add one month to the instance (using timestamp). + * @method CarbonImmutable subRealMonths(int $value = 1) Sub months (the $value count passed in) to the instance (using timestamp). + * @method CarbonImmutable subRealMonth() Sub one month to the instance (using timestamp). + * @method CarbonPeriod monthsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each month or every X months if a factor is given. + * @method CarbonImmutable addRealQuarters(int $value = 1) Add quarters (the $value count passed in) to the instance (using timestamp). + * @method CarbonImmutable addRealQuarter() Add one quarter to the instance (using timestamp). + * @method CarbonImmutable subRealQuarters(int $value = 1) Sub quarters (the $value count passed in) to the instance (using timestamp). + * @method CarbonImmutable subRealQuarter() Sub one quarter to the instance (using timestamp). + * @method CarbonPeriod quartersUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each quarter or every X quarters if a factor is given. + * @method CarbonImmutable addRealYears(int $value = 1) Add years (the $value count passed in) to the instance (using timestamp). + * @method CarbonImmutable addRealYear() Add one year to the instance (using timestamp). + * @method CarbonImmutable subRealYears(int $value = 1) Sub years (the $value count passed in) to the instance (using timestamp). + * @method CarbonImmutable subRealYear() Sub one year to the instance (using timestamp). + * @method CarbonPeriod yearsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each year or every X years if a factor is given. + * @method CarbonImmutable addRealDecades(int $value = 1) Add decades (the $value count passed in) to the instance (using timestamp). + * @method CarbonImmutable addRealDecade() Add one decade to the instance (using timestamp). + * @method CarbonImmutable subRealDecades(int $value = 1) Sub decades (the $value count passed in) to the instance (using timestamp). + * @method CarbonImmutable subRealDecade() Sub one decade to the instance (using timestamp). + * @method CarbonPeriod decadesUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each decade or every X decades if a factor is given. + * @method CarbonImmutable addRealCenturies(int $value = 1) Add centuries (the $value count passed in) to the instance (using timestamp). + * @method CarbonImmutable addRealCentury() Add one century to the instance (using timestamp). + * @method CarbonImmutable subRealCenturies(int $value = 1) Sub centuries (the $value count passed in) to the instance (using timestamp). + * @method CarbonImmutable subRealCentury() Sub one century to the instance (using timestamp). + * @method CarbonPeriod centuriesUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each century or every X centuries if a factor is given. + * @method CarbonImmutable addRealMillennia(int $value = 1) Add millennia (the $value count passed in) to the instance (using timestamp). + * @method CarbonImmutable addRealMillennium() Add one millennium to the instance (using timestamp). + * @method CarbonImmutable subRealMillennia(int $value = 1) Sub millennia (the $value count passed in) to the instance (using timestamp). + * @method CarbonImmutable subRealMillennium() Sub one millennium to the instance (using timestamp). + * @method CarbonPeriod millenniaUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each millennium or every X millennia if a factor is given. + * @method CarbonImmutable roundYear(float $precision = 1, string $function = "round") Round the current instance year with given precision using the given function. + * @method CarbonImmutable roundYears(float $precision = 1, string $function = "round") Round the current instance year with given precision using the given function. + * @method CarbonImmutable floorYear(float $precision = 1) Truncate the current instance year with given precision. + * @method CarbonImmutable floorYears(float $precision = 1) Truncate the current instance year with given precision. + * @method CarbonImmutable ceilYear(float $precision = 1) Ceil the current instance year with given precision. + * @method CarbonImmutable ceilYears(float $precision = 1) Ceil the current instance year with given precision. + * @method CarbonImmutable roundMonth(float $precision = 1, string $function = "round") Round the current instance month with given precision using the given function. + * @method CarbonImmutable roundMonths(float $precision = 1, string $function = "round") Round the current instance month with given precision using the given function. + * @method CarbonImmutable floorMonth(float $precision = 1) Truncate the current instance month with given precision. + * @method CarbonImmutable floorMonths(float $precision = 1) Truncate the current instance month with given precision. + * @method CarbonImmutable ceilMonth(float $precision = 1) Ceil the current instance month with given precision. + * @method CarbonImmutable ceilMonths(float $precision = 1) Ceil the current instance month with given precision. + * @method CarbonImmutable roundDay(float $precision = 1, string $function = "round") Round the current instance day with given precision using the given function. + * @method CarbonImmutable roundDays(float $precision = 1, string $function = "round") Round the current instance day with given precision using the given function. + * @method CarbonImmutable floorDay(float $precision = 1) Truncate the current instance day with given precision. + * @method CarbonImmutable floorDays(float $precision = 1) Truncate the current instance day with given precision. + * @method CarbonImmutable ceilDay(float $precision = 1) Ceil the current instance day with given precision. + * @method CarbonImmutable ceilDays(float $precision = 1) Ceil the current instance day with given precision. + * @method CarbonImmutable roundHour(float $precision = 1, string $function = "round") Round the current instance hour with given precision using the given function. + * @method CarbonImmutable roundHours(float $precision = 1, string $function = "round") Round the current instance hour with given precision using the given function. + * @method CarbonImmutable floorHour(float $precision = 1) Truncate the current instance hour with given precision. + * @method CarbonImmutable floorHours(float $precision = 1) Truncate the current instance hour with given precision. + * @method CarbonImmutable ceilHour(float $precision = 1) Ceil the current instance hour with given precision. + * @method CarbonImmutable ceilHours(float $precision = 1) Ceil the current instance hour with given precision. + * @method CarbonImmutable roundMinute(float $precision = 1, string $function = "round") Round the current instance minute with given precision using the given function. + * @method CarbonImmutable roundMinutes(float $precision = 1, string $function = "round") Round the current instance minute with given precision using the given function. + * @method CarbonImmutable floorMinute(float $precision = 1) Truncate the current instance minute with given precision. + * @method CarbonImmutable floorMinutes(float $precision = 1) Truncate the current instance minute with given precision. + * @method CarbonImmutable ceilMinute(float $precision = 1) Ceil the current instance minute with given precision. + * @method CarbonImmutable ceilMinutes(float $precision = 1) Ceil the current instance minute with given precision. + * @method CarbonImmutable roundSecond(float $precision = 1, string $function = "round") Round the current instance second with given precision using the given function. + * @method CarbonImmutable roundSeconds(float $precision = 1, string $function = "round") Round the current instance second with given precision using the given function. + * @method CarbonImmutable floorSecond(float $precision = 1) Truncate the current instance second with given precision. + * @method CarbonImmutable floorSeconds(float $precision = 1) Truncate the current instance second with given precision. + * @method CarbonImmutable ceilSecond(float $precision = 1) Ceil the current instance second with given precision. + * @method CarbonImmutable ceilSeconds(float $precision = 1) Ceil the current instance second with given precision. + * @method CarbonImmutable roundMillennium(float $precision = 1, string $function = "round") Round the current instance millennium with given precision using the given function. + * @method CarbonImmutable roundMillennia(float $precision = 1, string $function = "round") Round the current instance millennium with given precision using the given function. + * @method CarbonImmutable floorMillennium(float $precision = 1) Truncate the current instance millennium with given precision. + * @method CarbonImmutable floorMillennia(float $precision = 1) Truncate the current instance millennium with given precision. + * @method CarbonImmutable ceilMillennium(float $precision = 1) Ceil the current instance millennium with given precision. + * @method CarbonImmutable ceilMillennia(float $precision = 1) Ceil the current instance millennium with given precision. + * @method CarbonImmutable roundCentury(float $precision = 1, string $function = "round") Round the current instance century with given precision using the given function. + * @method CarbonImmutable roundCenturies(float $precision = 1, string $function = "round") Round the current instance century with given precision using the given function. + * @method CarbonImmutable floorCentury(float $precision = 1) Truncate the current instance century with given precision. + * @method CarbonImmutable floorCenturies(float $precision = 1) Truncate the current instance century with given precision. + * @method CarbonImmutable ceilCentury(float $precision = 1) Ceil the current instance century with given precision. + * @method CarbonImmutable ceilCenturies(float $precision = 1) Ceil the current instance century with given precision. + * @method CarbonImmutable roundDecade(float $precision = 1, string $function = "round") Round the current instance decade with given precision using the given function. + * @method CarbonImmutable roundDecades(float $precision = 1, string $function = "round") Round the current instance decade with given precision using the given function. + * @method CarbonImmutable floorDecade(float $precision = 1) Truncate the current instance decade with given precision. + * @method CarbonImmutable floorDecades(float $precision = 1) Truncate the current instance decade with given precision. + * @method CarbonImmutable ceilDecade(float $precision = 1) Ceil the current instance decade with given precision. + * @method CarbonImmutable ceilDecades(float $precision = 1) Ceil the current instance decade with given precision. + * @method CarbonImmutable roundQuarter(float $precision = 1, string $function = "round") Round the current instance quarter with given precision using the given function. + * @method CarbonImmutable roundQuarters(float $precision = 1, string $function = "round") Round the current instance quarter with given precision using the given function. + * @method CarbonImmutable floorQuarter(float $precision = 1) Truncate the current instance quarter with given precision. + * @method CarbonImmutable floorQuarters(float $precision = 1) Truncate the current instance quarter with given precision. + * @method CarbonImmutable ceilQuarter(float $precision = 1) Ceil the current instance quarter with given precision. + * @method CarbonImmutable ceilQuarters(float $precision = 1) Ceil the current instance quarter with given precision. + * @method CarbonImmutable roundMillisecond(float $precision = 1, string $function = "round") Round the current instance millisecond with given precision using the given function. + * @method CarbonImmutable roundMilliseconds(float $precision = 1, string $function = "round") Round the current instance millisecond with given precision using the given function. + * @method CarbonImmutable floorMillisecond(float $precision = 1) Truncate the current instance millisecond with given precision. + * @method CarbonImmutable floorMilliseconds(float $precision = 1) Truncate the current instance millisecond with given precision. + * @method CarbonImmutable ceilMillisecond(float $precision = 1) Ceil the current instance millisecond with given precision. + * @method CarbonImmutable ceilMilliseconds(float $precision = 1) Ceil the current instance millisecond with given precision. + * @method CarbonImmutable roundMicrosecond(float $precision = 1, string $function = "round") Round the current instance microsecond with given precision using the given function. + * @method CarbonImmutable roundMicroseconds(float $precision = 1, string $function = "round") Round the current instance microsecond with given precision using the given function. + * @method CarbonImmutable floorMicrosecond(float $precision = 1) Truncate the current instance microsecond with given precision. + * @method CarbonImmutable floorMicroseconds(float $precision = 1) Truncate the current instance microsecond with given precision. + * @method CarbonImmutable ceilMicrosecond(float $precision = 1) Ceil the current instance microsecond with given precision. + * @method CarbonImmutable ceilMicroseconds(float $precision = 1) Ceil the current instance microsecond with given precision. + * @method string shortAbsoluteDiffForHumans(DateTimeInterface $other = null, int $parts = 1) Get the difference (short format, 'Absolute' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.) + * @method string longAbsoluteDiffForHumans(DateTimeInterface $other = null, int $parts = 1) Get the difference (long format, 'Absolute' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.) + * @method string shortRelativeDiffForHumans(DateTimeInterface $other = null, int $parts = 1) Get the difference (short format, 'Relative' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.) + * @method string longRelativeDiffForHumans(DateTimeInterface $other = null, int $parts = 1) Get the difference (long format, 'Relative' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.) + * @method string shortRelativeToNowDiffForHumans(DateTimeInterface $other = null, int $parts = 1) Get the difference (short format, 'RelativeToNow' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.) + * @method string longRelativeToNowDiffForHumans(DateTimeInterface $other = null, int $parts = 1) Get the difference (long format, 'RelativeToNow' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.) + * @method string shortRelativeToOtherDiffForHumans(DateTimeInterface $other = null, int $parts = 1) Get the difference (short format, 'RelativeToOther' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.) + * @method string longRelativeToOtherDiffForHumans(DateTimeInterface $other = null, int $parts = 1) Get the difference (long format, 'RelativeToOther' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.) + * @method static static|false createFromFormat(string $format, string $time, string|DateTimeZone $timezone = null) Parse a string into a new CarbonImmutable object according to the specified format. + * @method static static __set_state(array $array) https://php.net/manual/en/datetime.set-state.php * * */ diff --git a/vendor/nesbot/carbon/src/Carbon/CarbonInterface.php b/vendor/nesbot/carbon/src/Carbon/CarbonInterface.php index 15e2061..4b6ce76 100644 --- a/vendor/nesbot/carbon/src/Carbon/CarbonInterface.php +++ b/vendor/nesbot/carbon/src/Carbon/CarbonInterface.php @@ -586,6 +586,7 @@ interface CarbonInterface extends DateTimeInterface, JsonSerializable public const YEARS_PER_DECADE = 10; public const MONTHS_PER_YEAR = 12; public const MONTHS_PER_QUARTER = 3; + public const QUARTERS_PER_YEAR = 4; public const WEEKS_PER_YEAR = 52; public const WEEKS_PER_MONTH = 4; public const DAYS_PER_YEAR = 365; @@ -701,6 +702,15 @@ interface CarbonInterface extends DateTimeInterface, JsonSerializable */ public function __isset($name); + /** + * Returns the values to dump on serialize() called on. + * + * Only used by PHP >= 7.4. + * + * @return array + */ + public function __serialize(): array; + /** * Set a part of the Carbon object * @@ -726,6 +736,8 @@ interface CarbonInterface extends DateTimeInterface, JsonSerializable /** * Returns the list of properties to dump on serialize() called on. * + * Only used by PHP < 7.4. + * * @return array */ public function __sleep(); @@ -735,13 +747,22 @@ interface CarbonInterface extends DateTimeInterface, JsonSerializable * * @example * ``` - * echo Carbon::now(); // Carbon instances can be casted to string + * echo Carbon::now(); // Carbon instances can be cast to string * ``` * * @return string */ public function __toString(); + /** + * Set locale if specified on unserialize() called. + * + * Only used by PHP >= 7.4. + * + * @return void + */ + public function __unserialize(array $data): void; + /** * Add given units or interval to the current instance. * @@ -987,7 +1008,7 @@ interface CarbonInterface extends DateTimeInterface, JsonSerializable * * @param string $modifier * - * @return static + * @return static|false */ public function change($modifier); @@ -1276,7 +1297,7 @@ interface CarbonInterface extends DateTimeInterface, JsonSerializable * * @return CarbonInterval */ - public function diffAsCarbonInterval($date = null, $absolute = true); + public function diffAsCarbonInterval($date = null, $absolute = true, array $skip = []); /** * Get the difference by the given interval using a filter closure. @@ -2116,6 +2137,18 @@ interface CarbonInterface extends DateTimeInterface, JsonSerializable */ public static function getDays(); + /** + * Return the number of days since the start of the week (using the current locale or the first parameter + * if explicitly given). + * + * @param int|null $weekStartsAt optional start allow you to specify the day of week to use to start the week, + * if not provided, start of week is inferred from the locale + * (Sunday for en_US, Monday for de_DE, etc.) + * + * @return int + */ + public function getDaysFromStartOfWeek(?int $weekStartsAt = null): int; + /** * Get the fallback locale. * @@ -3382,7 +3415,7 @@ interface CarbonInterface extends DateTimeInterface, JsonSerializable * * @param string|int|null $modifier * - * @return static + * @return static|false */ public function next($modifier = null); @@ -3528,7 +3561,7 @@ interface CarbonInterface extends DateTimeInterface, JsonSerializable * * @param string|int|null $modifier * - * @return static + * @return static|false */ public function previous($modifier = null); @@ -3773,6 +3806,19 @@ interface CarbonInterface extends DateTimeInterface, JsonSerializable */ public function setDateTimeFrom($date = null); + /** + * Set the day (keeping the current time) to the start of the week + the number of days passed as the first + * parameter. First day of week is driven by the locale unless explicitly set with the second parameter. + * + * @param int $numberOfDays number of days to add after the start of the current week + * @param int|null $weekStartsAt optional start allow you to specify the day of week to use to start the week, + * if not provided, start of week is inferred from the locale + * (Sunday for en_US, Monday for de_DE, etc.) + * + * @return static + */ + public function setDaysFromStartOfWeek(int $numberOfDays, ?int $weekStartsAt = null); + /** * Set the fallback locale. * @@ -3860,7 +3906,7 @@ interface CarbonInterface extends DateTimeInterface, JsonSerializable * * /!\ Use this method for unit tests only. * - * @param Closure|static|string|false|null $testNow real or mock Carbon instance + * @param DateTimeInterface|Closure|static|string|false|null $testNow real or mock Carbon instance */ public static function setTestNow($testNow = null); @@ -3881,7 +3927,7 @@ interface CarbonInterface extends DateTimeInterface, JsonSerializable * * /!\ Use this method for unit tests only. * - * @param Closure|static|string|false|null $testNow real or mock Carbon instance + * @param DateTimeInterface|Closure|static|string|false|null $testNow real or mock Carbon instance */ public static function setTestNowAndTimezone($testNow = null, $tz = null); @@ -3942,11 +3988,11 @@ interface CarbonInterface extends DateTimeInterface, JsonSerializable /** * @deprecated To avoid conflict between different third-party libraries, static setters should not be used. - * You should rather let Carbon object being casted to string with DEFAULT_TO_STRING_FORMAT, and - * use other method or custom format passed to format() method if you need to dump an other string + * You should rather let Carbon object being cast to string with DEFAULT_TO_STRING_FORMAT, and + * use other method or custom format passed to format() method if you need to dump another string * format. * - * Set the default format used when type juggling a Carbon instance to a string + * Set the default format used when type juggling a Carbon instance to a string. * * @param string|Closure|null $format * @@ -4537,6 +4583,18 @@ interface CarbonInterface extends DateTimeInterface, JsonSerializable */ public function toFormattedDateString(); + /** + * Format the instance with the day, and a readable date + * + * @example + * ``` + * echo Carbon::now()->toFormattedDayDateString(); + * ``` + * + * @return string + */ + public function toFormattedDayDateString(): string; + /** * Return the ISO-8601 string (ex: 1977-04-22T06:00:00Z, if $keepOffset truthy, offset will be kept: * 1977-04-22T01:00:00-05:00). @@ -5057,8 +5115,8 @@ interface CarbonInterface extends DateTimeInterface, JsonSerializable * * /!\ Use this method for unit tests only. * - * @param Closure|static|string|false|null $testNow real or mock Carbon instance - * @param Closure|null $callback + * @param DateTimeInterface|Closure|static|string|false|null $testNow real or mock Carbon instance + * @param Closure|null $callback * * @return mixed */ diff --git a/vendor/nesbot/carbon/src/Carbon/CarbonInterval.php b/vendor/nesbot/carbon/src/Carbon/CarbonInterval.php index d465bea..796f9cd 100644 --- a/vendor/nesbot/carbon/src/Carbon/CarbonInterval.php +++ b/vendor/nesbot/carbon/src/Carbon/CarbonInterval.php @@ -22,8 +22,10 @@ use Carbon\Exceptions\UnknownSetterException; use Carbon\Exceptions\UnknownUnitException; use Carbon\Traits\IntervalRounding; use Carbon\Traits\IntervalStep; +use Carbon\Traits\MagicParameter; use Carbon\Traits\Mixin; use Carbon\Traits\Options; +use Carbon\Traits\ToStringFormat; use Closure; use DateInterval; use DateTimeInterface; @@ -46,7 +48,7 @@ use Throwable; * @property int $minutes Total minutes of the current interval. * @property int $seconds Total seconds of the current interval. * @property int $microseconds Total microseconds of the current interval. - * @property int $milliseconds Total microseconds of the current interval. + * @property int $milliseconds Total milliseconds of the current interval. * @property int $microExcludeMilli Remaining microseconds without the milliseconds. * @property int $dayzExcludeWeeks Total days remaining in the final week of the current instance (days % 7). * @property int $daysExcludeWeeks alias of dayzExcludeWeeks @@ -184,10 +186,12 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface { use IntervalRounding; use IntervalStep; + use MagicParameter; use Mixin { Mixin::mixin as baseMixin; } use Options; + use ToStringFormat; /** * Interval spec period designators @@ -294,7 +298,12 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface */ public static function getCascadeFactors() { - return static::$cascadeFactors ?: [ + return static::$cascadeFactors ?: static::getDefaultCascadeFactors(); + } + + protected static function getDefaultCascadeFactors(): array + { + return [ 'milliseconds' => [Carbon::MICROSECONDS_PER_MILLISECOND, 'microseconds'], 'seconds' => [Carbon::MILLISECONDS_PER_SECOND, 'milliseconds'], 'minutes' => [Carbon::SECONDS_PER_MINUTE, 'seconds'], @@ -344,14 +353,14 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface /** * Create a new CarbonInterval instance. * - * @param int|null $years - * @param int|null $months - * @param int|null $weeks - * @param int|null $days - * @param int|null $hours - * @param int|null $minutes - * @param int|null $seconds - * @param int|null $microseconds + * @param Closure|DateInterval|string|int|null $years + * @param int|null $months + * @param int|null $weeks + * @param int|null $days + * @param int|null $hours + * @param int|null $minutes + * @param int|null $seconds + * @param int|null $microseconds * * @throws Exception when the interval_spec (passed as $years) cannot be parsed as an interval. */ @@ -372,7 +381,7 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface $spec = $years; - if (!\is_string($spec) || (float) $years || preg_match('/^[0-9.]/', $years)) { + if (!\is_string($spec) || (float) $years || preg_match('/^[\d.]/', $years)) { $spec = static::PERIOD_PREFIX; $spec .= $years > 0 ? $years.static::PERIOD_YEARS : ''; @@ -410,7 +419,7 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface * @param string $source * @param string $target * - * @return int|null + * @return int|float|null */ public static function getFactor($source, $target) { @@ -438,7 +447,7 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface * @param string $source * @param string $target * - * @return int|null + * @return int|float|null */ public static function getFactorWithDefault($source, $target) { @@ -465,7 +474,7 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface /** * Returns current config for days per week. * - * @return int + * @return int|float */ public static function getDaysPerWeek() { @@ -475,7 +484,7 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface /** * Returns current config for hours per day. * - * @return int + * @return int|float */ public static function getHoursPerDay() { @@ -485,7 +494,7 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface /** * Returns current config for minutes per hour. * - * @return int + * @return int|float */ public static function getMinutesPerHour() { @@ -495,7 +504,7 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface /** * Returns current config for seconds per minute. * - * @return int + * @return int|float */ public static function getSecondsPerMinute() { @@ -505,7 +514,7 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface /** * Returns current config for microseconds per second. * - * @return int + * @return int|float */ public static function getMillisecondsPerSecond() { @@ -515,7 +524,7 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface /** * Returns current config for microseconds per second. * - * @return int + * @return int|float */ public static function getMicrosecondsPerMillisecond() { @@ -767,6 +776,8 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface case 'year': case 'years': case 'y': + case 'yr': + case 'yrs': $years += $intValue; break; @@ -780,6 +791,7 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface case 'month': case 'months': case 'mo': + case 'mos': $months += $intValue; break; @@ -882,7 +894,7 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface return static::fromString(Carbon::translateTimeString($interval, $locale ?: static::getLocale(), 'en')); } - private static function castIntervalToClass(DateInterval $interval, string $className) + private static function castIntervalToClass(DateInterval $interval, string $className, array $skip = []) { $mainClass = DateInterval::class; @@ -891,7 +903,7 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface } $microseconds = $interval->f; - $instance = new $className(static::getDateIntervalSpec($interval)); + $instance = new $className(static::getDateIntervalSpec($interval, false, $skip)); if ($microseconds) { $instance->f = $microseconds; @@ -943,9 +955,9 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface * * @return static */ - public static function instance(DateInterval $interval) + public static function instance(DateInterval $interval, array $skip = []) { - return self::castIntervalToClass($interval, static::class); + return self::castIntervalToClass($interval, static::class, $skip); } /** @@ -984,7 +996,7 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface { $interval = preg_replace('/\s+/', ' ', trim($interval)); - if (preg_match('/^P[T0-9]/', $interval)) { + if (preg_match('/^P[T\d]/', $interval)) { return new static($interval); } @@ -1081,11 +1093,11 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface return (int) round($this->f * Carbon::MICROSECONDS_PER_SECOND) % Carbon::MICROSECONDS_PER_MILLISECOND; case 'weeks': - return (int) ($this->d / static::getDaysPerWeek()); + return (int) ($this->d / (int) static::getDaysPerWeek()); case 'daysExcludeWeeks': case 'dayzExcludeWeeks': - return $this->d % static::getDaysPerWeek(); + return $this->d % (int) static::getDaysPerWeek(); case 'locale': return $this->getTranslatorLocale(); @@ -1136,7 +1148,7 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface break; case 'week': - $this->d = $value * static::getDaysPerWeek(); + $this->d = $value * (int) static::getDaysPerWeek(); break; @@ -1147,7 +1159,7 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface case 'daysexcludeweek': case 'dayzexcludeweek': - $this->d = $this->weeks * static::getDaysPerWeek() + $value; + $this->d = $this->weeks * (int) static::getDaysPerWeek() + $value; break; @@ -1355,11 +1367,15 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface } if (preg_match('/^(?add|sub)(?[A-Z].*)$/', $method, $match)) { - return $this->{$match['method']}($parameters[0], $match['unit']); + $value = $this->getMagicParameter($parameters, 0, Carbon::pluralUnit($match['unit']), 0); + + return $this->{$match['method']}($value, $match['unit']); } + $value = $this->getMagicParameter($parameters, 0, Carbon::pluralUnit($method), 1); + try { - $this->set($method, \count($parameters) === 0 ? 1 : $parameters[0]); + $this->set($method, $value); } catch (UnknownSetterException $exception) { if ($this->localStrictModeEnabled ?? Carbon::isStrictModeEnabled()) { throw new BadFluentSetterException($method, 0, $exception); @@ -1410,9 +1426,9 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface $minimumUnit = 's'; $skip = []; extract($this->getForHumansInitialVariables($syntax, $short)); - $skip = array_filter((array) $skip, static function ($value) { + $skip = array_map('strtolower', array_filter((array) $skip, static function ($value) { return \is_string($value) && $value !== ''; - }); + })); if ($syntax === null) { $syntax = CarbonInterface::DIFF_ABSOLUTE; @@ -1435,11 +1451,9 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface ]; } - if ($altNumbers) { - if ($altNumbers !== true) { - $language = new Language($this->locale); - $altNumbers = \in_array($language->getCode(), (array) $altNumbers); - } + if ($altNumbers && $altNumbers !== true) { + $language = new Language($this->locale); + $altNumbers = \in_array($language->getCode(), (array) $altNumbers, true); } if (\is_array($join)) { @@ -1620,18 +1634,23 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface $unit = $short ? 's' : 'second'; $isFuture = $this->invert === 1; $transId = $relativeToNow ? ($isFuture ? 'from_now' : 'ago') : ($isFuture ? 'after' : 'before'); + $declensionMode = null; /** @var \Symfony\Component\Translation\Translator $translator */ $translator = $this->getLocalTranslator(); - $handleDeclensions = function ($unit, $count) use ($interpolations, $transId, $translator, $altNumbers, $absolute) { + $handleDeclensions = function ($unit, $count, $index = 0, $parts = 1) use ($interpolations, $transId, $translator, $altNumbers, $absolute, &$declensionMode) { if (!$absolute) { - // Some languages have special pluralization for past and future tense. - $key = $unit.'_'.$transId; - $result = $this->translate($key, $interpolations, $count, $translator, $altNumbers); + $declensionMode = $declensionMode ?? $this->translate($transId.'_mode'); - if ($result !== $key) { - return $result; + if ($this->needsDeclension($declensionMode, $index, $parts)) { + // Some languages have special pluralization for past and future tense. + $key = $unit.'_'.$transId; + $result = $this->translate($key, $interpolations, $count, $translator, $altNumbers); + + if ($result !== $key) { + return $result; + } } } @@ -1696,17 +1715,17 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface } } - $transChoice = function ($short, $unitData) use ($absolute, $handleDeclensions, $translator, $aUnit, $altNumbers, $interpolations) { + $transChoice = function ($short, $unitData, $index, $parts) use ($absolute, $handleDeclensions, $translator, $aUnit, $altNumbers, $interpolations) { $count = $unitData['value']; if ($short) { - $result = $handleDeclensions($unitData['unitShort'], $count); + $result = $handleDeclensions($unitData['unitShort'], $count, $index, $parts); if ($result !== null) { return $result; } } elseif ($aUnit) { - $result = $handleDeclensions('a_'.$unitData['unit'], $count); + $result = $handleDeclensions('a_'.$unitData['unit'], $count, $index, $parts); if ($result !== null) { return $result; @@ -1714,7 +1733,7 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface } if (!$absolute) { - return $handleDeclensions($unitData['unit'], $count); + return $handleDeclensions($unitData['unit'], $count, $index, $parts); } return $this->translate($unitData['unit'], $interpolations, $count, $translator, $altNumbers); @@ -1726,7 +1745,7 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface if ($diffIntervalData['value'] > 0) { $unit = $short ? $diffIntervalData['unitShort'] : $diffIntervalData['unit']; $count = $diffIntervalData['value']; - $interval[] = $transChoice($short, $diffIntervalData); + $interval[] = [$short, $diffIntervalData]; } elseif ($options & CarbonInterface::SEQUENTIAL_PARTS_ONLY && \count($interval) > 0) { break; } @@ -1737,13 +1756,19 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface } // break the loop after we have reached the minimum unit - if (\in_array($minimumUnit, [$diffIntervalData['unit'], $diffIntervalData['unitShort']])) { + if (\in_array($minimumUnit, [$diffIntervalData['unit'], $diffIntervalData['unitShort']], true)) { $fallbackUnit = [$diffIntervalData['unit'], $diffIntervalData['unitShort']]; break; } } + $actualParts = \count($interval); + + foreach ($interval as $index => &$item) { + $item = $transChoice($item[0], $item[1], $index, $actualParts); + } + if (\count($interval) === 0) { if ($relativeToNow && $options & CarbonInterface::JUST_NOW) { $key = 'diff_now'; @@ -1812,17 +1837,17 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface */ public function __toString() { - $format = $this->localToStringFormat; + $format = $this->localToStringFormat ?? static::$toStringFormat; - if ($format) { - if ($format instanceof Closure) { - return $format($this); - } - - return $this->format($format); + if (!$format) { + return $this->forHumans(); } - return $this->forHumans(); + if ($format instanceof Closure) { + return $format($this); + } + + return $this->format($format); } /** @@ -1863,7 +1888,7 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface /** * Invert the interval. * - * @param bool|int $inverted if a parameter is passed, the passed value casted as 1 or 0 is used + * @param bool|int $inverted if a parameter is passed, the passed value cast as 1 or 0 is used * as the new value of the ->invert property. * * @return $this @@ -2141,7 +2166,7 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface * * @return string */ - public static function getDateIntervalSpec(DateInterval $interval) + public static function getDateIntervalSpec(DateInterval $interval, bool $microseconds = false, array $skip = []) { $date = array_filter([ static::PERIOD_YEARS => abs($interval->y), @@ -2149,10 +2174,25 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface static::PERIOD_DAYS => abs($interval->d), ]); + if ( + $interval->days >= CarbonInterface::DAYS_PER_WEEK * CarbonInterface::WEEKS_PER_MONTH && + (!isset($date[static::PERIOD_YEARS]) || \count(array_intersect(['y', 'year', 'years'], $skip))) && + (!isset($date[static::PERIOD_MONTHS]) || \count(array_intersect(['m', 'month', 'months'], $skip))) + ) { + $date = [ + static::PERIOD_DAYS => abs($interval->days), + ]; + } + + $seconds = abs($interval->s); + if ($microseconds && $interval->f > 0) { + $seconds = sprintf('%d.%06d', $seconds, abs($interval->f) * 1000000); + } + $time = array_filter([ static::PERIOD_HOURS => abs($interval->h), static::PERIOD_MINUTES => abs($interval->i), - static::PERIOD_SECONDS => abs($interval->s), + static::PERIOD_SECONDS => $seconds, ]); $specString = static::PERIOD_PREFIX; @@ -2176,9 +2216,9 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface * * @return string */ - public function spec() + public function spec(bool $microseconds = false) { - return static::getDateIntervalSpec($this); + return static::getDateIntervalSpec($this, $microseconds); } /** @@ -2229,9 +2269,11 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface $originalData = $this->toArray(); $originalData['milliseconds'] = (int) ($originalData['microseconds'] / static::getMicrosecondsPerMillisecond()); $originalData['microseconds'] = $originalData['microseconds'] % static::getMicrosecondsPerMillisecond(); - $originalData['daysExcludeWeeks'] = $originalData['days']; + $originalData['weeks'] = (int) ($this->d / static::getDaysPerWeek()); + $originalData['daysExcludeWeeks'] = fmod($this->d, static::getDaysPerWeek()); unset($originalData['days']); $newData = $originalData; + $previous = []; foreach (self::getFlipCascadeFactors() as $source => [$target, $factor]) { foreach (['source', 'target'] as $key) { @@ -2241,9 +2283,29 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface } $value = $newData[$source]; - $modulo = ($factor + ($value % $factor)) % $factor; + $modulo = fmod($factor + fmod($value, $factor), $factor); $newData[$source] = $modulo; $newData[$target] += ($value - $modulo) / $factor; + + $decimalPart = fmod($newData[$source], 1); + + if ($decimalPart !== 0.0) { + $unit = $source; + + foreach ($previous as [$subUnit, $subFactor]) { + $newData[$unit] -= $decimalPart; + $newData[$subUnit] += $decimalPart * $subFactor; + $decimalPart = fmod($newData[$subUnit], 1); + + if ($decimalPart === 0.0) { + break; + } + + $unit = $subUnit; + } + } + + array_unshift($previous, [$source, $factor]); } $positive = null; @@ -2324,13 +2386,13 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface $cumulativeFactor = 0; $unitFound = false; $factors = self::getFlipCascadeFactors(); - $daysPerWeek = static::getDaysPerWeek(); + $daysPerWeek = (int) static::getDaysPerWeek(); $values = [ 'years' => $this->years, 'months' => $this->months, 'weeks' => (int) ($this->d / $daysPerWeek), - 'dayz' => $this->d % $daysPerWeek, + 'dayz' => fmod($this->d, $daysPerWeek), 'hours' => $this->hours, 'minutes' => $this->minutes, 'seconds' => $this->seconds, @@ -2391,10 +2453,11 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface } if ($unit === 'weeks') { - return $result / $daysPerWeek; + $result /= $daysPerWeek; } - return $result; + // Cast as int numbers with no decimal part + return fmod($result, 1) === 0.0 ? (int) $result : $result; } /** @@ -2662,6 +2725,15 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface */ public function roundUnit($unit, $precision = 1, $function = 'round') { + if (static::getCascadeFactors() !== static::getDefaultCascadeFactors()) { + $value = $function($this->total($unit) / $precision) * $precision; + $inverted = $value < 0; + + return $this->copyProperties(self::fromString( + number_format(abs($value), 12, '.', '').' '.$unit + )->invert($inverted)->cascade()); + } + $base = CarbonImmutable::parse('2000-01-01 00:00:00', 'UTC') ->roundUnit($unit, $precision, $function); $next = $base->add($this); @@ -2752,4 +2824,14 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface { return $this->round($precision, 'ceil'); } + + private function needsDeclension(string $mode, int $index, int $parts): bool + { + switch ($mode) { + case 'last': + return $index === $parts - 1; + default: + return true; + } + } } diff --git a/vendor/nesbot/carbon/src/Carbon/CarbonPeriod.php b/vendor/nesbot/carbon/src/Carbon/CarbonPeriod.php index 0e81e75..0167914 100644 --- a/vendor/nesbot/carbon/src/Carbon/CarbonPeriod.php +++ b/vendor/nesbot/carbon/src/Carbon/CarbonPeriod.php @@ -11,6 +11,7 @@ namespace Carbon; +use Carbon\Exceptions\EndLessPeriodException; use Carbon\Exceptions\InvalidCastException; use Carbon\Exceptions\InvalidIntervalException; use Carbon\Exceptions\InvalidPeriodDateException; @@ -23,11 +24,13 @@ use Carbon\Exceptions\UnreachableException; use Carbon\Traits\IntervalRounding; use Carbon\Traits\Mixin; use Carbon\Traits\Options; +use Carbon\Traits\ToStringFormat; use Closure; use Countable; use DateInterval; use DatePeriod; use DateTime; +use DateTimeImmutable; use DateTimeInterface; use DateTimeZone; use InvalidArgumentException; @@ -173,6 +176,7 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable Mixin::mixin as baseMixin; } use Options; + use ToStringFormat; /** * Built-in filter for limit by recurrences. @@ -251,6 +255,13 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable */ protected $dateInterval; + /** + * True once __construct is finished. + * + * @var bool + */ + protected $constructed = false; + /** * Whether current date interval was set by default. * @@ -377,7 +388,7 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable ); } - $class = \get_called_class(); + $class = static::class; $type = \gettype($period); throw new NotAPeriodException( @@ -484,7 +495,7 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable $end = null; foreach (explode('/', $iso) as $key => $part) { - if ($key === 0 && preg_match('/^R([0-9]*|INF)$/', $part, $match)) { + if ($key === 0 && preg_match('/^R(\d*|INF)$/', $part, $match)) { $parsed = \strlen($match[1]) ? (($match[1] !== 'INF') ? (int) $match[1] : INF) : null; } elseif ($interval === null && $parsed = CarbonInterval::make($part)) { $interval = $part; @@ -512,7 +523,7 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable */ protected static function addMissingParts($source, $target) { - $pattern = '/'.preg_replace('/[0-9]+/', '[0-9]+', preg_quote($target, '/')).'$/'; + $pattern = '/'.preg_replace('/\d+/', '[0-9]+', preg_quote($target, '/')).'$/'; $result = preg_replace($pattern, $target, $source, 1, $count); @@ -655,10 +666,10 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable $this->setTimezone($argument); } elseif ($this->dateInterval === null && ( - \is_string($argument) && preg_match( - '/^(-?\d(\d(?![\/-])|[^\d\/-]([\/-])?)*|P[T0-9].*|(?:\h*\d+(?:\.\d+)?\h*[a-z]+)+)$/i', + (\is_string($argument) && preg_match( + '/^(-?\d(\d(?![\/-])|[^\d\/-]([\/-])?)*|P[T\d].*|(?:\h*\d+(?:\.\d+)?\h*[a-z]+)+)$/i', $argument - ) || + )) || $argument instanceof DateInterval || $argument instanceof Closure ) && @@ -691,6 +702,8 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable if ($this->options === null) { $this->setOptions(0); } + + $this->constructed = true; } /** @@ -703,6 +716,17 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable return clone $this; } + /** + * Prepare the instance to be set (self if mutable to be mutated, + * copy if immutable to generate a new instance). + * + * @return static + */ + protected function copyIfImmutable() + { + return $this; + } + /** * Get the getter for a property allowing both `DatePeriod` snakeCase and camelCase names. * @@ -794,7 +818,7 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable * * @param string $dateClass * - * @return $this + * @return static */ public function setDateClass(string $dateClass) { @@ -802,15 +826,16 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable throw new NotACarbonClassException($dateClass); } - $this->dateClass = $dateClass; + $self = $this->copyIfImmutable(); + $self->dateClass = $dateClass; if (is_a($dateClass, Carbon::class, true)) { - $this->toggleOptions(static::IMMUTABLE, false); + $self->options = $self->options & ~static::IMMUTABLE; } elseif (is_a($dateClass, CarbonImmutable::class, true)) { - $this->toggleOptions(static::IMMUTABLE, true); + $self->options = $self->options | static::IMMUTABLE; } - return $this; + return $self; } /** @@ -830,7 +855,7 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable * * @throws InvalidIntervalException * - * @return $this + * @return static */ public function setDateInterval($interval) { @@ -842,25 +867,24 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable throw new InvalidIntervalException('Empty interval is not accepted.'); } - $this->dateInterval = $interval; + $self = $this->copyIfImmutable(); + $self->dateInterval = $interval; - $this->isDefaultInterval = false; + $self->isDefaultInterval = false; - $this->handleChangedParameters(); + $self->handleChangedParameters(); - return $this; + return $self; } /** * Invert the period date interval. * - * @return $this + * @return static */ public function invertDateInterval() { - $interval = $this->dateInterval->invert(); - - return $this->setDateInterval($interval); + return $this->setDateInterval($this->dateInterval->invert()); } /** @@ -869,14 +893,11 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable * @param DateTime|DateTimeInterface|string $start * @param DateTime|DateTimeInterface|string|null $end * - * @return $this + * @return static */ public function setDates($start, $end) { - $this->setStartDate($start); - $this->setEndDate($end); - - return $this; + return $this->setStartDate($start)->setEndDate($end); } /** @@ -886,7 +907,7 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable * * @throws InvalidArgumentException * - * @return $this + * @return static */ public function setOptions($options) { @@ -894,11 +915,12 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable throw new InvalidPeriodParameterException('Invalid options.'); } - $this->options = $options ?: 0; + $self = $this->copyIfImmutable(); + $self->options = $options ?: 0; - $this->handleChangedParameters(); + $self->handleChangedParameters(); - return $this; + return $self; } /** @@ -919,7 +941,7 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable * * @throws \InvalidArgumentException * - * @return $this + * @return static */ public function toggleOptions($options, $state = null) { @@ -939,7 +961,7 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable * * @param bool $state * - * @return $this + * @return static */ public function excludeStartDate($state = true) { @@ -951,7 +973,7 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable * * @param bool $state * - * @return $this + * @return static */ public function excludeEndDate($state = true) { @@ -1095,17 +1117,18 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable * @param callable $callback * @param string $name * - * @return $this + * @return static */ public function addFilter($callback, $name = null) { - $tuple = $this->createFilterTuple(\func_get_args()); + $self = $this->copyIfImmutable(); + $tuple = $self->createFilterTuple(\func_get_args()); - $this->filters[] = $tuple; + $self->filters[] = $tuple; - $this->handleChangedParameters(); + $self->handleChangedParameters(); - return $this; + return $self; } /** @@ -1116,17 +1139,18 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable * @param callable $callback * @param string $name * - * @return $this + * @return static */ public function prependFilter($callback, $name = null) { - $tuple = $this->createFilterTuple(\func_get_args()); + $self = $this->copyIfImmutable(); + $tuple = $self->createFilterTuple(\func_get_args()); - array_unshift($this->filters, $tuple); + array_unshift($self->filters, $tuple); - $this->handleChangedParameters(); + $self->handleChangedParameters(); - return $this; + return $self; } /** @@ -1134,24 +1158,25 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable * * @param callable|string $filter * - * @return $this + * @return static */ public function removeFilter($filter) { + $self = $this->copyIfImmutable(); $key = \is_callable($filter) ? 0 : 1; - $this->filters = array_values(array_filter( + $self->filters = array_values(array_filter( $this->filters, function ($tuple) use ($key, $filter) { return $tuple[$key] !== $filter; } )); - $this->updateInternalState(); + $self->updateInternalState(); - $this->handleChangedParameters(); + $self->handleChangedParameters(); - return $this; + return $self; } /** @@ -1189,39 +1214,41 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable * * @param array $filters * - * @return $this + * @return static */ public function setFilters(array $filters) { - $this->filters = $filters; + $self = $this->copyIfImmutable(); + $self->filters = $filters; - $this->updateInternalState(); + $self->updateInternalState(); - $this->handleChangedParameters(); + $self->handleChangedParameters(); - return $this; + return $self; } /** * Reset filters stack. * - * @return $this + * @return static */ public function resetFilters() { - $this->filters = []; + $self = $this->copyIfImmutable(); + $self->filters = []; - if ($this->endDate !== null) { - $this->filters[] = [static::END_DATE_FILTER, null]; + if ($self->endDate !== null) { + $self->filters[] = [static::END_DATE_FILTER, null]; } - if ($this->recurrences !== null) { - $this->filters[] = [static::RECURRENCES_FILTER, null]; + if ($self->recurrences !== null) { + $self->filters[] = [static::RECURRENCES_FILTER, null]; } - $this->handleChangedParameters(); + $self->handleChangedParameters(); - return $this; + return $self; } /** @@ -1231,11 +1258,11 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable * * @throws InvalidArgumentException * - * @return $this + * @return static */ public function setRecurrences($recurrences) { - if (!is_numeric($recurrences) && $recurrences !== null || $recurrences < 0) { + if ((!is_numeric($recurrences) && $recurrences !== null) || $recurrences < 0) { throw new InvalidPeriodParameterException('Invalid number of recurrences.'); } @@ -1243,15 +1270,17 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable return $this->removeFilter(static::RECURRENCES_FILTER); } - $this->recurrences = $recurrences === INF ? INF : (int) $recurrences; + /** @var self $self */ + $self = $this->copyIfImmutable(); + $self->recurrences = $recurrences === INF ? INF : (int) $recurrences; - if (!$this->hasFilter(static::RECURRENCES_FILTER)) { - return $this->addFilter(static::RECURRENCES_FILTER); + if (!$self->hasFilter(static::RECURRENCES_FILTER)) { + return $self->addFilter(static::RECURRENCES_FILTER); } - $this->handleChangedParameters(); + $self->handleChangedParameters(); - return $this; + return $self; } /** @@ -1262,21 +1291,22 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable * * @throws InvalidPeriodDateException * - * @return $this + * @return static */ public function setStartDate($date, $inclusive = null) { - if (!$date = ([$this->dateClass, 'make'])($date)) { + if (!$this->isInfiniteDate($date) && !($date = ([$this->dateClass, 'make'])($date))) { throw new InvalidPeriodDateException('Invalid start date.'); } - $this->startDate = $date; + $self = $this->copyIfImmutable(); + $self->startDate = $date; if ($inclusive !== null) { - $this->toggleOptions(static::EXCLUDE_START_DATE, !$inclusive); + $self = $self->toggleOptions(static::EXCLUDE_START_DATE, !$inclusive); } - return $this; + return $self; } /** @@ -1287,11 +1317,11 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable * * @throws \InvalidArgumentException * - * @return $this + * @return static */ public function setEndDate($date, $inclusive = null) { - if ($date !== null && !$date = ([$this->dateClass, 'make'])($date)) { + if ($date !== null && !$this->isInfiniteDate($date) && !$date = ([$this->dateClass, 'make'])($date)) { throw new InvalidPeriodDateException('Invalid end date.'); } @@ -1299,19 +1329,20 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable return $this->removeFilter(static::END_DATE_FILTER); } - $this->endDate = $date; + $self = $this->copyIfImmutable(); + $self->endDate = $date; if ($inclusive !== null) { - $this->toggleOptions(static::EXCLUDE_END_DATE, !$inclusive); + $self = $self->toggleOptions(static::EXCLUDE_END_DATE, !$inclusive); } - if (!$this->hasFilter(static::END_DATE_FILTER)) { - return $this->addFilter(static::END_DATE_FILTER); + if (!$self->hasFilter(static::END_DATE_FILTER)) { + return $self->addFilter(static::END_DATE_FILTER); } - $this->handleChangedParameters(); + $self->handleChangedParameters(); - return $this; + return $self; } /** @@ -1457,13 +1488,21 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable */ public function toString() { + $format = $this->localToStringFormat ?? static::$toStringFormat; + + if ($format instanceof Closure) { + return $format($this); + } + $translator = ([$this->dateClass, 'getTranslator'])(); $parts = []; - $format = !$this->startDate->isStartOfDay() || $this->endDate && !$this->endDate->isStartOfDay() - ? 'Y-m-d H:i:s' - : 'Y-m-d'; + $format = $format ?? ( + !$this->startDate->isStartOfDay() || ($this->endDate && !$this->endDate->isStartOfDay()) + ? 'Y-m-d H:i:s' + : 'Y-m-d' + ); if ($this->recurrences !== null) { $parts[] = $this->translate('period_recurrences', [], $this->recurrences, $translator); @@ -1506,9 +1545,9 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable if (!method_exists($className, 'instance')) { if (is_a($className, DatePeriod::class, true)) { return new $className( - $this->getStartDate(), + $this->rawDate($this->getStartDate()), $this->getDateInterval(), - $this->getEndDate() ? $this->getIncludedEndDate() : $this->getRecurrences(), + $this->getEndDate() ? $this->rawDate($this->getIncludedEndDate()) : $this->getRecurrences(), $this->isStartExcluded() ? DatePeriod::EXCLUDE_START_DATE : 0 ); } @@ -1534,6 +1573,39 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable return $this->cast(DatePeriod::class); } + /** + * Return `true` if the period has no custom filter and is guaranteed to be endless. + * + * Note that we can't check if a period is endless as soon as it has custom filters + * because filters can emit `CarbonPeriod::END_ITERATION` to stop the iteration in + * a way we can't predict without actually iterating the period. + */ + public function isUnfilteredAndEndLess(): bool + { + foreach ($this->filters as $filter) { + switch ($filter) { + case [static::RECURRENCES_FILTER, null]: + if ($this->recurrences !== null && is_finite($this->recurrences)) { + return false; + } + + break; + + case [static::END_DATE_FILTER, null]: + if ($this->endDate !== null && !$this->endDate->isEndOfTime()) { + return false; + } + + break; + + default: + return false; + } + } + + return true; + } + /** * Convert the date period into an array without changing current iteration state. * @@ -1541,6 +1613,10 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable */ public function toArray() { + if ($this->isUnfilteredAndEndLess()) { + throw new EndLessPeriodException("Endless period can't be converted to array nor counted."); + } + $state = [ $this->key, $this->current ? $this->current->avoidMutation() : null, @@ -1572,6 +1648,16 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable */ public function first() { + if ($this->isUnfilteredAndEndLess()) { + foreach ($this as $date) { + $this->rewind(); + + return $date; + } + + return null; + } + return ($this->toArray() ?: [])[0] ?? null; } @@ -1626,54 +1712,80 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable return $roundedValue; } - $first = \count($parameters) >= 1 ? $parameters[0] : null; - $second = \count($parameters) >= 2 ? $parameters[1] : null; - switch ($method) { case 'start': case 'since': - return $this->setStartDate($first, $second); + self::setDefaultParameters($parameters, [ + [0, 'date', null], + ]); + + return $this->setStartDate(...$parameters); case 'sinceNow': - return $this->setStartDate(new Carbon(), $first); + return $this->setStartDate(new Carbon(), ...$parameters); case 'end': case 'until': - return $this->setEndDate($first, $second); + self::setDefaultParameters($parameters, [ + [0, 'date', null], + ]); + + return $this->setEndDate(...$parameters); case 'untilNow': - return $this->setEndDate(new Carbon(), $first); + return $this->setEndDate(new Carbon(), ...$parameters); case 'dates': case 'between': - return $this->setDates($first, $second); + self::setDefaultParameters($parameters, [ + [0, 'start', null], + [1, 'end', null], + ]); + + return $this->setDates(...$parameters); case 'recurrences': case 'times': - return $this->setRecurrences($first); + self::setDefaultParameters($parameters, [ + [0, 'recurrences', null], + ]); + + return $this->setRecurrences(...$parameters); case 'options': - return $this->setOptions($first); + self::setDefaultParameters($parameters, [ + [0, 'options', null], + ]); + + return $this->setOptions(...$parameters); case 'toggle': - return $this->toggleOptions($first, $second); + self::setDefaultParameters($parameters, [ + [0, 'options', null], + ]); + + return $this->toggleOptions(...$parameters); case 'filter': case 'push': - return $this->addFilter($first, $second); + return $this->addFilter(...$parameters); case 'prepend': - return $this->prependFilter($first, $second); + return $this->prependFilter(...$parameters); case 'filters': - return $this->setFilters($first ?: []); + self::setDefaultParameters($parameters, [ + [0, 'filters', []], + ]); + + return $this->setFilters(...$parameters); case 'interval': case 'each': case 'every': case 'step': case 'stepBy': - return $this->setDateInterval($first); + return $this->setDateInterval(...$parameters); case 'invert': return $this->invertDateInterval(); @@ -1696,9 +1808,7 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable return $this->setDateInterval(( // Override default P1D when instantiating via fluent setters. [$this->isDefaultInterval ? new CarbonInterval('PT0S') : $this->dateInterval, $method] - )( - \count($parameters) === 0 ? 1 : $first - )); + )(...$parameters)); } if ($this->localStrictModeEnabled ?? Carbon::isStrictModeEnabled()) { @@ -1717,18 +1827,19 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable */ public function setTimezone($timezone) { - $this->tzName = $timezone; - $this->timezone = $timezone; + $self = $this->copyIfImmutable(); + $self->tzName = $timezone; + $self->timezone = $timezone; - if ($this->startDate) { - $this->setStartDate($this->startDate->setTimezone($timezone)); + if ($self->startDate) { + $self = $self->setStartDate($self->startDate->setTimezone($timezone)); } - if ($this->endDate) { - $this->setEndDate($this->endDate->setTimezone($timezone)); + if ($self->endDate) { + $self = $self->setEndDate($self->endDate->setTimezone($timezone)); } - return $this; + return $self; } /** @@ -1740,18 +1851,19 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable */ public function shiftTimezone($timezone) { - $this->tzName = $timezone; - $this->timezone = $timezone; + $self = $this->copyIfImmutable(); + $self->tzName = $timezone; + $self->timezone = $timezone; - if ($this->startDate) { - $this->setStartDate($this->startDate->shiftTimezone($timezone)); + if ($self->startDate) { + $self = $self->setStartDate($self->startDate->shiftTimezone($timezone)); } - if ($this->endDate) { - $this->setEndDate($this->endDate->shiftTimezone($timezone)); + if ($self->endDate) { + $self = $self->setEndDate($self->endDate->shiftTimezone($timezone)); } - return $this; + return $self; } /** @@ -2130,19 +2242,18 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable * @param float|int|string|\DateInterval|null $precision * @param string $function * - * @return $this + * @return static */ public function roundUnit($unit, $precision = 1, $function = 'round') { - $this->setStartDate($this->getStartDate()->roundUnit($unit, $precision, $function)); + $self = $this->copyIfImmutable(); + $self = $self->setStartDate($self->getStartDate()->roundUnit($unit, $precision, $function)); - if ($this->endDate) { - $this->setEndDate($this->getEndDate()->roundUnit($unit, $precision, $function)); + if ($self->endDate) { + $self = $self->setEndDate($self->getEndDate()->roundUnit($unit, $precision, $function)); } - $this->setDateInterval($this->getDateInterval()->roundUnit($unit, $precision, $function)); - - return $this; + return $self->setDateInterval($self->getDateInterval()->roundUnit($unit, $precision, $function)); } /** @@ -2151,7 +2262,7 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable * @param string $unit * @param float|int|string|\DateInterval|null $precision * - * @return $this + * @return static */ public function floorUnit($unit, $precision = 1) { @@ -2164,7 +2275,7 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable * @param string $unit * @param float|int|string|\DateInterval|null $precision * - * @return $this + * @return static */ public function ceilUnit($unit, $precision = 1) { @@ -2177,7 +2288,7 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable * @param float|int|string|\DateInterval|null $precision * @param string $function * - * @return $this + * @return static */ public function round($precision = null, $function = 'round') { @@ -2192,7 +2303,7 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable * * @param float|int|string|\DateInterval|null $precision * - * @return $this + * @return static */ public function floor($precision = null) { @@ -2204,7 +2315,7 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable * * @param float|int|string|\DateInterval|null $precision * - * @return $this + * @return static */ public function ceil($precision = null) { @@ -2393,9 +2504,9 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable protected function handleChangedParameters() { if (($this->getOptions() & static::IMMUTABLE) && $this->dateClass === Carbon::class) { - $this->setDateClass(CarbonImmutable::class); + $this->dateClass = CarbonImmutable::class; } elseif (!($this->getOptions() & static::IMMUTABLE) && $this->dateClass === CarbonImmutable::class) { - $this->setDateClass(Carbon::class); + $this->dateClass = Carbon::class; } $this->validationResult = null; @@ -2555,9 +2666,9 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable if (\is_string($value)) { $value = trim($value); - if (!preg_match('/^P[0-9T]/', $value) && - !preg_match('/^R[0-9]/', $value) && - preg_match('/[a-z0-9]/i', $value) + if (!preg_match('/^P[\dT]/', $value) && + !preg_match('/^R\d/', $value) && + preg_match('/[a-z\d]/i', $value) ) { return Carbon::parse($value, $this->tzName); } @@ -2565,4 +2676,39 @@ class CarbonPeriod implements Iterator, Countable, JsonSerializable return null; } + + private function isInfiniteDate($date): bool + { + return $date instanceof CarbonInterface && ($date->isEndOfTime() || $date->isStartOfTime()); + } + + private function rawDate($date): ?DateTimeInterface + { + if ($date === false || $date === null) { + return null; + } + + if ($date instanceof CarbonInterface) { + return $date->isMutable() + ? $date->toDateTime() + : $date->toDateTimeImmutable(); + } + + if (\in_array(\get_class($date), [DateTime::class, DateTimeImmutable::class], true)) { + return $date; + } + + $class = $date instanceof DateTime ? DateTime::class : DateTimeImmutable::class; + + return new $class($date->format('Y-m-d H:i:s.u'), $date->getTimezone()); + } + + private static function setDefaultParameters(array &$parameters, array $defaults): void + { + foreach ($defaults as [$index, $name, $value]) { + if (!\array_key_exists($index, $parameters) && !\array_key_exists($name, $parameters)) { + $parameters[$index] = $value; + } + } + } } diff --git a/vendor/nesbot/carbon/src/Carbon/CarbonPeriodImmutable.php b/vendor/nesbot/carbon/src/Carbon/CarbonPeriodImmutable.php new file mode 100644 index 0000000..cda0733 --- /dev/null +++ b/vendor/nesbot/carbon/src/Carbon/CarbonPeriodImmutable.php @@ -0,0 +1,33 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Carbon; + +class CarbonPeriodImmutable extends CarbonPeriod +{ + /** + * Date class of iteration items. + * + * @var string + */ + protected $dateClass = CarbonImmutable::class; + + /** + * Prepare the instance to be set (self if mutable to be mutated, + * copy if immutable to generate a new instance). + * + * @return static + */ + protected function copyIfImmutable() + { + return $this->constructed ? clone $this : $this; + } +} diff --git a/vendor/nesbot/carbon/src/Carbon/CarbonTimeZone.php b/vendor/nesbot/carbon/src/Carbon/CarbonTimeZone.php index b4d16ba..c81899f 100644 --- a/vendor/nesbot/carbon/src/Carbon/CarbonTimeZone.php +++ b/vendor/nesbot/carbon/src/Carbon/CarbonTimeZone.php @@ -30,7 +30,7 @@ class CarbonTimeZone extends DateTimeZone throw new InvalidTimeZoneException('Absolute timezone offset cannot be greater than 100.'); } - return ($timezone >= 0 ? '+' : '').$timezone.':00'; + return ($timezone >= 0 ? '+' : '').ltrim($timezone, '+').':00'; } protected static function getDateTimeZoneNameFromMixed($timezone) @@ -101,15 +101,15 @@ class CarbonTimeZone extends DateTimeZone $tz = static::getDateTimeZoneFromName($object); } - if ($tz === false) { - if (Carbon::isStrictModeEnabled()) { - throw new InvalidTimeZoneException('Unknown or bad timezone ('.($objectDump ?: $object).')'); - } - - return false; + if ($tz !== false) { + return new static($tz->getName()); } - return new static($tz->getName()); + if (Carbon::isStrictModeEnabled()) { + throw new InvalidTimeZoneException('Unknown or bad timezone ('.($objectDump ?: $object).')'); + } + + return false; } /** @@ -231,15 +231,15 @@ class CarbonTimeZone extends DateTimeZone { $tz = $this->toRegionName($date); - if ($tz === false) { - if (Carbon::isStrictModeEnabled()) { - throw new InvalidTimeZoneException('Unknown timezone for offset '.$this->getOffset($date ?: Carbon::now($this)).' seconds.'); - } - - return false; + if ($tz !== false) { + return new static($tz); } - return new static($tz); + if (Carbon::isStrictModeEnabled()) { + throw new InvalidTimeZoneException('Unknown timezone for offset '.$this->getOffset($date ?: Carbon::now($this)).' seconds.'); + } + + return false; } /** @@ -252,6 +252,18 @@ class CarbonTimeZone extends DateTimeZone return $this->getName(); } + /** + * Return the type number: + * + * Type 1; A UTC offset, such as -0300 + * Type 2; A timezone abbreviation, such as GMT + * Type 3: A timezone identifier, such as Europe/London + */ + public function getType(): int + { + return preg_match('/"timezone_type";i:(\d)/', serialize($this), $match) ? (int) $match[1] : 3; + } + /** * Create a CarbonTimeZone from mixed input. * diff --git a/vendor/nesbot/carbon/src/Carbon/Exceptions/BadComparisonUnitException.php b/vendor/nesbot/carbon/src/Carbon/Exceptions/BadComparisonUnitException.php index b3a0871..3ca8837 100644 --- a/vendor/nesbot/carbon/src/Carbon/Exceptions/BadComparisonUnitException.php +++ b/vendor/nesbot/carbon/src/Carbon/Exceptions/BadComparisonUnitException.php @@ -11,19 +11,38 @@ namespace Carbon\Exceptions; -use Exception; +use Throwable; class BadComparisonUnitException extends UnitException { + /** + * The unit. + * + * @var string + */ + protected $unit; + /** * Constructor. * * @param string $unit * @param int $code - * @param Exception|null $previous + * @param Throwable|null $previous */ - public function __construct($unit, $code = 0, Exception $previous = null) + public function __construct($unit, $code = 0, Throwable $previous = null) { + $this->unit = $unit; + parent::__construct("Bad comparison unit: '$unit'", $code, $previous); } + + /** + * Get the unit. + * + * @return string + */ + public function getUnit(): string + { + return $this->unit; + } } diff --git a/vendor/nesbot/carbon/src/Carbon/Exceptions/BadFluentConstructorException.php b/vendor/nesbot/carbon/src/Carbon/Exceptions/BadFluentConstructorException.php index d5cd556..2e222e5 100644 --- a/vendor/nesbot/carbon/src/Carbon/Exceptions/BadFluentConstructorException.php +++ b/vendor/nesbot/carbon/src/Carbon/Exceptions/BadFluentConstructorException.php @@ -12,19 +12,38 @@ namespace Carbon\Exceptions; use BadMethodCallException as BaseBadMethodCallException; -use Exception; +use Throwable; class BadFluentConstructorException extends BaseBadMethodCallException implements BadMethodCallException { + /** + * The method. + * + * @var string + */ + protected $method; + /** * Constructor. * * @param string $method * @param int $code - * @param Exception|null $previous + * @param Throwable|null $previous */ - public function __construct($method, $code = 0, Exception $previous = null) + public function __construct($method, $code = 0, Throwable $previous = null) { + $this->method = $method; + parent::__construct(sprintf("Unknown fluent constructor '%s'.", $method), $code, $previous); } + + /** + * Get the method. + * + * @return string + */ + public function getMethod(): string + { + return $this->method; + } } diff --git a/vendor/nesbot/carbon/src/Carbon/Exceptions/BadFluentSetterException.php b/vendor/nesbot/carbon/src/Carbon/Exceptions/BadFluentSetterException.php index 1d7ec54..4ceaa2e 100644 --- a/vendor/nesbot/carbon/src/Carbon/Exceptions/BadFluentSetterException.php +++ b/vendor/nesbot/carbon/src/Carbon/Exceptions/BadFluentSetterException.php @@ -12,19 +12,38 @@ namespace Carbon\Exceptions; use BadMethodCallException as BaseBadMethodCallException; -use Exception; +use Throwable; class BadFluentSetterException extends BaseBadMethodCallException implements BadMethodCallException { + /** + * The setter. + * + * @var string + */ + protected $setter; + /** * Constructor. * - * @param string $method + * @param string $setter * @param int $code - * @param Exception|null $previous + * @param Throwable|null $previous */ - public function __construct($method, $code = 0, Exception $previous = null) + public function __construct($setter, $code = 0, Throwable $previous = null) { - parent::__construct(sprintf("Unknown fluent setter '%s'", $method), $code, $previous); + $this->setter = $setter; + + parent::__construct(sprintf("Unknown fluent setter '%s'", $setter), $code, $previous); + } + + /** + * Get the setter. + * + * @return string + */ + public function getSetter(): string + { + return $this->setter; } } diff --git a/vendor/nesbot/carbon/src/Carbon/Exceptions/BadMethodCallException.php b/vendor/nesbot/carbon/src/Carbon/Exceptions/BadMethodCallException.php index 73c2dd8..108206d 100644 --- a/vendor/nesbot/carbon/src/Carbon/Exceptions/BadMethodCallException.php +++ b/vendor/nesbot/carbon/src/Carbon/Exceptions/BadMethodCallException.php @@ -13,4 +13,5 @@ namespace Carbon\Exceptions; interface BadMethodCallException extends Exception { + // } diff --git a/vendor/nesbot/carbon/src/Carbon/Exceptions/EndLessPeriodException.php b/vendor/nesbot/carbon/src/Carbon/Exceptions/EndLessPeriodException.php new file mode 100644 index 0000000..e104926 --- /dev/null +++ b/vendor/nesbot/carbon/src/Carbon/Exceptions/EndLessPeriodException.php @@ -0,0 +1,19 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Carbon\Exceptions; + +use RuntimeException as BaseRuntimeException; + +final class EndLessPeriodException extends BaseRuntimeException implements RuntimeException +{ + // +} diff --git a/vendor/nesbot/carbon/src/Carbon/Exceptions/Exception.php b/vendor/nesbot/carbon/src/Carbon/Exceptions/Exception.php index 3bbbd77..8ad747e 100644 --- a/vendor/nesbot/carbon/src/Carbon/Exceptions/Exception.php +++ b/vendor/nesbot/carbon/src/Carbon/Exceptions/Exception.php @@ -13,4 +13,5 @@ namespace Carbon\Exceptions; interface Exception { + // } diff --git a/vendor/nesbot/carbon/src/Carbon/Exceptions/ImmutableException.php b/vendor/nesbot/carbon/src/Carbon/Exceptions/ImmutableException.php index a48d4f9..db334c6 100644 --- a/vendor/nesbot/carbon/src/Carbon/Exceptions/ImmutableException.php +++ b/vendor/nesbot/carbon/src/Carbon/Exceptions/ImmutableException.php @@ -11,20 +11,38 @@ namespace Carbon\Exceptions; -use Exception; use RuntimeException as BaseRuntimeException; +use Throwable; class ImmutableException extends BaseRuntimeException implements RuntimeException { + /** + * The value. + * + * @var string + */ + protected $value; + /** * Constructor. * * @param string $value the immutable type/value * @param int $code - * @param Exception|null $previous + * @param Throwable|null $previous */ - public function __construct($value, $code = 0, Exception $previous = null) + public function __construct($value, $code = 0, Throwable $previous = null) { + $this->value = $value; parent::__construct("$value is immutable.", $code, $previous); } + + /** + * Get the value. + * + * @return string + */ + public function getValue(): string + { + return $this->value; + } } diff --git a/vendor/nesbot/carbon/src/Carbon/Exceptions/InvalidArgumentException.php b/vendor/nesbot/carbon/src/Carbon/Exceptions/InvalidArgumentException.php index 9739f4d..5b013cd 100644 --- a/vendor/nesbot/carbon/src/Carbon/Exceptions/InvalidArgumentException.php +++ b/vendor/nesbot/carbon/src/Carbon/Exceptions/InvalidArgumentException.php @@ -13,4 +13,5 @@ namespace Carbon\Exceptions; interface InvalidArgumentException extends Exception { + // } diff --git a/vendor/nesbot/carbon/src/Carbon/Exceptions/InvalidCastException.php b/vendor/nesbot/carbon/src/Carbon/Exceptions/InvalidCastException.php index d2f3701..a421401 100644 --- a/vendor/nesbot/carbon/src/Carbon/Exceptions/InvalidCastException.php +++ b/vendor/nesbot/carbon/src/Carbon/Exceptions/InvalidCastException.php @@ -11,20 +11,9 @@ namespace Carbon\Exceptions; -use Exception; use InvalidArgumentException as BaseInvalidArgumentException; class InvalidCastException extends BaseInvalidArgumentException implements InvalidArgumentException { - /** - * Constructor. - * - * @param string $message - * @param int $code - * @param Exception|null $previous - */ - public function __construct($message, $code = 0, Exception $previous = null) - { - parent::__construct($message, $code, $previous); - } + // } diff --git a/vendor/nesbot/carbon/src/Carbon/Exceptions/InvalidDateException.php b/vendor/nesbot/carbon/src/Carbon/Exceptions/InvalidDateException.php index 99bb91c..c9ecb6b 100644 --- a/vendor/nesbot/carbon/src/Carbon/Exceptions/InvalidDateException.php +++ b/vendor/nesbot/carbon/src/Carbon/Exceptions/InvalidDateException.php @@ -11,8 +11,8 @@ namespace Carbon\Exceptions; -use Exception; use InvalidArgumentException as BaseInvalidArgumentException; +use Throwable; class InvalidDateException extends BaseInvalidArgumentException implements InvalidArgumentException { @@ -36,9 +36,9 @@ class InvalidDateException extends BaseInvalidArgumentException implements Inval * @param string $field * @param mixed $value * @param int $code - * @param Exception|null $previous + * @param Throwable|null $previous */ - public function __construct($field, $value, $code = 0, Exception $previous = null) + public function __construct($field, $value, $code = 0, Throwable $previous = null) { $this->field = $field; $this->value = $value; diff --git a/vendor/nesbot/carbon/src/Carbon/Exceptions/InvalidFormatException.php b/vendor/nesbot/carbon/src/Carbon/Exceptions/InvalidFormatException.php index 3341b49..92d55fe 100644 --- a/vendor/nesbot/carbon/src/Carbon/Exceptions/InvalidFormatException.php +++ b/vendor/nesbot/carbon/src/Carbon/Exceptions/InvalidFormatException.php @@ -11,20 +11,9 @@ namespace Carbon\Exceptions; -use Exception; use InvalidArgumentException as BaseInvalidArgumentException; class InvalidFormatException extends BaseInvalidArgumentException implements InvalidArgumentException { - /** - * Constructor. - * - * @param string $message - * @param int $code - * @param Exception|null $previous - */ - public function __construct($message, $code = 0, Exception $previous = null) - { - parent::__construct($message, $code, $previous); - } + // } diff --git a/vendor/nesbot/carbon/src/Carbon/Exceptions/InvalidIntervalException.php b/vendor/nesbot/carbon/src/Carbon/Exceptions/InvalidIntervalException.php index 5f9f142..69cf412 100644 --- a/vendor/nesbot/carbon/src/Carbon/Exceptions/InvalidIntervalException.php +++ b/vendor/nesbot/carbon/src/Carbon/Exceptions/InvalidIntervalException.php @@ -11,20 +11,9 @@ namespace Carbon\Exceptions; -use Exception; use InvalidArgumentException as BaseInvalidArgumentException; class InvalidIntervalException extends BaseInvalidArgumentException implements InvalidArgumentException { - /** - * Constructor. - * - * @param string $message - * @param int $code - * @param Exception|null $previous - */ - public function __construct($message, $code = 0, Exception $previous = null) - { - parent::__construct($message, $code, $previous); - } + // } diff --git a/vendor/nesbot/carbon/src/Carbon/Exceptions/InvalidPeriodDateException.php b/vendor/nesbot/carbon/src/Carbon/Exceptions/InvalidPeriodDateException.php index a37e3f5..9bd84a9 100644 --- a/vendor/nesbot/carbon/src/Carbon/Exceptions/InvalidPeriodDateException.php +++ b/vendor/nesbot/carbon/src/Carbon/Exceptions/InvalidPeriodDateException.php @@ -11,20 +11,9 @@ namespace Carbon\Exceptions; -use Exception; use InvalidArgumentException as BaseInvalidArgumentException; class InvalidPeriodDateException extends BaseInvalidArgumentException implements InvalidArgumentException { - /** - * Constructor. - * - * @param string $message - * @param int $code - * @param Exception|null $previous - */ - public function __construct($message, $code = 0, Exception $previous = null) - { - parent::__construct($message, $code, $previous); - } + // } diff --git a/vendor/nesbot/carbon/src/Carbon/Exceptions/InvalidPeriodParameterException.php b/vendor/nesbot/carbon/src/Carbon/Exceptions/InvalidPeriodParameterException.php index ede4771..cf2c902 100644 --- a/vendor/nesbot/carbon/src/Carbon/Exceptions/InvalidPeriodParameterException.php +++ b/vendor/nesbot/carbon/src/Carbon/Exceptions/InvalidPeriodParameterException.php @@ -11,20 +11,9 @@ namespace Carbon\Exceptions; -use Exception; use InvalidArgumentException as BaseInvalidArgumentException; class InvalidPeriodParameterException extends BaseInvalidArgumentException implements InvalidArgumentException { - /** - * Constructor. - * - * @param string $message - * @param int $code - * @param Exception|null $previous - */ - public function __construct($message, $code = 0, Exception $previous = null) - { - parent::__construct($message, $code, $previous); - } + // } diff --git a/vendor/nesbot/carbon/src/Carbon/Exceptions/InvalidTimeZoneException.php b/vendor/nesbot/carbon/src/Carbon/Exceptions/InvalidTimeZoneException.php index 892e16e..f725955 100644 --- a/vendor/nesbot/carbon/src/Carbon/Exceptions/InvalidTimeZoneException.php +++ b/vendor/nesbot/carbon/src/Carbon/Exceptions/InvalidTimeZoneException.php @@ -11,20 +11,9 @@ namespace Carbon\Exceptions; -use Exception; use InvalidArgumentException as BaseInvalidArgumentException; class InvalidTimeZoneException extends BaseInvalidArgumentException implements InvalidArgumentException { - /** - * Constructor. - * - * @param string $message - * @param int $code - * @param Exception|null $previous - */ - public function __construct($message, $code = 0, Exception $previous = null) - { - parent::__construct($message, $code, $previous); - } + // } diff --git a/vendor/nesbot/carbon/src/Carbon/Exceptions/InvalidTypeException.php b/vendor/nesbot/carbon/src/Carbon/Exceptions/InvalidTypeException.php index 3fbe3fc..2c8ec9b 100644 --- a/vendor/nesbot/carbon/src/Carbon/Exceptions/InvalidTypeException.php +++ b/vendor/nesbot/carbon/src/Carbon/Exceptions/InvalidTypeException.php @@ -11,20 +11,9 @@ namespace Carbon\Exceptions; -use Exception; use InvalidArgumentException as BaseInvalidArgumentException; class InvalidTypeException extends BaseInvalidArgumentException implements InvalidArgumentException { - /** - * Constructor. - * - * @param string $message - * @param int $code - * @param Exception|null $previous - */ - public function __construct($message, $code = 0, Exception $previous = null) - { - parent::__construct($message, $code, $previous); - } + // } diff --git a/vendor/nesbot/carbon/src/Carbon/Exceptions/NotACarbonClassException.php b/vendor/nesbot/carbon/src/Carbon/Exceptions/NotACarbonClassException.php index 2b4c48e..7a87632 100644 --- a/vendor/nesbot/carbon/src/Carbon/Exceptions/NotACarbonClassException.php +++ b/vendor/nesbot/carbon/src/Carbon/Exceptions/NotACarbonClassException.php @@ -12,24 +12,39 @@ namespace Carbon\Exceptions; use Carbon\CarbonInterface; -use Exception; use InvalidArgumentException as BaseInvalidArgumentException; +use Throwable; class NotACarbonClassException extends BaseInvalidArgumentException implements InvalidArgumentException { + /** + * The className. + * + * @var string + */ + protected $className; + /** * Constructor. * * @param string $className * @param int $code - * @param Exception|null $previous + * @param Throwable|null $previous */ - public function __construct($className, $code = 0, Exception $previous = null) + public function __construct($className, $code = 0, Throwable $previous = null) { - parent::__construct(sprintf( - 'Given class does not implement %s: %s', - CarbonInterface::class, - $className - ), $code, $previous); + $this->className = $className; + + parent::__construct(sprintf('Given class does not implement %s: %s', CarbonInterface::class, $className), $code, $previous); + } + + /** + * Get the className. + * + * @return string + */ + public function getClassName(): string + { + return $this->className; } } diff --git a/vendor/nesbot/carbon/src/Carbon/Exceptions/NotAPeriodException.php b/vendor/nesbot/carbon/src/Carbon/Exceptions/NotAPeriodException.php index 41bb629..4edd7a4 100644 --- a/vendor/nesbot/carbon/src/Carbon/Exceptions/NotAPeriodException.php +++ b/vendor/nesbot/carbon/src/Carbon/Exceptions/NotAPeriodException.php @@ -11,20 +11,9 @@ namespace Carbon\Exceptions; -use Exception; use InvalidArgumentException as BaseInvalidArgumentException; class NotAPeriodException extends BaseInvalidArgumentException implements InvalidArgumentException { - /** - * Constructor. - * - * @param string $message - * @param int $code - * @param Exception|null $previous - */ - public function __construct($message, $code = 0, Exception $previous = null) - { - parent::__construct($message, $code, $previous); - } + // } diff --git a/vendor/nesbot/carbon/src/Carbon/Exceptions/NotLocaleAwareException.php b/vendor/nesbot/carbon/src/Carbon/Exceptions/NotLocaleAwareException.php index adbc36c..f2c5468 100644 --- a/vendor/nesbot/carbon/src/Carbon/Exceptions/NotLocaleAwareException.php +++ b/vendor/nesbot/carbon/src/Carbon/Exceptions/NotLocaleAwareException.php @@ -11,8 +11,8 @@ namespace Carbon\Exceptions; -use Exception; use InvalidArgumentException as BaseInvalidArgumentException; +use Throwable; class NotLocaleAwareException extends BaseInvalidArgumentException implements InvalidArgumentException { @@ -21,9 +21,9 @@ class NotLocaleAwareException extends BaseInvalidArgumentException implements In * * @param mixed $object * @param int $code - * @param Exception|null $previous + * @param Throwable|null $previous */ - public function __construct($object, $code = 0, Exception $previous = null) + public function __construct($object, $code = 0, Throwable $previous = null) { $dump = \is_object($object) ? \get_class($object) : \gettype($object); diff --git a/vendor/nesbot/carbon/src/Carbon/Exceptions/OutOfRangeException.php b/vendor/nesbot/carbon/src/Carbon/Exceptions/OutOfRangeException.php index 54822d9..2c586d0 100644 --- a/vendor/nesbot/carbon/src/Carbon/Exceptions/OutOfRangeException.php +++ b/vendor/nesbot/carbon/src/Carbon/Exceptions/OutOfRangeException.php @@ -11,8 +11,8 @@ namespace Carbon\Exceptions; -use Exception; use InvalidArgumentException as BaseInvalidArgumentException; +use Throwable; // This will extends OutOfRangeException instead of InvalidArgumentException since 3.0.0 // use OutOfRangeException as BaseOutOfRangeException; @@ -55,9 +55,9 @@ class OutOfRangeException extends BaseInvalidArgumentException implements Invali * @param mixed $max * @param mixed $value * @param int $code - * @param Exception|null $previous + * @param Throwable|null $previous */ - public function __construct($unit, $min, $max, $value, $code = 0, Exception $previous = null) + public function __construct($unit, $min, $max, $value, $code = 0, Throwable $previous = null) { $this->unit = $unit; $this->min = $min; diff --git a/vendor/nesbot/carbon/src/Carbon/Exceptions/ParseErrorException.php b/vendor/nesbot/carbon/src/Carbon/Exceptions/ParseErrorException.php index 0314c5d..5416fd1 100644 --- a/vendor/nesbot/carbon/src/Carbon/Exceptions/ParseErrorException.php +++ b/vendor/nesbot/carbon/src/Carbon/Exceptions/ParseErrorException.php @@ -11,23 +11,78 @@ namespace Carbon\Exceptions; -use Exception; use InvalidArgumentException as BaseInvalidArgumentException; +use Throwable; class ParseErrorException extends BaseInvalidArgumentException implements InvalidArgumentException { + /** + * The expected. + * + * @var string + */ + protected $expected; + + /** + * The actual. + * + * @var string + */ + protected $actual; + + /** + * The help message. + * + * @var string + */ + protected $help; + /** * Constructor. * * @param string $expected * @param string $actual * @param int $code - * @param Exception|null $previous + * @param Throwable|null $previous */ - public function __construct($expected, $actual, $help = '', $code = 0, Exception $previous = null) + public function __construct($expected, $actual, $help = '', $code = 0, Throwable $previous = null) { + $this->expected = $expected; + $this->actual = $actual; + $this->help = $help; + $actual = $actual === '' ? 'data is missing' : "get '$actual'"; parent::__construct(trim("Format expected $expected but $actual\n$help"), $code, $previous); } + + /** + * Get the expected. + * + * @return string + */ + public function getExpected(): string + { + return $this->expected; + } + + /** + * Get the actual. + * + * @return string + */ + public function getActual(): string + { + return $this->actual; + } + + /** + * Get the help message. + * + * @return string + */ + public function getHelp(): string + { + return $this->help; + } } diff --git a/vendor/nesbot/carbon/src/Carbon/Exceptions/RuntimeException.php b/vendor/nesbot/carbon/src/Carbon/Exceptions/RuntimeException.php index 24bf5a6..ad196f7 100644 --- a/vendor/nesbot/carbon/src/Carbon/Exceptions/RuntimeException.php +++ b/vendor/nesbot/carbon/src/Carbon/Exceptions/RuntimeException.php @@ -13,4 +13,5 @@ namespace Carbon\Exceptions; interface RuntimeException extends Exception { + // } diff --git a/vendor/nesbot/carbon/src/Carbon/Exceptions/UnitException.php b/vendor/nesbot/carbon/src/Carbon/Exceptions/UnitException.php index 8bd8653..ee99953 100644 --- a/vendor/nesbot/carbon/src/Carbon/Exceptions/UnitException.php +++ b/vendor/nesbot/carbon/src/Carbon/Exceptions/UnitException.php @@ -11,20 +11,9 @@ namespace Carbon\Exceptions; -use Exception; use InvalidArgumentException as BaseInvalidArgumentException; class UnitException extends BaseInvalidArgumentException implements InvalidArgumentException { - /** - * Constructor. - * - * @param string $message - * @param int $code - * @param Exception|null $previous - */ - public function __construct($message, $code = 0, Exception $previous = null) - { - parent::__construct($message, $code, $previous); - } + // } diff --git a/vendor/nesbot/carbon/src/Carbon/Exceptions/UnitNotConfiguredException.php b/vendor/nesbot/carbon/src/Carbon/Exceptions/UnitNotConfiguredException.php index 39ee12c..0e72305 100644 --- a/vendor/nesbot/carbon/src/Carbon/Exceptions/UnitNotConfiguredException.php +++ b/vendor/nesbot/carbon/src/Carbon/Exceptions/UnitNotConfiguredException.php @@ -11,19 +11,38 @@ namespace Carbon\Exceptions; -use Exception; +use Throwable; class UnitNotConfiguredException extends UnitException { + /** + * The unit. + * + * @var string + */ + protected $unit; + /** * Constructor. * * @param string $unit * @param int $code - * @param Exception|null $previous + * @param Throwable|null $previous */ - public function __construct($unit, $code = 0, Exception $previous = null) + public function __construct($unit, $code = 0, Throwable $previous = null) { + $this->unit = $unit; + parent::__construct("Unit $unit have no configuration to get total from other units.", $code, $previous); } + + /** + * Get the unit. + * + * @return string + */ + public function getUnit(): string + { + return $this->unit; + } } diff --git a/vendor/nesbot/carbon/src/Carbon/Exceptions/UnknownGetterException.php b/vendor/nesbot/carbon/src/Carbon/Exceptions/UnknownGetterException.php index 6c8c01b..5c50497 100644 --- a/vendor/nesbot/carbon/src/Carbon/Exceptions/UnknownGetterException.php +++ b/vendor/nesbot/carbon/src/Carbon/Exceptions/UnknownGetterException.php @@ -11,20 +11,39 @@ namespace Carbon\Exceptions; -use Exception; use InvalidArgumentException as BaseInvalidArgumentException; +use Throwable; class UnknownGetterException extends BaseInvalidArgumentException implements InvalidArgumentException { + /** + * The getter. + * + * @var string + */ + protected $getter; + /** * Constructor. * - * @param string $name getter name + * @param string $getter getter name * @param int $code - * @param Exception|null $previous + * @param Throwable|null $previous */ - public function __construct($name, $code = 0, Exception $previous = null) + public function __construct($getter, $code = 0, Throwable $previous = null) { - parent::__construct("Unknown getter '$name'", $code, $previous); + $this->getter = $getter; + + parent::__construct("Unknown getter '$getter'", $code, $previous); + } + + /** + * Get the getter. + * + * @return string + */ + public function getGetter(): string + { + return $this->getter; } } diff --git a/vendor/nesbot/carbon/src/Carbon/Exceptions/UnknownMethodException.php b/vendor/nesbot/carbon/src/Carbon/Exceptions/UnknownMethodException.php index 901db98..75273a7 100644 --- a/vendor/nesbot/carbon/src/Carbon/Exceptions/UnknownMethodException.php +++ b/vendor/nesbot/carbon/src/Carbon/Exceptions/UnknownMethodException.php @@ -12,19 +12,38 @@ namespace Carbon\Exceptions; use BadMethodCallException as BaseBadMethodCallException; -use Exception; +use Throwable; class UnknownMethodException extends BaseBadMethodCallException implements BadMethodCallException { + /** + * The method. + * + * @var string + */ + protected $method; + /** * Constructor. * * @param string $method * @param int $code - * @param Exception|null $previous + * @param Throwable|null $previous */ - public function __construct($method, $code = 0, Exception $previous = null) + public function __construct($method, $code = 0, Throwable $previous = null) { + $this->method = $method; + parent::__construct("Method $method does not exist.", $code, $previous); } + + /** + * Get the method. + * + * @return string + */ + public function getMethod(): string + { + return $this->method; + } } diff --git a/vendor/nesbot/carbon/src/Carbon/Exceptions/UnknownSetterException.php b/vendor/nesbot/carbon/src/Carbon/Exceptions/UnknownSetterException.php index c9e9c9f..a795f5d 100644 --- a/vendor/nesbot/carbon/src/Carbon/Exceptions/UnknownSetterException.php +++ b/vendor/nesbot/carbon/src/Carbon/Exceptions/UnknownSetterException.php @@ -11,20 +11,39 @@ namespace Carbon\Exceptions; -use Exception; use InvalidArgumentException as BaseInvalidArgumentException; +use Throwable; class UnknownSetterException extends BaseInvalidArgumentException implements BadMethodCallException { + /** + * The setter. + * + * @var string + */ + protected $setter; + /** * Constructor. * - * @param string $name setter name + * @param string $setter setter name * @param int $code - * @param Exception|null $previous + * @param Throwable|null $previous */ - public function __construct($name, $code = 0, Exception $previous = null) + public function __construct($setter, $code = 0, Throwable $previous = null) { - parent::__construct("Unknown setter '$name'", $code, $previous); + $this->setter = $setter; + + parent::__construct("Unknown setter '$setter'", $code, $previous); + } + + /** + * Get the setter. + * + * @return string + */ + public function getSetter(): string + { + return $this->setter; } } diff --git a/vendor/nesbot/carbon/src/Carbon/Exceptions/UnknownUnitException.php b/vendor/nesbot/carbon/src/Carbon/Exceptions/UnknownUnitException.php index d965c82..ecd7f7a 100644 --- a/vendor/nesbot/carbon/src/Carbon/Exceptions/UnknownUnitException.php +++ b/vendor/nesbot/carbon/src/Carbon/Exceptions/UnknownUnitException.php @@ -11,19 +11,38 @@ namespace Carbon\Exceptions; -use Exception; +use Throwable; class UnknownUnitException extends UnitException { + /** + * The unit. + * + * @var string + */ + protected $unit; + /** * Constructor. * * @param string $unit * @param int $code - * @param Exception|null $previous + * @param Throwable|null $previous */ - public function __construct($unit, $code = 0, Exception $previous = null) + public function __construct($unit, $code = 0, Throwable $previous = null) { + $this->unit = $unit; + parent::__construct("Unknown unit '$unit'.", $code, $previous); } + + /** + * Get the unit. + * + * @return string + */ + public function getUnit(): string + { + return $this->unit; + } } diff --git a/vendor/nesbot/carbon/src/Carbon/Exceptions/UnreachableException.php b/vendor/nesbot/carbon/src/Carbon/Exceptions/UnreachableException.php index 6f8b39f..1654ab1 100644 --- a/vendor/nesbot/carbon/src/Carbon/Exceptions/UnreachableException.php +++ b/vendor/nesbot/carbon/src/Carbon/Exceptions/UnreachableException.php @@ -11,20 +11,9 @@ namespace Carbon\Exceptions; -use Exception; use RuntimeException as BaseRuntimeException; class UnreachableException extends BaseRuntimeException implements RuntimeException { - /** - * Constructor. - * - * @param string $message - * @param int $code - * @param Exception|null $previous - */ - public function __construct($message, $code = 0, Exception $previous = null) - { - parent::__construct($message, $code, $previous); - } + // } diff --git a/vendor/nesbot/carbon/src/Carbon/Factory.php b/vendor/nesbot/carbon/src/Carbon/Factory.php index f8c7289..a4a496c 100644 --- a/vendor/nesbot/carbon/src/Carbon/Factory.php +++ b/vendor/nesbot/carbon/src/Carbon/Factory.php @@ -177,10 +177,10 @@ use ReflectionMethod; * parameter of null. * /!\ Use this method for unit tests only. * @method void setToStringFormat($format) @deprecated To avoid conflict between different third-party libraries, static setters should not be used. - * You should rather let Carbon object being casted to string with DEFAULT_TO_STRING_FORMAT, and - * use other method or custom format passed to format() method if you need to dump an other string + * You should rather let Carbon object being cast to string with DEFAULT_TO_STRING_FORMAT, and + * use other method or custom format passed to format() method if you need to dump another string * format. - * Set the default format used when type juggling a Carbon instance to a string + * Set the default format used when type juggling a Carbon instance to a string. * @method void setTranslator(TranslatorInterface $translator) Set the default translator instance to use. * @method Carbon setUtf8($utf8) @deprecated To avoid conflict between different third-party libraries, static setters should not be used. * You should rather use UTF-8 language packages on every machine. diff --git a/vendor/nesbot/carbon/src/Carbon/FactoryImmutable.php b/vendor/nesbot/carbon/src/Carbon/FactoryImmutable.php index 596ee80..67088f2 100644 --- a/vendor/nesbot/carbon/src/Carbon/FactoryImmutable.php +++ b/vendor/nesbot/carbon/src/Carbon/FactoryImmutable.php @@ -175,10 +175,10 @@ use Closure; * parameter of null. * /!\ Use this method for unit tests only. * @method void setToStringFormat($format) @deprecated To avoid conflict between different third-party libraries, static setters should not be used. - * You should rather let Carbon object being casted to string with DEFAULT_TO_STRING_FORMAT, and - * use other method or custom format passed to format() method if you need to dump an other string + * You should rather let Carbon object being cast to string with DEFAULT_TO_STRING_FORMAT, and + * use other method or custom format passed to format() method if you need to dump another string * format. - * Set the default format used when type juggling a Carbon instance to a string + * Set the default format used when type juggling a Carbon instance to a string. * @method void setTranslator(TranslatorInterface $translator) Set the default translator instance to use. * @method CarbonImmutable setUtf8($utf8) @deprecated To avoid conflict between different third-party libraries, static setters should not be used. * You should rather use UTF-8 language packages on every machine. diff --git a/vendor/nesbot/carbon/src/Carbon/Lang/ar_AE.php b/vendor/nesbot/carbon/src/Carbon/Lang/ar_AE.php index 75fe47f..35a22b1 100644 --- a/vendor/nesbot/carbon/src/Carbon/Lang/ar_AE.php +++ b/vendor/nesbot/carbon/src/Carbon/Lang/ar_AE.php @@ -12,6 +12,7 @@ /* * Authors: * - IBM Globalization Center of Competency, Yamato Software Laboratory bug-glibc-locales@gnu.org + * - Abdullah-Alhariri */ return array_replace_recursive(require __DIR__.'/ar.php', [ 'formats' => [ @@ -24,4 +25,5 @@ return array_replace_recursive(require __DIR__.'/ar.php', [ 'weekdays_min' => ['ح', 'ن', 'ث', 'ر', 'خ', 'ج', 'س'], 'first_day_of_week' => 6, 'day_of_first_week_of_year' => 1, + 'alt_numbers' => ['۰۰', '۰۱', '۰۲', '۰۳', '۰٤', '۰٥', '۰٦', '۰۷', '۰۸', '۰۹', '۱۰', '۱۱', '۱۲', '۱۳', '۱٤', '۱٥', '۱٦', '۱۷', '۱۸', '۱۹', '۲۰', '۲۱', '۲۲', '۲۳', '۲٤', '۲٥', '۲٦', '۲۷', '۲۸', '۲۹', '۳۰', '۳۱', '۳۲', '۳۳', '۳٤', '۳٥', '۳٦', '۳۷', '۳۸', '۳۹', '٤۰', '٤۱', '٤۲', '٤۳', '٤٤', '٤٥', '٤٦', '٤۷', '٤۸', '٤۹', '٥۰', '٥۱', '٥۲', '٥۳', '٥٤', '٥٥', '٥٦', '٥۷', '٥۸', '٥۹', '٦۰', '٦۱', '٦۲', '٦۳', '٦٤', '٦٥', '٦٦', '٦۷', '٦۸', '٦۹', '۷۰', '۷۱', '۷۲', '۷۳', '۷٤', '۷٥', '۷٦', '۷۷', '۷۸', '۷۹', '۸۰', '۸۱', '۸۲', '۸۳', '۸٤', '۸٥', '۸٦', '۸۷', '۸۸', '۸۹', '۹۰', '۹۱', '۹۲', '۹۳', '۹٤', '۹٥', '۹٦', '۹۷', '۹۸', '۹۹'], ]); diff --git a/vendor/nesbot/carbon/src/Carbon/Lang/ar_BH.php b/vendor/nesbot/carbon/src/Carbon/Lang/ar_BH.php index 362009e..3518096 100644 --- a/vendor/nesbot/carbon/src/Carbon/Lang/ar_BH.php +++ b/vendor/nesbot/carbon/src/Carbon/Lang/ar_BH.php @@ -12,6 +12,7 @@ /* * Authors: * - IBM Globalization Center of Competency, Yamato Software Laboratory bug-glibc-locales@gnu.org + * - Abdullah-Alhariri */ return array_replace_recursive(require __DIR__.'/ar.php', [ 'formats' => [ @@ -24,4 +25,5 @@ return array_replace_recursive(require __DIR__.'/ar.php', [ 'weekdays_min' => ['ح', 'ن', 'ث', 'ر', 'خ', 'ج', 'س'], 'first_day_of_week' => 6, 'day_of_first_week_of_year' => 1, + 'alt_numbers' => ['۰۰', '۰۱', '۰۲', '۰۳', '۰٤', '۰٥', '۰٦', '۰۷', '۰۸', '۰۹', '۱۰', '۱۱', '۱۲', '۱۳', '۱٤', '۱٥', '۱٦', '۱۷', '۱۸', '۱۹', '۲۰', '۲۱', '۲۲', '۲۳', '۲٤', '۲٥', '۲٦', '۲۷', '۲۸', '۲۹', '۳۰', '۳۱', '۳۲', '۳۳', '۳٤', '۳٥', '۳٦', '۳۷', '۳۸', '۳۹', '٤۰', '٤۱', '٤۲', '٤۳', '٤٤', '٤٥', '٤٦', '٤۷', '٤۸', '٤۹', '٥۰', '٥۱', '٥۲', '٥۳', '٥٤', '٥٥', '٥٦', '٥۷', '٥۸', '٥۹', '٦۰', '٦۱', '٦۲', '٦۳', '٦٤', '٦٥', '٦٦', '٦۷', '٦۸', '٦۹', '۷۰', '۷۱', '۷۲', '۷۳', '۷٤', '۷٥', '۷٦', '۷۷', '۷۸', '۷۹', '۸۰', '۸۱', '۸۲', '۸۳', '۸٤', '۸٥', '۸٦', '۸۷', '۸۸', '۸۹', '۹۰', '۹۱', '۹۲', '۹۳', '۹٤', '۹٥', '۹٦', '۹۷', '۹۸', '۹۹'], ]); diff --git a/vendor/nesbot/carbon/src/Carbon/Lang/ar_EG.php b/vendor/nesbot/carbon/src/Carbon/Lang/ar_EG.php index 362009e..3518096 100644 --- a/vendor/nesbot/carbon/src/Carbon/Lang/ar_EG.php +++ b/vendor/nesbot/carbon/src/Carbon/Lang/ar_EG.php @@ -12,6 +12,7 @@ /* * Authors: * - IBM Globalization Center of Competency, Yamato Software Laboratory bug-glibc-locales@gnu.org + * - Abdullah-Alhariri */ return array_replace_recursive(require __DIR__.'/ar.php', [ 'formats' => [ @@ -24,4 +25,5 @@ return array_replace_recursive(require __DIR__.'/ar.php', [ 'weekdays_min' => ['ح', 'ن', 'ث', 'ر', 'خ', 'ج', 'س'], 'first_day_of_week' => 6, 'day_of_first_week_of_year' => 1, + 'alt_numbers' => ['۰۰', '۰۱', '۰۲', '۰۳', '۰٤', '۰٥', '۰٦', '۰۷', '۰۸', '۰۹', '۱۰', '۱۱', '۱۲', '۱۳', '۱٤', '۱٥', '۱٦', '۱۷', '۱۸', '۱۹', '۲۰', '۲۱', '۲۲', '۲۳', '۲٤', '۲٥', '۲٦', '۲۷', '۲۸', '۲۹', '۳۰', '۳۱', '۳۲', '۳۳', '۳٤', '۳٥', '۳٦', '۳۷', '۳۸', '۳۹', '٤۰', '٤۱', '٤۲', '٤۳', '٤٤', '٤٥', '٤٦', '٤۷', '٤۸', '٤۹', '٥۰', '٥۱', '٥۲', '٥۳', '٥٤', '٥٥', '٥٦', '٥۷', '٥۸', '٥۹', '٦۰', '٦۱', '٦۲', '٦۳', '٦٤', '٦٥', '٦٦', '٦۷', '٦۸', '٦۹', '۷۰', '۷۱', '۷۲', '۷۳', '۷٤', '۷٥', '۷٦', '۷۷', '۷۸', '۷۹', '۸۰', '۸۱', '۸۲', '۸۳', '۸٤', '۸٥', '۸٦', '۸۷', '۸۸', '۸۹', '۹۰', '۹۱', '۹۲', '۹۳', '۹٤', '۹٥', '۹٦', '۹۷', '۹۸', '۹۹'], ]); diff --git a/vendor/nesbot/carbon/src/Carbon/Lang/ar_IQ.php b/vendor/nesbot/carbon/src/Carbon/Lang/ar_IQ.php index 0ac0995..2d42008 100644 --- a/vendor/nesbot/carbon/src/Carbon/Lang/ar_IQ.php +++ b/vendor/nesbot/carbon/src/Carbon/Lang/ar_IQ.php @@ -12,6 +12,7 @@ /* * Authors: * - IBM Globalization Center of Competency, Yamato Software Laboratory bug-glibc-locales@gnu.org + * - Abdullah-Alhariri */ return array_replace_recursive(require __DIR__.'/ar.php', [ 'formats' => [ @@ -24,4 +25,5 @@ return array_replace_recursive(require __DIR__.'/ar.php', [ 'weekdays_min' => ['ح', 'ن', 'ث', 'ر', 'خ', 'ج', 'س'], 'first_day_of_week' => 6, 'day_of_first_week_of_year' => 1, + 'alt_numbers' => ['۰۰', '۰۱', '۰۲', '۰۳', '۰٤', '۰٥', '۰٦', '۰۷', '۰۸', '۰۹', '۱۰', '۱۱', '۱۲', '۱۳', '۱٤', '۱٥', '۱٦', '۱۷', '۱۸', '۱۹', '۲۰', '۲۱', '۲۲', '۲۳', '۲٤', '۲٥', '۲٦', '۲۷', '۲۸', '۲۹', '۳۰', '۳۱', '۳۲', '۳۳', '۳٤', '۳٥', '۳٦', '۳۷', '۳۸', '۳۹', '٤۰', '٤۱', '٤۲', '٤۳', '٤٤', '٤٥', '٤٦', '٤۷', '٤۸', '٤۹', '٥۰', '٥۱', '٥۲', '٥۳', '٥٤', '٥٥', '٥٦', '٥۷', '٥۸', '٥۹', '٦۰', '٦۱', '٦۲', '٦۳', '٦٤', '٦٥', '٦٦', '٦۷', '٦۸', '٦۹', '۷۰', '۷۱', '۷۲', '۷۳', '۷٤', '۷٥', '۷٦', '۷۷', '۷۸', '۷۹', '۸۰', '۸۱', '۸۲', '۸۳', '۸٤', '۸٥', '۸٦', '۸۷', '۸۸', '۸۹', '۹۰', '۹۱', '۹۲', '۹۳', '۹٤', '۹٥', '۹٦', '۹۷', '۹۸', '۹۹'], ]); diff --git a/vendor/nesbot/carbon/src/Carbon/Lang/ar_JO.php b/vendor/nesbot/carbon/src/Carbon/Lang/ar_JO.php index 0ac0995..2d42008 100644 --- a/vendor/nesbot/carbon/src/Carbon/Lang/ar_JO.php +++ b/vendor/nesbot/carbon/src/Carbon/Lang/ar_JO.php @@ -12,6 +12,7 @@ /* * Authors: * - IBM Globalization Center of Competency, Yamato Software Laboratory bug-glibc-locales@gnu.org + * - Abdullah-Alhariri */ return array_replace_recursive(require __DIR__.'/ar.php', [ 'formats' => [ @@ -24,4 +25,5 @@ return array_replace_recursive(require __DIR__.'/ar.php', [ 'weekdays_min' => ['ح', 'ن', 'ث', 'ر', 'خ', 'ج', 'س'], 'first_day_of_week' => 6, 'day_of_first_week_of_year' => 1, + 'alt_numbers' => ['۰۰', '۰۱', '۰۲', '۰۳', '۰٤', '۰٥', '۰٦', '۰۷', '۰۸', '۰۹', '۱۰', '۱۱', '۱۲', '۱۳', '۱٤', '۱٥', '۱٦', '۱۷', '۱۸', '۱۹', '۲۰', '۲۱', '۲۲', '۲۳', '۲٤', '۲٥', '۲٦', '۲۷', '۲۸', '۲۹', '۳۰', '۳۱', '۳۲', '۳۳', '۳٤', '۳٥', '۳٦', '۳۷', '۳۸', '۳۹', '٤۰', '٤۱', '٤۲', '٤۳', '٤٤', '٤٥', '٤٦', '٤۷', '٤۸', '٤۹', '٥۰', '٥۱', '٥۲', '٥۳', '٥٤', '٥٥', '٥٦', '٥۷', '٥۸', '٥۹', '٦۰', '٦۱', '٦۲', '٦۳', '٦٤', '٦٥', '٦٦', '٦۷', '٦۸', '٦۹', '۷۰', '۷۱', '۷۲', '۷۳', '۷٤', '۷٥', '۷٦', '۷۷', '۷۸', '۷۹', '۸۰', '۸۱', '۸۲', '۸۳', '۸٤', '۸٥', '۸٦', '۸۷', '۸۸', '۸۹', '۹۰', '۹۱', '۹۲', '۹۳', '۹٤', '۹٥', '۹٦', '۹۷', '۹۸', '۹۹'], ]); diff --git a/vendor/nesbot/carbon/src/Carbon/Lang/ar_KW.php b/vendor/nesbot/carbon/src/Carbon/Lang/ar_KW.php index e6f0531..b3fb1cf 100644 --- a/vendor/nesbot/carbon/src/Carbon/Lang/ar_KW.php +++ b/vendor/nesbot/carbon/src/Carbon/Lang/ar_KW.php @@ -16,6 +16,7 @@ * - JD Isaacks * - Atef Ben Ali (atefBB) * - Mohamed Sabil (mohamedsabil83) + * - Abdullah-Alhariri */ $months = [ 'يناير', @@ -90,4 +91,5 @@ return [ ], 'meridiem' => ['ص', 'م'], 'weekend' => [5, 6], + 'alt_numbers' => ['۰۰', '۰۱', '۰۲', '۰۳', '۰٤', '۰٥', '۰٦', '۰۷', '۰۸', '۰۹', '۱۰', '۱۱', '۱۲', '۱۳', '۱٤', '۱٥', '۱٦', '۱۷', '۱۸', '۱۹', '۲۰', '۲۱', '۲۲', '۲۳', '۲٤', '۲٥', '۲٦', '۲۷', '۲۸', '۲۹', '۳۰', '۳۱', '۳۲', '۳۳', '۳٤', '۳٥', '۳٦', '۳۷', '۳۸', '۳۹', '٤۰', '٤۱', '٤۲', '٤۳', '٤٤', '٤٥', '٤٦', '٤۷', '٤۸', '٤۹', '٥۰', '٥۱', '٥۲', '٥۳', '٥٤', '٥٥', '٥٦', '٥۷', '٥۸', '٥۹', '٦۰', '٦۱', '٦۲', '٦۳', '٦٤', '٦٥', '٦٦', '٦۷', '٦۸', '٦۹', '۷۰', '۷۱', '۷۲', '۷۳', '۷٤', '۷٥', '۷٦', '۷۷', '۷۸', '۷۹', '۸۰', '۸۱', '۸۲', '۸۳', '۸٤', '۸٥', '۸٦', '۸۷', '۸۸', '۸۹', '۹۰', '۹۱', '۹۲', '۹۳', '۹٤', '۹٥', '۹٦', '۹۷', '۹۸', '۹۹'], ]; diff --git a/vendor/nesbot/carbon/src/Carbon/Lang/ar_LB.php b/vendor/nesbot/carbon/src/Carbon/Lang/ar_LB.php index 55bb10c..2792745 100644 --- a/vendor/nesbot/carbon/src/Carbon/Lang/ar_LB.php +++ b/vendor/nesbot/carbon/src/Carbon/Lang/ar_LB.php @@ -12,6 +12,7 @@ /* * Authors: * - IBM Globalization Center of Competency, Yamato Software Laboratory bug-glibc-locales@gnu.org + * - Abdullah-Alhariri */ return array_replace_recursive(require __DIR__.'/ar.php', [ 'formats' => [ @@ -24,4 +25,5 @@ return array_replace_recursive(require __DIR__.'/ar.php', [ 'weekdays_min' => ['ح', 'ن', 'ث', 'ر', 'خ', 'ج', 'س'], 'first_day_of_week' => 1, 'day_of_first_week_of_year' => 1, + 'alt_numbers' => ['۰۰', '۰۱', '۰۲', '۰۳', '۰٤', '۰٥', '۰٦', '۰۷', '۰۸', '۰۹', '۱۰', '۱۱', '۱۲', '۱۳', '۱٤', '۱٥', '۱٦', '۱۷', '۱۸', '۱۹', '۲۰', '۲۱', '۲۲', '۲۳', '۲٤', '۲٥', '۲٦', '۲۷', '۲۸', '۲۹', '۳۰', '۳۱', '۳۲', '۳۳', '۳٤', '۳٥', '۳٦', '۳۷', '۳۸', '۳۹', '٤۰', '٤۱', '٤۲', '٤۳', '٤٤', '٤٥', '٤٦', '٤۷', '٤۸', '٤۹', '٥۰', '٥۱', '٥۲', '٥۳', '٥٤', '٥٥', '٥٦', '٥۷', '٥۸', '٥۹', '٦۰', '٦۱', '٦۲', '٦۳', '٦٤', '٦٥', '٦٦', '٦۷', '٦۸', '٦۹', '۷۰', '۷۱', '۷۲', '۷۳', '۷٤', '۷٥', '۷٦', '۷۷', '۷۸', '۷۹', '۸۰', '۸۱', '۸۲', '۸۳', '۸٤', '۸٥', '۸٦', '۸۷', '۸۸', '۸۹', '۹۰', '۹۱', '۹۲', '۹۳', '۹٤', '۹٥', '۹٦', '۹۷', '۹۸', '۹۹'], ]); diff --git a/vendor/nesbot/carbon/src/Carbon/Lang/ar_OM.php b/vendor/nesbot/carbon/src/Carbon/Lang/ar_OM.php index 362009e..3518096 100644 --- a/vendor/nesbot/carbon/src/Carbon/Lang/ar_OM.php +++ b/vendor/nesbot/carbon/src/Carbon/Lang/ar_OM.php @@ -12,6 +12,7 @@ /* * Authors: * - IBM Globalization Center of Competency, Yamato Software Laboratory bug-glibc-locales@gnu.org + * - Abdullah-Alhariri */ return array_replace_recursive(require __DIR__.'/ar.php', [ 'formats' => [ @@ -24,4 +25,5 @@ return array_replace_recursive(require __DIR__.'/ar.php', [ 'weekdays_min' => ['ح', 'ن', 'ث', 'ر', 'خ', 'ج', 'س'], 'first_day_of_week' => 6, 'day_of_first_week_of_year' => 1, + 'alt_numbers' => ['۰۰', '۰۱', '۰۲', '۰۳', '۰٤', '۰٥', '۰٦', '۰۷', '۰۸', '۰۹', '۱۰', '۱۱', '۱۲', '۱۳', '۱٤', '۱٥', '۱٦', '۱۷', '۱۸', '۱۹', '۲۰', '۲۱', '۲۲', '۲۳', '۲٤', '۲٥', '۲٦', '۲۷', '۲۸', '۲۹', '۳۰', '۳۱', '۳۲', '۳۳', '۳٤', '۳٥', '۳٦', '۳۷', '۳۸', '۳۹', '٤۰', '٤۱', '٤۲', '٤۳', '٤٤', '٤٥', '٤٦', '٤۷', '٤۸', '٤۹', '٥۰', '٥۱', '٥۲', '٥۳', '٥٤', '٥٥', '٥٦', '٥۷', '٥۸', '٥۹', '٦۰', '٦۱', '٦۲', '٦۳', '٦٤', '٦٥', '٦٦', '٦۷', '٦۸', '٦۹', '۷۰', '۷۱', '۷۲', '۷۳', '۷٤', '۷٥', '۷٦', '۷۷', '۷۸', '۷۹', '۸۰', '۸۱', '۸۲', '۸۳', '۸٤', '۸٥', '۸٦', '۸۷', '۸۸', '۸۹', '۹۰', '۹۱', '۹۲', '۹۳', '۹٤', '۹٥', '۹٦', '۹۷', '۹۸', '۹۹'], ]); diff --git a/vendor/nesbot/carbon/src/Carbon/Lang/ar_PS.php b/vendor/nesbot/carbon/src/Carbon/Lang/ar_PS.php index e790b99..503c60d 100644 --- a/vendor/nesbot/carbon/src/Carbon/Lang/ar_PS.php +++ b/vendor/nesbot/carbon/src/Carbon/Lang/ar_PS.php @@ -9,5 +9,10 @@ * file that was distributed with this source code. */ +/* + * Authors: + * - Abdullah-Alhariri + */ return array_replace_recursive(require __DIR__.'/ar.php', [ + 'alt_numbers' => ['۰۰', '۰۱', '۰۲', '۰۳', '۰٤', '۰٥', '۰٦', '۰۷', '۰۸', '۰۹', '۱۰', '۱۱', '۱۲', '۱۳', '۱٤', '۱٥', '۱٦', '۱۷', '۱۸', '۱۹', '۲۰', '۲۱', '۲۲', '۲۳', '۲٤', '۲٥', '۲٦', '۲۷', '۲۸', '۲۹', '۳۰', '۳۱', '۳۲', '۳۳', '۳٤', '۳٥', '۳٦', '۳۷', '۳۸', '۳۹', '٤۰', '٤۱', '٤۲', '٤۳', '٤٤', '٤٥', '٤٦', '٤۷', '٤۸', '٤۹', '٥۰', '٥۱', '٥۲', '٥۳', '٥٤', '٥٥', '٥٦', '٥۷', '٥۸', '٥۹', '٦۰', '٦۱', '٦۲', '٦۳', '٦٤', '٦٥', '٦٦', '٦۷', '٦۸', '٦۹', '۷۰', '۷۱', '۷۲', '۷۳', '۷٤', '۷٥', '۷٦', '۷۷', '۷۸', '۷۹', '۸۰', '۸۱', '۸۲', '۸۳', '۸٤', '۸٥', '۸٦', '۸۷', '۸۸', '۸۹', '۹۰', '۹۱', '۹۲', '۹۳', '۹٤', '۹٥', '۹٦', '۹۷', '۹۸', '۹۹'], ]); diff --git a/vendor/nesbot/carbon/src/Carbon/Lang/ar_QA.php b/vendor/nesbot/carbon/src/Carbon/Lang/ar_QA.php index 362009e..3518096 100644 --- a/vendor/nesbot/carbon/src/Carbon/Lang/ar_QA.php +++ b/vendor/nesbot/carbon/src/Carbon/Lang/ar_QA.php @@ -12,6 +12,7 @@ /* * Authors: * - IBM Globalization Center of Competency, Yamato Software Laboratory bug-glibc-locales@gnu.org + * - Abdullah-Alhariri */ return array_replace_recursive(require __DIR__.'/ar.php', [ 'formats' => [ @@ -24,4 +25,5 @@ return array_replace_recursive(require __DIR__.'/ar.php', [ 'weekdays_min' => ['ح', 'ن', 'ث', 'ر', 'خ', 'ج', 'س'], 'first_day_of_week' => 6, 'day_of_first_week_of_year' => 1, + 'alt_numbers' => ['۰۰', '۰۱', '۰۲', '۰۳', '۰٤', '۰٥', '۰٦', '۰۷', '۰۸', '۰۹', '۱۰', '۱۱', '۱۲', '۱۳', '۱٤', '۱٥', '۱٦', '۱۷', '۱۸', '۱۹', '۲۰', '۲۱', '۲۲', '۲۳', '۲٤', '۲٥', '۲٦', '۲۷', '۲۸', '۲۹', '۳۰', '۳۱', '۳۲', '۳۳', '۳٤', '۳٥', '۳٦', '۳۷', '۳۸', '۳۹', '٤۰', '٤۱', '٤۲', '٤۳', '٤٤', '٤٥', '٤٦', '٤۷', '٤۸', '٤۹', '٥۰', '٥۱', '٥۲', '٥۳', '٥٤', '٥٥', '٥٦', '٥۷', '٥۸', '٥۹', '٦۰', '٦۱', '٦۲', '٦۳', '٦٤', '٦٥', '٦٦', '٦۷', '٦۸', '٦۹', '۷۰', '۷۱', '۷۲', '۷۳', '۷٤', '۷٥', '۷٦', '۷۷', '۷۸', '۷۹', '۸۰', '۸۱', '۸۲', '۸۳', '۸٤', '۸٥', '۸٦', '۸۷', '۸۸', '۸۹', '۹۰', '۹۱', '۹۲', '۹۳', '۹٤', '۹٥', '۹٦', '۹۷', '۹۸', '۹۹'], ]); diff --git a/vendor/nesbot/carbon/src/Carbon/Lang/ar_SA.php b/vendor/nesbot/carbon/src/Carbon/Lang/ar_SA.php index 10aaa2e..550b0c7 100644 --- a/vendor/nesbot/carbon/src/Carbon/Lang/ar_SA.php +++ b/vendor/nesbot/carbon/src/Carbon/Lang/ar_SA.php @@ -15,6 +15,7 @@ * - JD Isaacks * - Atef Ben Ali (atefBB) * - Mohamed Sabil (mohamedsabil83) + * - Abdullah-Alhariri */ $months = [ 'يناير', @@ -89,4 +90,5 @@ return [ ], 'meridiem' => ['ص', 'م'], 'weekend' => [5, 6], + 'alt_numbers' => ['۰۰', '۰۱', '۰۲', '۰۳', '۰٤', '۰٥', '۰٦', '۰۷', '۰۸', '۰۹', '۱۰', '۱۱', '۱۲', '۱۳', '۱٤', '۱٥', '۱٦', '۱۷', '۱۸', '۱۹', '۲۰', '۲۱', '۲۲', '۲۳', '۲٤', '۲٥', '۲٦', '۲۷', '۲۸', '۲۹', '۳۰', '۳۱', '۳۲', '۳۳', '۳٤', '۳٥', '۳٦', '۳۷', '۳۸', '۳۹', '٤۰', '٤۱', '٤۲', '٤۳', '٤٤', '٤٥', '٤٦', '٤۷', '٤۸', '٤۹', '٥۰', '٥۱', '٥۲', '٥۳', '٥٤', '٥٥', '٥٦', '٥۷', '٥۸', '٥۹', '٦۰', '٦۱', '٦۲', '٦۳', '٦٤', '٦٥', '٦٦', '٦۷', '٦۸', '٦۹', '۷۰', '۷۱', '۷۲', '۷۳', '۷٤', '۷٥', '۷٦', '۷۷', '۷۸', '۷۹', '۸۰', '۸۱', '۸۲', '۸۳', '۸٤', '۸٥', '۸٦', '۸۷', '۸۸', '۸۹', '۹۰', '۹۱', '۹۲', '۹۳', '۹٤', '۹٥', '۹٦', '۹۷', '۹۸', '۹۹'], ]; diff --git a/vendor/nesbot/carbon/src/Carbon/Lang/ar_SD.php b/vendor/nesbot/carbon/src/Carbon/Lang/ar_SD.php index 362009e..3518096 100644 --- a/vendor/nesbot/carbon/src/Carbon/Lang/ar_SD.php +++ b/vendor/nesbot/carbon/src/Carbon/Lang/ar_SD.php @@ -12,6 +12,7 @@ /* * Authors: * - IBM Globalization Center of Competency, Yamato Software Laboratory bug-glibc-locales@gnu.org + * - Abdullah-Alhariri */ return array_replace_recursive(require __DIR__.'/ar.php', [ 'formats' => [ @@ -24,4 +25,5 @@ return array_replace_recursive(require __DIR__.'/ar.php', [ 'weekdays_min' => ['ح', 'ن', 'ث', 'ر', 'خ', 'ج', 'س'], 'first_day_of_week' => 6, 'day_of_first_week_of_year' => 1, + 'alt_numbers' => ['۰۰', '۰۱', '۰۲', '۰۳', '۰٤', '۰٥', '۰٦', '۰۷', '۰۸', '۰۹', '۱۰', '۱۱', '۱۲', '۱۳', '۱٤', '۱٥', '۱٦', '۱۷', '۱۸', '۱۹', '۲۰', '۲۱', '۲۲', '۲۳', '۲٤', '۲٥', '۲٦', '۲۷', '۲۸', '۲۹', '۳۰', '۳۱', '۳۲', '۳۳', '۳٤', '۳٥', '۳٦', '۳۷', '۳۸', '۳۹', '٤۰', '٤۱', '٤۲', '٤۳', '٤٤', '٤٥', '٤٦', '٤۷', '٤۸', '٤۹', '٥۰', '٥۱', '٥۲', '٥۳', '٥٤', '٥٥', '٥٦', '٥۷', '٥۸', '٥۹', '٦۰', '٦۱', '٦۲', '٦۳', '٦٤', '٦٥', '٦٦', '٦۷', '٦۸', '٦۹', '۷۰', '۷۱', '۷۲', '۷۳', '۷٤', '۷٥', '۷٦', '۷۷', '۷۸', '۷۹', '۸۰', '۸۱', '۸۲', '۸۳', '۸٤', '۸٥', '۸٦', '۸۷', '۸۸', '۸۹', '۹۰', '۹۱', '۹۲', '۹۳', '۹٤', '۹٥', '۹٦', '۹۷', '۹۸', '۹۹'], ]); diff --git a/vendor/nesbot/carbon/src/Carbon/Lang/ar_SY.php b/vendor/nesbot/carbon/src/Carbon/Lang/ar_SY.php index 0ac0995..2d42008 100644 --- a/vendor/nesbot/carbon/src/Carbon/Lang/ar_SY.php +++ b/vendor/nesbot/carbon/src/Carbon/Lang/ar_SY.php @@ -12,6 +12,7 @@ /* * Authors: * - IBM Globalization Center of Competency, Yamato Software Laboratory bug-glibc-locales@gnu.org + * - Abdullah-Alhariri */ return array_replace_recursive(require __DIR__.'/ar.php', [ 'formats' => [ @@ -24,4 +25,5 @@ return array_replace_recursive(require __DIR__.'/ar.php', [ 'weekdays_min' => ['ح', 'ن', 'ث', 'ر', 'خ', 'ج', 'س'], 'first_day_of_week' => 6, 'day_of_first_week_of_year' => 1, + 'alt_numbers' => ['۰۰', '۰۱', '۰۲', '۰۳', '۰٤', '۰٥', '۰٦', '۰۷', '۰۸', '۰۹', '۱۰', '۱۱', '۱۲', '۱۳', '۱٤', '۱٥', '۱٦', '۱۷', '۱۸', '۱۹', '۲۰', '۲۱', '۲۲', '۲۳', '۲٤', '۲٥', '۲٦', '۲۷', '۲۸', '۲۹', '۳۰', '۳۱', '۳۲', '۳۳', '۳٤', '۳٥', '۳٦', '۳۷', '۳۸', '۳۹', '٤۰', '٤۱', '٤۲', '٤۳', '٤٤', '٤٥', '٤٦', '٤۷', '٤۸', '٤۹', '٥۰', '٥۱', '٥۲', '٥۳', '٥٤', '٥٥', '٥٦', '٥۷', '٥۸', '٥۹', '٦۰', '٦۱', '٦۲', '٦۳', '٦٤', '٦٥', '٦٦', '٦۷', '٦۸', '٦۹', '۷۰', '۷۱', '۷۲', '۷۳', '۷٤', '۷٥', '۷٦', '۷۷', '۷۸', '۷۹', '۸۰', '۸۱', '۸۲', '۸۳', '۸٤', '۸٥', '۸٦', '۸۷', '۸۸', '۸۹', '۹۰', '۹۱', '۹۲', '۹۳', '۹٤', '۹٥', '۹٦', '۹۷', '۹۸', '۹۹'], ]); diff --git a/vendor/nesbot/carbon/src/Carbon/Lang/ar_YE.php b/vendor/nesbot/carbon/src/Carbon/Lang/ar_YE.php index 5dc2938..169fe88 100644 --- a/vendor/nesbot/carbon/src/Carbon/Lang/ar_YE.php +++ b/vendor/nesbot/carbon/src/Carbon/Lang/ar_YE.php @@ -12,6 +12,7 @@ /* * Authors: * - IBM Globalization Center of Competency, Yamato Software Laboratory bug-glibc-locales@gnu.org + * - Abdullah-Alhariri */ return array_replace_recursive(require __DIR__.'/ar.php', [ 'formats' => [ @@ -23,4 +24,5 @@ return array_replace_recursive(require __DIR__.'/ar.php', [ 'weekdays_short' => ['ح', 'ن', 'ث', 'ر', 'خ', 'ج', 'س'], 'weekdays_min' => ['ح', 'ن', 'ث', 'ر', 'خ', 'ج', 'س'], 'day_of_first_week_of_year' => 1, + 'alt_numbers' => ['۰۰', '۰۱', '۰۲', '۰۳', '۰٤', '۰٥', '۰٦', '۰۷', '۰۸', '۰۹', '۱۰', '۱۱', '۱۲', '۱۳', '۱٤', '۱٥', '۱٦', '۱۷', '۱۸', '۱۹', '۲۰', '۲۱', '۲۲', '۲۳', '۲٤', '۲٥', '۲٦', '۲۷', '۲۸', '۲۹', '۳۰', '۳۱', '۳۲', '۳۳', '۳٤', '۳٥', '۳٦', '۳۷', '۳۸', '۳۹', '٤۰', '٤۱', '٤۲', '٤۳', '٤٤', '٤٥', '٤٦', '٤۷', '٤۸', '٤۹', '٥۰', '٥۱', '٥۲', '٥۳', '٥٤', '٥٥', '٥٦', '٥۷', '٥۸', '٥۹', '٦۰', '٦۱', '٦۲', '٦۳', '٦٤', '٦٥', '٦٦', '٦۷', '٦۸', '٦۹', '۷۰', '۷۱', '۷۲', '۷۳', '۷٤', '۷٥', '۷٦', '۷۷', '۷۸', '۷۹', '۸۰', '۸۱', '۸۲', '۸۳', '۸٤', '۸٥', '۸٦', '۸۷', '۸۸', '۸۹', '۹۰', '۹۱', '۹۲', '۹۳', '۹٤', '۹٥', '۹٦', '۹۷', '۹۸', '۹۹'], ]); diff --git a/vendor/nesbot/carbon/src/Carbon/Lang/be.php b/vendor/nesbot/carbon/src/Carbon/Lang/be.php index 51b4d0c..ee73636 100644 --- a/vendor/nesbot/carbon/src/Carbon/Lang/be.php +++ b/vendor/nesbot/carbon/src/Carbon/Lang/be.php @@ -9,13 +9,12 @@ * file that was distributed with this source code. */ -// @codeCoverageIgnoreStart - use Carbon\CarbonInterface; use Symfony\Component\Translation\PluralizationRules; -if (class_exists('Symfony\\Component\\Translation\\PluralizationRules')) { - PluralizationRules::set(function ($number) { +// @codeCoverageIgnoreStart +if (class_exists(PluralizationRules::class)) { + PluralizationRules::set(static function ($number) { return (($number % 10 == 1) && ($number % 100 != 11)) ? 0 : ((($number % 10 >= 2) && ($number % 10 <= 4) && (($number % 100 < 10) || ($number % 100 >= 20))) ? 1 : 2); }, 'be'); } diff --git a/vendor/nesbot/carbon/src/Carbon/Lang/ca_ES_Valencia.php b/vendor/nesbot/carbon/src/Carbon/Lang/ca_ES_Valencia.php index 861acd2..1c16421 100644 --- a/vendor/nesbot/carbon/src/Carbon/Lang/ca_ES_Valencia.php +++ b/vendor/nesbot/carbon/src/Carbon/Lang/ca_ES_Valencia.php @@ -9,5 +9,15 @@ * file that was distributed with this source code. */ +use Symfony\Component\Translation\PluralizationRules; + +// @codeCoverageIgnoreStart +if (class_exists(PluralizationRules::class)) { + PluralizationRules::set(static function ($number) { + return PluralizationRules::get($number, 'ca'); + }, 'ca_ES_Valencia'); +} +// @codeCoverageIgnoreEnd + return array_replace_recursive(require __DIR__.'/ca.php', [ ]); diff --git a/vendor/nesbot/carbon/src/Carbon/Lang/ckb.php b/vendor/nesbot/carbon/src/Carbon/Lang/ckb.php new file mode 100644 index 0000000..acf4dc2 --- /dev/null +++ b/vendor/nesbot/carbon/src/Carbon/Lang/ckb.php @@ -0,0 +1,89 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/* + * Authors: + * - Swara Mohammed + */ +$months = [ + 'ڕێبەندان', + 'ڕەشەمە', + 'نەورۆز', + 'گوڵان', + 'جۆزەردان', + 'پوشپەڕ', + 'گەلاوێژ', + 'خەرمانان', + 'ڕەزبەر', + 'گەڵاڕێزان', + 'سەرماوەرز', + 'بەفرانبار', +]; + +return [ + 'year' => implode('|', ['{0}:count ساڵێک', '{1}ساڵێک', '{2}دوو ساڵ', ']2,11[:count ساڵ', ']10,Inf[:count ساڵ']), + 'a_year' => implode('|', ['{0}:count ساڵێک', '{1}ساڵێک', '{2}دوو ساڵ', ']2,11[:count ساڵ', ']10,Inf[:count ساڵ']), + 'month' => implode('|', ['{0}:count مانگێک', '{1}مانگێک', '{2}دوو مانگ', ']2,11[:count مانگ', ']10,Inf[:count مانگ']), + 'a_month' => implode('|', ['{0}:count مانگێک', '{1}مانگێک', '{2}دوو مانگ', ']2,11[:count مانگ', ']10,Inf[:count مانگ']), + 'week' => implode('|', ['{0}:count هەفتەیەک', '{1}هەفتەیەک', '{2}دوو هەفتە', ']2,11[:count هەفتە', ']10,Inf[:count هەفتە']), + 'a_week' => implode('|', ['{0}:count هەفتەیەک', '{1}هەفتەیەک', '{2}دوو هەفتە', ']2,11[:count هەفتە', ']10,Inf[:count هەفتە']), + 'day' => implode('|', ['{0}:count ڕۆژێک', '{1}ڕۆژێک', '{2}دوو ڕۆژ', ']2,11[:count ڕۆژ', ']10,Inf[:count ڕۆژ']), + 'a_day' => implode('|', ['{0}:count ڕۆژێک', '{1}ڕۆژێک', '{2}دوو ڕۆژ', ']2,11[:count ڕۆژ', ']10,Inf[:count ڕۆژ']), + 'hour' => implode('|', ['{0}:count کاتژمێرێک', '{1}کاتژمێرێک', '{2}دوو کاتژمێر', ']2,11[:count کاتژمێر', ']10,Inf[:count کاتژمێر']), + 'a_hour' => implode('|', ['{0}:count کاتژمێرێک', '{1}کاتژمێرێک', '{2}دوو کاتژمێر', ']2,11[:count کاتژمێر', ']10,Inf[:count کاتژمێر']), + 'minute' => implode('|', ['{0}:count خولەکێک', '{1}خولەکێک', '{2}دوو خولەک', ']2,11[:count خولەک', ']10,Inf[:count خولەک']), + 'a_minute' => implode('|', ['{0}:count خولەکێک', '{1}خولەکێک', '{2}دوو خولەک', ']2,11[:count خولەک', ']10,Inf[:count خولەک']), + 'second' => implode('|', ['{0}:count چرکەیەک', '{1}چرکەیەک', '{2}دوو چرکە', ']2,11[:count چرکە', ']10,Inf[:count چرکە']), + 'a_second' => implode('|', ['{0}:count چرکەیەک', '{1}چرکەیەک', '{2}دوو چرکە', ']2,11[:count چرکە', ']10,Inf[:count چرکە']), + 'ago' => 'پێش :time', + 'from_now' => ':time لە ئێستاوە', + 'after' => 'دوای :time', + 'before' => 'پێش :time', + 'diff_now' => 'ئێستا', + 'diff_today' => 'ئەمڕۆ', + 'diff_today_regexp' => 'ڕۆژ(?:\\s+لە)?(?:\\s+کاتژمێر)?', + 'diff_yesterday' => 'دوێنێ', + 'diff_yesterday_regexp' => 'دوێنێ(?:\\s+لە)?(?:\\s+کاتژمێر)?', + 'diff_tomorrow' => 'سبەینێ', + 'diff_tomorrow_regexp' => 'سبەینێ(?:\\s+لە)?(?:\\s+کاتژمێر)?', + 'diff_before_yesterday' => 'پێش دوێنێ', + 'diff_after_tomorrow' => 'دوای سبەینێ', + 'period_recurrences' => implode('|', ['{0}جار', '{1}جار', '{2}:count دووجار', ']2,11[:count جار', ']10,Inf[:count جار']), + 'period_interval' => 'هەموو :interval', + 'period_start_date' => 'لە :date', + 'period_end_date' => 'بۆ :date', + 'months' => $months, + 'months_short' => $months, + 'weekdays' => ['یەکشەممە', 'دووشەممە', 'سێشەممە', 'چوارشەممە', 'پێنجشەممە', 'هەینی', 'شەممە'], + 'weekdays_short' => ['یەکشەممە', 'دووشەممە', 'سێشەممە', 'چوارشەممە', 'پێنجشەممە', 'هەینی', 'شەممە'], + 'weekdays_min' => ['یەکشەممە', 'دووشەممە', 'سێشەممە', 'چوارشەممە', 'پێنجشەممە', 'هەینی', 'شەممە'], + 'list' => ['، ', ' و '], + 'first_day_of_week' => 6, + 'day_of_first_week_of_year' => 1, + 'formats' => [ + 'LT' => 'HH:mm', + 'LTS' => 'HH:mm:ss', + 'L' => 'D/M/YYYY', + 'LL' => 'D MMMM YYYY', + 'LLL' => 'D MMMM YYYY HH:mm', + 'LLLL' => 'dddd D MMMM YYYY HH:mm', + ], + 'calendar' => [ + 'sameDay' => '[ئەمڕۆ لە کاتژمێر] LT', + 'nextDay' => '[سبەینێ لە کاتژمێر] LT', + 'nextWeek' => 'dddd [لە کاتژمێر] LT', + 'lastDay' => '[دوێنێ لە کاتژمێر] LT', + 'lastWeek' => 'dddd [لە کاتژمێر] LT', + 'sameElse' => 'L', + ], + 'meridiem' => ['پ.ن', 'د.ن'], + 'weekend' => [5, 6], +]; diff --git a/vendor/nesbot/carbon/src/Carbon/Lang/cs.php b/vendor/nesbot/carbon/src/Carbon/Lang/cs.php index 8cff9a0..c01e3cc 100644 --- a/vendor/nesbot/carbon/src/Carbon/Lang/cs.php +++ b/vendor/nesbot/carbon/src/Carbon/Lang/cs.php @@ -101,7 +101,8 @@ return [ 'after' => $za, 'first_day_of_week' => 1, 'day_of_first_week_of_year' => 4, - 'months' => ['leden', 'únor', 'březen', 'duben', 'květen', 'červen', 'červenec', 'srpen', 'září', 'říjen', 'listopad', 'prosinec'], + 'months' => ['ledna', 'února', 'března', 'dubna', 'května', 'června', 'července', 'srpna', 'září', 'října', 'listopadu', 'prosince'], + 'months_standalone' => ['leden', 'únor', 'březen', 'duben', 'květen', 'červen', 'červenec', 'srpen', 'září', 'říjen', 'listopad', 'prosinec'], 'months_short' => ['led', 'úno', 'bře', 'dub', 'kvě', 'čvn', 'čvc', 'srp', 'zář', 'říj', 'lis', 'pro'], 'weekdays' => ['neděle', 'pondělí', 'úterý', 'středa', 'čtvrtek', 'pátek', 'sobota'], 'weekdays_short' => ['ned', 'pon', 'úte', 'stř', 'čtv', 'pát', 'sob'], diff --git a/vendor/nesbot/carbon/src/Carbon/Lang/cy.php b/vendor/nesbot/carbon/src/Carbon/Lang/cy.php index ab7c45a..119274f 100644 --- a/vendor/nesbot/carbon/src/Carbon/Lang/cy.php +++ b/vendor/nesbot/carbon/src/Carbon/Lang/cy.php @@ -60,7 +60,7 @@ return [ 'ordinal' => function ($number) { return $number.( $number > 20 - ? (\in_array($number, [40, 50, 60, 80, 100]) ? 'fed' : 'ain') + ? (\in_array((int) $number, [40, 50, 60, 80, 100], true) ? 'fed' : 'ain') : ([ '', 'af', 'il', 'ydd', 'ydd', 'ed', 'ed', 'ed', 'fed', 'fed', 'fed', // 1af to 10fed 'eg', 'fed', 'eg', 'eg', 'fed', 'eg', 'eg', 'fed', 'eg', 'fed', // 11eg to 20fed diff --git a/vendor/nesbot/carbon/src/Carbon/Lang/da.php b/vendor/nesbot/carbon/src/Carbon/Lang/da.php index 4e6640a..322f91d 100644 --- a/vendor/nesbot/carbon/src/Carbon/Lang/da.php +++ b/vendor/nesbot/carbon/src/Carbon/Lang/da.php @@ -18,6 +18,7 @@ * - Jens Herlevsen * - Ulrik McArdle (mcardle) * - Frederik Sauer (FrittenKeeZ) + * - Janus Bahs Jacquet (kokoshneta) */ return [ 'year' => ':count år|:count år', @@ -41,7 +42,7 @@ return [ 'second' => ':count sekund|:count sekunder', 'a_second' => 'få sekunder|:count sekunder', 's' => ':count s.', - 'ago' => ':time siden', + 'ago' => 'for :time siden', 'from_now' => 'om :time', 'after' => ':time efter', 'before' => ':time før', @@ -70,9 +71,9 @@ return [ ], 'ordinal' => ':number.', 'months' => ['januar', 'februar', 'marts', 'april', 'maj', 'juni', 'juli', 'august', 'september', 'oktober', 'november', 'december'], - 'months_short' => ['jan', 'feb', 'mar', 'apr', 'maj', 'jun', 'jul', 'aug', 'sep', 'okt', 'nov', 'dec'], + 'months_short' => ['jan.', 'feb.', 'mar.', 'apr.', 'maj.', 'jun.', 'jul.', 'aug.', 'sep.', 'okt.', 'nov.', 'dec.'], 'weekdays' => ['søndag', 'mandag', 'tirsdag', 'onsdag', 'torsdag', 'fredag', 'lørdag'], - 'weekdays_short' => ['søn', 'man', 'tir', 'ons', 'tor', 'fre', 'lør'], + 'weekdays_short' => ['søn.', 'man.', 'tir.', 'ons.', 'tor.', 'fre.', 'lør.'], 'weekdays_min' => ['sø', 'ma', 'ti', 'on', 'to', 'fr', 'lø'], 'first_day_of_week' => 1, 'day_of_first_week_of_year' => 4, diff --git a/vendor/nesbot/carbon/src/Carbon/Lang/de.php b/vendor/nesbot/carbon/src/Carbon/Lang/de.php index ff00c97..3b70750 100644 --- a/vendor/nesbot/carbon/src/Carbon/Lang/de.php +++ b/vendor/nesbot/carbon/src/Carbon/Lang/de.php @@ -105,4 +105,13 @@ return [ 'first_day_of_week' => 1, 'day_of_first_week_of_year' => 4, 'list' => [', ', ' und '], + 'ordinal_words' => [ + 'of' => 'im', + 'first' => 'erster', + 'second' => 'zweiter', + 'third' => 'dritter', + 'fourth' => 'vierten', + 'fifth' => 'fünfter', + 'last' => 'letzten', + ], ]; diff --git a/vendor/nesbot/carbon/src/Carbon/Lang/en.php b/vendor/nesbot/carbon/src/Carbon/Lang/en.php index a8633fe..f81f617 100644 --- a/vendor/nesbot/carbon/src/Carbon/Lang/en.php +++ b/vendor/nesbot/carbon/src/Carbon/Lang/en.php @@ -72,7 +72,7 @@ return [ $lastDigit = $number % 10; return $number.( - (~~($number % 100 / 10) === 1) ? 'th' : ( + ((int) ($number % 100 / 10) === 1) ? 'th' : ( ($lastDigit === 1) ? 'st' : ( ($lastDigit === 2) ? 'nd' : ( ($lastDigit === 3) ? 'rd' : 'th' diff --git a/vendor/nesbot/carbon/src/Carbon/Lang/es.php b/vendor/nesbot/carbon/src/Carbon/Lang/es.php index f77ec39..1c4fcfd 100644 --- a/vendor/nesbot/carbon/src/Carbon/Lang/es.php +++ b/vendor/nesbot/carbon/src/Carbon/Lang/es.php @@ -26,6 +26,7 @@ * - quinterocesar * - Daniel Commesse Liévanos (danielcommesse) * - Pete Scopes (pdscopes) + * - gam04 */ use Carbon\CarbonInterface; @@ -108,4 +109,13 @@ return [ 'day_of_first_week_of_year' => 4, 'list' => [', ', ' y '], 'meridiem' => ['a. m.', 'p. m.'], + 'ordinal_words' => [ + 'of' => 'de', + 'first' => 'primer', + 'second' => 'segundo', + 'third' => 'tercer', + 'fourth' => 'cuarto', + 'fifth' => 'quinto', + 'last' => 'último', + ], ]; diff --git a/vendor/nesbot/carbon/src/Carbon/Lang/fi.php b/vendor/nesbot/carbon/src/Carbon/Lang/fi.php index 2003e1e..edf2d6d 100644 --- a/vendor/nesbot/carbon/src/Carbon/Lang/fi.php +++ b/vendor/nesbot/carbon/src/Carbon/Lang/fi.php @@ -74,8 +74,10 @@ return [ 'LTS' => 'HH.mm:ss', 'L' => 'D.M.YYYY', 'LL' => 'dddd D. MMMM[ta] YYYY', + 'll' => 'ddd D. MMM YYYY', 'LLL' => 'D.MM. HH.mm', 'LLLL' => 'D. MMMM[ta] YYYY HH.mm', + 'llll' => 'D. MMM YY HH.mm', ], 'weekdays' => ['sunnuntai', 'maanantai', 'tiistai', 'keskiviikko', 'torstai', 'perjantai', 'lauantai'], 'weekdays_short' => ['su', 'ma', 'ti', 'ke', 'to', 'pe', 'la'], diff --git a/vendor/nesbot/carbon/src/Carbon/Lang/fr.php b/vendor/nesbot/carbon/src/Carbon/Lang/fr.php index 73fe5e4..f4c7247 100644 --- a/vendor/nesbot/carbon/src/Carbon/Lang/fr.php +++ b/vendor/nesbot/carbon/src/Carbon/Lang/fr.php @@ -90,7 +90,7 @@ return [ 'weekdays_min' => ['di', 'lu', 'ma', 'me', 'je', 've', 'sa'], 'ordinal' => function ($number, $period) { switch ($period) { - // In french, only the first has be ordinal, other number remains cardinal + // In French, only the first has to be ordinal, other number remains cardinal // @link https://fr.wikihow.com/%C3%A9crire-la-date-en-fran%C3%A7ais case 'D': return $number.($number === 1 ? 'er' : ''); @@ -111,4 +111,13 @@ return [ 'first_day_of_week' => 1, 'day_of_first_week_of_year' => 4, 'list' => [', ', ' et '], + 'ordinal_words' => [ + 'of' => 'de', + 'first' => 'premier', + 'second' => 'deuxième', + 'third' => 'troisième', + 'fourth' => 'quatrième', + 'fifth' => 'cinquième', + 'last' => 'dernier', + ], ]; diff --git a/vendor/nesbot/carbon/src/Carbon/Lang/it.php b/vendor/nesbot/carbon/src/Carbon/Lang/it.php index 605bcbb..49875d7 100644 --- a/vendor/nesbot/carbon/src/Carbon/Lang/it.php +++ b/vendor/nesbot/carbon/src/Carbon/Lang/it.php @@ -55,7 +55,7 @@ return [ 'µs' => ':countµs', 'ago' => ':time fa', 'from_now' => function ($time) { - return (preg_match('/^[0-9].+$/', $time) ? 'tra' : 'in')." $time"; + return (preg_match('/^\d.+$/', $time) ? 'tra' : 'in')." $time"; }, 'after' => ':time dopo', 'before' => ':time prima', @@ -103,4 +103,13 @@ return [ 'first_day_of_week' => 1, 'day_of_first_week_of_year' => 4, 'list' => [', ', ' e '], + 'ordinal_words' => [ + 'of' => 'di', + 'first' => 'primo', + 'second' => 'secondo', + 'third' => 'terzo', + 'fourth' => 'quarto', + 'fifth' => 'quinto', + 'last' => 'ultimo', + ], ]; diff --git a/vendor/nesbot/carbon/src/Carbon/Lang/ku.php b/vendor/nesbot/carbon/src/Carbon/Lang/ku.php index b001e30..189960c 100644 --- a/vendor/nesbot/carbon/src/Carbon/Lang/ku.php +++ b/vendor/nesbot/carbon/src/Carbon/Lang/ku.php @@ -11,31 +11,29 @@ /* * Authors: - * - Halwest Manguri - * - Kardo Qadir + * - Unicode, Inc. */ -$months = ['کانونی دووەم', 'شوبات', 'ئازار', 'نیسان', 'ئایار', '‌حوزەیران', 'تەمموز', 'ئاب', 'ئەیلول', 'تشرینی یەکەم', 'تشرینی دووەم', 'کانونی یەکەم']; - -$weekdays = ['دوو شەممە', 'سێ شەممە', 'چوار شەممە', 'پێنج شەممە', 'هەینی', 'شەممە', 'یەک شەممە']; return [ - 'ago' => 'پێش :time', - 'from_now' => ':time لە ئێستاوە', - 'after' => 'دوای :time', - 'before' => 'پێش :time', - 'year' => '{0}ساڵ|{1}ساڵێک|{2}٢ ساڵ|[3,10]:count ساڵ|[11,Inf]:count ساڵ', - 'month' => '{0}مانگ|{1}مانگێک|{2}٢ مانگ|[3,10]:count مانگ|[11,Inf]:count مانگ', - 'week' => '{0}هەفتە|{1}هەفتەیەک|{2}٢ هەفتە|[3,10]:count هەفتە|[11,Inf]:count هەفتە', - 'day' => '{0}ڕۆژ|{1}ڕۆژێک|{2}٢ ڕۆژ|[3,10]:count ڕۆژ|[11,Inf]:count ڕۆژ', - 'hour' => '{0}کاتژمێر|{1}کاتژمێرێک|{2}٢ کاتژمێر|[3,10]:count کاتژمێر|[11,Inf]:count کاتژمێر', - 'minute' => '{0}خولەک|{1}خولەکێک|{2}٢ خولەک|[3,10]:count خولەک|[11,Inf]:count خولەک', - 'second' => '{0}چرکە|{1}چرکەیەک|{2}٢ چرکە|[3,10]:count چرکە|[11,Inf]:count چرکە', - 'months' => $months, - 'months_standalone' => $months, - 'months_short' => $months, - 'weekdays' => $weekdays, - 'weekdays_short' => $weekdays, - 'weekdays_min' => $weekdays, + 'ago' => 'berî :time', + 'from_now' => 'di :time de', + 'after' => ':time piştî', + 'before' => ':time berê', + 'year' => ':count sal', + 'year_ago' => ':count salê|:count salan', + 'year_from_now' => 'salekê|:count salan', + 'month' => ':count meh', + 'week' => ':count hefte', + 'day' => ':count roj', + 'hour' => ':count saet', + 'minute' => ':count deqîqe', + 'second' => ':count saniye', + 'months' => ['rêbendanê', 'reşemiyê', 'adarê', 'avrêlê', 'gulanê', 'pûşperê', 'tîrmehê', 'gelawêjê', 'rezberê', 'kewçêrê', 'sermawezê', 'berfanbarê'], + 'months_standalone' => ['rêbendan', 'reşemî', 'adar', 'avrêl', 'gulan', 'pûşper', 'tîrmeh', 'gelawêj', 'rezber', 'kewçêr', 'sermawez', 'berfanbar'], + 'months_short' => ['rêb', 'reş', 'ada', 'avr', 'gul', 'pûş', 'tîr', 'gel', 'rez', 'kew', 'ser', 'ber'], + 'weekdays' => ['yekşem', 'duşem', 'sêşem', 'çarşem', 'pêncşem', 'în', 'şemî'], + 'weekdays_short' => ['yş', 'dş', 'sş', 'çş', 'pş', 'în', 'ş'], + 'weekdays_min' => ['Y', 'D', 'S', 'Ç', 'P', 'Î', 'Ş'], 'list' => [', ', ' û '], 'first_day_of_week' => 6, 'day_of_first_week_of_year' => 1, diff --git a/vendor/nesbot/carbon/src/Carbon/Lang/lv.php b/vendor/nesbot/carbon/src/Carbon/Lang/lv.php index 693eceb..d5cba7c 100644 --- a/vendor/nesbot/carbon/src/Carbon/Lang/lv.php +++ b/vendor/nesbot/carbon/src/Carbon/Lang/lv.php @@ -176,7 +176,8 @@ return [ 'weekdays' => $daysOfWeek, 'weekdays_short' => ['Sv.', 'P.', 'O.', 'T.', 'C.', 'Pk.', 'S.'], 'weekdays_min' => ['Sv.', 'P.', 'O.', 'T.', 'C.', 'Pk.', 'S.'], - 'months' => ['janvārī', 'februārī', 'martā', 'aprīlī', 'maijā', 'jūnijā', 'jūlijā', 'augustā', 'septembrī', 'oktobrī', 'novembrī', 'decembrī'], + 'months' => ['janvāris', 'februāris', 'marts', 'aprīlis', 'maijs', 'jūnijs', 'jūlijs', 'augusts', 'septembris', 'oktobris', 'novembris', 'decembris'], + 'months_standalone' => ['janvārī', 'februārī', 'martā', 'aprīlī', 'maijā', 'jūnijā', 'jūlijā', 'augustā', 'septembrī', 'oktobrī', 'novembrī', 'decembrī'], 'months_short' => ['janv.', 'febr.', 'martā', 'apr.', 'maijā', 'jūn.', 'jūl.', 'aug.', 'sept.', 'okt.', 'nov.', 'dec.'], 'meridiem' => ['priekšpusdiena', 'pēcpusdiena'], ]; diff --git a/vendor/nesbot/carbon/src/Carbon/Lang/mn.php b/vendor/nesbot/carbon/src/Carbon/Lang/mn.php index 717d199..38c6434 100644 --- a/vendor/nesbot/carbon/src/Carbon/Lang/mn.php +++ b/vendor/nesbot/carbon/src/Carbon/Lang/mn.php @@ -26,6 +26,7 @@ * - Nicolás Hock Isaza * - Ochirkhuyag * - Batmandakh + * - lucifer-crybaby */ return [ 'year' => ':count жил', @@ -43,38 +44,55 @@ return [ 'second' => ':count секунд', 's' => ':countс', - 'ago' => ':timeн өмнө', - 'year_ago' => ':count жилий', - 'month_ago' => ':count сары', - 'day_ago' => ':count хоногий', - 'hour_ago' => ':count цагий', - 'minute_ago' => ':count минуты', - 'second_ago' => ':count секунды', + 'ago_mode' => 'last', + 'ago' => ':time өмнө', + 'year_ago' => ':count жилийн', + 'y_ago' => ':count жилийн', + 'month_ago' => ':count сарын', + 'm_ago' => ':count сарын', + 'day_ago' => ':count хоногийн', + 'd_ago' => ':count хоногийн', + 'week_ago' => ':count долоо хоногийн', + 'w_ago' => ':count долоо хоногийн', + 'hour_ago' => ':count цагийн', + 'minute_ago' => ':count минутын', + 'second_ago' => ':count секундын', + 'from_now_mode' => 'last', 'from_now' => 'одоогоос :time', 'year_from_now' => ':count жилийн дараа', + 'y_from_now' => ':count жилийн дараа', 'month_from_now' => ':count сарын дараа', + 'm_from_now' => ':count сарын дараа', 'day_from_now' => ':count хоногийн дараа', + 'd_from_now' => ':count хоногийн дараа', 'hour_from_now' => ':count цагийн дараа', 'minute_from_now' => ':count минутын дараа', 'second_from_now' => ':count секундын дараа', - // Does it required to make translation for before, after as follows? hmm, I think we've made it with ago and from now keywords already. Anyway, I've included it just in case of undesired action... - 'after' => ':timeн дараа', - 'year_after' => ':count жилий', - 'month_after' => ':count сары', - 'day_after' => ':count хоногий', - 'hour_after' => ':count цагий', - 'minute_after' => ':count минуты', - 'second_after' => ':count секунды', + 'after_mode' => 'last', + 'after' => ':time дараа', + 'year_after' => ':count жилийн', + 'y_after' => ':count жилийн', + 'month_after' => ':count сарын', + 'm_after' => ':count сарын', + 'day_after' => ':count хоногийн', + 'd_after' => ':count хоногийн', + 'hour_after' => ':count цагийн', + 'minute_after' => ':count минутын', + 'second_after' => ':count секундын', - 'before' => ':timeн өмнө', - 'year_before' => ':count жилий', - 'month_before' => ':count сары', - 'day_before' => ':count хоногий', - 'hour_before' => ':count цагий', - 'minute_before' => ':count минуты', - 'second_before' => ':count секунды', + 'before_mode' => 'last', + 'before' => ':time өмнө', + 'year_before' => ':count жилийн', + 'y_before' => ':count жилийн', + 'month_before' => ':count сарын', + 'm_before' => ':count сарын', + 'day_before' => ':count хоногийн', + 'd_before' => ':count хоногийн', + 'hour_before' => ':count цагийн', + 'minute_before' => ':count минутын', + 'second_before' => ':count секундын', 'list' => ', ', 'diff_now' => 'одоо', diff --git a/vendor/nesbot/carbon/src/Carbon/Lang/oc.php b/vendor/nesbot/carbon/src/Carbon/Lang/oc.php index 89693e6..c9411d6 100644 --- a/vendor/nesbot/carbon/src/Carbon/Lang/oc.php +++ b/vendor/nesbot/carbon/src/Carbon/Lang/oc.php @@ -17,7 +17,7 @@ use Symfony\Component\Translation\PluralizationRules; if (class_exists('Symfony\\Component\\Translation\\PluralizationRules')) { - PluralizationRules::set(function ($number) { + PluralizationRules::set(static function ($number) { return $number == 1 ? 0 : 1; }, 'oc'); } diff --git a/vendor/nesbot/carbon/src/Carbon/Lang/pl.php b/vendor/nesbot/carbon/src/Carbon/Lang/pl.php index f0196c0..b720535 100644 --- a/vendor/nesbot/carbon/src/Carbon/Lang/pl.php +++ b/vendor/nesbot/carbon/src/Carbon/Lang/pl.php @@ -62,7 +62,7 @@ return [ }, 'after' => ':time po', 'before' => ':time przed', - 'diff_now' => 'przed chwilą', + 'diff_now' => 'teraz', 'diff_today' => 'Dziś', 'diff_today_regexp' => 'Dziś(?:\\s+o)?', 'diff_yesterday' => 'wczoraj', diff --git a/vendor/nesbot/carbon/src/Carbon/Lang/pt.php b/vendor/nesbot/carbon/src/Carbon/Lang/pt.php index 0af8949..bb6359b 100644 --- a/vendor/nesbot/carbon/src/Carbon/Lang/pt.php +++ b/vendor/nesbot/carbon/src/Carbon/Lang/pt.php @@ -104,4 +104,13 @@ return [ 'first_day_of_week' => 1, 'day_of_first_week_of_year' => 4, 'list' => [', ', ' e '], + 'ordinal_words' => [ + 'of' => 'de', + 'first' => 'primeira', + 'second' => 'segunda', + 'third' => 'terceira', + 'fourth' => 'quarta', + 'fifth' => 'quinta', + 'last' => 'última', + ], ]; diff --git a/vendor/nesbot/carbon/src/Carbon/Lang/sh.php b/vendor/nesbot/carbon/src/Carbon/Lang/sh.php index e4aa5a1..e03b506 100644 --- a/vendor/nesbot/carbon/src/Carbon/Lang/sh.php +++ b/vendor/nesbot/carbon/src/Carbon/Lang/sh.php @@ -13,7 +13,7 @@ use Symfony\Component\Translation\PluralizationRules; if (class_exists('Symfony\\Component\\Translation\\PluralizationRules')) { - PluralizationRules::set(function ($number) { + PluralizationRules::set(static function ($number) { return (($number % 10 == 1) && ($number % 100 != 11)) ? 0 : ((($number % 10 >= 2) && ($number % 10 <= 4) && (($number % 100 < 10) || ($number % 100 >= 20))) ? 1 : 2); }, 'sh'); } diff --git a/vendor/nesbot/carbon/src/Carbon/Lang/sk.php b/vendor/nesbot/carbon/src/Carbon/Lang/sk.php index fd0f6b3..08af197 100644 --- a/vendor/nesbot/carbon/src/Carbon/Lang/sk.php +++ b/vendor/nesbot/carbon/src/Carbon/Lang/sk.php @@ -31,6 +31,7 @@ * - jofi * - Jakub ADAMEC * - Marek Adamický + * - AlterwebStudio */ return [ 'year' => 'rok|:count roky|:count rokov', @@ -46,11 +47,12 @@ return [ 'minute' => 'minútu|:count minúty|:count minút', 'min' => ':count min', 'second' => 'sekundu|:count sekundy|:count sekúnd', + 'a_second' => 'pár sekúnd|:count sekundy|:count sekúnd', 's' => ':count s', 'ago' => 'pred :time', - 'from_now' => 'za :time', - 'after' => 'o :time neskôr', - 'before' => ':time predtým', + 'from_now' => 'o :time', + 'after' => ':time po', + 'before' => ':time pred', 'year_ago' => 'rokom|:count rokmi|:count rokmi', 'month_ago' => 'mesiacom|:count mesiacmi|:count mesiacmi', 'week_ago' => 'týždňom|:count týždňami|:count týždňami', @@ -73,7 +75,7 @@ return [ 'LLLL' => 'dddd D. MMMM YYYY HH:mm', ], 'weekdays' => ['nedeľa', 'pondelok', 'utorok', 'streda', 'štvrtok', 'piatok', 'sobota'], - 'weekdays_short' => ['ne', 'po', 'ut', 'st', 'št', 'pi', 'so'], + 'weekdays_short' => ['ned', 'pod', 'uto', 'str', 'štv', 'pia', 'sob'], 'weekdays_min' => ['ne', 'po', 'ut', 'st', 'št', 'pi', 'so'], 'months' => ['január', 'február', 'marec', 'apríl', 'máj', 'jún', 'júl', 'august', 'september', 'október', 'november', 'december'], 'months_short' => ['jan', 'feb', 'mar', 'apr', 'máj', 'jún', 'júl', 'aug', 'sep', 'okt', 'nov', 'dec'], diff --git a/vendor/nesbot/carbon/src/Carbon/Lang/sl.php b/vendor/nesbot/carbon/src/Carbon/Lang/sl.php index 2e19721..b000e30 100644 --- a/vendor/nesbot/carbon/src/Carbon/Lang/sl.php +++ b/vendor/nesbot/carbon/src/Carbon/Lang/sl.php @@ -49,8 +49,8 @@ return [ 'a_second' => '{1}nekaj sekund|:count sekunda|:count sekundi|:count sekunde|:count sekund', 's' => ':count s', - 'year_ago' => ':count letom|:count leti|:count leti|:count leti', - 'y_ago' => ':count letom|:count leti|:count leti|:count leti', + 'year_ago' => ':count letom|:count letoma|:count leti|:count leti', + 'y_ago' => ':count letom|:count letoma|:count leti|:count leti', 'month_ago' => ':count mesecem|:count meseci|:count meseci|:count meseci', 'week_ago' => ':count tednom|:count tednoma|:count tedni|:count tedni', 'day_ago' => ':count dnem|:count dnevoma|:count dnevi|:count dnevi', diff --git a/vendor/nesbot/carbon/src/Carbon/Lang/sr_Cyrl.php b/vendor/nesbot/carbon/src/Carbon/Lang/sr_Cyrl.php index c09df19..8becbc5 100644 --- a/vendor/nesbot/carbon/src/Carbon/Lang/sr_Cyrl.php +++ b/vendor/nesbot/carbon/src/Carbon/Lang/sr_Cyrl.php @@ -24,28 +24,28 @@ use Carbon\CarbonInterface; return [ - 'year' => '{2,3,4,22,23,24,32,33,34,42,43,44,52,53,54}:count године|[0,Inf[:count година', + 'year' => ':count година|:count године|:count година', 'y' => ':count г.', - 'month' => '{1}:count месец|{2,3,4}:count месеца|[0,Inf[:count месеци', + 'month' => ':count месец|:count месеца|:count месеци', 'm' => ':count м.', - 'week' => '{1}:count недеља|{2,3,4}:count недеље|[0,Inf[:count недеља', + 'week' => ':count недеља|:count недеље|:count недеља', 'w' => ':count нед.', - 'day' => '{1,21,31}:count дан|[0,Inf[:count дана', + 'day' => ':count дан|:count дана|:count дана', 'd' => ':count д.', - 'hour' => '{1,21}:count сат|{2,3,4,22,23,24}:count сата|[0,Inf[:count сати', + 'hour' => ':count сат|:count сата|:count сати', 'h' => ':count ч.', - 'minute' => '{1,21,31,41,51}:count минут|[0,Inf[:count минута', + 'minute' => ':count минут|:count минута|:count минута', 'min' => ':count мин.', - 'second' => '{1,21,31,41,51}:count секунд|{2,3,4,22,23,24,32,33,34,42,43,44,52,53,54}:count секунде|[0,Inf[:count секунди', + 'second' => ':count секунд|:count секунде|:count секунди', 's' => ':count сек.', 'ago' => 'пре :time', 'from_now' => 'за :time', 'after' => ':time након', 'before' => ':time пре', - 'year_from_now' => '{1,21,31,41,51}:count годину|{2,3,4,22,23,24,32,33,34,42,43,44,52,53,54}:count године|[0,Inf[:count година', - 'year_ago' => '{1,21,31,41,51}:count годину|{2,3,4,22,23,24,32,33,34,42,43,44,52,53,54}:count године|[0,Inf[:count година', - 'week_from_now' => '{1}:count недељу|{2,3,4}:count недеље|[0,Inf[:count недеља', - 'week_ago' => '{1}:count недељу|{2,3,4}:count недеље|[0,Inf[:count недеља', + 'year_from_now' => ':count годину|:count године|:count година', + 'year_ago' => ':count годину|:count године|:count година', + 'week_from_now' => ':count недељу|:count недеље|:count недеља', + 'week_ago' => ':count недељу|:count недеље|:count недеља', 'diff_now' => 'управо сада', 'diff_today' => 'данас', 'diff_today_regexp' => 'данас(?:\\s+у)?', diff --git a/vendor/nesbot/carbon/src/Carbon/Lang/sr_Cyrl_BA.php b/vendor/nesbot/carbon/src/Carbon/Lang/sr_Cyrl_BA.php index 0fb63d7..4b29a45 100644 --- a/vendor/nesbot/carbon/src/Carbon/Lang/sr_Cyrl_BA.php +++ b/vendor/nesbot/carbon/src/Carbon/Lang/sr_Cyrl_BA.php @@ -9,6 +9,16 @@ * file that was distributed with this source code. */ +use Symfony\Component\Translation\PluralizationRules; + +// @codeCoverageIgnoreStart +if (class_exists(PluralizationRules::class)) { + PluralizationRules::set(static function ($number) { + return PluralizationRules::get($number, 'sr'); + }, 'sr_Cyrl_BA'); +} +// @codeCoverageIgnoreEnd + return array_replace_recursive(require __DIR__.'/sr_Cyrl.php', [ 'formats' => [ 'LT' => 'HH:mm', diff --git a/vendor/nesbot/carbon/src/Carbon/Lang/sr_Cyrl_ME.php b/vendor/nesbot/carbon/src/Carbon/Lang/sr_Cyrl_ME.php index d13229a..28d22fd 100644 --- a/vendor/nesbot/carbon/src/Carbon/Lang/sr_Cyrl_ME.php +++ b/vendor/nesbot/carbon/src/Carbon/Lang/sr_Cyrl_ME.php @@ -16,32 +16,41 @@ */ use Carbon\CarbonInterface; +use Symfony\Component\Translation\PluralizationRules; + +// @codeCoverageIgnoreStart +if (class_exists(PluralizationRules::class)) { + PluralizationRules::set(static function ($number) { + return PluralizationRules::get($number, 'sr'); + }, 'sr_Cyrl_ME'); +} +// @codeCoverageIgnoreEnd return [ - 'year' => '{2,3,4,22,23,24,32,33,34,42,43,44,52,53,54}:count године|[0,Inf[:count година', + 'year' => ':count година|:count године|:count година', 'y' => ':count г.', - 'month' => '{1}:count мјесец|{2,3,4}:count мјесеца|[0,Inf[:count мјесеци', + 'month' => ':count мјесец|:count мјесеца|:count мјесеци', 'm' => ':count мј.', - 'week' => '{1}:count недјеља|{2,3,4}:count недјеље|[0,Inf[:count недјеља', + 'week' => ':count недјеља|:count недјеље|:count недјеља', 'w' => ':count нед.', - 'day' => '{1,21,31}:count дан|[0,Inf[:count дана', + 'day' => ':count дан|:count дана|:count дана', 'd' => ':count д.', - 'hour' => '{1,21}:count сат|{2,3,4,22,23,24}:count сата|[0,Inf[:count сати', + 'hour' => ':count сат|:count сата|:count сати', 'h' => ':count ч.', - 'minute' => '{1,21,31,41,51}:count минут|[0,Inf[:count минута', + 'minute' => ':count минут|:count минута|:count минута', 'min' => ':count мин.', - 'second' => '{1,21,31,41,51}:count секунд|{2,3,4,22,23,24,32,33,34,42,43,44,52,53,54}:count секунде|[0,Inf[:count секунди', + 'second' => ':count секунд|:count секунде|:count секунди', 's' => ':count сек.', 'ago' => 'прије :time', 'from_now' => 'за :time', 'after' => ':time након', 'before' => ':time прије', - 'year_from_now' => '{1,21,31,41,51}:count годину|{2,3,4,22,23,24,32,33,34,42,43,44,52,53,54}:count године|[0,Inf[:count година', - 'year_ago' => '{1,21,31,41,51}:count годину|{2,3,4,22,23,24,32,33,34,42,43,44,52,53,54}:count године|[0,Inf[:count година', + 'year_from_now' => ':count годину|:count године|:count година', + 'year_ago' => ':count годину|:count године|:count година', - 'week_from_now' => '{1}:count недјељу|{2,3,4}:count недјеље|[0,Inf[:count недјеља', - 'week_ago' => '{1}:count недјељу|{2,3,4}:count недјеље|[0,Inf[:count недјеља', + 'week_from_now' => ':count недјељу|:count недјеље|:count недјеља', + 'week_ago' => ':count недјељу|:count недјеље|:count недјеља', 'diff_now' => 'управо сада', 'diff_today' => 'данас', diff --git a/vendor/nesbot/carbon/src/Carbon/Lang/sr_Cyrl_XK.php b/vendor/nesbot/carbon/src/Carbon/Lang/sr_Cyrl_XK.php index 492baf0..d6e29b8 100644 --- a/vendor/nesbot/carbon/src/Carbon/Lang/sr_Cyrl_XK.php +++ b/vendor/nesbot/carbon/src/Carbon/Lang/sr_Cyrl_XK.php @@ -9,6 +9,16 @@ * file that was distributed with this source code. */ +use Symfony\Component\Translation\PluralizationRules; + +// @codeCoverageIgnoreStart +if (class_exists(PluralizationRules::class)) { + PluralizationRules::set(static function ($number) { + return PluralizationRules::get($number, 'sr'); + }, 'sr_Cyrl_XK'); +} +// @codeCoverageIgnoreEnd + return array_replace_recursive(require __DIR__.'/sr_Cyrl_BA.php', [ 'weekdays' => ['недеља', 'понедељак', 'уторак', 'среда', 'четвртак', 'петак', 'субота'], ]); diff --git a/vendor/nesbot/carbon/src/Carbon/Lang/sr_Latn_BA.php b/vendor/nesbot/carbon/src/Carbon/Lang/sr_Latn_BA.php index 897c674..95b2770 100644 --- a/vendor/nesbot/carbon/src/Carbon/Lang/sr_Latn_BA.php +++ b/vendor/nesbot/carbon/src/Carbon/Lang/sr_Latn_BA.php @@ -9,6 +9,16 @@ * file that was distributed with this source code. */ +use Symfony\Component\Translation\PluralizationRules; + +// @codeCoverageIgnoreStart +if (class_exists(PluralizationRules::class)) { + PluralizationRules::set(static function ($number) { + return PluralizationRules::get($number, 'sr'); + }, 'sr_Latn_BA'); +} +// @codeCoverageIgnoreEnd + return array_replace_recursive(require __DIR__.'/sr_Latn.php', [ 'formats' => [ 'LT' => 'HH:mm', diff --git a/vendor/nesbot/carbon/src/Carbon/Lang/sr_Latn_ME.php b/vendor/nesbot/carbon/src/Carbon/Lang/sr_Latn_ME.php index e2133ef..5b8f2d0 100644 --- a/vendor/nesbot/carbon/src/Carbon/Lang/sr_Latn_ME.php +++ b/vendor/nesbot/carbon/src/Carbon/Lang/sr_Latn_ME.php @@ -16,6 +16,15 @@ */ use Carbon\CarbonInterface; +use Symfony\Component\Translation\PluralizationRules; + +// @codeCoverageIgnoreStart +if (class_exists(PluralizationRules::class)) { + PluralizationRules::set(static function ($number) { + return PluralizationRules::get($number, 'sr'); + }, 'sr_Latn_ME'); +} +// @codeCoverageIgnoreEnd return array_replace_recursive(require __DIR__.'/sr.php', [ 'month' => ':count mjesec|:count mjeseca|:count mjeseci', @@ -27,6 +36,7 @@ return array_replace_recursive(require __DIR__.'/sr.php', [ 'before' => ':time prije', 'week_from_now' => ':count nedjelju|:count nedjelje|:count nedjelja', 'week_ago' => ':count nedjelju|:count nedjelje|:count nedjelja', + 'second_ago' => ':count sekund|:count sekunde|:count sekundi', 'diff_tomorrow' => 'sjutra', 'calendar' => [ 'nextDay' => '[sjutra u] LT', diff --git a/vendor/nesbot/carbon/src/Carbon/Lang/sr_Latn_XK.php b/vendor/nesbot/carbon/src/Carbon/Lang/sr_Latn_XK.php index d0b9d10..5278e2e 100644 --- a/vendor/nesbot/carbon/src/Carbon/Lang/sr_Latn_XK.php +++ b/vendor/nesbot/carbon/src/Carbon/Lang/sr_Latn_XK.php @@ -9,6 +9,16 @@ * file that was distributed with this source code. */ +use Symfony\Component\Translation\PluralizationRules; + +// @codeCoverageIgnoreStart +if (class_exists(PluralizationRules::class)) { + PluralizationRules::set(static function ($number) { + return PluralizationRules::get($number, 'sr'); + }, 'sr_Latn_XK'); +} +// @codeCoverageIgnoreEnd + return array_replace_recursive(require __DIR__.'/sr_Latn_BA.php', [ 'weekdays' => ['nedelja', 'ponedeljak', 'utorak', 'sreda', 'četvrtak', 'petak', 'subota'], ]); diff --git a/vendor/nesbot/carbon/src/Carbon/Lang/ss.php b/vendor/nesbot/carbon/src/Carbon/Lang/ss.php index cd4b919..1c52c9b 100644 --- a/vendor/nesbot/carbon/src/Carbon/Lang/ss.php +++ b/vendor/nesbot/carbon/src/Carbon/Lang/ss.php @@ -50,7 +50,7 @@ return [ $lastDigit = $number % 10; return $number.( - (~~($number % 100 / 10) === 1) ? 'e' : ( + ((int) ($number % 100 / 10) === 1) ? 'e' : ( ($lastDigit === 1 || $lastDigit === 2) ? 'a' : 'e' ) ); diff --git a/vendor/nesbot/carbon/src/Carbon/Lang/sv.php b/vendor/nesbot/carbon/src/Carbon/Lang/sv.php index ca33e1c..1706c71 100644 --- a/vendor/nesbot/carbon/src/Carbon/Lang/sv.php +++ b/vendor/nesbot/carbon/src/Carbon/Lang/sv.php @@ -70,7 +70,7 @@ return [ $lastDigit = $number % 10; return $number.( - (~~($number % 100 / 10) === 1) ? 'e' : ( + ((int) ($number % 100 / 10) === 1) ? 'e' : ( ($lastDigit === 1 || $lastDigit === 2) ? 'a' : 'e' ) ); diff --git a/vendor/nesbot/carbon/src/Carbon/Lang/uk.php b/vendor/nesbot/carbon/src/Carbon/Lang/uk.php index b267b00..1d5ba70 100644 --- a/vendor/nesbot/carbon/src/Carbon/Lang/uk.php +++ b/vendor/nesbot/carbon/src/Carbon/Lang/uk.php @@ -193,6 +193,7 @@ return [ 'genitive' => ['неділі', 'понеділка', 'вівторка', 'середи', 'четверга', 'п’ятниці', 'суботи'], ]; + $format = $format ?? ''; $nounCase = preg_match('/(\[(В|в|У|у)\])\s+dddd/u', $format) ? 'accusative' : ( diff --git a/vendor/nesbot/carbon/src/Carbon/Laravel/ServiceProvider.php b/vendor/nesbot/carbon/src/Carbon/Laravel/ServiceProvider.php index 8be0569..84e241e 100644 --- a/vendor/nesbot/carbon/src/Carbon/Laravel/ServiceProvider.php +++ b/vendor/nesbot/carbon/src/Carbon/Laravel/ServiceProvider.php @@ -24,6 +24,22 @@ use Throwable; class ServiceProvider extends \Illuminate\Support\ServiceProvider { + /** @var callable|null */ + protected $appGetter = null; + + /** @var callable|null */ + protected $localeGetter = null; + + public function setAppGetter(?callable $appGetter): void + { + $this->appGetter = $appGetter; + } + + public function setLocaleGetter(?callable $localeGetter): void + { + $this->localeGetter = $localeGetter; + } + public function boot() { $this->updateLocale(); @@ -44,8 +60,12 @@ class ServiceProvider extends \Illuminate\Support\ServiceProvider public function updateLocale() { - $app = $this->app && method_exists($this->app, 'getLocale') ? $this->app : app('translator'); - $locale = $app->getLocale(); + $locale = $this->getLocale(); + + if ($locale === null) { + return; + } + Carbon::setLocale($locale); CarbonImmutable::setLocale($locale); CarbonPeriod::setLocale($locale); @@ -70,6 +90,34 @@ class ServiceProvider extends \Illuminate\Support\ServiceProvider // Needed for Laravel < 5.3 compatibility } + protected function getLocale() + { + if ($this->localeGetter) { + return ($this->localeGetter)(); + } + + $app = $this->getApp(); + $app = $app && method_exists($app, 'getLocale') + ? $app + : $this->getGlobalApp('translator'); + + return $app ? $app->getLocale() : null; + } + + protected function getApp() + { + if ($this->appGetter) { + return ($this->appGetter)(); + } + + return $this->app ?? $this->getGlobalApp(); + } + + protected function getGlobalApp(...$args) + { + return \function_exists('app') ? \app(...$args) : null; + } + protected function isEventDispatcher($instance) { return $instance instanceof EventDispatcher diff --git a/vendor/nesbot/carbon/src/Carbon/MessageFormatter/MessageFormatterMapper.php b/vendor/nesbot/carbon/src/Carbon/MessageFormatter/MessageFormatterMapper.php new file mode 100644 index 0000000..a230b06 --- /dev/null +++ b/vendor/nesbot/carbon/src/Carbon/MessageFormatter/MessageFormatterMapper.php @@ -0,0 +1,42 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Carbon\MessageFormatter; + +use ReflectionMethod; +use Symfony\Component\Translation\Formatter\MessageFormatter; +use Symfony\Component\Translation\Formatter\MessageFormatterInterface; + +$transMethod = new ReflectionMethod(MessageFormatterInterface::class, 'format'); + +require $transMethod->getParameters()[0]->hasType() + ? __DIR__.'/../../../lazy/Carbon/MessageFormatter/MessageFormatterMapperStrongType.php' + : __DIR__.'/../../../lazy/Carbon/MessageFormatter/MessageFormatterMapperWeakType.php'; + +final class MessageFormatterMapper extends LazyMessageFormatter +{ + /** + * Wrapped formatter. + * + * @var MessageFormatterInterface + */ + protected $formatter; + + public function __construct(?MessageFormatterInterface $formatter = null) + { + $this->formatter = $formatter ?? new MessageFormatter(); + } + + protected function transformLocale(?string $locale): ?string + { + return $locale ? preg_replace('/[_@][A-Za-z][a-z]{2,}/', '', $locale) : $locale; + } +} diff --git a/vendor/nesbot/carbon/src/Carbon/PHPStan/AbstractMacro.php b/vendor/nesbot/carbon/src/Carbon/PHPStan/AbstractMacro.php index fc6fd2a..5123d1e 100644 --- a/vendor/nesbot/carbon/src/Carbon/PHPStan/AbstractMacro.php +++ b/vendor/nesbot/carbon/src/Carbon/PHPStan/AbstractMacro.php @@ -14,6 +14,12 @@ declare(strict_types=1); namespace Carbon\PHPStan; use Closure; +use InvalidArgumentException; +use PHPStan\BetterReflection\Reflection\Adapter\ReflectionParameter as AdapterReflectionParameter; +use PHPStan\BetterReflection\Reflection\Adapter\ReflectionType as AdapterReflectionType; +use PHPStan\BetterReflection\Reflection\ReflectionClass as BetterReflectionClass; +use PHPStan\BetterReflection\Reflection\ReflectionFunction as BetterReflectionFunction; +use PHPStan\BetterReflection\Reflection\ReflectionParameter as BetterReflectionParameter; use PHPStan\Reflection\Php\BuiltinMethodReflection; use PHPStan\TrinaryLogic; use ReflectionClass; @@ -74,14 +80,26 @@ abstract class AbstractMacro implements BuiltinMethodReflection { $this->className = $className; $this->methodName = $methodName; - $this->reflectionFunction = \is_array($macro) + $rawReflectionFunction = \is_array($macro) ? new ReflectionMethod($macro[0], $macro[1]) : new ReflectionFunction($macro); - $this->parameters = $this->reflectionFunction->getParameters(); + $this->reflectionFunction = self::hasModernParser() + ? $this->getReflectionFunction($macro) + : $rawReflectionFunction; // @codeCoverageIgnore + $this->parameters = array_map( + function ($parameter) { + if ($parameter instanceof BetterReflectionParameter) { + return new AdapterReflectionParameter($parameter); + } - if ($this->reflectionFunction->isClosure()) { + return $parameter; // @codeCoverageIgnore + }, + $this->reflectionFunction->getParameters() + ); + + if ($rawReflectionFunction->isClosure()) { try { - $closure = $this->reflectionFunction->getClosure(); + $closure = $rawReflectionFunction->getClosure(); $boundClosure = Closure::bind($closure, new stdClass()); $this->static = (!$boundClosure || (new ReflectionFunction($boundClosure))->getClosureThis() === null); } catch (Throwable $e) { @@ -90,6 +108,31 @@ abstract class AbstractMacro implements BuiltinMethodReflection } } + private function getReflectionFunction($spec) + { + if (\is_array($spec) && \count($spec) === 2 && \is_string($spec[1])) { + \assert($spec[1] !== ''); + + if (\is_object($spec[0])) { + return BetterReflectionClass::createFromInstance($spec[0]) + ->getMethod($spec[1]); + } + + return BetterReflectionClass::createFromName($spec[0]) + ->getMethod($spec[1]); + } + + if (\is_string($spec)) { + return BetterReflectionFunction::createFromName($spec); + } + + if ($spec instanceof Closure) { + return BetterReflectionFunction::createFromClosure($spec); + } + + throw new InvalidArgumentException('Could not create reflection from the spec given'); // @codeCoverageIgnore + } + /** * {@inheritdoc} */ @@ -175,7 +218,13 @@ abstract class AbstractMacro implements BuiltinMethodReflection */ public function getReturnType(): ?ReflectionType { - return $this->reflectionFunction->getReturnType(); + $type = $this->reflectionFunction->getReturnType(); + + if ($type instanceof ReflectionType) { + return $type; // @codeCoverageIgnore + } + + return self::adaptType($type); } /** @@ -205,18 +254,35 @@ abstract class AbstractMacro implements BuiltinMethodReflection return $this; } - /** - * {@inheritdoc} - */ - public function getReflection(): ?ReflectionMethod - { - return $this->reflectionFunction instanceof ReflectionMethod - ? $this->reflectionFunction - : null; - } - public function getTentativeReturnType(): ?ReflectionType { return null; } + + public function returnsByReference(): TrinaryLogic + { + return TrinaryLogic::createNo(); + } + + private static function adaptType($type) + { + $method = method_exists(AdapterReflectionType::class, 'fromTypeOrNull') + ? 'fromTypeOrNull' + : 'fromReturnTypeOrNull'; // @codeCoverageIgnore + + return AdapterReflectionType::$method($type); + } + + private static function hasModernParser(): bool + { + static $modernParser = null; + + if ($modernParser !== null) { + return $modernParser; + } + + $modernParser = method_exists(AdapterReflectionType::class, 'fromTypeOrNull'); + + return $modernParser; + } } diff --git a/vendor/nesbot/carbon/src/Carbon/PHPStan/Macro.php b/vendor/nesbot/carbon/src/Carbon/PHPStan/Macro.php index 8392587..de3e51f 100644 --- a/vendor/nesbot/carbon/src/Carbon/PHPStan/Macro.php +++ b/vendor/nesbot/carbon/src/Carbon/PHPStan/Macro.php @@ -13,9 +13,16 @@ declare(strict_types=1); namespace Carbon\PHPStan; +use PHPStan\BetterReflection\Reflection\Adapter; use PHPStan\Reflection\Php\BuiltinMethodReflection; use ReflectionMethod; +$method = new ReflectionMethod(BuiltinMethodReflection::class, 'getReflection'); + +require $method->hasReturnType() && $method->getReturnType()->getName() === Adapter\ReflectionMethod::class + ? __DIR__.'/../../../lazy/Carbon/PHPStan/AbstractMacroStatic.php' + : __DIR__.'/../../../lazy/Carbon/PHPStan/AbstractMacroBuiltin.php'; + $method = new ReflectionMethod(BuiltinMethodReflection::class, 'getFileName'); require $method->hasReturnType() diff --git a/vendor/nesbot/carbon/src/Carbon/PHPStan/MacroExtension.php b/vendor/nesbot/carbon/src/Carbon/PHPStan/MacroExtension.php index 8e2524c..2cd6fce 100644 --- a/vendor/nesbot/carbon/src/Carbon/PHPStan/MacroExtension.php +++ b/vendor/nesbot/carbon/src/Carbon/PHPStan/MacroExtension.php @@ -11,10 +11,12 @@ namespace Carbon\PHPStan; +use PHPStan\Reflection\Assertions; use PHPStan\Reflection\ClassReflection; use PHPStan\Reflection\MethodReflection; use PHPStan\Reflection\MethodsClassReflectionExtension; use PHPStan\Reflection\Php\PhpMethodReflectionFactory; +use PHPStan\Reflection\ReflectionProvider; use PHPStan\Type\TypehintHelper; /** @@ -38,10 +40,13 @@ final class MacroExtension implements MethodsClassReflectionExtension * Extension constructor. * * @param PhpMethodReflectionFactory $methodReflectionFactory + * @param ReflectionProvider $reflectionProvider */ - public function __construct(PhpMethodReflectionFactory $methodReflectionFactory) - { - $this->scanner = new MacroScanner(); + public function __construct( + PhpMethodReflectionFactory $methodReflectionFactory, + ReflectionProvider $reflectionProvider + ) { + $this->scanner = new MacroScanner($reflectionProvider); $this->methodReflectionFactory = $methodReflectionFactory; } @@ -59,6 +64,7 @@ final class MacroExtension implements MethodsClassReflectionExtension public function getMethod(ClassReflection $classReflection, string $methodName): MethodReflection { $builtinMacro = $this->scanner->getMethod($classReflection->getName(), $methodName); + $supportAssertions = class_exists(Assertions::class); return $this->methodReflectionFactory->create( $classReflection, @@ -72,7 +78,11 @@ final class MacroExtension implements MethodsClassReflectionExtension $builtinMacro->isDeprecated()->yes(), $builtinMacro->isInternal(), $builtinMacro->isFinal(), - $builtinMacro->getDocComment() + $supportAssertions ? null : $builtinMacro->getDocComment(), + $supportAssertions ? Assertions::createEmpty() : null, + null, + $builtinMacro->getDocComment(), + [] ); } } diff --git a/vendor/nesbot/carbon/src/Carbon/PHPStan/MacroScanner.php b/vendor/nesbot/carbon/src/Carbon/PHPStan/MacroScanner.php index d169939..c88e49e 100644 --- a/vendor/nesbot/carbon/src/Carbon/PHPStan/MacroScanner.php +++ b/vendor/nesbot/carbon/src/Carbon/PHPStan/MacroScanner.php @@ -12,11 +12,27 @@ namespace Carbon\PHPStan; use Carbon\CarbonInterface; +use PHPStan\Reflection\ReflectionProvider; use ReflectionClass; use ReflectionException; final class MacroScanner { + /** + * @var \PHPStan\Reflection\ReflectionProvider + */ + private $reflectionProvider; + + /** + * MacroScanner constructor. + * + * @param \PHPStan\Reflection\ReflectionProvider $reflectionProvider + */ + public function __construct(ReflectionProvider $reflectionProvider) + { + $this->reflectionProvider = $reflectionProvider; + } + /** * Return true if the given pair class-method is a Carbon macro. * @@ -29,8 +45,16 @@ final class MacroScanner */ public function hasMethod(string $className, string $methodName): bool { - return is_a($className, CarbonInterface::class, true) && - \is_callable([$className, 'hasMacro']) && + $classReflection = $this->reflectionProvider->getClass($className); + + if ( + $classReflection->getName() !== CarbonInterface::class && + !$classReflection->isSubclassOf(CarbonInterface::class) + ) { + return false; + } + + return \is_callable([$className, 'hasMacro']) && $className::hasMacro($methodName); } diff --git a/vendor/nesbot/carbon/src/Carbon/Traits/Comparison.php b/vendor/nesbot/carbon/src/Carbon/Traits/Comparison.php index a23e6ed..f6261d8 100644 --- a/vendor/nesbot/carbon/src/Carbon/Traits/Comparison.php +++ b/vendor/nesbot/carbon/src/Carbon/Traits/Comparison.php @@ -75,6 +75,9 @@ trait Comparison */ public function equalTo($date): bool { + $this->discourageNull($date); + $this->discourageBoolean($date); + return $this == $this->resolveCarbon($date); } @@ -155,6 +158,9 @@ trait Comparison */ public function greaterThan($date): bool { + $this->discourageNull($date); + $this->discourageBoolean($date); + return $this > $this->resolveCarbon($date); } @@ -216,7 +222,10 @@ trait Comparison */ public function greaterThanOrEqualTo($date): bool { - return $this >= $date; + $this->discourageNull($date); + $this->discourageBoolean($date); + + return $this >= $this->resolveCarbon($date); } /** @@ -256,6 +265,9 @@ trait Comparison */ public function lessThan($date): bool { + $this->discourageNull($date); + $this->discourageBoolean($date); + return $this < $this->resolveCarbon($date); } @@ -317,7 +329,10 @@ trait Comparison */ public function lessThanOrEqualTo($date): bool { - return $this <= $date; + $this->discourageNull($date); + $this->discourageBoolean($date); + + return $this <= $this->resolveCarbon($date); } /** @@ -351,10 +366,10 @@ trait Comparison } if ($equal) { - return $this->greaterThanOrEqualTo($date1) && $this->lessThanOrEqualTo($date2); + return $this >= $date1 && $this <= $date2; } - return $this->greaterThan($date1) && $this->lessThan($date2); + return $this > $date1 && $this < $date2; } /** @@ -448,7 +463,7 @@ trait Comparison */ public function isWeekend() { - return \in_array($this->dayOfWeek, static::$weekendDays); + return \in_array($this->dayOfWeek, static::$weekendDays, true); } /** @@ -548,12 +563,17 @@ trait Comparison } /** - * Determines if the instance is a long year + * Determines if the instance is a long year (using calendar year). + * + * ⚠️ This method completely ignores month and day to use the numeric year number, + * it's not correct if the exact date matters. For instance as `2019-12-30` is already + * in the first week of the 2020 year, if you want to know from this date if ISO week + * year 2020 is a long year, use `isLongIsoYear` instead. * * @example * ``` - * Carbon::parse('2015-01-01')->isLongYear(); // true - * Carbon::parse('2016-01-01')->isLongYear(); // false + * Carbon::create(2015)->isLongYear(); // true + * Carbon::create(2016)->isLongYear(); // false * ``` * * @see https://en.wikipedia.org/wiki/ISO_8601#Week_dates @@ -565,6 +585,27 @@ trait Comparison return static::create($this->year, 12, 28, 0, 0, 0, $this->tz)->weekOfYear === 53; } + /** + * Determines if the instance is a long year (using ISO 8601 year). + * + * @example + * ``` + * Carbon::parse('2015-01-01')->isLongIsoYear(); // true + * Carbon::parse('2016-01-01')->isLongIsoYear(); // true + * Carbon::parse('2016-01-03')->isLongIsoYear(); // false + * Carbon::parse('2019-12-29')->isLongIsoYear(); // false + * Carbon::parse('2019-12-30')->isLongIsoYear(); // true + * ``` + * + * @see https://en.wikipedia.org/wiki/ISO_8601#Week_dates + * + * @return bool + */ + public function isLongIsoYear() + { + return static::create($this->isoWeekYear, 12, 28, 0, 0, 0, $this->tz)->weekOfYear === 53; + } + /** * Compares the formatted values of the two dates. * @@ -621,19 +662,19 @@ trait Comparison 'microsecond' => 'Y-m-d H:i:s.u', ]; - if (!isset($units[$unit])) { - if (isset($this->$unit)) { - return $this->resolveCarbon($date)->$unit === $this->$unit; - } - - if ($this->localStrictModeEnabled ?? static::isStrictModeEnabled()) { - throw new BadComparisonUnitException($unit); - } - - return false; + if (isset($units[$unit])) { + return $this->isSameAs($units[$unit], $date); } - return $this->isSameAs($units[$unit], $date); + if (isset($this->$unit)) { + return $this->resolveCarbon($date)->$unit === $this->$unit; + } + + if ($this->localStrictModeEnabled ?? static::isStrictModeEnabled()) { + throw new BadComparisonUnitException($unit); + } + + return false; } /** @@ -981,12 +1022,12 @@ trait Comparison return $current->startOfMinute()->eq($other); } - if (preg_match('/\d(h|am|pm)$/', $tester)) { + if (preg_match('/\d(?:h|am|pm)$/', $tester)) { return $current->startOfHour()->eq($other); } if (preg_match( - '/^(january|february|march|april|may|june|july|august|september|october|november|december)\s+\d+$/i', + '/^(?:january|february|march|april|may|june|july|august|september|october|november|december)(?:\s+\d+)?$/i', $tester )) { return $current->startOfMonth()->eq($other->startOfMonth()); @@ -1067,4 +1108,18 @@ trait Comparison { return $this->endOfTime ?? false; } + + private function discourageNull($value): void + { + if ($value === null) { + @trigger_error("Since 2.61.0, it's deprecated to compare a date to null, meaning of such comparison is ambiguous and will no longer be possible in 3.0.0, you should explicitly pass 'now' or make an other check to eliminate null values.", \E_USER_DEPRECATED); + } + } + + private function discourageBoolean($value): void + { + if (\is_bool($value)) { + @trigger_error("Since 2.61.0, it's deprecated to compare a date to true or false, meaning of such comparison is ambiguous and will no longer be possible in 3.0.0, you should explicitly pass 'now' or make an other check to eliminate boolean values.", \E_USER_DEPRECATED); + } + } } diff --git a/vendor/nesbot/carbon/src/Carbon/Traits/Converter.php b/vendor/nesbot/carbon/src/Carbon/Traits/Converter.php index 8fe008a..fff8a60 100644 --- a/vendor/nesbot/carbon/src/Carbon/Traits/Converter.php +++ b/vendor/nesbot/carbon/src/Carbon/Traits/Converter.php @@ -16,6 +16,7 @@ use Carbon\CarbonImmutable; use Carbon\CarbonInterface; use Carbon\CarbonInterval; use Carbon\CarbonPeriod; +use Carbon\CarbonPeriodImmutable; use Carbon\Exceptions\UnitException; use Closure; use DateTime; @@ -34,39 +35,7 @@ use ReturnTypeWillChange; */ trait Converter { - /** - * Format to use for __toString method when type juggling occurs. - * - * @var string|Closure|null - */ - protected static $toStringFormat; - - /** - * Reset the format used to the default when type juggling a Carbon instance to a string - * - * @return void - */ - public static function resetToStringFormat() - { - static::setToStringFormat(null); - } - - /** - * @deprecated To avoid conflict between different third-party libraries, static setters should not be used. - * You should rather let Carbon object being casted to string with DEFAULT_TO_STRING_FORMAT, and - * use other method or custom format passed to format() method if you need to dump an other string - * format. - * - * Set the default format used when type juggling a Carbon instance to a string - * - * @param string|Closure|null $format - * - * @return void - */ - public static function setToStringFormat($format) - { - static::$toStringFormat = $format; - } + use ToStringFormat; /** * Returns the formatted date string on success or FALSE on failure. @@ -110,7 +79,7 @@ trait Converter * * @example * ``` - * echo Carbon::now(); // Carbon instances can be casted to string + * echo Carbon::now(); // Carbon instances can be cast to string * ``` * * @return string @@ -158,6 +127,21 @@ trait Converter return $this->rawFormat('M j, Y'); } + /** + * Format the instance with the day, and a readable date + * + * @example + * ``` + * echo Carbon::now()->toFormattedDayDateString(); + * ``` + * + * @return string + */ + public function toFormattedDayDateString(): string + { + return $this->rawFormat('D, M j, Y'); + } + /** * Format the instance as time * @@ -622,16 +606,18 @@ trait Converter $interval = CarbonInterval::make("$interval ".static::pluralUnit($unit)); } - $period = (new CarbonPeriod())->setDateClass(static::class)->setStartDate($this); + $period = ($this->isMutable() ? new CarbonPeriod() : new CarbonPeriodImmutable()) + ->setDateClass(static::class) + ->setStartDate($this); if ($interval) { - $period->setDateInterval($interval); + $period = $period->setDateInterval($interval); } - if (\is_int($end) || \is_string($end) && ctype_digit($end)) { - $period->setRecurrences($end); + if (\is_int($end) || (\is_string($end) && ctype_digit($end))) { + $period = $period->setRecurrences($end); } elseif ($end) { - $period->setEndDate($end); + $period = $period->setEndDate($end); } return $period; diff --git a/vendor/nesbot/carbon/src/Carbon/Traits/Creator.php b/vendor/nesbot/carbon/src/Carbon/Traits/Creator.php index f2adee5..d73dad5 100644 --- a/vendor/nesbot/carbon/src/Carbon/Traits/Creator.php +++ b/vendor/nesbot/carbon/src/Carbon/Traits/Creator.php @@ -79,8 +79,8 @@ trait Creator // Work-around for PHP bug https://bugs.php.net/bug.php?id=67127 if (!str_contains((string) .1, '.')) { - $locale = setlocale(LC_NUMERIC, '0'); - setlocale(LC_NUMERIC, 'C'); + $locale = setlocale(LC_NUMERIC, '0'); // @codeCoverageIgnore + setlocale(LC_NUMERIC, 'C'); // @codeCoverageIgnore } try { @@ -92,7 +92,7 @@ trait Creator $this->constructedObjectId = spl_object_hash($this); if (isset($locale)) { - setlocale(LC_NUMERIC, $locale); + setlocale(LC_NUMERIC, $locale); // @codeCoverageIgnore } self::setLastErrors(parent::getLastErrors()); @@ -148,7 +148,7 @@ trait Creator $instance = new static($date->format('Y-m-d H:i:s.u'), $date->getTimezone()); - if ($date instanceof CarbonInterface || $date instanceof Options) { + if ($date instanceof CarbonInterface) { $settings = $date->getSettings(); if (!$date->hasLocalTranslator()) { @@ -354,13 +354,13 @@ trait Creator * If $hour is not null then the default values for $minute and $second * will be 0. * - * @param int|null $year - * @param int|null $month - * @param int|null $day - * @param int|null $hour - * @param int|null $minute - * @param int|null $second - * @param DateTimeZone|string|null $tz + * @param DateTimeInterface|int|null $year + * @param int|null $month + * @param int|null $day + * @param int|null $hour + * @param int|null $minute + * @param int|null $second + * @param DateTimeZone|string|null $tz * * @throws InvalidFormatException * @@ -368,7 +368,7 @@ trait Creator */ public static function create($year = 0, $month = 1, $day = 1, $hour = 0, $minute = 0, $second = 0, $tz = null) { - if (\is_string($year) && !is_numeric($year) || $year instanceof DateTimeInterface) { + if ((\is_string($year) && !is_numeric($year)) || $year instanceof DateTimeInterface) { return static::parse($year, $tz ?: (\is_string($month) || $month instanceof DateTimeZone ? $month : null)); } @@ -862,6 +862,19 @@ trait Creator */ public static function createFromLocaleFormat($format, $locale, $time, $tz = null) { + $format = preg_replace_callback( + '/(?:\\\\[a-zA-Z]|[bfkqCEJKQRV]){2,}/', + static function (array $match) use ($locale): string { + $word = str_replace('\\', '', $match[0]); + $translatedWord = static::translateTimeString($word, $locale, 'en'); + + return $word === $translatedWord + ? $match[0] + : preg_replace('/[a-zA-Z]/', '\\\\$0', $translatedWord); + }, + $format + ); + return static::rawCreateFromFormat($format, static::translateTimeString($time, $locale, 'en'), $tz); } @@ -907,9 +920,9 @@ trait Creator if (\is_string($var)) { $var = trim($var); - if (!preg_match('/^P[0-9T]/', $var) && - !preg_match('/^R[0-9]/', $var) && - preg_match('/[a-z0-9]/i', $var) + if (!preg_match('/^P[\dT]/', $var) && + !preg_match('/^R\d/', $var) && + preg_match('/[a-z\d]/i', $var) ) { $date = static::parse($var); } @@ -921,13 +934,20 @@ trait Creator /** * Set last errors. * - * @param array $lastErrors + * @param array|bool $lastErrors * * @return void */ - private static function setLastErrors(array $lastErrors) + private static function setLastErrors($lastErrors) { - static::$lastErrors = $lastErrors; + if (\is_array($lastErrors) || $lastErrors === false) { + static::$lastErrors = \is_array($lastErrors) ? $lastErrors : [ + 'warning_count' => 0, + 'warnings' => [], + 'error_count' => 0, + 'errors' => [], + ]; + } } /** diff --git a/vendor/nesbot/carbon/src/Carbon/Traits/Date.php b/vendor/nesbot/carbon/src/Carbon/Traits/Date.php index 8c8af6f..da3775c 100644 --- a/vendor/nesbot/carbon/src/Carbon/Traits/Date.php +++ b/vendor/nesbot/carbon/src/Carbon/Traits/Date.php @@ -532,6 +532,7 @@ trait Date use Creator; use Difference; use Macro; + use MagicParameter; use Modifiers; use Mutability; use ObjectInitialisation; @@ -641,9 +642,11 @@ trait Date /** * List of minimum and maximums for each unit. * + * @param int $daysInMonth + * * @return array */ - protected static function getRangesByUnit() + protected static function getRangesByUnit(int $daysInMonth = 31): array { return [ // @call roundUnit @@ -651,7 +654,7 @@ trait Date // @call roundUnit 'month' => [1, static::MONTHS_PER_YEAR], // @call roundUnit - 'day' => [1, 31], + 'day' => [1, $daysInMonth], // @call roundUnit 'hour' => [0, static::HOURS_PER_DAY - 1], // @call roundUnit @@ -940,7 +943,7 @@ trait Date case $name === 'millisecond': // @property int case $name === 'milli': - return (int) floor($this->rawFormat('u') / 1000); + return (int) floor(((int) $this->rawFormat('u')) / 1000); // @property int 1 through 53 case $name === 'week': @@ -1250,7 +1253,7 @@ trait Date protected function getTranslatedFormByRegExp($baseKey, $keySuffix, $context, $subKey, $defaultValue) { $key = $baseKey.$keySuffix; - $standaloneKey = "${key}_standalone"; + $standaloneKey = "{$key}_standalone"; $baseTranslation = $this->getTranslationMessage($key); if ($baseTranslation instanceof Closure) { @@ -1259,7 +1262,7 @@ trait Date if ( $this->getTranslationMessage("$standaloneKey.$subKey") && - (!$context || ($regExp = $this->getTranslationMessage("${baseKey}_regexp")) && !preg_match($regExp, $context)) + (!$context || (($regExp = $this->getTranslationMessage("{$baseKey}_regexp")) && !preg_match($regExp, $context))) ) { $key = $standaloneKey; } @@ -1354,9 +1357,14 @@ trait Date */ public function weekday($value = null) { - $dayOfWeek = ($this->dayOfWeek + 7 - (int) ($this->getTranslationMessage('first_day_of_week') ?? 0)) % 7; + if ($value === null) { + return $this->dayOfWeek; + } - return $value === null ? $dayOfWeek : $this->addDays($value - $dayOfWeek); + $firstDay = (int) ($this->getTranslationMessage('first_day_of_week') ?? 0); + $dayOfWeek = ($this->dayOfWeek + 7 - $firstDay) % 7; + + return $this->addDays((($value + 7 - $firstDay) % 7) - $dayOfWeek); } /** @@ -1373,6 +1381,39 @@ trait Date return $value === null ? $dayOfWeekIso : $this->addDays($value - $dayOfWeekIso); } + /** + * Return the number of days since the start of the week (using the current locale or the first parameter + * if explicitly given). + * + * @param int|null $weekStartsAt optional start allow you to specify the day of week to use to start the week, + * if not provided, start of week is inferred from the locale + * (Sunday for en_US, Monday for de_DE, etc.) + * + * @return int + */ + public function getDaysFromStartOfWeek(int $weekStartsAt = null): int + { + $firstDay = (int) ($weekStartsAt ?? $this->getTranslationMessage('first_day_of_week') ?? 0); + + return ($this->dayOfWeek + 7 - $firstDay) % 7; + } + + /** + * Set the day (keeping the current time) to the start of the week + the number of days passed as the first + * parameter. First day of week is driven by the locale unless explicitly set with the second parameter. + * + * @param int $numberOfDays number of days to add after the start of the current week + * @param int|null $weekStartsAt optional start allow you to specify the day of week to use to start the week, + * if not provided, start of week is inferred from the locale + * (Sunday for en_US, Monday for de_DE, etc.) + * + * @return static + */ + public function setDaysFromStartOfWeek(int $numberOfDays, int $weekStartsAt = null) + { + return $this->addDays($numberOfDays - $this->getDaysFromStartOfWeek($weekStartsAt)); + } + /** * Set any unit to a new value without overflowing current other unit given. * @@ -1848,9 +1889,18 @@ trait Date $format = preg_replace('#(?toDateTimeString())); + $time = strtotime($this->toDateTimeString()); + $formatted = ($this->localStrictModeEnabled ?? static::isStrictModeEnabled()) + ? strftime($format, $time) + : @strftime($format, $time); - return static::$utf8 ? utf8_encode($formatted) : $formatted; + return static::$utf8 + ? ( + \function_exists('mb_convert_encoding') + ? mb_convert_encoding($formatted, 'UTF-8', mb_list_encodings()) + : utf8_encode($formatted) + ) + : $formatted; } /** @@ -1869,6 +1919,10 @@ trait Date 'LL' => $this->getTranslationMessage('formats.LL', $locale, 'MMMM D, YYYY'), 'LLL' => $this->getTranslationMessage('formats.LLL', $locale, 'MMMM D, YYYY h:mm A'), 'LLLL' => $this->getTranslationMessage('formats.LLLL', $locale, 'dddd, MMMM D, YYYY h:mm A'), + 'l' => $this->getTranslationMessage('formats.l', $locale), + 'll' => $this->getTranslationMessage('formats.ll', $locale), + 'lll' => $this->getTranslationMessage('formats.lll', $locale), + 'llll' => $this->getTranslationMessage('formats.llll', $locale), ]; } @@ -2152,7 +2206,7 @@ trait Date $input = mb_substr($format, $i); - if (preg_match('/^(LTS|LT|[Ll]{1,4})/', $input, $match)) { + if (preg_match('/^(LTS|LT|l{1,4}|L{1,4})/', $input, $match)) { if ($formats === null) { $formats = $this->getIsoFormats(); } @@ -2359,7 +2413,7 @@ trait Date $symbol = $second < 0 ? '-' : '+'; $minute = abs($second) / static::SECONDS_PER_MINUTE; $hour = str_pad((string) floor($minute / static::MINUTES_PER_HOUR), 2, '0', STR_PAD_LEFT); - $minute = str_pad((string) ($minute % static::MINUTES_PER_HOUR), 2, '0', STR_PAD_LEFT); + $minute = str_pad((string) (((int) $minute) % static::MINUTES_PER_HOUR), 2, '0', STR_PAD_LEFT); return "$symbol$hour$separator$minute"; } @@ -2479,7 +2533,7 @@ trait Date return 'millennia'; } - return "${unit}s"; + return "{$unit}s"; } protected function executeCallable($macro, ...$parameters) @@ -2566,7 +2620,7 @@ trait Date if (str_starts_with($unit, 'is')) { $word = substr($unit, 2); - if (\in_array($word, static::$days)) { + if (\in_array($word, static::$days, true)) { return $this->isDayOfWeek($word); } @@ -2594,7 +2648,7 @@ trait Date $unit = strtolower(substr($unit, 3)); } - if (\in_array($unit, static::$units)) { + if (\in_array($unit, static::$units, true)) { return $this->setUnit($unit, ...$parameters); } @@ -2604,7 +2658,7 @@ trait Date if (str_starts_with($unit, 'Real')) { $unit = static::singularUnit(substr($unit, 4)); - return $this->{"${action}RealUnit"}($unit, ...$parameters); + return $this->{"{$action}RealUnit"}($unit, ...$parameters); } if (preg_match('/^(Month|Quarter|Year|Decade|Century|Centurie|Millennium|Millennia)s?(No|With|Without|WithNo)Overflow$/', $unit, $match)) { @@ -2616,7 +2670,7 @@ trait Date } if (static::isModifiableUnit($unit)) { - return $this->{"${action}Unit"}($unit, $parameters[0] ?? 1, $overflow); + return $this->{"{$action}Unit"}($unit, $this->getMagicParameter($parameters, 0, 'value', 1), $overflow); } $sixFirstLetters = substr($unit, 0, 6); @@ -2655,7 +2709,11 @@ trait Date try { $unit = static::singularUnit(substr($method, 0, -5)); - return $this->range($parameters[0] ?? $this, $parameters[1] ?? 1, $unit); + return $this->range( + $this->getMagicParameter($parameters, 0, 'endDate', $this), + $this->getMagicParameter($parameters, 1, 'factor', 1), + $unit + ); } catch (InvalidArgumentException $exception) { // Try macros } diff --git a/vendor/nesbot/carbon/src/Carbon/Traits/Difference.php b/vendor/nesbot/carbon/src/Carbon/Traits/Difference.php index cce1d2c..a9868eb 100644 --- a/vendor/nesbot/carbon/src/Carbon/Traits/Difference.php +++ b/vendor/nesbot/carbon/src/Carbon/Traits/Difference.php @@ -83,9 +83,9 @@ trait Difference * * @return CarbonInterval */ - protected static function fixDiffInterval(DateInterval $diff, $absolute) + protected static function fixDiffInterval(DateInterval $diff, $absolute, array $skip = []) { - $diff = CarbonInterval::instance($diff); + $diff = CarbonInterval::instance($diff, $skip); // Work-around for https://bugs.php.net/bug.php?id=77145 // @codeCoverageIgnoreStart @@ -148,9 +148,9 @@ trait Difference * * @return CarbonInterval */ - public function diffAsCarbonInterval($date = null, $absolute = true) + public function diffAsCarbonInterval($date = null, $absolute = true, array $skip = []) { - return static::fixDiffInterval($this->diff($this->resolveCarbon($date), $absolute), $absolute); + return static::fixDiffInterval($this->diff($this->resolveCarbon($date), $absolute), $absolute, $skip); } /** @@ -189,9 +189,21 @@ trait Difference */ public function diffInMonths($date = null, $absolute = true) { - $date = $this->resolveCarbon($date); + $date = $this->resolveCarbon($date)->avoidMutation()->tz($this->tz); - return $this->diffInYears($date, $absolute) * static::MONTHS_PER_YEAR + (int) $this->diff($date, $absolute)->format('%r%m'); + [$yearStart, $monthStart, $dayStart] = explode('-', $this->format('Y-m-dHisu')); + [$yearEnd, $monthEnd, $dayEnd] = explode('-', $date->format('Y-m-dHisu')); + + $diff = (((int) $yearEnd) - ((int) $yearStart)) * static::MONTHS_PER_YEAR + + ((int) $monthEnd) - ((int) $monthStart); + + if ($diff > 0) { + $diff -= ($dayStart > $dayEnd ? 1 : 0); + } elseif ($diff < 0) { + $diff += ($dayStart < $dayEnd ? 1 : 0); + } + + return $absolute ? abs($diff) : $diff; } /** @@ -472,7 +484,7 @@ trait Difference */ public function floatDiffInSeconds($date = null, $absolute = true) { - return $this->diffInMicroseconds($date, $absolute) / static::MICROSECONDS_PER_SECOND; + return (float) ($this->diffInMicroseconds($date, $absolute) / static::MICROSECONDS_PER_SECOND); } /** @@ -830,8 +842,9 @@ trait Difference $intSyntax = $intSyntax === static::DIFF_RELATIVE_AUTO && $other === null ? static::DIFF_RELATIVE_TO_NOW : $intSyntax; $parts = min(7, max(1, (int) $parts)); + $skip = \is_array($syntax) ? ($syntax['skip'] ?? []) : []; - return $this->diffAsCarbonInterval($other, false) + return $this->diffAsCarbonInterval($other, false, (array) $skip) ->setLocalTranslator($this->getLocalTranslator()) ->forHumans($syntax, (bool) $short, $parts, $options ?? $this->localHumanDiffOptions ?? static::getHumanDiffOptions()); } @@ -1161,7 +1174,7 @@ trait Difference version_compare(PHP_VERSION, '8.1.0-dev', '<') && abs($interval->d - $daysDiff) === 1 ) { - $daysDiff = abs($interval->d); + $daysDiff = abs($interval->d); // @codeCoverageIgnore } return $daysDiff * $sign; diff --git a/vendor/nesbot/carbon/src/Carbon/Traits/Localization.php b/vendor/nesbot/carbon/src/Carbon/Traits/Localization.php index ddd2b4e..ff24956 100644 --- a/vendor/nesbot/carbon/src/Carbon/Traits/Localization.php +++ b/vendor/nesbot/carbon/src/Carbon/Traits/Localization.php @@ -23,7 +23,9 @@ use Symfony\Component\Translation\TranslatorInterface; use Symfony\Contracts\Translation\LocaleAwareInterface; use Symfony\Contracts\Translation\TranslatorInterface as ContractsTranslatorInterface; -if (!interface_exists('Symfony\\Component\\Translation\\TranslatorInterface')) { +if (interface_exists('Symfony\\Contracts\\Translation\\TranslatorInterface') && + !interface_exists('Symfony\\Component\\Translation\\TranslatorInterface') +) { class_alias( 'Symfony\\Contracts\\Translation\\TranslatorInterface', 'Symfony\\Component\\Translation\\TranslatorInterface' @@ -355,6 +357,13 @@ trait Localization $weekdays = $messages['weekdays'] ?? []; $meridiem = $messages['meridiem'] ?? ['AM', 'PM']; + if (isset($messages['ordinal_words'])) { + $timeString = self::replaceOrdinalWords( + $timeString, + $key === 'from' ? array_flip($messages['ordinal_words']) : $messages['ordinal_words'] + ); + } + if ($key === 'from') { foreach (['months', 'weekdays'] as $variable) { $list = $messages[$variable.'_standalone'] ?? null; @@ -454,7 +463,7 @@ trait Localization } } - $this->setLocalTranslator($translator); + $this->localTranslator = $translator; } return $this; @@ -555,17 +564,13 @@ trait Localization public static function localeHasShortUnits($locale) { return static::executeWithLocale($locale, function ($newLocale, TranslatorInterface $translator) { - return $newLocale && - ( - ($y = static::translateWith($translator, 'y')) !== 'y' && - $y !== static::translateWith($translator, 'year') - ) || ( - ($y = static::translateWith($translator, 'd')) !== 'd' && + return ($newLocale && (($y = static::translateWith($translator, 'y')) !== 'y' && $y !== static::translateWith($translator, 'year'))) || ( + ($y = static::translateWith($translator, 'd')) !== 'd' && $y !== static::translateWith($translator, 'day') - ) || ( - ($y = static::translateWith($translator, 'h')) !== 'h' && + ) || ( + ($y = static::translateWith($translator, 'h')) !== 'h' && $y !== static::translateWith($translator, 'hour') - ); + ); }); } @@ -734,7 +739,7 @@ trait Localization } if ($translator && !($translator instanceof LocaleAwareInterface || method_exists($translator, 'getLocale'))) { - throw new NotLocaleAwareException($translator); + throw new NotLocaleAwareException($translator); // @codeCoverageIgnore } return $translator; @@ -823,4 +828,11 @@ trait Localization return $list; } + + private static function replaceOrdinalWords(string $timeString, array $ordinalWords): string + { + return preg_replace_callback('/(? + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Carbon\Traits; + +/** + * Trait MagicParameter. + * + * Allows to retrieve parameter in magic calls by index or name. + */ +trait MagicParameter +{ + private function getMagicParameter(array $parameters, int $index, string $key, $default) + { + if (\array_key_exists($index, $parameters)) { + return $parameters[$index]; + } + + if (\array_key_exists($key, $parameters)) { + return $parameters[$key]; + } + + return $default; + } +} diff --git a/vendor/nesbot/carbon/src/Carbon/Traits/Mixin.php b/vendor/nesbot/carbon/src/Carbon/Traits/Mixin.php index 88b251d..595c287 100644 --- a/vendor/nesbot/carbon/src/Carbon/Traits/Mixin.php +++ b/vendor/nesbot/carbon/src/Carbon/Traits/Mixin.php @@ -151,22 +151,12 @@ trait Mixin protected static function bindMacroContext($context, callable $callable) { static::$macroContextStack[] = $context; - $exception = null; - $result = null; try { - $result = $callable(); - } catch (Throwable $throwable) { - $exception = $throwable; + return $callable(); + } finally { + array_pop(static::$macroContextStack); } - - array_pop(static::$macroContextStack); - - if ($exception) { - throw $exception; - } - - return $result; } /** diff --git a/vendor/nesbot/carbon/src/Carbon/Traits/Modifiers.php b/vendor/nesbot/carbon/src/Carbon/Traits/Modifiers.php index 164dbbd..39343d8 100644 --- a/vendor/nesbot/carbon/src/Carbon/Traits/Modifiers.php +++ b/vendor/nesbot/carbon/src/Carbon/Traits/Modifiers.php @@ -75,7 +75,7 @@ trait Modifiers * * @param string|int|null $modifier * - * @return static + * @return static|false */ public function next($modifier = null) { @@ -157,7 +157,7 @@ trait Modifiers * * @param string|int|null $modifier * - * @return static + * @return static|false */ public function previous($modifier = null) { @@ -451,7 +451,7 @@ trait Modifiers * * @param string $modifier * - * @return static + * @return static|false */ public function change($modifier) { diff --git a/vendor/nesbot/carbon/src/Carbon/Traits/Options.php b/vendor/nesbot/carbon/src/Carbon/Traits/Options.php index 0ddee8d..9bb3071 100644 --- a/vendor/nesbot/carbon/src/Carbon/Traits/Options.php +++ b/vendor/nesbot/carbon/src/Carbon/Traits/Options.php @@ -441,7 +441,7 @@ trait Options return $var; }); - foreach (['dumpProperties', 'constructedObjectId'] as $property) { + foreach (['dumpProperties', 'constructedObjectId', 'constructed'] as $property) { if (isset($infos[$property])) { unset($infos[$property]); } diff --git a/vendor/nesbot/carbon/src/Carbon/Traits/Rounding.php b/vendor/nesbot/carbon/src/Carbon/Traits/Rounding.php index 3306239..f98c2a3 100644 --- a/vendor/nesbot/carbon/src/Carbon/Traits/Rounding.php +++ b/vendor/nesbot/carbon/src/Carbon/Traits/Rounding.php @@ -52,7 +52,7 @@ trait Rounding 'millisecond' => [1000, 'microsecond'], ]; $normalizedUnit = static::singularUnit($unit); - $ranges = array_merge(static::getRangesByUnit(), [ + $ranges = array_merge(static::getRangesByUnit($this->daysInMonth), [ // @call roundUnit 'microsecond' => [0, 999999], ]); @@ -77,12 +77,15 @@ trait Rounding $found = false; $fraction = 0; $arguments = null; + $initialValue = null; $factor = $this->year < 0 ? -1 : 1; $changes = []; + $minimumInc = null; foreach ($ranges as $unit => [$minimum, $maximum]) { if ($normalizedUnit === $unit) { $arguments = [$this->$unit, $minimum]; + $initialValue = $this->$unit; $fraction = $precision - floor($precision); $found = true; @@ -93,7 +96,23 @@ trait Rounding $delta = $maximum + 1 - $minimum; $factor /= $delta; $fraction *= $delta; - $arguments[0] += $this->$unit * $factor; + $inc = ($this->$unit - $minimum) * $factor; + + if ($inc !== 0.0) { + $minimumInc = $minimumInc ?? ($arguments[0] / pow(2, 52)); + + // If value is still the same when adding a non-zero increment/decrement, + // it means precision got lost in the addition + if (abs($inc) < $minimumInc) { + $inc = $minimumInc * ($inc < 0 ? -1 : 1); + } + + // If greater than $precision, assume precision loss caused an overflow + if ($function !== 'floor' || abs($arguments[0] + $inc - $initialValue) >= $precision) { + $arguments[0] += $inc; + } + } + $changes[$unit] = round( $minimum + ($fraction ? $fraction * $function(($this->$unit - $minimum) / $fraction) : 0) ); diff --git a/vendor/nesbot/carbon/src/Carbon/Traits/Serialization.php b/vendor/nesbot/carbon/src/Carbon/Traits/Serialization.php index eebc69b..53fead6 100644 --- a/vendor/nesbot/carbon/src/Carbon/Traits/Serialization.php +++ b/vendor/nesbot/carbon/src/Carbon/Traits/Serialization.php @@ -120,6 +120,8 @@ trait Serialization /** * Returns the list of properties to dump on serialize() called on. * + * Only used by PHP < 7.4. + * * @return array */ public function __sleep() @@ -134,22 +136,70 @@ trait Serialization return $properties; } + /** + * Returns the values to dump on serialize() called on. + * + * Only used by PHP >= 7.4. + * + * @return array + */ + public function __serialize(): array + { + // @codeCoverageIgnoreStart + if (isset($this->timezone_type)) { + return [ + 'date' => $this->date ?? null, + 'timezone_type' => $this->timezone_type, + 'timezone' => $this->timezone ?? null, + ]; + } + // @codeCoverageIgnoreEnd + + $timezone = $this->getTimezone(); + $export = [ + 'date' => $this->format('Y-m-d H:i:s.u'), + 'timezone_type' => $timezone->getType(), + 'timezone' => $timezone->getName(), + ]; + + // @codeCoverageIgnoreStart + if (\extension_loaded('msgpack') && isset($this->constructedObjectId)) { + $export['dumpDateProperties'] = [ + 'date' => $this->format('Y-m-d H:i:s.u'), + 'timezone' => serialize($this->timezone ?? null), + ]; + } + // @codeCoverageIgnoreEnd + + if ($this->localTranslator ?? null) { + $export['dumpLocale'] = $this->locale ?? null; + } + + return $export; + } + /** * Set locale if specified on unserialize() called. * + * Only used by PHP < 7.4. + * * @return void */ #[ReturnTypeWillChange] public function __wakeup() { - if (get_parent_class() && method_exists(parent::class, '__wakeup')) { + if (parent::class && method_exists(parent::class, '__wakeup')) { // @codeCoverageIgnoreStart try { parent::__wakeup(); } catch (Throwable $exception) { - // FatalError occurs when calling msgpack_unpack() in PHP 7.4 or later. - ['date' => $date, 'timezone' => $timezone] = $this->dumpDateProperties; - parent::__construct($date, unserialize($timezone)); + try { + // FatalError occurs when calling msgpack_unpack() in PHP 7.4 or later. + ['date' => $date, 'timezone' => $timezone] = $this->dumpDateProperties; + parent::__construct($date, unserialize($timezone)); + } catch (Throwable $ignoredException) { + throw $exception; + } } // @codeCoverageIgnoreEnd } @@ -164,6 +214,38 @@ trait Serialization $this->cleanupDumpProperties(); } + /** + * Set locale if specified on unserialize() called. + * + * Only used by PHP >= 7.4. + * + * @return void + */ + public function __unserialize(array $data): void + { + // @codeCoverageIgnoreStart + try { + $this->__construct($data['date'] ?? null, $data['timezone'] ?? null); + } catch (Throwable $exception) { + if (!isset($data['dumpDateProperties']['date'], $data['dumpDateProperties']['timezone'])) { + throw $exception; + } + + try { + // FatalError occurs when calling msgpack_unpack() in PHP 7.4 or later. + ['date' => $date, 'timezone' => $timezone] = $data['dumpDateProperties']; + $this->__construct($date, unserialize($timezone)); + } catch (Throwable $ignoredException) { + throw $exception; + } + } + // @codeCoverageIgnoreEnd + + if (isset($data['dumpLocale'])) { + $this->locale($data['dumpLocale']); + } + } + /** * Prepare the object for JSON serialization. * @@ -207,11 +289,15 @@ trait Serialization */ public function cleanupDumpProperties() { - foreach ($this->dumpProperties as $property) { - if (isset($this->$property)) { - unset($this->$property); + // @codeCoverageIgnoreStart + if (PHP_VERSION < 8.2) { + foreach ($this->dumpProperties as $property) { + if (isset($this->$property)) { + unset($this->$property); + } } } + // @codeCoverageIgnoreEnd return $this; } diff --git a/vendor/nesbot/carbon/src/Carbon/Traits/Test.php b/vendor/nesbot/carbon/src/Carbon/Traits/Test.php index c86faa7..e0c9e80 100644 --- a/vendor/nesbot/carbon/src/Carbon/Traits/Test.php +++ b/vendor/nesbot/carbon/src/Carbon/Traits/Test.php @@ -28,7 +28,7 @@ trait Test /** * A test Carbon instance to be returned when now instances are created. * - * @var static + * @var Closure|static|null */ protected static $testNow; @@ -59,15 +59,13 @@ trait Test * * /!\ Use this method for unit tests only. * - * @param Closure|static|string|false|null $testNow real or mock Carbon instance + * @param DateTimeInterface|Closure|static|string|false|null $testNow real or mock Carbon instance */ public static function setTestNow($testNow = null) { - if ($testNow === false) { - $testNow = null; - } - - static::$testNow = \is_string($testNow) ? static::parse($testNow) : $testNow; + static::$testNow = $testNow instanceof self || $testNow instanceof Closure + ? $testNow + : static::make($testNow); } /** @@ -87,7 +85,7 @@ trait Test * * /!\ Use this method for unit tests only. * - * @param Closure|static|string|false|null $testNow real or mock Carbon instance + * @param DateTimeInterface|Closure|static|string|false|null $testNow real or mock Carbon instance */ public static function setTestNowAndTimezone($testNow = null, $tz = null) { @@ -121,16 +119,20 @@ trait Test * * /!\ Use this method for unit tests only. * - * @param Closure|static|string|false|null $testNow real or mock Carbon instance - * @param Closure|null $callback + * @param DateTimeInterface|Closure|static|string|false|null $testNow real or mock Carbon instance + * @param Closure|null $callback * * @return mixed */ public static function withTestNow($testNow = null, $callback = null) { static::setTestNow($testNow); - $result = $callback(); - static::setTestNow(); + + try { + $result = $callback(); + } finally { + static::setTestNow(); + } return $result; } diff --git a/vendor/nesbot/carbon/src/Carbon/Traits/Timestamp.php b/vendor/nesbot/carbon/src/Carbon/Traits/Timestamp.php index 2cb5c48..88a465c 100644 --- a/vendor/nesbot/carbon/src/Carbon/Traits/Timestamp.php +++ b/vendor/nesbot/carbon/src/Carbon/Traits/Timestamp.php @@ -63,7 +63,7 @@ trait Timestamp public static function createFromTimestampMsUTC($timestamp) { [$milliseconds, $microseconds] = self::getIntegerAndDecimalParts($timestamp, 3); - $sign = $milliseconds < 0 || $milliseconds === 0.0 && $microseconds < 0 ? -1 : 1; + $sign = $milliseconds < 0 || ($milliseconds === 0.0 && $microseconds < 0) ? -1 : 1; $milliseconds = abs($milliseconds); $microseconds = $sign * abs($microseconds) + static::MICROSECONDS_PER_MILLISECOND * ($milliseconds % static::MILLISECONDS_PER_SECOND); $seconds = $sign * floor($milliseconds / static::MILLISECONDS_PER_SECOND); @@ -125,7 +125,7 @@ trait Timestamp */ public function getPreciseTimestamp($precision = 6) { - return round($this->rawFormat('Uu') / pow(10, 6 - $precision)); + return round(((float) $this->rawFormat('Uu')) / pow(10, 6 - $precision)); } /** @@ -182,7 +182,7 @@ trait Timestamp $integer = 0; $decimal = 0; - foreach (preg_split('`[^0-9.]+`', $numbers) as $chunk) { + foreach (preg_split('`[^\d.]+`', $numbers) as $chunk) { [$integerPart, $decimalPart] = explode('.', "$chunk."); $integer += (int) $integerPart; diff --git a/vendor/nesbot/carbon/src/Carbon/Traits/ToStringFormat.php b/vendor/nesbot/carbon/src/Carbon/Traits/ToStringFormat.php new file mode 100644 index 0000000..a81164f --- /dev/null +++ b/vendor/nesbot/carbon/src/Carbon/Traits/ToStringFormat.php @@ -0,0 +1,56 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Carbon\Traits; + +use Closure; + +/** + * Trait ToStringFormat. + * + * Handle global format customization for string cast of the object. + */ +trait ToStringFormat +{ + /** + * Format to use for __toString method when type juggling occurs. + * + * @var string|Closure|null + */ + protected static $toStringFormat; + + /** + * Reset the format used to the default when type juggling a Carbon instance to a string + * + * @return void + */ + public static function resetToStringFormat() + { + static::setToStringFormat(null); + } + + /** + * @deprecated To avoid conflict between different third-party libraries, static setters should not be used. + * You should rather let Carbon object being cast to string with DEFAULT_TO_STRING_FORMAT, and + * use other method or custom format passed to format() method if you need to dump another string + * format. + * + * Set the default format used when type juggling a Carbon instance to a string. + * + * @param string|Closure|null $format + * + * @return void + */ + public static function setToStringFormat($format) + { + static::$toStringFormat = $format; + } +} diff --git a/vendor/nesbot/carbon/src/Carbon/Traits/Units.php b/vendor/nesbot/carbon/src/Carbon/Traits/Units.php index 2902a8b..f4f797d 100644 --- a/vendor/nesbot/carbon/src/Carbon/Traits/Units.php +++ b/vendor/nesbot/carbon/src/Carbon/Traits/Units.php @@ -60,8 +60,6 @@ trait Units case 'millisecond': return $this->addRealUnit('microsecond', $value * static::MICROSECONDS_PER_MILLISECOND); - break; - // @call addRealUnit case 'second': break; @@ -167,7 +165,7 @@ trait Units 'weekday', ]; - return \in_array($unit, $modifiableUnits) || \in_array($unit, static::$units); + return \in_array($unit, $modifiableUnits, true) || \in_array($unit, static::$units, true); } /** @@ -232,6 +230,8 @@ trait Units */ public function addUnit($unit, $value = 1, $overflow = null) { + $originalArgs = \func_get_args(); + $date = $this; if (!is_numeric($value) || !(float) $value) { @@ -264,7 +264,7 @@ trait Units /** @var static $date */ $date = $date->addDays($sign); - while (\in_array($date->dayOfWeek, $weekendDays)) { + while (\in_array($date->dayOfWeek, $weekendDays, true)) { $date = $date->addDays($sign); } } @@ -274,14 +274,14 @@ trait Units } $timeString = $date->toTimeString(); - } elseif ($canOverflow = \in_array($unit, [ + } elseif ($canOverflow = (\in_array($unit, [ 'month', 'year', ]) && ($overflow === false || ( $overflow === null && ($ucUnit = ucfirst($unit).'s') && !($this->{'local'.$ucUnit.'Overflow'} ?? static::{'shouldOverflow'.$ucUnit}()) - ))) { + )))) { $day = $date->day; } @@ -313,7 +313,7 @@ trait Units } if (!$date) { - throw new UnitException('Unable to add unit '.var_export(\func_get_args(), true)); + throw new UnitException('Unable to add unit '.var_export($originalArgs, true)); } return $date; diff --git a/vendor/symfony/console/Application.php b/vendor/symfony/console/Application.php index 5a2323d..d4ec1be 100644 --- a/vendor/symfony/console/Application.php +++ b/vendor/symfony/console/Application.php @@ -21,6 +21,7 @@ use Symfony\Component\Console\Command\SignalableCommandInterface; use Symfony\Component\Console\CommandLoader\CommandLoaderInterface; use Symfony\Component\Console\Completion\CompletionInput; use Symfony\Component\Console\Completion\CompletionSuggestions; +use Symfony\Component\Console\Completion\Suggestion; use Symfony\Component\Console\Event\ConsoleCommandEvent; use Symfony\Component\Console\Event\ConsoleErrorEvent; use Symfony\Component\Console\Event\ConsoleSignalEvent; @@ -32,6 +33,7 @@ use Symfony\Component\Console\Exception\NamespaceNotFoundException; use Symfony\Component\Console\Exception\RuntimeException; use Symfony\Component\Console\Formatter\OutputFormatter; use Symfony\Component\Console\Helper\DebugFormatterHelper; +use Symfony\Component\Console\Helper\DescriptorHelper; use Symfony\Component\Console\Helper\FormatterHelper; use Symfony\Component\Console\Helper\Helper; use Symfony\Component\Console\Helper\HelperSet; @@ -72,20 +74,20 @@ class Application implements ResetInterface { private array $commands = []; private bool $wantHelps = false; - private $runningCommand = null; + private ?Command $runningCommand = null; private string $name; private string $version; - private $commandLoader = null; + private ?CommandLoaderInterface $commandLoader = null; private bool $catchExceptions = true; private bool $autoExit = true; - private $definition; - private $helperSet; - private $dispatcher = null; - private $terminal; + private InputDefinition $definition; + private HelperSet $helperSet; + private ?EventDispatcherInterface $dispatcher = null; + private Terminal $terminal; private string $defaultCommand; private bool $singleCommand = false; private bool $initialized = false; - private $signalRegistry; + private SignalRegistry $signalRegistry; private array $signalsToDispatchEvent = []; public function __construct(string $name = 'UNKNOWN', string $version = 'UNKNOWN') @@ -141,13 +143,8 @@ class Application implements ResetInterface @putenv('COLUMNS='.$this->terminal->getWidth()); } - if (null === $input) { - $input = new ArgvInput(); - } - - if (null === $output) { - $output = new ConsoleOutput(); - } + $input ??= new ArgvInput(); + $output ??= new ConsoleOutput(); $renderException = function (\Throwable $e) use ($output) { if ($output instanceof ConsoleOutputInterface) { @@ -179,7 +176,7 @@ class Application implements ResetInterface $exitCode = $e->getCode(); if (is_numeric($exitCode)) { $exitCode = (int) $exitCode; - if (0 === $exitCode) { + if ($exitCode <= 0) { $exitCode = 1; } } else { @@ -228,7 +225,7 @@ class Application implements ResetInterface try { // Makes ArgvInput::getFirstArgument() able to distinguish an option from an argument. $input->bind($this->getDefinition()); - } catch (ExceptionInterface $e) { + } catch (ExceptionInterface) { // Errors must be ignored, full binding/validation happens later when the command is known. } @@ -258,7 +255,26 @@ class Application implements ResetInterface // the command name MUST be the first element of the input $command = $this->find($name); } catch (\Throwable $e) { - if (!($e instanceof CommandNotFoundException && !$e instanceof NamespaceNotFoundException) || 1 !== \count($alternatives = $e->getAlternatives()) || !$input->isInteractive()) { + if (($e instanceof CommandNotFoundException && !$e instanceof NamespaceNotFoundException) && 1 === \count($alternatives = $e->getAlternatives()) && $input->isInteractive()) { + $alternative = $alternatives[0]; + + $style = new SymfonyStyle($input, $output); + $output->writeln(''); + $formattedBlock = (new FormatterHelper())->formatBlock(sprintf('Command "%s" is not defined.', $name), 'error', true); + $output->writeln($formattedBlock); + if (!$style->confirm(sprintf('Do you want to run "%s" instead? ', $alternative), false)) { + if (null !== $this->dispatcher) { + $event = new ConsoleErrorEvent($input, $output, $e); + $this->dispatcher->dispatch($event, ConsoleEvents::ERROR); + + return $event->getExitCode(); + } + + return 1; + } + + $command = $this->find($alternative); + } else { if (null !== $this->dispatcher) { $event = new ConsoleErrorEvent($input, $output, $e); $this->dispatcher->dispatch($event, ConsoleEvents::ERROR); @@ -270,25 +286,24 @@ class Application implements ResetInterface $e = $event->getError(); } - throw $e; - } + try { + if ($e instanceof CommandNotFoundException && $namespace = $this->findNamespace($name)) { + $helper = new DescriptorHelper(); + $helper->describe($output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output, $this, [ + 'format' => 'txt', + 'raw_text' => false, + 'namespace' => $namespace, + 'short' => false, + ]); - $alternative = $alternatives[0]; + return isset($event) ? $event->getExitCode() : 1; + } - $style = new SymfonyStyle($input, $output); - $style->block(sprintf("\nCommand \"%s\" is not defined.\n", $name), null, 'error'); - if (!$style->confirm(sprintf('Do you want to run "%s" instead? ', $alternative), false)) { - if (null !== $this->dispatcher) { - $event = new ConsoleErrorEvent($input, $output, $e); - $this->dispatcher->dispatch($event, ConsoleEvents::ERROR); - - return $event->getExitCode(); + throw $e; + } catch (NamespaceNotFoundException) { + throw $e; } - - return 1; } - - $command = $this->find($alternative); } if ($command instanceof LazyCommand) { @@ -302,9 +317,6 @@ class Application implements ResetInterface return $exitCode; } - /** - * {@inheritdoc} - */ public function reset() { } @@ -353,9 +365,16 @@ class Application implements ResetInterface CompletionInput::TYPE_ARGUMENT_VALUE === $input->getCompletionType() && 'command' === $input->getCompletionName() ) { - $suggestions->suggestValues(array_filter(array_map(function (Command $command) { - return $command->isHidden() ? null : $command->getName(); - }, $this->all()))); + foreach ($this->all() as $name => $command) { + // skip hidden commands and aliased commands as they already get added below + if ($command->isHidden() || $command->getName() !== $name) { + continue; + } + $suggestions->suggestValue(new Suggestion($command->getName(), $command->getDescription())); + foreach ($command->getAliases() as $name) { + $suggestions->suggestValue(new Suggestion($name, $command->getDescription())); + } + } return; } @@ -558,7 +577,7 @@ class Application implements ResetInterface { $this->init(); - return isset($this->commands[$name]) || ($this->commandLoader && $this->commandLoader->has($name) && $this->add($this->commandLoader->get($name))); + return isset($this->commands[$name]) || ($this->commandLoader?->has($name) && $this->add($this->commandLoader->get($name))); } /** @@ -898,11 +917,21 @@ class Application implements ResetInterface } switch ($shellVerbosity = (int) getenv('SHELL_VERBOSITY')) { - case -1: $output->setVerbosity(OutputInterface::VERBOSITY_QUIET); break; - case 1: $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE); break; - case 2: $output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE); break; - case 3: $output->setVerbosity(OutputInterface::VERBOSITY_DEBUG); break; - default: $shellVerbosity = 0; break; + case -1: + $output->setVerbosity(OutputInterface::VERBOSITY_QUIET); + break; + case 1: + $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE); + break; + case 2: + $output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE); + break; + case 3: + $output->setVerbosity(OutputInterface::VERBOSITY_DEBUG); + break; + default: + $shellVerbosity = 0; + break; } if (true === $input->hasParameterOption(['--quiet', '-q'], true)) { @@ -948,22 +977,26 @@ class Application implements ResetInterface } } - if ($command instanceof SignalableCommandInterface && ($this->signalsToDispatchEvent || $command->getSubscribedSignals())) { - if (!$this->signalRegistry) { - throw new RuntimeException('Unable to subscribe to signal events. Make sure that the `pcntl` extension is installed and that "pcntl_*" functions are not disabled by your php.ini\'s "disable_functions" directive.'); - } + if ($this->signalsToDispatchEvent) { + $commandSignals = $command instanceof SignalableCommandInterface ? $command->getSubscribedSignals() : []; - if (Terminal::hasSttyAvailable()) { - $sttyMode = shell_exec('stty -g'); + if ($commandSignals || null !== $this->dispatcher) { + if (!$this->signalRegistry) { + throw new RuntimeException('Unable to subscribe to signal events. Make sure that the `pcntl` extension is installed and that "pcntl_*" functions are not disabled by your php.ini\'s "disable_functions" directive.'); + } - foreach ([\SIGINT, \SIGTERM] as $signal) { - $this->signalRegistry->register($signal, static function () use ($sttyMode) { - shell_exec('stty '.$sttyMode); - }); + if (Terminal::hasSttyAvailable()) { + $sttyMode = shell_exec('stty -g'); + + foreach ([\SIGINT, \SIGTERM] as $signal) { + $this->signalRegistry->register($signal, static function () use ($sttyMode) { + shell_exec('stty '.$sttyMode); + }); + } } } - if ($this->dispatcher) { + if (null !== $this->dispatcher) { foreach ($this->signalsToDispatchEvent as $signal) { $event = new ConsoleSignalEvent($command, $input, $output, $signal); @@ -980,7 +1013,7 @@ class Application implements ResetInterface } } - foreach ($command->getSubscribedSignals() as $signal) { + foreach ($commandSignals as $signal) { $this->signalRegistry->register($signal, [$command, 'handleSignal']); } } @@ -993,7 +1026,7 @@ class Application implements ResetInterface try { $command->mergeApplicationDefinition(); $input->bind($command->getDefinition()); - } catch (ExceptionInterface $e) { + } catch (ExceptionInterface) { // ignore invalid options/arguments for now, to allow the event listeners to customize the InputDefinition } diff --git a/vendor/symfony/console/CHANGELOG.md b/vendor/symfony/console/CHANGELOG.md index 9a93c79..61c36b0 100644 --- a/vendor/symfony/console/CHANGELOG.md +++ b/vendor/symfony/console/CHANGELOG.md @@ -1,6 +1,25 @@ CHANGELOG ========= +6.2 +--- + + * Improve truecolor terminal detection in some cases + * Add support for 256 color terminals (conversion from Ansi24 to Ansi8 if terminal is capable of it) + * Deprecate calling `*Command::setApplication()`, `*FormatterStyle::setForeground/setBackground()`, `Helper::setHelpSet()`, `Input*::setDefault()`, `Question::setAutocompleterCallback/setValidator()`without any arguments + * Change the signature of `OutputFormatterStyleInterface::setForeground/setBackground()` to `setForeground/setBackground(?string)` + * Change the signature of `HelperInterface::setHelperSet()` to `setHelperSet(?HelperSet)` + +6.1 +--- + + * Add support to display table vertically when calling setVertical() + * Add method `__toString()` to `InputInterface` + * Added `OutputWrapper` to prevent truncated URL in `SymfonyStyle::createBlock`. + * Deprecate `Command::$defaultName` and `Command::$defaultDescription`, use the `AsCommand` attribute instead + * Add suggested values for arguments and options in input definition, for input completion + * Add `$resumeAt` parameter to `ProgressBar#start()`, so that one can easily 'resume' progress on longer tasks, and still get accurate `getEstimate()` and `getRemaining()` results. + 6.0 --- diff --git a/vendor/symfony/console/CI/GithubActionReporter.php b/vendor/symfony/console/CI/GithubActionReporter.php index a15c1ff..7e55654 100644 --- a/vendor/symfony/console/CI/GithubActionReporter.php +++ b/vendor/symfony/console/CI/GithubActionReporter.php @@ -20,7 +20,7 @@ use Symfony\Component\Console\Output\OutputInterface; */ class GithubActionReporter { - private $output; + private OutputInterface $output; /** * @see https://github.com/actions/toolkit/blob/5e5e1b7aacba68a53836a34db4a288c3c1c1585b/packages/core/src/command.ts#L80-L85 diff --git a/vendor/symfony/console/Color.php b/vendor/symfony/console/Color.php index 7fcc507..60ed046 100644 --- a/vendor/symfony/console/Color.php +++ b/vendor/symfony/console/Color.php @@ -117,17 +117,7 @@ final class Color } if ('#' === $color[0]) { - $color = substr($color, 1); - - if (3 === \strlen($color)) { - $color = $color[0].$color[0].$color[1].$color[1].$color[2].$color[2]; - } - - if (6 !== \strlen($color)) { - throw new InvalidArgumentException(sprintf('Invalid "%s" color.', $color)); - } - - return ($background ? '4' : '3').$this->convertHexColorToAnsi(hexdec($color)); + return ($background ? '4' : '3').Terminal::getColorMode()->convertFromHexToAnsiColorCode($color); } if (isset(self::COLORS[$color])) { @@ -140,41 +130,4 @@ final class Color throw new InvalidArgumentException(sprintf('Invalid "%s" color; expected one of (%s).', $color, implode(', ', array_merge(array_keys(self::COLORS), array_keys(self::BRIGHT_COLORS))))); } - - private function convertHexColorToAnsi(int $color): string - { - $r = ($color >> 16) & 255; - $g = ($color >> 8) & 255; - $b = $color & 255; - - // see https://github.com/termstandard/colors/ for more information about true color support - if ('truecolor' !== getenv('COLORTERM')) { - return (string) $this->degradeHexColorToAnsi($r, $g, $b); - } - - return sprintf('8;2;%d;%d;%d', $r, $g, $b); - } - - private function degradeHexColorToAnsi(int $r, int $g, int $b): int - { - if (0 === round($this->getSaturation($r, $g, $b) / 50)) { - return 0; - } - - return (round($b / 255) << 2) | (round($g / 255) << 1) | round($r / 255); - } - - private function getSaturation(int $r, int $g, int $b): int - { - $r = $r / 255; - $g = $g / 255; - $b = $b / 255; - $v = max($r, $g, $b); - - if (0 === $diff = $v - min($r, $g, $b)) { - return 0; - } - - return (int) $diff * 100 / $v; - } } diff --git a/vendor/symfony/console/Command/Command.php b/vendor/symfony/console/Command/Command.php index e69bae0..1e3c1a5 100644 --- a/vendor/symfony/console/Command/Command.php +++ b/vendor/symfony/console/Command/Command.php @@ -15,9 +15,11 @@ use Symfony\Component\Console\Application; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Completion\CompletionInput; use Symfony\Component\Console\Completion\CompletionSuggestions; +use Symfony\Component\Console\Completion\Suggestion; use Symfony\Component\Console\Exception\ExceptionInterface; use Symfony\Component\Console\Exception\InvalidArgumentException; use Symfony\Component\Console\Exception\LogicException; +use Symfony\Component\Console\Helper\HelperInterface; use Symfony\Component\Console\Helper\HelperSet; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputDefinition; @@ -39,28 +41,32 @@ class Command /** * @var string|null The default command name + * + * @deprecated since Symfony 6.1, use the AsCommand attribute instead */ protected static $defaultName; /** * @var string|null The default command description + * + * @deprecated since Symfony 6.1, use the AsCommand attribute instead */ protected static $defaultDescription; - private $application = null; + private ?Application $application = null; private ?string $name = null; private ?string $processTitle = null; private array $aliases = []; - private $definition; + private InputDefinition $definition; private bool $hidden = false; private string $help = ''; private string $description = ''; - private $fullDefinition = null; + private ?InputDefinition $fullDefinition = null; private bool $ignoreValidationErrors = false; private ?\Closure $code = null; private array $synopsis = []; private array $usages = []; - private $helperSet = null; + private ?HelperSet $helperSet = null; public static function getDefaultName(): ?string { @@ -72,7 +78,13 @@ class Command $r = new \ReflectionProperty($class, 'defaultName'); - return $class === $r->class ? static::$defaultName : null; + if ($class !== $r->class || null === static::$defaultName) { + return null; + } + + trigger_deprecation('symfony/console', '6.1', 'Relying on the static property "$defaultName" for setting a command name is deprecated. Add the "%s" attribute to the "%s" class instead.', AsCommand::class, static::class); + + return static::$defaultName; } public static function getDefaultDescription(): ?string @@ -85,7 +97,13 @@ class Command $r = new \ReflectionProperty($class, 'defaultDescription'); - return $class === $r->class ? static::$defaultDescription : null; + if ($class !== $r->class || null === static::$defaultDescription) { + return null; + } + + trigger_deprecation('symfony/console', '6.1', 'Relying on the static property "$defaultDescription" for setting a command description is deprecated. Add the "%s" attribute to the "%s" class instead.', AsCommand::class, static::class); + + return static::$defaultDescription; } /** @@ -131,6 +149,9 @@ class Command public function setApplication(Application $application = null) { + if (1 > \func_num_args()) { + trigger_deprecation('symfony/console', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__); + } $this->application = $application; if ($application) { $this->setHelperSet($application->getHelperSet()); @@ -235,7 +256,7 @@ class Command * * @return int The command exit code * - * @throws \Exception When binding input fails. Bypass this by calling {@link ignoreValidationErrors()}. + * @throws ExceptionInterface When input binding fails. Bypass this by calling {@link ignoreValidationErrors()}. * * @see setCode() * @see execute() @@ -303,6 +324,12 @@ class Command */ public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void { + $definition = $this->getDefinition(); + if (CompletionInput::TYPE_OPTION_VALUE === $input->getCompletionType() && $definition->hasOption($input->getCompletionName())) { + $definition->getOption($input->getCompletionName())->complete($input, $suggestions); + } elseif (CompletionInput::TYPE_ARGUMENT_VALUE === $input->getCompletionType() && $definition->hasArgument($input->getCompletionName())) { + $definition->getArgument($input->getCompletionName())->complete($input, $suggestions); + } } /** @@ -334,7 +361,7 @@ class Command } } } else { - $code = \Closure::fromCallable($code); + $code = $code(...); } $this->code = $code; @@ -411,19 +438,22 @@ class Command /** * Adds an argument. * - * @param int|null $mode The argument mode: InputArgument::REQUIRED or InputArgument::OPTIONAL - * @param mixed $default The default value (for InputArgument::OPTIONAL mode only) - * - * @throws InvalidArgumentException When argument mode is not valid + * @param $mode The argument mode: InputArgument::REQUIRED or InputArgument::OPTIONAL + * @param $default The default value (for InputArgument::OPTIONAL mode only) + * @param array|\Closure(CompletionInput,CompletionSuggestions):list $suggestedValues The values used for input completion * * @return $this + * + * @throws InvalidArgumentException When argument mode is not valid */ - public function addArgument(string $name, int $mode = null, string $description = '', mixed $default = null): static + public function addArgument(string $name, int $mode = null, string $description = '', mixed $default = null /* array|\Closure $suggestedValues = null */): static { - $this->definition->addArgument(new InputArgument($name, $mode, $description, $default)); - if (null !== $this->fullDefinition) { - $this->fullDefinition->addArgument(new InputArgument($name, $mode, $description, $default)); + $suggestedValues = 5 <= \func_num_args() ? func_get_arg(4) : []; + if (!\is_array($suggestedValues) && !$suggestedValues instanceof \Closure) { + throw new \TypeError(sprintf('Argument 5 passed to "%s()" must be array or \Closure, "%s" given.', __METHOD__, get_debug_type($suggestedValues))); } + $this->definition->addArgument(new InputArgument($name, $mode, $description, $default, $suggestedValues)); + $this->fullDefinition?->addArgument(new InputArgument($name, $mode, $description, $default, $suggestedValues)); return $this; } @@ -434,17 +464,20 @@ class Command * @param $shortcut The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts * @param $mode The option mode: One of the InputOption::VALUE_* constants * @param $default The default value (must be null for InputOption::VALUE_NONE) - * - * @throws InvalidArgumentException If option mode is invalid or incompatible + * @param array|\Closure(CompletionInput,CompletionSuggestions):list $suggestedValues The values used for input completion * * @return $this + * + * @throws InvalidArgumentException If option mode is invalid or incompatible */ - public function addOption(string $name, string|array $shortcut = null, int $mode = null, string $description = '', mixed $default = null): static + public function addOption(string $name, string|array $shortcut = null, int $mode = null, string $description = '', mixed $default = null /* array|\Closure $suggestedValues = [] */): static { - $this->definition->addOption(new InputOption($name, $shortcut, $mode, $description, $default)); - if (null !== $this->fullDefinition) { - $this->fullDefinition->addOption(new InputOption($name, $shortcut, $mode, $description, $default)); + $suggestedValues = 6 <= \func_num_args() ? func_get_arg(5) : []; + if (!\is_array($suggestedValues) && !$suggestedValues instanceof \Closure) { + throw new \TypeError(sprintf('Argument 5 passed to "%s()" must be array or \Closure, "%s" given.', __METHOD__, get_debug_type($suggestedValues))); } + $this->definition->addOption(new InputOption($name, $shortcut, $mode, $description, $default, $suggestedValues)); + $this->fullDefinition?->addOption(new InputOption($name, $shortcut, $mode, $description, $default, $suggestedValues)); return $this; } @@ -560,7 +593,7 @@ class Command public function getProcessedHelp(): string { $name = $this->name; - $isSingleCommand = $this->application && $this->application->isSingleCommand(); + $isSingleCommand = $this->application?->isSingleCommand(); $placeholders = [ '%command.name%', @@ -648,6 +681,8 @@ class Command /** * Gets a helper instance by name. * + * @return HelperInterface + * * @throws LogicException if no HelperSet is defined * @throws InvalidArgumentException if the helper is not defined */ diff --git a/vendor/symfony/console/Command/CompleteCommand.php b/vendor/symfony/console/Command/CompleteCommand.php index 97357d6..e65b334 100644 --- a/vendor/symfony/console/Command/CompleteCommand.php +++ b/vendor/symfony/console/Command/CompleteCommand.php @@ -11,10 +11,13 @@ namespace Symfony\Component\Console\Command; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Completion\CompletionInput; use Symfony\Component\Console\Completion\CompletionSuggestions; use Symfony\Component\Console\Completion\Output\BashCompletionOutput; use Symfony\Component\Console\Completion\Output\CompletionOutputInterface; +use Symfony\Component\Console\Completion\Output\FishCompletionOutput; +use Symfony\Component\Console\Completion\Output\ZshCompletionOutput; use Symfony\Component\Console\Exception\CommandNotFoundException; use Symfony\Component\Console\Exception\ExceptionInterface; use Symfony\Component\Console\Input\InputInterface; @@ -26,9 +29,19 @@ use Symfony\Component\Console\Output\OutputInterface; * * @author Wouter de Jong */ +#[AsCommand(name: '|_complete', description: 'Internal command to provide shell completion suggestions')] final class CompleteCommand extends Command { + public const COMPLETION_API_VERSION = '1'; + + /** + * @deprecated since Symfony 6.1 + */ protected static $defaultName = '|_complete'; + + /** + * @deprecated since Symfony 6.1 + */ protected static $defaultDescription = 'Internal command to provide shell completion suggestions'; private $completionOutputs; @@ -41,7 +54,11 @@ final class CompleteCommand extends Command public function __construct(array $completionOutputs = []) { // must be set before the parent constructor, as the property value is used in configure() - $this->completionOutputs = $completionOutputs + ['bash' => BashCompletionOutput::class]; + $this->completionOutputs = $completionOutputs + [ + 'bash' => BashCompletionOutput::class, + 'fish' => FishCompletionOutput::class, + 'zsh' => ZshCompletionOutput::class, + ]; parent::__construct(); } @@ -52,28 +69,29 @@ final class CompleteCommand extends Command ->addOption('shell', 's', InputOption::VALUE_REQUIRED, 'The shell type ("'.implode('", "', array_keys($this->completionOutputs)).'")') ->addOption('input', 'i', InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'An array of input tokens (e.g. COMP_WORDS or argv)') ->addOption('current', 'c', InputOption::VALUE_REQUIRED, 'The index of the "input" array that the cursor is in (e.g. COMP_CWORD)') - ->addOption('symfony', 'S', InputOption::VALUE_REQUIRED, 'The version of the completion script') + ->addOption('api-version', 'a', InputOption::VALUE_REQUIRED, 'The API version of the completion script') + ->addOption('symfony', 'S', InputOption::VALUE_REQUIRED, 'deprecated') ; } protected function initialize(InputInterface $input, OutputInterface $output) { - $this->isDebug = filter_var(getenv('SYMFONY_COMPLETION_DEBUG'), \FILTER_VALIDATE_BOOLEAN); + $this->isDebug = filter_var(getenv('SYMFONY_COMPLETION_DEBUG'), \FILTER_VALIDATE_BOOL); } protected function execute(InputInterface $input, OutputInterface $output): int { try { - // uncomment when a bugfix or BC break has been introduced in the shell completion scripts - //$version = $input->getOption('symfony'); - //if ($version && version_compare($version, 'x.y', '>=')) { - // $message = sprintf('Completion script version is not supported ("%s" given, ">=x.y" required).', $version); - // $this->log($message); + // "symfony" must be kept for compat with the shell scripts generated by Symfony Console 5.4 - 6.1 + $version = $input->getOption('symfony') ? '1' : $input->getOption('api-version'); + if ($version && version_compare($version, self::COMPLETION_API_VERSION, '<')) { + $message = sprintf('Completion script version is not supported ("%s" given, ">=%s" required).', $version, self::COMPLETION_API_VERSION); + $this->log($message); - // $output->writeln($message.' Install the Symfony completion script again by using the "completion" command.'); + $output->writeln($message.' Install the Symfony completion script again by using the "completion" command.'); - // return 126; - //} + return 126; + } $shell = $input->getOption('shell'); if (!$shell) { @@ -105,11 +123,12 @@ final class CompleteCommand extends Command } elseif ( $completionInput->mustSuggestArgumentValuesFor('command') && $command->getName() !== $completionInput->getCompletionValue() + && !\in_array($completionInput->getCompletionValue(), $command->getAliases(), true) ) { $this->log(' No command found, completing using the Application class.'); // expand shortcut names ("cache:cl") into their full name ("cache:clear") - $suggestions->suggestValue($command->getName()); + $suggestions->suggestValues(array_filter(array_merge([$command->getName()], $command->getAliases()))); } else { $command->mergeApplicationDefinition(); $completionInput->bind($command->getDefinition()); @@ -171,7 +190,7 @@ final class CompleteCommand extends Command try { $completionInput->bind($this->getApplication()->getDefinition()); - } catch (ExceptionInterface $e) { + } catch (ExceptionInterface) { } return $completionInput; @@ -186,7 +205,7 @@ final class CompleteCommand extends Command } return $this->getApplication()->find($inputName); - } catch (CommandNotFoundException $e) { + } catch (CommandNotFoundException) { } return null; diff --git a/vendor/symfony/console/Command/DumpCompletionCommand.php b/vendor/symfony/console/Command/DumpCompletionCommand.php index 64a8005..1ad1c0e 100644 --- a/vendor/symfony/console/Command/DumpCompletionCommand.php +++ b/vendor/symfony/console/Command/DumpCompletionCommand.php @@ -11,8 +11,7 @@ namespace Symfony\Component\Console\Command; -use Symfony\Component\Console\Completion\CompletionInput; -use Symfony\Component\Console\Completion\CompletionSuggestions; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -25,55 +24,65 @@ use Symfony\Component\Process\Process; * * @author Wouter de Jong */ +#[AsCommand(name: 'completion', description: 'Dump the shell completion script')] final class DumpCompletionCommand extends Command { + /** + * @deprecated since Symfony 6.1 + */ protected static $defaultName = 'completion'; + + /** + * @deprecated since Symfony 6.1 + */ protected static $defaultDescription = 'Dump the shell completion script'; - public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void - { - if ($input->mustSuggestArgumentValuesFor('shell')) { - $suggestions->suggestValues($this->getSupportedShells()); - } - } + private array $supportedShells; protected function configure() { $fullCommand = $_SERVER['PHP_SELF']; $commandName = basename($fullCommand); - $fullCommand = realpath($fullCommand) ?: $fullCommand; + $fullCommand = @realpath($fullCommand) ?: $fullCommand; + + $shell = $this->guessShell(); + [$rcFile, $completionFile] = match ($shell) { + 'fish' => ['~/.config/fish/config.fish', "/etc/fish/completions/$commandName.fish"], + 'zsh' => ['~/.zshrc', '$fpath[1]/'.$commandName], + default => ['~/.bashrc', "/etc/bash_completion.d/$commandName"], + }; $this ->setHelp(<<%command.name% command dumps the shell completion script required -to use shell autocompletion (currently only bash completion is supported). +to use shell autocompletion (currently, bash and fish completion is supported). Static installation ------------------- Dump the script to a global completion file and restart your shell: - %command.full_name% bash | sudo tee /etc/bash_completion.d/${commandName} + %command.full_name% {$shell} | sudo tee {$completionFile} Or dump the script to a local file and source it: - %command.full_name% bash > completion.sh + %command.full_name% {$shell} > completion.sh # source the file whenever you use the project source completion.sh - # or add this line at the end of your "~/.bashrc" file: + # or add this line at the end of your "{$rcFile}" file: source /path/to/completion.sh Dynamic installation -------------------- -Add this to the end of your shell configuration file (e.g. "~/.bashrc"): +Add this to the end of your shell configuration file (e.g. "{$rcFile}"): - eval "$(${fullCommand} completion bash)" + eval "$({$fullCommand} completion {$shell})" EOH ) - ->addArgument('shell', InputArgument::OPTIONAL, 'The shell type (e.g. "bash"), the value of the "$SHELL" env var will be used if this is not given') + ->addArgument('shell', InputArgument::OPTIONAL, 'The shell type (e.g. "bash"), the value of the "$SHELL" env var will be used if this is not given', null, $this->getSupportedShells(...)) ->addOption('debug', null, InputOption::VALUE_NONE, 'Tail the completion debug log') ; } @@ -93,13 +102,19 @@ EOH if (!file_exists($completionFile)) { $supportedShells = $this->getSupportedShells(); - ($output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output) - ->writeln(sprintf('Detected shell "%s", which is not supported by Symfony shell completion (supported shells: "%s").', $shell, implode('", "', $supportedShells))); + if ($output instanceof ConsoleOutputInterface) { + $output = $output->getErrorOutput(); + } + if ($shell) { + $output->writeln(sprintf('Detected shell "%s", which is not supported by Symfony shell completion (supported shells: "%s").', $shell, implode('", "', $supportedShells))); + } else { + $output->writeln(sprintf('Shell not detected, Symfony shell completion only supports "%s").', implode('", "', $supportedShells))); + } return self::INVALID; } - $output->write(str_replace(['{{ COMMAND_NAME }}', '{{ VERSION }}'], [$commandName, $this->getApplication()->getVersion()], file_get_contents($completionFile))); + $output->write(str_replace(['{{ COMMAND_NAME }}', '{{ VERSION }}'], [$commandName, CompleteCommand::COMPLETION_API_VERSION], file_get_contents($completionFile))); return self::SUCCESS; } @@ -126,7 +141,7 @@ EOH */ private function getSupportedShells(): array { - return array_map(function ($f) { + return $this->supportedShells ??= array_map(function ($f) { return pathinfo($f, \PATHINFO_EXTENSION); }, glob(__DIR__.'/../Resources/completion.*')); } diff --git a/vendor/symfony/console/Command/HelpCommand.php b/vendor/symfony/console/Command/HelpCommand.php index 66f8593..d4134e1 100644 --- a/vendor/symfony/console/Command/HelpCommand.php +++ b/vendor/symfony/console/Command/HelpCommand.php @@ -11,8 +11,6 @@ namespace Symfony\Component\Console\Command; -use Symfony\Component\Console\Completion\CompletionInput; -use Symfony\Component\Console\Completion\CompletionSuggestions; use Symfony\Component\Console\Descriptor\ApplicationDescription; use Symfony\Component\Console\Helper\DescriptorHelper; use Symfony\Component\Console\Input\InputArgument; @@ -27,11 +25,8 @@ use Symfony\Component\Console\Output\OutputInterface; */ class HelpCommand extends Command { - private $command; + private Command $command; - /** - * {@inheritdoc} - */ protected function configure() { $this->ignoreValidationErrors(); @@ -39,8 +34,12 @@ class HelpCommand extends Command $this ->setName('help') ->setDefinition([ - new InputArgument('command_name', InputArgument::OPTIONAL, 'The command name', 'help'), - new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt'), + new InputArgument('command_name', InputArgument::OPTIONAL, 'The command name', 'help', function () { + return array_keys((new ApplicationDescription($this->getApplication()))->getCommands()); + }), + new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt', function () { + return (new DescriptorHelper())->getFormats(); + }), new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command help'), ]) ->setDescription('Display help for a command') @@ -64,9 +63,6 @@ EOF $this->command = $command; } - /** - * {@inheritdoc} - */ protected function execute(InputInterface $input, OutputInterface $output): int { $this->command ??= $this->getApplication()->find($input->getArgument('command_name')); @@ -81,19 +77,4 @@ EOF return 0; } - - public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void - { - if ($input->mustSuggestArgumentValuesFor('command_name')) { - $descriptor = new ApplicationDescription($this->getApplication()); - $suggestions->suggestValues(array_keys($descriptor->getCommands())); - - return; - } - - if ($input->mustSuggestOptionValuesFor('format')) { - $helper = new DescriptorHelper(); - $suggestions->suggestValues($helper->getFormats()); - } - } } diff --git a/vendor/symfony/console/Command/LazyCommand.php b/vendor/symfony/console/Command/LazyCommand.php index aec4126..d560582 100644 --- a/vendor/symfony/console/Command/LazyCommand.php +++ b/vendor/symfony/console/Command/LazyCommand.php @@ -14,6 +14,8 @@ namespace Symfony\Component\Console\Command; use Symfony\Component\Console\Application; use Symfony\Component\Console\Completion\CompletionInput; use Symfony\Component\Console\Completion\CompletionSuggestions; +use Symfony\Component\Console\Completion\Suggestion; +use Symfony\Component\Console\Helper\HelperInterface; use Symfony\Component\Console\Helper\HelperSet; use Symfony\Component\Console\Input\InputDefinition; use Symfony\Component\Console\Input\InputInterface; @@ -24,7 +26,7 @@ use Symfony\Component\Console\Output\OutputInterface; */ final class LazyCommand extends Command { - private $command; + private \Closure|Command $command; private ?bool $isEnabled; public function __construct(string $name, array $aliases, string $description, bool $isHidden, \Closure $commandFactory, ?bool $isEnabled = true) @@ -45,6 +47,9 @@ final class LazyCommand extends Command public function setApplication(Application $application = null): void { + if (1 > \func_num_args()) { + trigger_deprecation('symfony/console', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__); + } if ($this->command instanceof parent) { $this->command->setApplication($application); } @@ -108,16 +113,24 @@ final class LazyCommand extends Command return $this->getCommand()->getNativeDefinition(); } - public function addArgument(string $name, int $mode = null, string $description = '', mixed $default = null): static + /** + * @param array|\Closure(CompletionInput,CompletionSuggestions):list $suggestedValues The values used for input completion + */ + public function addArgument(string $name, int $mode = null, string $description = '', mixed $default = null /* array|\Closure $suggestedValues = [] */): static { - $this->getCommand()->addArgument($name, $mode, $description, $default); + $suggestedValues = 5 <= \func_num_args() ? func_get_arg(4) : []; + $this->getCommand()->addArgument($name, $mode, $description, $default, $suggestedValues); return $this; } - public function addOption(string $name, string|array $shortcut = null, int $mode = null, string $description = '', mixed $default = null): static + /** + * @param array|\Closure(CompletionInput,CompletionSuggestions):list $suggestedValues The values used for input completion + */ + public function addOption(string $name, string|array $shortcut = null, int $mode = null, string $description = '', mixed $default = null /* array|\Closure $suggestedValues = [] */): static { - $this->getCommand()->addOption($name, $shortcut, $mode, $description, $default); + $suggestedValues = 6 <= \func_num_args() ? func_get_arg(5) : []; + $this->getCommand()->addOption($name, $shortcut, $mode, $description, $default, $suggestedValues); return $this; } @@ -163,7 +176,7 @@ final class LazyCommand extends Command return $this->getCommand()->getUsages(); } - public function getHelper(string $name): mixed + public function getHelper(string $name): HelperInterface { return $this->getCommand()->getHelper($name); } diff --git a/vendor/symfony/console/Command/ListCommand.php b/vendor/symfony/console/Command/ListCommand.php index 5c7260f..cab88b4 100644 --- a/vendor/symfony/console/Command/ListCommand.php +++ b/vendor/symfony/console/Command/ListCommand.php @@ -11,8 +11,6 @@ namespace Symfony\Component\Console\Command; -use Symfony\Component\Console\Completion\CompletionInput; -use Symfony\Component\Console\Completion\CompletionSuggestions; use Symfony\Component\Console\Descriptor\ApplicationDescription; use Symfony\Component\Console\Helper\DescriptorHelper; use Symfony\Component\Console\Input\InputArgument; @@ -27,17 +25,18 @@ use Symfony\Component\Console\Output\OutputInterface; */ class ListCommand extends Command { - /** - * {@inheritdoc} - */ protected function configure() { $this ->setName('list') ->setDefinition([ - new InputArgument('namespace', InputArgument::OPTIONAL, 'The namespace name'), + new InputArgument('namespace', InputArgument::OPTIONAL, 'The namespace name', null, function () { + return array_keys((new ApplicationDescription($this->getApplication()))->getNamespaces()); + }), new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command list'), - new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt'), + new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt', function () { + return (new DescriptorHelper())->getFormats(); + }), new InputOption('short', null, InputOption::VALUE_NONE, 'To skip describing commands\' arguments'), ]) ->setDescription('List commands') @@ -62,9 +61,6 @@ EOF ; } - /** - * {@inheritdoc} - */ protected function execute(InputInterface $input, OutputInterface $output): int { $helper = new DescriptorHelper(); @@ -77,19 +73,4 @@ EOF return 0; } - - public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void - { - if ($input->mustSuggestArgumentValuesFor('namespace')) { - $descriptor = new ApplicationDescription($this->getApplication()); - $suggestions->suggestValues(array_keys($descriptor->getNamespaces())); - - return; - } - - if ($input->mustSuggestOptionValuesFor('format')) { - $helper = new DescriptorHelper(); - $suggestions->suggestValues($helper->getFormats()); - } - } } diff --git a/vendor/symfony/console/Command/LockableTrait.php b/vendor/symfony/console/Command/LockableTrait.php index 7969551..67923a9 100644 --- a/vendor/symfony/console/Command/LockableTrait.php +++ b/vendor/symfony/console/Command/LockableTrait.php @@ -13,6 +13,7 @@ namespace Symfony\Component\Console\Command; use Symfony\Component\Console\Exception\LogicException; use Symfony\Component\Lock\LockFactory; +use Symfony\Component\Lock\LockInterface; use Symfony\Component\Lock\Store\FlockStore; use Symfony\Component\Lock\Store\SemaphoreStore; @@ -23,7 +24,7 @@ use Symfony\Component\Lock\Store\SemaphoreStore; */ trait LockableTrait { - private $lock = null; + private ?LockInterface $lock = null; /** * Locks a command. diff --git a/vendor/symfony/console/CommandLoader/ContainerCommandLoader.php b/vendor/symfony/console/CommandLoader/ContainerCommandLoader.php index 9b26577..bfa0ac4 100644 --- a/vendor/symfony/console/CommandLoader/ContainerCommandLoader.php +++ b/vendor/symfony/console/CommandLoader/ContainerCommandLoader.php @@ -22,7 +22,7 @@ use Symfony\Component\Console\Exception\CommandNotFoundException; */ class ContainerCommandLoader implements CommandLoaderInterface { - private $container; + private ContainerInterface $container; private array $commandMap; /** @@ -34,9 +34,6 @@ class ContainerCommandLoader implements CommandLoaderInterface $this->commandMap = $commandMap; } - /** - * {@inheritdoc} - */ public function get(string $name): Command { if (!$this->has($name)) { @@ -46,17 +43,11 @@ class ContainerCommandLoader implements CommandLoaderInterface return $this->container->get($this->commandMap[$name]); } - /** - * {@inheritdoc} - */ public function has(string $name): bool { return isset($this->commandMap[$name]) && $this->container->has($this->commandMap[$name]); } - /** - * {@inheritdoc} - */ public function getNames(): array { return array_keys($this->commandMap); diff --git a/vendor/symfony/console/CommandLoader/FactoryCommandLoader.php b/vendor/symfony/console/CommandLoader/FactoryCommandLoader.php index c55dc1d..9ced75a 100644 --- a/vendor/symfony/console/CommandLoader/FactoryCommandLoader.php +++ b/vendor/symfony/console/CommandLoader/FactoryCommandLoader.php @@ -31,17 +31,11 @@ class FactoryCommandLoader implements CommandLoaderInterface $this->factories = $factories; } - /** - * {@inheritdoc} - */ public function has(string $name): bool { return isset($this->factories[$name]); } - /** - * {@inheritdoc} - */ public function get(string $name): Command { if (!isset($this->factories[$name])) { @@ -53,9 +47,6 @@ class FactoryCommandLoader implements CommandLoaderInterface return $factory(); } - /** - * {@inheritdoc} - */ public function getNames(): array { return array_keys($this->factories); diff --git a/vendor/symfony/console/Completion/CompletionInput.php b/vendor/symfony/console/Completion/CompletionInput.php index 368b945..3ef8db5 100644 --- a/vendor/symfony/console/Completion/CompletionInput.php +++ b/vendor/symfony/console/Completion/CompletionInput.php @@ -64,9 +64,6 @@ final class CompletionInput extends ArgvInput return $input; } - /** - * {@inheritdoc} - */ public function bind(InputDefinition $definition): void { parent::bind($definition); @@ -84,7 +81,7 @@ final class CompletionInput extends ArgvInput return; } - if (null !== $option && $option->acceptValue()) { + if ($option?->acceptValue()) { $this->completionType = self::TYPE_OPTION_VALUE; $this->completionName = $option->getName(); $this->completionValue = $optionValue ?: (!str_starts_with($optionToken, '--') ? substr($optionToken, 2) : ''); @@ -97,7 +94,7 @@ final class CompletionInput extends ArgvInput if ('-' === $previousToken[0] && '' !== trim($previousToken, '-')) { // check if previous option accepted a value $previousOption = $this->getOptionFromToken($previousToken); - if (null !== $previousOption && $previousOption->acceptValue()) { + if ($previousOption?->acceptValue()) { $this->completionType = self::TYPE_OPTION_VALUE; $this->completionName = $previousOption->getName(); $this->completionValue = $relevantToken; @@ -183,7 +180,7 @@ final class CompletionInput extends ArgvInput { try { return parent::parseToken($token, $parseOptions); - } catch (RuntimeException $e) { + } catch (RuntimeException) { // suppress errors, completed input is almost never valid } diff --git a/vendor/symfony/console/Completion/Output/BashCompletionOutput.php b/vendor/symfony/console/Completion/Output/BashCompletionOutput.php index 8d5ffa6..c6f76eb 100644 --- a/vendor/symfony/console/Completion/Output/BashCompletionOutput.php +++ b/vendor/symfony/console/Completion/Output/BashCompletionOutput.php @@ -24,6 +24,9 @@ class BashCompletionOutput implements CompletionOutputInterface $values = $suggestions->getValueSuggestions(); foreach ($suggestions->getOptionSuggestions() as $option) { $values[] = '--'.$option->getName(); + if ($option->isNegatable()) { + $values[] = '--no-'.$option->getName(); + } } $output->writeln(implode("\n", $values)); } diff --git a/vendor/symfony/console/Completion/Output/FishCompletionOutput.php b/vendor/symfony/console/Completion/Output/FishCompletionOutput.php new file mode 100644 index 0000000..d2c414e --- /dev/null +++ b/vendor/symfony/console/Completion/Output/FishCompletionOutput.php @@ -0,0 +1,33 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Completion\Output; + +use Symfony\Component\Console\Completion\CompletionSuggestions; +use Symfony\Component\Console\Output\OutputInterface; + +/** + * @author Guillaume Aveline + */ +class FishCompletionOutput implements CompletionOutputInterface +{ + public function write(CompletionSuggestions $suggestions, OutputInterface $output): void + { + $values = $suggestions->getValueSuggestions(); + foreach ($suggestions->getOptionSuggestions() as $option) { + $values[] = '--'.$option->getName(); + if ($option->isNegatable()) { + $values[] = '--no-'.$option->getName(); + } + } + $output->write(implode("\n", $values)); + } +} diff --git a/vendor/symfony/console/Completion/Output/ZshCompletionOutput.php b/vendor/symfony/console/Completion/Output/ZshCompletionOutput.php new file mode 100644 index 0000000..bb4ce70 --- /dev/null +++ b/vendor/symfony/console/Completion/Output/ZshCompletionOutput.php @@ -0,0 +1,36 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Completion\Output; + +use Symfony\Component\Console\Completion\CompletionSuggestions; +use Symfony\Component\Console\Output\OutputInterface; + +/** + * @author Jitendra A + */ +class ZshCompletionOutput implements CompletionOutputInterface +{ + public function write(CompletionSuggestions $suggestions, OutputInterface $output): void + { + $values = []; + foreach ($suggestions->getValueSuggestions() as $value) { + $values[] = $value->getValue().($value->getDescription() ? "\t".$value->getDescription() : ''); + } + foreach ($suggestions->getOptionSuggestions() as $option) { + $values[] = '--'.$option->getName().($option->getDescription() ? "\t".$option->getDescription() : ''); + if ($option->isNegatable()) { + $values[] = '--no-'.$option->getName().($option->getDescription() ? "\t".$option->getDescription() : ''); + } + } + $output->write(implode("\n", $values)."\n"); + } +} diff --git a/vendor/symfony/console/Completion/Suggestion.php b/vendor/symfony/console/Completion/Suggestion.php index ff156f8..7392965 100644 --- a/vendor/symfony/console/Completion/Suggestion.php +++ b/vendor/symfony/console/Completion/Suggestion.php @@ -16,13 +16,12 @@ namespace Symfony\Component\Console\Completion; * * @author Wouter de Jong */ -class Suggestion +class Suggestion implements \Stringable { - private string $value; - - public function __construct(string $value) - { - $this->value = $value; + public function __construct( + private readonly string $value, + private readonly string $description = '' + ) { } public function getValue(): string @@ -30,6 +29,11 @@ class Suggestion return $this->value; } + public function getDescription(): string + { + return $this->description; + } + public function __toString(): string { return $this->getValue(); diff --git a/vendor/symfony/console/Cursor.php b/vendor/symfony/console/Cursor.php index 995e3d7..b7f5a17 100644 --- a/vendor/symfony/console/Cursor.php +++ b/vendor/symfony/console/Cursor.php @@ -18,7 +18,7 @@ use Symfony\Component\Console\Output\OutputInterface; */ final class Cursor { - private $output; + private OutputInterface $output; private $input; /** @@ -183,11 +183,7 @@ final class Cursor { static $isTtySupported; - if (null === $isTtySupported && \function_exists('proc_open')) { - $isTtySupported = (bool) @proc_open('echo 1 >/dev/null', [['file', '/dev/tty', 'r'], ['file', '/dev/tty', 'w'], ['file', '/dev/tty', 'w']], $pipes); - } - - if (!$isTtySupported) { + if (!$isTtySupported ??= '/' === \DIRECTORY_SEPARATOR && stream_isatty(\STDOUT)) { return [1, 1]; } diff --git a/vendor/symfony/console/DependencyInjection/AddConsoleCommandPass.php b/vendor/symfony/console/DependencyInjection/AddConsoleCommandPass.php index efaf39a..62c80c3 100644 --- a/vendor/symfony/console/DependencyInjection/AddConsoleCommandPass.php +++ b/vendor/symfony/console/DependencyInjection/AddConsoleCommandPass.php @@ -50,7 +50,7 @@ class AddConsoleCommandPass implements CompilerPassInterface if (!$r->isSubclassOf(Command::class)) { throw new InvalidArgumentException(sprintf('The service "%s" tagged "%s" must be a subclass of "%s".', $id, 'console.command', Command::class)); } - $aliases = $class::getDefaultName(); + $aliases = str_replace('%', '%%', $class::getDefaultName() ?? ''); } $aliases = explode('|', $aliases ?? ''); @@ -87,7 +87,7 @@ class AddConsoleCommandPass implements CompilerPassInterface $lazyCommandMap[$tag['command']] = $id; } - $description = $description ?? $tag['description'] ?? null; + $description ??= $tag['description'] ?? null; } $definition->addMethodCall('setName', [$commandName]); @@ -107,7 +107,7 @@ class AddConsoleCommandPass implements CompilerPassInterface if (!$r->isSubclassOf(Command::class)) { throw new InvalidArgumentException(sprintf('The service "%s" tagged "%s" must be a subclass of "%s".', $id, 'console.command', Command::class)); } - $description = $class::getDefaultDescription(); + $description = str_replace('%', '%%', $class::getDefaultDescription() ?? ''); } if ($description) { diff --git a/vendor/symfony/console/Descriptor/ApplicationDescription.php b/vendor/symfony/console/Descriptor/ApplicationDescription.php index 0802f1b..2158339 100644 --- a/vendor/symfony/console/Descriptor/ApplicationDescription.php +++ b/vendor/symfony/console/Descriptor/ApplicationDescription.php @@ -24,7 +24,7 @@ class ApplicationDescription { public const GLOBAL_NAMESPACE = '_global'; - private $application; + private Application $application; private ?string $namespace; private bool $showHidden; private array $namespaces; @@ -127,7 +127,7 @@ class ApplicationDescription } if ($namespacedCommands) { - ksort($namespacedCommands); + ksort($namespacedCommands, \SORT_STRING); foreach ($namespacedCommands as $key => $commandsSet) { ksort($commandsSet); $sortedCommands[$key] = $commandsSet; diff --git a/vendor/symfony/console/Descriptor/Descriptor.php b/vendor/symfony/console/Descriptor/Descriptor.php index a364830..1476f57 100644 --- a/vendor/symfony/console/Descriptor/Descriptor.php +++ b/vendor/symfony/console/Descriptor/Descriptor.php @@ -31,32 +31,18 @@ abstract class Descriptor implements DescriptorInterface */ protected $output; - /** - * {@inheritdoc} - */ public function describe(OutputInterface $output, object $object, array $options = []) { $this->output = $output; - switch (true) { - case $object instanceof InputArgument: - $this->describeInputArgument($object, $options); - break; - case $object instanceof InputOption: - $this->describeInputOption($object, $options); - break; - case $object instanceof InputDefinition: - $this->describeInputDefinition($object, $options); - break; - case $object instanceof Command: - $this->describeCommand($object, $options); - break; - case $object instanceof Application: - $this->describeApplication($object, $options); - break; - default: - throw new InvalidArgumentException(sprintf('Object of type "%s" is not describable.', get_debug_type($object))); - } + match (true) { + $object instanceof InputArgument => $this->describeInputArgument($object, $options), + $object instanceof InputOption => $this->describeInputOption($object, $options), + $object instanceof InputDefinition => $this->describeInputDefinition($object, $options), + $object instanceof Command => $this->describeCommand($object, $options), + $object instanceof Application => $this->describeApplication($object, $options), + default => throw new InvalidArgumentException(sprintf('Object of type "%s" is not describable.', get_debug_type($object))), + }; } /** diff --git a/vendor/symfony/console/Descriptor/JsonDescriptor.php b/vendor/symfony/console/Descriptor/JsonDescriptor.php index 1d28659..6f79a17 100644 --- a/vendor/symfony/console/Descriptor/JsonDescriptor.php +++ b/vendor/symfony/console/Descriptor/JsonDescriptor.php @@ -26,17 +26,11 @@ use Symfony\Component\Console\Input\InputOption; */ class JsonDescriptor extends Descriptor { - /** - * {@inheritdoc} - */ protected function describeInputArgument(InputArgument $argument, array $options = []) { $this->writeData($this->getInputArgumentData($argument), $options); } - /** - * {@inheritdoc} - */ protected function describeInputOption(InputOption $option, array $options = []) { $this->writeData($this->getInputOptionData($option), $options); @@ -45,25 +39,16 @@ class JsonDescriptor extends Descriptor } } - /** - * {@inheritdoc} - */ protected function describeInputDefinition(InputDefinition $definition, array $options = []) { $this->writeData($this->getInputDefinitionData($definition), $options); } - /** - * {@inheritdoc} - */ protected function describeCommand(Command $command, array $options = []) { $this->writeData($this->getCommandData($command, $options['short'] ?? false), $options); } - /** - * {@inheritdoc} - */ protected function describeApplication(Application $application, array $options = []) { $describedNamespace = $options['namespace'] ?? null; diff --git a/vendor/symfony/console/Descriptor/MarkdownDescriptor.php b/vendor/symfony/console/Descriptor/MarkdownDescriptor.php index 21ceca6..fbd9c53 100644 --- a/vendor/symfony/console/Descriptor/MarkdownDescriptor.php +++ b/vendor/symfony/console/Descriptor/MarkdownDescriptor.php @@ -28,9 +28,6 @@ use Symfony\Component\Console\Output\OutputInterface; */ class MarkdownDescriptor extends Descriptor { - /** - * {@inheritdoc} - */ public function describe(OutputInterface $output, object $object, array $options = []) { $decorated = $output->isDecorated(); @@ -41,17 +38,11 @@ class MarkdownDescriptor extends Descriptor $output->setDecorated($decorated); } - /** - * {@inheritdoc} - */ protected function write(string $content, bool $decorated = true) { parent::write($content, $decorated); } - /** - * {@inheritdoc} - */ protected function describeInputArgument(InputArgument $argument, array $options = []) { $this->write( @@ -63,9 +54,6 @@ class MarkdownDescriptor extends Descriptor ); } - /** - * {@inheritdoc} - */ protected function describeInputOption(InputOption $option, array $options = []) { $name = '--'.$option->getName(); @@ -87,9 +75,6 @@ class MarkdownDescriptor extends Descriptor ); } - /** - * {@inheritdoc} - */ protected function describeInputDefinition(InputDefinition $definition, array $options = []) { if ($showArguments = \count($definition->getArguments()) > 0) { @@ -117,9 +102,6 @@ class MarkdownDescriptor extends Descriptor } } - /** - * {@inheritdoc} - */ protected function describeCommand(Command $command, array $options = []) { if ($options['short'] ?? false) { @@ -160,9 +142,6 @@ class MarkdownDescriptor extends Descriptor } } - /** - * {@inheritdoc} - */ protected function describeApplication(Application $application, array $options = []) { $describedNamespace = $options['namespace'] ?? null; diff --git a/vendor/symfony/console/Descriptor/TextDescriptor.php b/vendor/symfony/console/Descriptor/TextDescriptor.php index 3f309f5..48a0b42 100644 --- a/vendor/symfony/console/Descriptor/TextDescriptor.php +++ b/vendor/symfony/console/Descriptor/TextDescriptor.php @@ -28,9 +28,6 @@ use Symfony\Component\Console\Input\InputOption; */ class TextDescriptor extends Descriptor { - /** - * {@inheritdoc} - */ protected function describeInputArgument(InputArgument $argument, array $options = []) { if (null !== $argument->getDefault() && (!\is_array($argument->getDefault()) || \count($argument->getDefault()))) { @@ -51,9 +48,6 @@ class TextDescriptor extends Descriptor ), $options); } - /** - * {@inheritdoc} - */ protected function describeInputOption(InputOption $option, array $options = []) { if ($option->acceptValue() && null !== $option->getDefault() && (!\is_array($option->getDefault()) || \count($option->getDefault()))) { @@ -89,9 +83,6 @@ class TextDescriptor extends Descriptor ), $options); } - /** - * {@inheritdoc} - */ protected function describeInputDefinition(InputDefinition $definition, array $options = []) { $totalWidth = $this->calculateTotalWidthForOptions($definition->getOptions()); @@ -131,9 +122,6 @@ class TextDescriptor extends Descriptor } } - /** - * {@inheritdoc} - */ protected function describeCommand(Command $command, array $options = []) { $command->mergeApplicationDefinition(false); @@ -169,9 +157,6 @@ class TextDescriptor extends Descriptor } } - /** - * {@inheritdoc} - */ protected function describeApplication(Application $application, array $options = []) { $describedNamespace = $options['namespace'] ?? null; @@ -245,9 +230,6 @@ class TextDescriptor extends Descriptor } } - /** - * {@inheritdoc} - */ private function writeText(string $content, array $options = []) { $this->write( diff --git a/vendor/symfony/console/Descriptor/XmlDescriptor.php b/vendor/symfony/console/Descriptor/XmlDescriptor.php index 4f7cd8b..f4643a9 100644 --- a/vendor/symfony/console/Descriptor/XmlDescriptor.php +++ b/vendor/symfony/console/Descriptor/XmlDescriptor.php @@ -120,41 +120,26 @@ class XmlDescriptor extends Descriptor return $dom; } - /** - * {@inheritdoc} - */ protected function describeInputArgument(InputArgument $argument, array $options = []) { $this->writeDocument($this->getInputArgumentDocument($argument)); } - /** - * {@inheritdoc} - */ protected function describeInputOption(InputOption $option, array $options = []) { $this->writeDocument($this->getInputOptionDocument($option)); } - /** - * {@inheritdoc} - */ protected function describeInputDefinition(InputDefinition $definition, array $options = []) { $this->writeDocument($this->getInputDefinitionDocument($definition)); } - /** - * {@inheritdoc} - */ protected function describeCommand(Command $command, array $options = []) { $this->writeDocument($this->getCommandDocument($command, $options['short'] ?? false)); } - /** - * {@inheritdoc} - */ protected function describeApplication(Application $application, array $options = []) { $this->writeDocument($this->getApplicationDocument($application, $options['namespace'] ?? null, $options['short'] ?? false)); diff --git a/vendor/symfony/console/Event/ConsoleErrorEvent.php b/vendor/symfony/console/Event/ConsoleErrorEvent.php index 19bd4bf..d4a6912 100644 --- a/vendor/symfony/console/Event/ConsoleErrorEvent.php +++ b/vendor/symfony/console/Event/ConsoleErrorEvent.php @@ -47,7 +47,6 @@ final class ConsoleErrorEvent extends ConsoleEvent $this->exitCode = $exitCode; $r = new \ReflectionProperty($this->error, 'code'); - $r->setAccessible(true); $r->setValue($this->error, $this->exitCode); } diff --git a/vendor/symfony/console/Event/ConsoleEvent.php b/vendor/symfony/console/Event/ConsoleEvent.php index 56b8a9a..6ba1615 100644 --- a/vendor/symfony/console/Event/ConsoleEvent.php +++ b/vendor/symfony/console/Event/ConsoleEvent.php @@ -25,8 +25,8 @@ class ConsoleEvent extends Event { protected $command; - private $input; - private $output; + private InputInterface $input; + private OutputInterface $output; public function __construct(?Command $command, InputInterface $input, OutputInterface $output) { diff --git a/vendor/symfony/console/EventListener/ErrorListener.php b/vendor/symfony/console/EventListener/ErrorListener.php index 61bd9d3..773a13a 100644 --- a/vendor/symfony/console/EventListener/ErrorListener.php +++ b/vendor/symfony/console/EventListener/ErrorListener.php @@ -24,7 +24,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface; */ class ErrorListener implements EventSubscriberInterface { - private $logger; + private ?LoggerInterface $logger; public function __construct(LoggerInterface $logger = null) { @@ -79,7 +79,7 @@ class ErrorListener implements EventSubscriberInterface private static function getInputString(ConsoleEvent $event): ?string { - $commandName = $event->getCommand() ? $event->getCommand()->getName() : null; + $commandName = $event->getCommand()?->getName(); $input = $event->getInput(); if ($input instanceof \Stringable) { diff --git a/vendor/symfony/console/Exception/InvalidOptionException.php b/vendor/symfony/console/Exception/InvalidOptionException.php index b2eec61..5cf6279 100644 --- a/vendor/symfony/console/Exception/InvalidOptionException.php +++ b/vendor/symfony/console/Exception/InvalidOptionException.php @@ -12,7 +12,7 @@ namespace Symfony\Component\Console\Exception; /** - * Represents an incorrect option name typed in the console. + * Represents an incorrect option name or value typed in the console. * * @author Jérôme Tamarelle */ diff --git a/vendor/symfony/console/Formatter/NullOutputFormatter.php b/vendor/symfony/console/Formatter/NullOutputFormatter.php index d770e14..5c11c76 100644 --- a/vendor/symfony/console/Formatter/NullOutputFormatter.php +++ b/vendor/symfony/console/Formatter/NullOutputFormatter.php @@ -16,52 +16,34 @@ namespace Symfony\Component\Console\Formatter; */ final class NullOutputFormatter implements OutputFormatterInterface { - private $style; + private NullOutputFormatterStyle $style; - /** - * {@inheritdoc} - */ public function format(?string $message): ?string { return null; } - /** - * {@inheritdoc} - */ public function getStyle(string $name): OutputFormatterStyleInterface { // to comply with the interface we must return a OutputFormatterStyleInterface - return $this->style ?? $this->style = new NullOutputFormatterStyle(); + return $this->style ??= new NullOutputFormatterStyle(); } - /** - * {@inheritdoc} - */ public function hasStyle(string $name): bool { return false; } - /** - * {@inheritdoc} - */ public function isDecorated(): bool { return false; } - /** - * {@inheritdoc} - */ public function setDecorated(bool $decorated): void { // do nothing } - /** - * {@inheritdoc} - */ public function setStyle(string $name, OutputFormatterStyleInterface $style): void { // do nothing diff --git a/vendor/symfony/console/Formatter/NullOutputFormatterStyle.php b/vendor/symfony/console/Formatter/NullOutputFormatterStyle.php index bfd0afe..c2ce7d1 100644 --- a/vendor/symfony/console/Formatter/NullOutputFormatterStyle.php +++ b/vendor/symfony/console/Formatter/NullOutputFormatterStyle.php @@ -1,4 +1,5 @@ \func_num_args()) { + trigger_deprecation('symfony/console', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__); + } // do nothing } - /** - * {@inheritdoc} - */ public function setForeground(string $color = null): void { + if (1 > \func_num_args()) { + trigger_deprecation('symfony/console', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__); + } // do nothing } - /** - * {@inheritdoc} - */ public function setOption(string $option): void { // do nothing } - /** - * {@inheritdoc} - */ public function setOptions(array $options): void { // do nothing } - /** - * {@inheritdoc} - */ public function unsetOption(string $option): void { // do nothing diff --git a/vendor/symfony/console/Formatter/OutputFormatter.php b/vendor/symfony/console/Formatter/OutputFormatter.php index 4a6ae91..38e75c3 100644 --- a/vendor/symfony/console/Formatter/OutputFormatter.php +++ b/vendor/symfony/console/Formatter/OutputFormatter.php @@ -23,7 +23,7 @@ class OutputFormatter implements WrappableOutputFormatterInterface { private bool $decorated; private array $styles = []; - private $styleStack; + private OutputFormatterStyleStack $styleStack; public function __clone() { @@ -81,41 +81,26 @@ class OutputFormatter implements WrappableOutputFormatterInterface $this->styleStack = new OutputFormatterStyleStack(); } - /** - * {@inheritdoc} - */ public function setDecorated(bool $decorated) { $this->decorated = $decorated; } - /** - * {@inheritdoc} - */ public function isDecorated(): bool { return $this->decorated; } - /** - * {@inheritdoc} - */ public function setStyle(string $name, OutputFormatterStyleInterface $style) { $this->styles[strtolower($name)] = $style; } - /** - * {@inheritdoc} - */ public function hasStyle(string $name): bool { return isset($this->styles[strtolower($name)]); } - /** - * {@inheritdoc} - */ public function getStyle(string $name): OutputFormatterStyleInterface { if (!$this->hasStyle($name)) { @@ -125,17 +110,11 @@ class OutputFormatter implements WrappableOutputFormatterInterface return $this->styles[strtolower($name)]; } - /** - * {@inheritdoc} - */ public function format(?string $message): ?string { return $this->formatAndWrap($message, 0); } - /** - * {@inheritdoc} - */ public function formatAndWrap(?string $message, int $width) { if (null === $message) { @@ -161,7 +140,7 @@ class OutputFormatter implements WrappableOutputFormatterInterface $offset = $pos + \strlen($text); // opening tag? - if ($open = '/' != $text[1]) { + if ($open = '/' !== $text[1]) { $tag = $matches[1][$i][0]; } else { $tag = $matches[3][$i][0] ?? ''; @@ -256,7 +235,7 @@ class OutputFormatter implements WrappableOutputFormatterInterface $text = $prefix.preg_replace('~([^\\n]{'.$width.'})\\ *~', "\$1\n", $text); $text = rtrim($text, "\n").($matches[1] ?? ''); - if (!$currentLineLength && '' !== $current && "\n" !== substr($current, -1)) { + if (!$currentLineLength && '' !== $current && !str_ends_with($current, "\n")) { $text = "\n".$text; } diff --git a/vendor/symfony/console/Formatter/OutputFormatterStyle.php b/vendor/symfony/console/Formatter/OutputFormatterStyle.php index 0a009e9..1659986 100644 --- a/vendor/symfony/console/Formatter/OutputFormatterStyle.php +++ b/vendor/symfony/console/Formatter/OutputFormatterStyle.php @@ -20,7 +20,7 @@ use Symfony\Component\Console\Color; */ class OutputFormatterStyle implements OutputFormatterStyleInterface { - private $color; + private Color $color; private string $foreground; private string $background; private array $options; @@ -38,19 +38,19 @@ class OutputFormatterStyle implements OutputFormatterStyleInterface $this->color = new Color($this->foreground = $foreground ?: '', $this->background = $background ?: '', $this->options = $options); } - /** - * {@inheritdoc} - */ public function setForeground(string $color = null) { + if (1 > \func_num_args()) { + trigger_deprecation('symfony/console', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__); + } $this->color = new Color($this->foreground = $color ?: '', $this->background, $this->options); } - /** - * {@inheritdoc} - */ public function setBackground(string $color = null) { + if (1 > \func_num_args()) { + trigger_deprecation('symfony/console', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__); + } $this->color = new Color($this->foreground, $this->background = $color ?: '', $this->options); } @@ -59,18 +59,12 @@ class OutputFormatterStyle implements OutputFormatterStyleInterface $this->href = $url; } - /** - * {@inheritdoc} - */ public function setOption(string $option) { $this->options[] = $option; $this->color = new Color($this->foreground, $this->background, $this->options); } - /** - * {@inheritdoc} - */ public function unsetOption(string $option) { $pos = array_search($option, $this->options); @@ -81,17 +75,11 @@ class OutputFormatterStyle implements OutputFormatterStyleInterface $this->color = new Color($this->foreground, $this->background, $this->options); } - /** - * {@inheritdoc} - */ public function setOptions(array $options) { $this->color = new Color($this->foreground, $this->background, $this->options = $options); } - /** - * {@inheritdoc} - */ public function apply(string $text): string { $this->handlesHrefGracefully ??= 'JetBrains-JediTerm' !== getenv('TERMINAL_EMULATOR') diff --git a/vendor/symfony/console/Formatter/OutputFormatterStyleInterface.php b/vendor/symfony/console/Formatter/OutputFormatterStyleInterface.php index 91d50aa..7ed67d9 100644 --- a/vendor/symfony/console/Formatter/OutputFormatterStyleInterface.php +++ b/vendor/symfony/console/Formatter/OutputFormatterStyleInterface.php @@ -21,12 +21,12 @@ interface OutputFormatterStyleInterface /** * Sets style foreground color. */ - public function setForeground(string $color = null); + public function setForeground(?string $color); /** * Sets style background color. */ - public function setBackground(string $color = null); + public function setBackground(?string $color); /** * Sets some specific style option. diff --git a/vendor/symfony/console/Formatter/OutputFormatterStyleStack.php b/vendor/symfony/console/Formatter/OutputFormatterStyleStack.php index b425449..2c5cdf9 100644 --- a/vendor/symfony/console/Formatter/OutputFormatterStyleStack.php +++ b/vendor/symfony/console/Formatter/OutputFormatterStyleStack.php @@ -24,7 +24,7 @@ class OutputFormatterStyleStack implements ResetInterface */ private array $styles = []; - private $emptyStyle; + private OutputFormatterStyleInterface $emptyStyle; public function __construct(OutputFormatterStyleInterface $emptyStyle = null) { @@ -55,7 +55,7 @@ class OutputFormatterStyleStack implements ResetInterface */ public function pop(OutputFormatterStyleInterface $style = null): OutputFormatterStyleInterface { - if (empty($this->styles)) { + if (!$this->styles) { return $this->emptyStyle; } @@ -77,9 +77,9 @@ class OutputFormatterStyleStack implements ResetInterface /** * Computes current style with stacks top codes. */ - public function getCurrent(): OutputFormatterStyle + public function getCurrent(): OutputFormatterStyleInterface { - if (empty($this->styles)) { + if (!$this->styles) { return $this->emptyStyle; } diff --git a/vendor/symfony/console/Formatter/WrappableOutputFormatterInterface.php b/vendor/symfony/console/Formatter/WrappableOutputFormatterInterface.php index 42319ee..746cd27 100644 --- a/vendor/symfony/console/Formatter/WrappableOutputFormatterInterface.php +++ b/vendor/symfony/console/Formatter/WrappableOutputFormatterInterface.php @@ -20,6 +20,8 @@ interface WrappableOutputFormatterInterface extends OutputFormatterInterface { /** * Formats a message according to the given styles, wrapping at `$width` (0 means no wrapping). + * + * @return string */ public function formatAndWrap(?string $message, int $width); } diff --git a/vendor/symfony/console/Helper/DebugFormatterHelper.php b/vendor/symfony/console/Helper/DebugFormatterHelper.php index 64c7cff..9ea7fb9 100644 --- a/vendor/symfony/console/Helper/DebugFormatterHelper.php +++ b/vendor/symfony/console/Helper/DebugFormatterHelper.php @@ -91,9 +91,6 @@ class DebugFormatterHelper extends Helper return sprintf(' ', self::COLORS[$this->started[$id]['border']]); } - /** - * {@inheritdoc} - */ public function getName(): string { return 'debug_formatter'; diff --git a/vendor/symfony/console/Helper/DescriptorHelper.php b/vendor/symfony/console/Helper/DescriptorHelper.php index 63597c6..3015ff0 100644 --- a/vendor/symfony/console/Helper/DescriptorHelper.php +++ b/vendor/symfony/console/Helper/DescriptorHelper.php @@ -77,9 +77,6 @@ class DescriptorHelper extends Helper return $this; } - /** - * {@inheritdoc} - */ public function getName(): string { return 'descriptor'; diff --git a/vendor/symfony/console/Helper/Dumper.php b/vendor/symfony/console/Helper/Dumper.php index 5019095..ac7571c 100644 --- a/vendor/symfony/console/Helper/Dumper.php +++ b/vendor/symfony/console/Helper/Dumper.php @@ -21,9 +21,9 @@ use Symfony\Component\VarDumper\Dumper\CliDumper; */ final class Dumper { - private $output; - private $dumper; - private $cloner; + private OutputInterface $output; + private ?CliDumper $dumper; + private ?ClonerInterface $cloner; private \Closure $handler; public function __construct(OutputInterface $output, CliDumper $dumper = null, ClonerInterface $cloner = null) @@ -34,25 +34,20 @@ final class Dumper if (class_exists(CliDumper::class)) { $this->handler = function ($var): string { - $dumper = $this->dumper ?? $this->dumper = new CliDumper(null, null, CliDumper::DUMP_LIGHT_ARRAY | CliDumper::DUMP_COMMA_SEPARATOR); + $dumper = $this->dumper ??= new CliDumper(null, null, CliDumper::DUMP_LIGHT_ARRAY | CliDumper::DUMP_COMMA_SEPARATOR); $dumper->setColors($this->output->isDecorated()); - return rtrim($dumper->dump(($this->cloner ?? $this->cloner = new VarCloner())->cloneVar($var)->withRefHandles(false), true)); + return rtrim($dumper->dump(($this->cloner ??= new VarCloner())->cloneVar($var)->withRefHandles(false), true)); }; } else { $this->handler = function ($var): string { - switch (true) { - case null === $var: - return 'null'; - case true === $var: - return 'true'; - case false === $var: - return 'false'; - case \is_string($var): - return '"'.$var.'"'; - default: - return rtrim(print_r($var, true)); - } + return match (true) { + null === $var => 'null', + true === $var => 'true', + false === $var => 'false', + \is_string($var) => '"'.$var.'"', + default => rtrim(print_r($var, true)), + }; }; } } diff --git a/vendor/symfony/console/Helper/FormatterHelper.php b/vendor/symfony/console/Helper/FormatterHelper.php index 2d7d1fa..279e4c7 100644 --- a/vendor/symfony/console/Helper/FormatterHelper.php +++ b/vendor/symfony/console/Helper/FormatterHelper.php @@ -74,9 +74,6 @@ class FormatterHelper extends Helper return self::substr($message, 0, $length).$suffix; } - /** - * {@inheritdoc} - */ public function getName(): string { return 'formatter'; diff --git a/vendor/symfony/console/Helper/Helper.php b/vendor/symfony/console/Helper/Helper.php index 01e39a9..920196e 100644 --- a/vendor/symfony/console/Helper/Helper.php +++ b/vendor/symfony/console/Helper/Helper.php @@ -23,17 +23,14 @@ abstract class Helper implements HelperInterface { protected $helperSet = null; - /** - * {@inheritdoc} - */ public function setHelperSet(HelperSet $helperSet = null) { + if (1 > \func_num_args()) { + trigger_deprecation('symfony/console', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__); + } $this->helperSet = $helperSet; } - /** - * {@inheritdoc} - */ public function getHelperSet(): ?HelperSet { return $this->helperSet; @@ -45,7 +42,7 @@ abstract class Helper implements HelperInterface */ public static function width(?string $string): int { - $string ?? $string = ''; + $string ??= ''; if (preg_match('//u', $string)) { return (new UnicodeString($string))->width(false); @@ -64,7 +61,7 @@ abstract class Helper implements HelperInterface */ public static function length(?string $string): int { - $string ?? $string = ''; + $string ??= ''; if (preg_match('//u', $string)) { return (new UnicodeString($string))->length(); @@ -82,7 +79,7 @@ abstract class Helper implements HelperInterface */ public static function substr(?string $string, int $from, int $length = null): string { - $string ?? $string = ''; + $string ??= ''; if (false === $encoding = mb_detect_encoding($string, null, true)) { return substr($string, $from, $length); @@ -145,6 +142,8 @@ abstract class Helper implements HelperInterface $string = $formatter->format($string ?? ''); // remove already formatted characters $string = preg_replace("/\033\[[^m]*m/", '', $string ?? ''); + // remove terminal hyperlinks + $string = preg_replace('/\\033]8;[^;]*;[^\\033]*\\033\\\\/', '', $string ?? ''); $formatter->setDecorated($isDecorated); return $string; diff --git a/vendor/symfony/console/Helper/HelperInterface.php b/vendor/symfony/console/Helper/HelperInterface.php index 1d2b7bf..2762cdf 100644 --- a/vendor/symfony/console/Helper/HelperInterface.php +++ b/vendor/symfony/console/Helper/HelperInterface.php @@ -21,7 +21,7 @@ interface HelperInterface /** * Sets the helper set associated with this helper. */ - public function setHelperSet(HelperSet $helperSet = null); + public function setHelperSet(?HelperSet $helperSet); /** * Gets the helper set associated with this helper. diff --git a/vendor/symfony/console/Helper/HelperSet.php b/vendor/symfony/console/Helper/HelperSet.php index be0beca..cefe62b 100644 --- a/vendor/symfony/console/Helper/HelperSet.php +++ b/vendor/symfony/console/Helper/HelperSet.php @@ -18,15 +18,15 @@ use Symfony\Component\Console\Exception\InvalidArgumentException; * * @author Fabien Potencier * - * @implements \IteratorAggregate + * @implements \IteratorAggregate */ class HelperSet implements \IteratorAggregate { - /** @var array */ + /** @var array */ private array $helpers = []; /** - * @param Helper[] $helpers An array of helper + * @param HelperInterface[] $helpers */ public function __construct(array $helpers = []) { diff --git a/vendor/symfony/console/Helper/InputAwareHelper.php b/vendor/symfony/console/Helper/InputAwareHelper.php index 0d0dba2..ba81e37 100644 --- a/vendor/symfony/console/Helper/InputAwareHelper.php +++ b/vendor/symfony/console/Helper/InputAwareHelper.php @@ -23,9 +23,6 @@ abstract class InputAwareHelper extends Helper implements InputAwareInterface { protected $input; - /** - * {@inheritdoc} - */ public function setInput(InputInterface $input) { $this->input = $input; diff --git a/vendor/symfony/console/Helper/OutputWrapper.php b/vendor/symfony/console/Helper/OutputWrapper.php new file mode 100644 index 0000000..2ec819c --- /dev/null +++ b/vendor/symfony/console/Helper/OutputWrapper.php @@ -0,0 +1,76 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Helper; + +/** + * Simple output wrapper for "tagged outputs" instead of wordwrap(). This solution is based on a StackOverflow + * answer: https://stackoverflow.com/a/20434776/1476819 from user557597 (alias SLN). + * + * (?: + * # -- Words/Characters + * ( # (1 start) + * (?> # Atomic Group - Match words with valid breaks + * .{1,16} # 1-N characters + * # Followed by one of 4 prioritized, non-linebreak whitespace + * (?: # break types: + * (?<= [^\S\r\n] ) # 1. - Behind a non-linebreak whitespace + * [^\S\r\n]? # ( optionally accept an extra non-linebreak whitespace ) + * | (?= \r? \n ) # 2. - Ahead a linebreak + * | $ # 3. - EOS + * | [^\S\r\n] # 4. - Accept an extra non-linebreak whitespace + * ) + * ) # End atomic group + * | + * .{1,16} # No valid word breaks, just break on the N'th character + * ) # (1 end) + * (?: \r? \n )? # Optional linebreak after Words/Characters + * | + * # -- Or, Linebreak + * (?: \r? \n | $ ) # Stand alone linebreak or at EOS + * ) + * + * @author Krisztián Ferenczi + * + * @see https://stackoverflow.com/a/20434776/1476819 + */ +final class OutputWrapper +{ + private const TAG_OPEN_REGEX_SEGMENT = '[a-z](?:[^\\\\<>]*+ | \\\\.)*'; + private const TAG_CLOSE_REGEX_SEGMENT = '[a-z][^<>]*+'; + private const URL_PATTERN = 'https?://\S+'; + + public function __construct( + private bool $allowCutUrls = false + ) { + } + + public function wrap(string $text, int $width, string $break = "\n"): string + { + if (!$width) { + return $text; + } + + $tagPattern = sprintf('<(?:(?:%s)|/(?:%s)?)>', self::TAG_OPEN_REGEX_SEGMENT, self::TAG_CLOSE_REGEX_SEGMENT); + $limitPattern = "{1,$width}"; + $patternBlocks = [$tagPattern]; + if (!$this->allowCutUrls) { + $patternBlocks[] = self::URL_PATTERN; + } + $patternBlocks[] = '.'; + $blocks = implode('|', $patternBlocks); + $rowPattern = "(?:$blocks)$limitPattern"; + $pattern = sprintf('#(?:((?>(%1$s)((?<=[^\S\r\n])[^\S\r\n]?|(?=\r?\n)|$|[^\S\r\n]))|(%1$s))(?:\r?\n)?|(?:\r?\n|$))#imux', $rowPattern); + $output = rtrim(preg_replace($pattern, '\\1'.$break, $text), $break); + + return str_replace(' '.$break, $break, $output); + } +} diff --git a/vendor/symfony/console/Helper/ProcessHelper.php b/vendor/symfony/console/Helper/ProcessHelper.php index e5ba4db..26d35a1 100644 --- a/vendor/symfony/console/Helper/ProcessHelper.php +++ b/vendor/symfony/console/Helper/ProcessHelper.php @@ -130,9 +130,6 @@ class ProcessHelper extends Helper return str_replace('<', '\\<', $str); } - /** - * {@inheritdoc} - */ public function getName(): string { return 'process'; diff --git a/vendor/symfony/console/Helper/ProgressBar.php b/vendor/symfony/console/Helper/ProgressBar.php index 72c26f2..0d11260 100644 --- a/vendor/symfony/console/Helper/ProgressBar.php +++ b/vendor/symfony/console/Helper/ProgressBar.php @@ -47,18 +47,18 @@ final class ProgressBar private float $lastWriteTime = 0; private float $minSecondsBetweenRedraws = 0; private float $maxSecondsBetweenRedraws = 1; - private $output; + private OutputInterface $output; private int $step = 0; + private int $startingStep = 0; private ?int $max = null; private int $startTime; private int $stepWidth; private float $percent = 0.0; - private int $formatLineCount; private array $messages = []; private bool $overwrite = true; - private $terminal; + private Terminal $terminal; private ?string $previousMessage = null; - private $cursor; + private Cursor $cursor; private static array $formatters; private static array $formats; @@ -199,11 +199,11 @@ final class ProgressBar public function getEstimated(): float { - if (!$this->step) { + if (0 === $this->step || $this->step === $this->startingStep) { return 0; } - return round((time() - $this->startTime) / $this->step * $this->max); + return round((time() - $this->startTime) / ($this->step - $this->startingStep) * $this->max); } public function getRemaining(): float @@ -212,7 +212,7 @@ final class ProgressBar return 0; } - return round((time() - $this->startTime) / $this->step * ($this->max - $this->step)); + return round((time() - $this->startTime) / ($this->step - $this->startingStep) * ($this->max - $this->step)); } public function setBarWidth(int $size) @@ -302,13 +302,16 @@ final class ProgressBar /** * Starts the progress output. * - * @param int|null $max Number of steps to complete the bar (0 if indeterminate), null to leave unchanged + * @param int|null $max Number of steps to complete the bar (0 if indeterminate), null to leave unchanged + * @param int $startAt The starting point of the bar (useful e.g. when resuming a previously started bar) */ - public function start(int $max = null) + public function start(int $max = null, int $startAt = 0): void { $this->startTime = time(); - $this->step = 0; - $this->percent = 0.0; + $this->step = $startAt; + $this->startingStep = $startAt; + + $startAt > 0 ? $this->setProgress($startAt) : $this->percent = 0.0; if (null !== $max) { $this->setMaxSteps($max); @@ -438,8 +441,6 @@ final class ProgressBar } else { $this->format = $format; } - - $this->formatLineCount = substr_count($this->format, "\n"); } /** @@ -456,7 +457,7 @@ final class ProgressBar if ($this->overwrite) { if (null !== $this->previousMessage) { if ($this->output instanceof ConsoleSectionOutput) { - $messageLines = explode("\n", $message); + $messageLines = explode("\n", $this->previousMessage); $lineCount = \count($messageLines); foreach ($messageLines as $messageLine) { $messageLineLength = Helper::width(Helper::removeDecoration($this->output->getFormatter(), $messageLine)); @@ -466,7 +467,8 @@ final class ProgressBar } $this->output->clear($lineCount); } else { - for ($i = 0; $i < $this->formatLineCount; ++$i) { + $lineCount = substr_count($this->previousMessage, "\n"); + for ($i = 0; $i < $lineCount; ++$i) { $this->cursor->moveToColumn(1); $this->cursor->clearLine(); $this->cursor->moveUp(); @@ -489,17 +491,13 @@ final class ProgressBar private function determineBestFormat(): string { - switch ($this->output->getVerbosity()) { + return match ($this->output->getVerbosity()) { // OutputInterface::VERBOSITY_QUIET: display is disabled anyway - case OutputInterface::VERBOSITY_VERBOSE: - return $this->max ? self::FORMAT_VERBOSE : self::FORMAT_VERBOSE_NOMAX; - case OutputInterface::VERBOSITY_VERY_VERBOSE: - return $this->max ? self::FORMAT_VERY_VERBOSE : self::FORMAT_VERY_VERBOSE_NOMAX; - case OutputInterface::VERBOSITY_DEBUG: - return $this->max ? self::FORMAT_DEBUG : self::FORMAT_DEBUG_NOMAX; - default: - return $this->max ? self::FORMAT_NORMAL : self::FORMAT_NORMAL_NOMAX; - } + OutputInterface::VERBOSITY_VERBOSE => $this->max ? self::FORMAT_VERBOSE : self::FORMAT_VERBOSE_NOMAX, + OutputInterface::VERBOSITY_VERY_VERBOSE => $this->max ? self::FORMAT_VERY_VERBOSE : self::FORMAT_VERY_VERBOSE_NOMAX, + OutputInterface::VERBOSITY_DEBUG => $this->max ? self::FORMAT_DEBUG : self::FORMAT_DEBUG_NOMAX, + default => $this->max ? self::FORMAT_NORMAL : self::FORMAT_NORMAL_NOMAX, + }; } private static function initPlaceholderFormatters(): array diff --git a/vendor/symfony/console/Helper/ProgressIndicator.php b/vendor/symfony/console/Helper/ProgressIndicator.php index c746f9b..1720364 100644 --- a/vendor/symfony/console/Helper/ProgressIndicator.php +++ b/vendor/symfony/console/Helper/ProgressIndicator.php @@ -31,7 +31,7 @@ class ProgressIndicator 'very_verbose_no_ansi' => ' %message% (%elapsed:6s%, %memory:6s%)', ]; - private $output; + private OutputInterface $output; private int $startTime; private ?string $format = null; private ?string $message = null; @@ -54,14 +54,8 @@ class ProgressIndicator { $this->output = $output; - if (null === $format) { - $format = $this->determineBestFormat(); - } - - if (null === $indicatorValues) { - $indicatorValues = ['-', '\\', '|', '/']; - } - + $format ??= $this->determineBestFormat(); + $indicatorValues ??= ['-', '\\', '|', '/']; $indicatorValues = array_values($indicatorValues); if (2 > \count($indicatorValues)) { @@ -191,16 +185,13 @@ class ProgressIndicator private function determineBestFormat(): string { - switch ($this->output->getVerbosity()) { + return match ($this->output->getVerbosity()) { // OutputInterface::VERBOSITY_QUIET: display is disabled anyway - case OutputInterface::VERBOSITY_VERBOSE: - return $this->output->isDecorated() ? 'verbose' : 'verbose_no_ansi'; - case OutputInterface::VERBOSITY_VERY_VERBOSE: - case OutputInterface::VERBOSITY_DEBUG: - return $this->output->isDecorated() ? 'very_verbose' : 'very_verbose_no_ansi'; - default: - return $this->output->isDecorated() ? 'normal' : 'normal_no_ansi'; - } + OutputInterface::VERBOSITY_VERBOSE => $this->output->isDecorated() ? 'verbose' : 'verbose_no_ansi', + OutputInterface::VERBOSITY_VERY_VERBOSE, + OutputInterface::VERBOSITY_DEBUG => $this->output->isDecorated() ? 'very_verbose' : 'very_verbose_no_ansi', + default => $this->output->isDecorated() ? 'normal' : 'normal_no_ansi', + }; } /** diff --git a/vendor/symfony/console/Helper/QuestionHelper.php b/vendor/symfony/console/Helper/QuestionHelper.php index 2e1ccb2..c345b4a 100644 --- a/vendor/symfony/console/Helper/QuestionHelper.php +++ b/vendor/symfony/console/Helper/QuestionHelper.php @@ -24,6 +24,7 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\ChoiceQuestion; use Symfony\Component\Console\Question\Question; use Symfony\Component\Console\Terminal; + use function Symfony\Component\String\s; /** @@ -83,9 +84,6 @@ class QuestionHelper extends Helper } } - /** - * {@inheritdoc} - */ public function getName(): string { return 'question'; @@ -139,6 +137,7 @@ class QuestionHelper extends Helper } if ($output instanceof ConsoleSectionOutput) { + $output->addContent(''); // add EOL to the question $output->addContent($ret); } @@ -405,7 +404,7 @@ class QuestionHelper extends Helper $exe = __DIR__.'/../Resources/bin/hiddeninput.exe'; // handle code running from a phar - if ('phar:' === substr(__FILE__, 0, 5)) { + if (str_starts_with(__FILE__, 'phar:')) { $tmpExe = sys_get_temp_dir().'/hiddeninput.exe'; copy($exe, $tmpExe); $exe = $tmpExe; @@ -431,6 +430,11 @@ class QuestionHelper extends Helper $value = fgets($inputStream, 4096); + if (4095 === \strlen($value)) { + $errOutput = $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output; + $errOutput->warning('The value was possibly truncated by your shell or terminal emulator'); + } + if (self::$stty && Terminal::hasSttyAvailable()) { shell_exec('stty '.$sttyMode); } diff --git a/vendor/symfony/console/Helper/SymfonyQuestionHelper.php b/vendor/symfony/console/Helper/SymfonyQuestionHelper.php index 01f94ab..109045d 100644 --- a/vendor/symfony/console/Helper/SymfonyQuestionHelper.php +++ b/vendor/symfony/console/Helper/SymfonyQuestionHelper.php @@ -25,9 +25,6 @@ use Symfony\Component\Console\Style\SymfonyStyle; */ class SymfonyQuestionHelper extends QuestionHelper { - /** - * {@inheritdoc} - */ protected function writePrompt(OutputInterface $output, Question $question) { $text = OutputFormatter::escapeTrailingBackslash($question->getQuestion()); @@ -83,9 +80,6 @@ class SymfonyQuestionHelper extends QuestionHelper $output->write($prompt); } - /** - * {@inheritdoc} - */ protected function writeError(OutputInterface $output, \Exception $error) { if ($output instanceof SymfonyStyle) { diff --git a/vendor/symfony/console/Helper/Table.php b/vendor/symfony/console/Helper/Table.php index 2e87ed9..893b319 100644 --- a/vendor/symfony/console/Helper/Table.php +++ b/vendor/symfony/console/Helper/Table.php @@ -35,20 +35,23 @@ class Table private const SEPARATOR_BOTTOM = 3; private const BORDER_OUTSIDE = 0; private const BORDER_INSIDE = 1; + private const DISPLAY_ORIENTATION_DEFAULT = 'default'; + private const DISPLAY_ORIENTATION_HORIZONTAL = 'horizontal'; + private const DISPLAY_ORIENTATION_VERTICAL = 'vertical'; private ?string $headerTitle = null; private ?string $footerTitle = null; private array $headers = []; private array $rows = []; - private bool $horizontal = false; private array $effectiveColumnWidths = []; private int $numberOfColumns; - private $output; - private $style; + private OutputInterface $output; + private TableStyle $style; private array $columnStyles = []; private array $columnWidths = []; private array $columnMaxWidths = []; private bool $rendered = false; + private string $displayOrientation = self::DISPLAY_ORIENTATION_DEFAULT; private static array $styles; @@ -177,7 +180,7 @@ class Table public function setHeaders(array $headers): static { $headers = array_values($headers); - if (!empty($headers) && !\is_array($headers[0])) { + if ($headers && !\is_array($headers[0])) { $headers = [$headers]; } @@ -186,6 +189,9 @@ class Table return $this; } + /** + * @return $this + */ public function setRows(array $rows) { $this->rows = []; @@ -277,7 +283,17 @@ class Table */ public function setHorizontal(bool $horizontal = true): static { - $this->horizontal = $horizontal; + $this->displayOrientation = $horizontal ? self::DISPLAY_ORIENTATION_HORIZONTAL : self::DISPLAY_ORIENTATION_DEFAULT; + + return $this; + } + + /** + * @return $this + */ + public function setVertical(bool $vertical = true): static + { + $this->displayOrientation = $vertical ? self::DISPLAY_ORIENTATION_VERTICAL : self::DISPLAY_ORIENTATION_DEFAULT; return $this; } @@ -298,8 +314,13 @@ class Table public function render() { $divider = new TableSeparator(); - if ($this->horizontal) { - $rows = []; + $isCellWithColspan = static fn ($cell) => $cell instanceof TableCell && $cell->getColspan() >= 2; + + $horizontal = self::DISPLAY_ORIENTATION_HORIZONTAL === $this->displayOrientation; + $vertical = self::DISPLAY_ORIENTATION_VERTICAL === $this->displayOrientation; + + $rows = []; + if ($horizontal) { foreach ($this->headers[0] ?? [] as $i => $header) { $rows[$i] = [$header]; foreach ($this->rows as $row) { @@ -308,54 +329,112 @@ class Table } if (isset($row[$i])) { $rows[$i][] = $row[$i]; - } elseif ($rows[$i][0] instanceof TableCell && $rows[$i][0]->getColspan() >= 2) { + } elseif ($isCellWithColspan($rows[$i][0])) { // Noop, there is a "title" } else { $rows[$i][] = null; } } } + } elseif ($vertical) { + $formatter = $this->output->getFormatter(); + $maxHeaderLength = array_reduce($this->headers[0] ?? [], static fn ($max, $header) => max($max, Helper::width(Helper::removeDecoration($formatter, $header))), 0); + + foreach ($this->rows as $row) { + if ($row instanceof TableSeparator) { + continue; + } + + if ($rows) { + $rows[] = [$divider]; + } + + $containsColspan = false; + foreach ($row as $cell) { + if ($containsColspan = $isCellWithColspan($cell)) { + break; + } + } + + $headers = $this->headers[0] ?? []; + $maxRows = max(\count($headers), \count($row)); + for ($i = 0; $i < $maxRows; ++$i) { + $cell = (string) ($row[$i] ?? ''); + if ($headers && !$containsColspan) { + $rows[] = [sprintf( + '%s: %s', + str_pad($headers[$i] ?? '', $maxHeaderLength, ' ', \STR_PAD_LEFT), + $cell + )]; + } elseif ('' !== $cell) { + $rows[] = [$cell]; + } + } + } } else { $rows = array_merge($this->headers, [$divider], $this->rows); } $this->calculateNumberOfColumns($rows); - $rows = $this->buildTableRows($rows); - $this->calculateColumnsWidth($rows); + $rowGroups = $this->buildTableRows($rows); + $this->calculateColumnsWidth($rowGroups); - $isHeader = !$this->horizontal; - $isFirstRow = $this->horizontal; + $isHeader = !$horizontal; + $isFirstRow = $horizontal; $hasTitle = (bool) $this->headerTitle; - foreach ($rows as $row) { - if ($divider === $row) { - $isHeader = false; - $isFirstRow = true; - continue; - } - if ($row instanceof TableSeparator) { - $this->renderRowSeparator(); + foreach ($rowGroups as $rowGroup) { + $isHeaderSeparatorRendered = false; - continue; - } - if (!$row) { - continue; - } + foreach ($rowGroup as $row) { + if ($divider === $row) { + $isHeader = false; + $isFirstRow = true; - if ($isHeader || $isFirstRow) { - $this->renderRowSeparator( - $isHeader ? self::SEPARATOR_TOP : self::SEPARATOR_TOP_BOTTOM, - $hasTitle ? $this->headerTitle : null, - $hasTitle ? $this->style->getHeaderTitleFormat() : null - ); - $isFirstRow = false; - $hasTitle = false; - } - if ($this->horizontal) { - $this->renderRow($row, $this->style->getCellRowFormat(), $this->style->getCellHeaderFormat()); - } else { - $this->renderRow($row, $isHeader ? $this->style->getCellHeaderFormat() : $this->style->getCellRowFormat()); + continue; + } + + if ($row instanceof TableSeparator) { + $this->renderRowSeparator(); + + continue; + } + + if (!$row) { + continue; + } + + if ($isHeader && !$isHeaderSeparatorRendered) { + $this->renderRowSeparator( + $isHeader ? self::SEPARATOR_TOP : self::SEPARATOR_TOP_BOTTOM, + $hasTitle ? $this->headerTitle : null, + $hasTitle ? $this->style->getHeaderTitleFormat() : null + ); + $hasTitle = false; + $isHeaderSeparatorRendered = true; + } + + if ($isFirstRow) { + $this->renderRowSeparator( + $isHeader ? self::SEPARATOR_TOP : self::SEPARATOR_TOP_BOTTOM, + $hasTitle ? $this->headerTitle : null, + $hasTitle ? $this->style->getHeaderTitleFormat() : null + ); + $isFirstRow = false; + $hasTitle = false; + } + + if ($vertical) { + $isHeader = false; + $isFirstRow = false; + } + + if ($horizontal) { + $this->renderRow($row, $this->style->getCellRowFormat(), $this->style->getCellHeaderFormat()); + } else { + $this->renderRow($row, $isHeader ? $this->style->getCellHeaderFormat() : $this->style->getCellRowFormat()); + } } } $this->renderRowSeparator(self::SEPARATOR_BOTTOM, $this->footerTitle, $this->style->getFooterTitleFormat()); @@ -373,7 +452,7 @@ class Table */ private function renderRowSeparator(int $type = self::SEPARATOR_MID, string $title = null, string $titleFormat = null) { - if (0 === $count = $this->numberOfColumns) { + if (!$count = $this->numberOfColumns) { return; } @@ -490,11 +569,11 @@ class Table $cellFormat = '<'.$tag.'>%s'; } - if (strstr($content, '')) { + if (str_contains($content, '')) { $content = str_replace('', '', $content); $width -= 3; } - if (strstr($content, '')) { + if (str_contains($content, '')) { $content = str_replace('', '', $content); $width -= \strlen(''); } @@ -538,12 +617,12 @@ class Table if (isset($this->columnMaxWidths[$column]) && Helper::width(Helper::removeDecoration($formatter, $cell)) > $this->columnMaxWidths[$column]) { $cell = $formatter->formatAndWrap($cell, $this->columnMaxWidths[$column] * $colspan); } - if (!strstr($cell ?? '', "\n")) { + if (!str_contains($cell ?? '', "\n")) { continue; } - $escaped = implode("\n", array_map([OutputFormatter::class, 'escapeTrailingBackslash'], explode("\n", $cell))); + $escaped = implode("\n", array_map(OutputFormatter::escapeTrailingBackslash(...), explode("\n", $cell))); $cell = $cell instanceof TableCell ? new TableCell($escaped, ['colspan' => $cell->getColspan()]) : $escaped; - $lines = explode("\n", str_replace("\n", "\n", $cell)); + $lines = explode("\n", str_replace("\n", "\n", $cell)); foreach ($lines as $lineKey => $line) { if ($colspan > 1) { $line = new TableCell($line, ['colspan' => $colspan]); @@ -562,13 +641,14 @@ class Table return new TableRows(function () use ($rows, $unmergedRows): \Traversable { foreach ($rows as $rowKey => $row) { - yield $row instanceof TableSeparator ? $row : $this->fillCells($row); + $rowGroup = [$row instanceof TableSeparator ? $row : $this->fillCells($row)]; if (isset($unmergedRows[$rowKey])) { foreach ($unmergedRows[$rowKey] as $row) { - yield $row instanceof TableSeparator ? $row : $this->fillCells($row); + $rowGroup[] = $row instanceof TableSeparator ? $row : $this->fillCells($row); } } + yield $rowGroup; } }); } @@ -581,7 +661,7 @@ class Table ++$numberOfRows; // Add row for header separator } - if (\count($this->rows) > 0) { + if ($this->rows) { ++$numberOfRows; // Add row for footer separator } @@ -597,13 +677,13 @@ class Table { $unmergedRows = []; foreach ($rows[$line] as $column => $cell) { - if (null !== $cell && !$cell instanceof TableCell && !is_scalar($cell) && !$cell instanceof \Stringable) { + if (null !== $cell && !$cell instanceof TableCell && !\is_scalar($cell) && !$cell instanceof \Stringable) { throw new InvalidArgumentException(sprintf('A cell must be a TableCell, a scalar or an object implementing "__toString()", "%s" given.', get_debug_type($cell))); } if ($cell instanceof TableCell && $cell->getRowspan() > 1) { $nbLines = $cell->getRowspan() - 1; $lines = [$cell]; - if (strstr($cell, "\n")) { + if (str_contains($cell, "\n")) { $lines = explode("\n", str_replace("\n", "\n", $cell)); $nbLines = \count($lines) > $nbLines ? substr_count($cell, "\n") : $nbLines; @@ -709,29 +789,31 @@ class Table /** * Calculates columns widths. */ - private function calculateColumnsWidth(iterable $rows) + private function calculateColumnsWidth(iterable $groups) { for ($column = 0; $column < $this->numberOfColumns; ++$column) { $lengths = []; - foreach ($rows as $row) { - if ($row instanceof TableSeparator) { - continue; - } + foreach ($groups as $group) { + foreach ($group as $row) { + if ($row instanceof TableSeparator) { + continue; + } - foreach ($row as $i => $cell) { - if ($cell instanceof TableCell) { - $textContent = Helper::removeDecoration($this->output->getFormatter(), $cell); - $textLength = Helper::width($textContent); - if ($textLength > 0) { - $contentColumns = str_split($textContent, ceil($textLength / $cell->getColspan())); - foreach ($contentColumns as $position => $content) { - $row[$i + $position] = $content; + foreach ($row as $i => $cell) { + if ($cell instanceof TableCell) { + $textContent = Helper::removeDecoration($this->output->getFormatter(), $cell); + $textLength = Helper::width($textContent); + if ($textLength > 0) { + $contentColumns = str_split($textContent, ceil($textLength / $cell->getColspan())); + foreach ($contentColumns as $position => $content) { + $row[$i + $position] = $content; + } } } } - } - $lengths[] = $this->getCellWidth($row, $column); + $lengths[] = $this->getCellWidth($row, $column); + } } $this->effectiveColumnWidths[$column] = max($lengths) + Helper::width($this->style->getCellRowContentFormat()) - 2; @@ -782,9 +864,9 @@ class Table $compact = new TableStyle(); $compact ->setHorizontalBorderChars('') - ->setVerticalBorderChars(' ') + ->setVerticalBorderChars('') ->setDefaultCrossingChar('') - ->setCellRowContentFormat('%s') + ->setCellRowContentFormat('%s ') ; $styleGuide = new TableStyle(); diff --git a/vendor/symfony/console/Input/ArgvInput.php b/vendor/symfony/console/Input/ArgvInput.php index 4e90c81..c0c28bb 100644 --- a/vendor/symfony/console/Input/ArgvInput.php +++ b/vendor/symfony/console/Input/ArgvInput.php @@ -45,7 +45,7 @@ class ArgvInput extends Input public function __construct(array $argv = null, InputDefinition $definition = null) { - $argv = $argv ?? $_SERVER['argv'] ?? []; + $argv ??= $_SERVER['argv'] ?? []; // strip the application name array_shift($argv); @@ -60,9 +60,6 @@ class ArgvInput extends Input $this->tokens = $tokens; } - /** - * {@inheritdoc} - */ protected function parse() { $parseOptions = true; @@ -263,9 +260,6 @@ class ArgvInput extends Input } } - /** - * {@inheritdoc} - */ public function getFirstArgument(): ?string { $isOption = false; @@ -298,9 +292,6 @@ class ArgvInput extends Input return null; } - /** - * {@inheritdoc} - */ public function hasParameterOption(string|array $values, bool $onlyParams = false): bool { $values = (array) $values; @@ -323,9 +314,6 @@ class ArgvInput extends Input return false; } - /** - * {@inheritdoc} - */ public function getParameterOption(string|array $values, string|bool|int|float|array|null $default = false, bool $onlyParams = false): mixed { $values = (array) $values; diff --git a/vendor/symfony/console/Input/ArrayInput.php b/vendor/symfony/console/Input/ArrayInput.php index fdb47df..02fb4e8 100644 --- a/vendor/symfony/console/Input/ArrayInput.php +++ b/vendor/symfony/console/Input/ArrayInput.php @@ -34,9 +34,6 @@ class ArrayInput extends Input parent::__construct($definition); } - /** - * {@inheritdoc} - */ public function getFirstArgument(): ?string { foreach ($this->parameters as $param => $value) { @@ -50,9 +47,6 @@ class ArrayInput extends Input return null; } - /** - * {@inheritdoc} - */ public function hasParameterOption(string|array $values, bool $onlyParams = false): bool { $values = (array) $values; @@ -74,9 +68,6 @@ class ArrayInput extends Input return false; } - /** - * {@inheritdoc} - */ public function getParameterOption(string|array $values, string|bool|int|float|array|null $default = false, bool $onlyParams = false): mixed { $values = (array) $values; @@ -115,16 +106,13 @@ class ArrayInput extends Input $params[] = $param.('' != $val ? $glue.$this->escapeToken($val) : ''); } } else { - $params[] = \is_array($val) ? implode(' ', array_map([$this, 'escapeToken'], $val)) : $this->escapeToken($val); + $params[] = \is_array($val) ? implode(' ', array_map($this->escapeToken(...), $val)) : $this->escapeToken($val); } } return implode(' ', $params); } - /** - * {@inheritdoc} - */ protected function parse() { foreach ($this->parameters as $key => $value) { diff --git a/vendor/symfony/console/Input/Input.php b/vendor/symfony/console/Input/Input.php index 1db503c..7b90713 100644 --- a/vendor/symfony/console/Input/Input.php +++ b/vendor/symfony/console/Input/Input.php @@ -43,9 +43,6 @@ abstract class Input implements InputInterface, StreamableInputInterface } } - /** - * {@inheritdoc} - */ public function bind(InputDefinition $definition) { $this->arguments = []; @@ -60,9 +57,6 @@ abstract class Input implements InputInterface, StreamableInputInterface */ abstract protected function parse(); - /** - * {@inheritdoc} - */ public function validate() { $definition = $this->definition; @@ -77,33 +71,21 @@ abstract class Input implements InputInterface, StreamableInputInterface } } - /** - * {@inheritdoc} - */ public function isInteractive(): bool { return $this->interactive; } - /** - * {@inheritdoc} - */ public function setInteractive(bool $interactive) { $this->interactive = $interactive; } - /** - * {@inheritdoc} - */ public function getArguments(): array { return array_merge($this->definition->getArgumentDefaults(), $this->arguments); } - /** - * {@inheritdoc} - */ public function getArgument(string $name): mixed { if (!$this->definition->hasArgument($name)) { @@ -113,9 +95,6 @@ abstract class Input implements InputInterface, StreamableInputInterface return $this->arguments[$name] ?? $this->definition->getArgument($name)->getDefault(); } - /** - * {@inheritdoc} - */ public function setArgument(string $name, mixed $value) { if (!$this->definition->hasArgument($name)) { @@ -125,25 +104,16 @@ abstract class Input implements InputInterface, StreamableInputInterface $this->arguments[$name] = $value; } - /** - * {@inheritdoc} - */ public function hasArgument(string $name): bool { return $this->definition->hasArgument($name); } - /** - * {@inheritdoc} - */ public function getOptions(): array { return array_merge($this->definition->getOptionDefaults(), $this->options); } - /** - * {@inheritdoc} - */ public function getOption(string $name): mixed { if ($this->definition->hasNegation($name)) { @@ -161,9 +131,6 @@ abstract class Input implements InputInterface, StreamableInputInterface return \array_key_exists($name, $this->options) ? $this->options[$name] : $this->definition->getOption($name)->getDefault(); } - /** - * {@inheritdoc} - */ public function setOption(string $name, mixed $value) { if ($this->definition->hasNegation($name)) { @@ -177,9 +144,6 @@ abstract class Input implements InputInterface, StreamableInputInterface $this->options[$name] = $value; } - /** - * {@inheritdoc} - */ public function hasOption(string $name): bool { return $this->definition->hasOption($name) || $this->definition->hasNegation($name); @@ -193,17 +157,11 @@ abstract class Input implements InputInterface, StreamableInputInterface return preg_match('{^[\w-]+$}', $token) ? $token : escapeshellarg($token); } - /** - * {@inheritdoc} - */ public function setStream($stream) { $this->stream = $stream; } - /** - * {@inheritdoc} - */ public function getStream() { return $this->stream; diff --git a/vendor/symfony/console/Input/InputArgument.php b/vendor/symfony/console/Input/InputArgument.php index 143e4b1..f086719 100644 --- a/vendor/symfony/console/Input/InputArgument.php +++ b/vendor/symfony/console/Input/InputArgument.php @@ -11,6 +11,10 @@ namespace Symfony\Component\Console\Input; +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Completion\CompletionInput; +use Symfony\Component\Console\Completion\CompletionSuggestions; +use Symfony\Component\Console\Completion\Suggestion; use Symfony\Component\Console\Exception\InvalidArgumentException; use Symfony\Component\Console\Exception\LogicException; @@ -28,6 +32,7 @@ class InputArgument private string $name; private int $mode; private string|int|bool|array|null|float $default; + private array|\Closure $suggestedValues; private string $description; /** @@ -35,10 +40,11 @@ class InputArgument * @param int|null $mode The argument mode: self::REQUIRED or self::OPTIONAL * @param string $description A description text * @param string|bool|int|float|array|null $default The default value (for self::OPTIONAL mode only) + * @param array|\Closure(CompletionInput,CompletionSuggestions):list $suggestedValues The values used for input completion * * @throws InvalidArgumentException When argument mode is not valid */ - public function __construct(string $name, int $mode = null, string $description = '', string|bool|int|float|array $default = null) + public function __construct(string $name, int $mode = null, string $description = '', string|bool|int|float|array $default = null, \Closure|array $suggestedValues = []) { if (null === $mode) { $mode = self::OPTIONAL; @@ -49,6 +55,7 @@ class InputArgument $this->name = $name; $this->mode = $mode; $this->description = $description; + $this->suggestedValues = $suggestedValues; $this->setDefault($default); } @@ -88,7 +95,10 @@ class InputArgument */ public function setDefault(string|bool|int|float|array $default = null) { - if (self::REQUIRED === $this->mode && null !== $default) { + if (1 > \func_num_args()) { + trigger_deprecation('symfony/console', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__); + } + if ($this->isRequired() && null !== $default) { throw new LogicException('Cannot set a default value except for InputArgument::OPTIONAL mode.'); } @@ -111,6 +121,27 @@ class InputArgument return $this->default; } + public function hasCompletion(): bool + { + return [] !== $this->suggestedValues; + } + + /** + * Adds suggestions to $suggestions for the current completion input. + * + * @see Command::complete() + */ + public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void + { + $values = $this->suggestedValues; + if ($values instanceof \Closure && !\is_array($values = $values($input))) { + throw new LogicException(sprintf('Closure for argument "%s" must return an array. Got "%s".', $this->name, get_debug_type($values))); + } + if ($values) { + $suggestions->suggestValues($values); + } + } + /** * Returns the description text. */ diff --git a/vendor/symfony/console/Input/InputDefinition.php b/vendor/symfony/console/Input/InputDefinition.php index cb270d8..f4b14a1 100644 --- a/vendor/symfony/console/Input/InputDefinition.php +++ b/vendor/symfony/console/Input/InputDefinition.php @@ -30,8 +30,8 @@ class InputDefinition { private array $arguments = []; private int $requiredCount = 0; - private $lastArrayArgument = null; - private $lastOptionalArgument = null; + private ?InputArgument $lastArrayArgument = null; + private ?InputArgument $lastOptionalArgument = null; private array $options = []; private array $negations = []; private array $shortcuts = []; diff --git a/vendor/symfony/console/Input/InputInterface.php b/vendor/symfony/console/Input/InputInterface.php index 024da18..3af991a 100644 --- a/vendor/symfony/console/Input/InputInterface.php +++ b/vendor/symfony/console/Input/InputInterface.php @@ -18,6 +18,9 @@ use Symfony\Component\Console\Exception\RuntimeException; * InputInterface is the interface implemented by all input classes. * * @author Fabien Potencier + * + * @method string __toString() Returns a stringified representation of the args passed to the command. + * InputArguments MUST be escaped as well as the InputOption values passed to the command. */ interface InputInterface { diff --git a/vendor/symfony/console/Input/InputOption.php b/vendor/symfony/console/Input/InputOption.php index f9d74a8..452c9f7 100644 --- a/vendor/symfony/console/Input/InputOption.php +++ b/vendor/symfony/console/Input/InputOption.php @@ -11,6 +11,10 @@ namespace Symfony\Component\Console\Input; +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Completion\CompletionInput; +use Symfony\Component\Console\Completion\CompletionSuggestions; +use Symfony\Component\Console\Completion\Suggestion; use Symfony\Component\Console\Exception\InvalidArgumentException; use Symfony\Component\Console\Exception\LogicException; @@ -50,16 +54,18 @@ class InputOption private string|array|null $shortcut; private int $mode; private string|int|bool|array|null|float $default; + private array|\Closure $suggestedValues; private string $description; /** * @param string|array|null $shortcut The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts * @param int|null $mode The option mode: One of the VALUE_* constants * @param string|bool|int|float|array|null $default The default value (must be null for self::VALUE_NONE) + * @param array|\Closure(CompletionInput,CompletionSuggestions):list $suggestedValues The values used for input completion * * @throws InvalidArgumentException If option mode is invalid or incompatible */ - public function __construct(string $name, string|array $shortcut = null, int $mode = null, string $description = '', string|bool|int|float|array $default = null) + public function __construct(string $name, string|array $shortcut = null, int $mode = null, string $description = '', string|bool|int|float|array $default = null, array|\Closure $suggestedValues = []) { if (str_starts_with($name, '--')) { $name = substr($name, 2); @@ -96,7 +102,11 @@ class InputOption $this->shortcut = $shortcut; $this->mode = $mode; $this->description = $description; + $this->suggestedValues = $suggestedValues; + if ($suggestedValues && !$this->acceptValue()) { + throw new LogicException('Cannot set suggested values if the option does not accept a value.'); + } if ($this->isArray() && !$this->acceptValue()) { throw new InvalidArgumentException('Impossible to have an option mode VALUE_IS_ARRAY if the option does not accept a value.'); } @@ -170,6 +180,9 @@ class InputOption public function setDefault(string|bool|int|float|array $default = null) { + if (1 > \func_num_args()) { + trigger_deprecation('symfony/console', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__); + } if (self::VALUE_NONE === (self::VALUE_NONE & $this->mode) && null !== $default) { throw new LogicException('Cannot set a default value when using InputOption::VALUE_NONE mode.'); } @@ -201,6 +214,27 @@ class InputOption return $this->description; } + public function hasCompletion(): bool + { + return [] !== $this->suggestedValues; + } + + /** + * Adds suggestions to $suggestions for the current completion input. + * + * @see Command::complete() + */ + public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void + { + $values = $this->suggestedValues; + if ($values instanceof \Closure && !\is_array($values = $values($input))) { + throw new LogicException(sprintf('Closure for option "%s" must return an array. Got "%s".', $this->name, get_debug_type($values))); + } + if ($values) { + $suggestions->suggestValues($values); + } + } + /** * Checks whether the given option equals this one. */ diff --git a/vendor/symfony/console/Input/StringInput.php b/vendor/symfony/console/Input/StringInput.php index 56bb66c..82bd214 100644 --- a/vendor/symfony/console/Input/StringInput.php +++ b/vendor/symfony/console/Input/StringInput.php @@ -24,6 +24,9 @@ use Symfony\Component\Console\Exception\InvalidArgumentException; */ class StringInput extends ArgvInput { + /** + * @deprecated since Symfony 6.1 + */ public const REGEX_STRING = '([^\s]+?)(?:\s|(? OutputInterface::VERBOSITY_NORMAL, LogLevel::ALERT => OutputInterface::VERBOSITY_NORMAL, @@ -59,9 +59,6 @@ class ConsoleLogger extends AbstractLogger $this->formatLevelMap = $formatLevelMap + $this->formatLevelMap; } - /** - * {@inheritdoc} - */ public function log($level, $message, array $context = []): void { if (!isset($this->verbosityLevelMap[$level])) { @@ -106,12 +103,12 @@ class ConsoleLogger extends AbstractLogger $replacements = []; foreach ($context as $key => $val) { - if (null === $val || is_scalar($val) || $val instanceof \Stringable) { + if (null === $val || \is_scalar($val) || $val instanceof \Stringable) { $replacements["{{$key}}"] = $val; } elseif ($val instanceof \DateTimeInterface) { - $replacements["{{$key}}"] = $val->format(\DateTime::RFC3339); + $replacements["{{$key}}"] = $val->format(\DateTimeInterface::RFC3339); } elseif (\is_object($val)) { - $replacements["{{$key}}"] = '[object '.\get_class($val).']'; + $replacements["{{$key}}"] = '[object '.$val::class.']'; } else { $replacements["{{$key}}"] = '['.\gettype($val).']'; } diff --git a/vendor/symfony/console/Output/AnsiColorMode.php b/vendor/symfony/console/Output/AnsiColorMode.php new file mode 100644 index 0000000..c6cc5c1 --- /dev/null +++ b/vendor/symfony/console/Output/AnsiColorMode.php @@ -0,0 +1,124 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Output; + +use Symfony\Component\Console\Exception\InvalidArgumentException; + +/** + * @author Fabien Potencier + * @author Julien Boudry + */ +enum AnsiColorMode +{ + /* + * Classical 4-bit Ansi colors, including 8 classical colors and 8 bright color. Output syntax is "ESC[${foreGroundColorcode};${backGroundColorcode}m" + * Must be compatible with all terminals and it's the minimal version supported. + */ + case Ansi4; + + /* + * 8-bit Ansi colors (240 differents colors + 16 duplicate color codes, ensuring backward compatibility). + * Output syntax is: "ESC[38;5;${foreGroundColorcode};48;5;${backGroundColorcode}m" + * Should be compatible with most terminals. + */ + case Ansi8; + + /* + * 24-bit Ansi colors (RGB). + * Output syntax is: "ESC[38;2;${foreGroundColorcodeRed};${foreGroundColorcodeGreen};${foreGroundColorcodeBlue};48;2;${backGroundColorcodeRed};${backGroundColorcodeGreen};${backGroundColorcodeBlue}m" + * May be compatible with many modern terminals. + */ + case Ansi24; + + /** + * Converts an RGB hexadecimal color to the corresponding Ansi code. + */ + public function convertFromHexToAnsiColorCode(string $hexColor): string + { + $hexColor = str_replace('#', '', $hexColor); + + if (3 === \strlen($hexColor)) { + $hexColor = $hexColor[0].$hexColor[0].$hexColor[1].$hexColor[1].$hexColor[2].$hexColor[2]; + } + + if (6 !== \strlen($hexColor)) { + throw new InvalidArgumentException(sprintf('Invalid "#%s" color.', $hexColor)); + } + + $color = hexdec($hexColor); + + $r = ($color >> 16) & 255; + $g = ($color >> 8) & 255; + $b = $color & 255; + + return match ($this) { + self::Ansi4 => (string) $this->convertFromRGB($r, $g, $b), + self::Ansi8 => '8;5;'.((string) $this->convertFromRGB($r, $g, $b)), + self::Ansi24 => sprintf('8;2;%d;%d;%d', $r, $g, $b) + }; + } + + private function convertFromRGB(int $r, int $g, int $b): int + { + return match ($this) { + self::Ansi4 => $this->degradeHexColorToAnsi4($r, $g, $b), + self::Ansi8 => $this->degradeHexColorToAnsi8($r, $g, $b), + default => throw new InvalidArgumentException("RGB cannot be converted to {$this->name}.") + }; + } + + private function degradeHexColorToAnsi4(int $r, int $g, int $b): int + { + if (0 === round($this->getSaturation($r, $g, $b) / 50)) { + return 0; + } + + return (int) ((round($b / 255) << 2) | (round($g / 255) << 1) | round($r / 255)); + } + + private function getSaturation(int $r, int $g, int $b): int + { + $r = $r / 255; + $g = $g / 255; + $b = $b / 255; + $v = max($r, $g, $b); + + if (0 === $diff = $v - min($r, $g, $b)) { + return 0; + } + + return (int) ((int) $diff * 100 / $v); + } + + /** + * Inspired from https://github.com/ajalt/colormath/blob/e464e0da1b014976736cf97250063248fc77b8e7/colormath/src/commonMain/kotlin/com/github/ajalt/colormath/model/Ansi256.kt code (MIT license). + */ + private function degradeHexColorToAnsi8(int $r, int $g, int $b): int + { + if ($r === $g && $g === $b) { + if ($r < 8) { + return 16; + } + + if ($r > 248) { + return 231; + } + + return (int) round(($r - 8) / 247 * 24) + 232; + } else { + return 16 + + (36 * (int) round($r / 255 * 5)) + + (6 * (int) round($g / 255 * 5)) + + (int) round($b / 255 * 5); + } + } +} diff --git a/vendor/symfony/console/Output/BufferedOutput.php b/vendor/symfony/console/Output/BufferedOutput.php index 784e309..94d4e41 100644 --- a/vendor/symfony/console/Output/BufferedOutput.php +++ b/vendor/symfony/console/Output/BufferedOutput.php @@ -29,9 +29,6 @@ class BufferedOutput extends Output return $content; } - /** - * {@inheritdoc} - */ protected function doWrite(string $message, bool $newline) { $this->buffer .= $message; diff --git a/vendor/symfony/console/Output/ConsoleOutput.php b/vendor/symfony/console/Output/ConsoleOutput.php index c6ba068..e3aa92c 100644 --- a/vendor/symfony/console/Output/ConsoleOutput.php +++ b/vendor/symfony/console/Output/ConsoleOutput.php @@ -29,7 +29,7 @@ use Symfony\Component\Console\Formatter\OutputFormatterInterface; */ class ConsoleOutput extends StreamOutput implements ConsoleOutputInterface { - private $stderr; + private OutputInterface $stderr; private array $consoleSectionOutputs = []; /** @@ -64,44 +64,29 @@ class ConsoleOutput extends StreamOutput implements ConsoleOutputInterface return new ConsoleSectionOutput($this->getStream(), $this->consoleSectionOutputs, $this->getVerbosity(), $this->isDecorated(), $this->getFormatter()); } - /** - * {@inheritdoc} - */ public function setDecorated(bool $decorated) { parent::setDecorated($decorated); $this->stderr->setDecorated($decorated); } - /** - * {@inheritdoc} - */ public function setFormatter(OutputFormatterInterface $formatter) { parent::setFormatter($formatter); $this->stderr->setFormatter($formatter); } - /** - * {@inheritdoc} - */ public function setVerbosity(int $level) { parent::setVerbosity($level); $this->stderr->setVerbosity($level); } - /** - * {@inheritdoc} - */ public function getErrorOutput(): OutputInterface { return $this->stderr; } - /** - * {@inheritdoc} - */ public function setErrorOutput(OutputInterface $error) { $this->stderr = $error; diff --git a/vendor/symfony/console/Output/ConsoleSectionOutput.php b/vendor/symfony/console/Output/ConsoleSectionOutput.php index 92dca79..7978a92 100644 --- a/vendor/symfony/console/Output/ConsoleSectionOutput.php +++ b/vendor/symfony/console/Output/ConsoleSectionOutput.php @@ -24,7 +24,8 @@ class ConsoleSectionOutput extends StreamOutput private array $content = []; private int $lines = 0; private array $sections; - private $terminal; + private Terminal $terminal; + private int $maxHeight = 0; /** * @param resource $stream @@ -38,6 +39,23 @@ class ConsoleSectionOutput extends StreamOutput $this->terminal = new Terminal(); } + /** + * Defines a maximum number of lines for this section. + * + * When more lines are added, the section will automatically scroll to the + * end (i.e. remove the first lines to comply with the max height). + */ + public function setMaxHeight(int $maxHeight): void + { + // when changing max height, clear output of current section and redraw again with the new height + $existingContent = $this->popStreamContentUntilCurrentSection($this->maxHeight ? min($this->maxHeight, $this->lines) : $this->lines); + + $this->maxHeight = $maxHeight; + + parent::doWrite($this->getVisibleContent(), false); + parent::doWrite($existingContent, false); + } + /** * Clears previous output for this section. * @@ -50,7 +68,7 @@ class ConsoleSectionOutput extends StreamOutput } if ($lines) { - array_splice($this->content, -($lines * 2)); // Multiply lines by 2 to cater for each new line added between content + array_splice($this->content, -$lines); } else { $lines = $this->lines; $this->content = []; @@ -58,7 +76,7 @@ class ConsoleSectionOutput extends StreamOutput $this->lines -= $lines; - parent::doWrite($this->popStreamContentUntilCurrentSection($lines), false); + parent::doWrite($this->popStreamContentUntilCurrentSection($this->maxHeight ? min($this->maxHeight, $lines) : $lines), false); } /** @@ -75,21 +93,62 @@ class ConsoleSectionOutput extends StreamOutput return implode('', $this->content); } - /** - * @internal - */ - public function addContent(string $input) + public function getVisibleContent(): string { - foreach (explode(\PHP_EOL, $input) as $lineContent) { - $this->lines += ceil($this->getDisplayLength($lineContent) / $this->terminal->getWidth()) ?: 1; - $this->content[] = $lineContent; - $this->content[] = \PHP_EOL; + if (0 === $this->maxHeight) { + return $this->getContent(); } + + return implode('', \array_slice($this->content, -$this->maxHeight)); } /** - * {@inheritdoc} + * @internal */ + public function addContent(string $input, bool $newline = true): int + { + $width = $this->terminal->getWidth(); + $lines = explode(\PHP_EOL, $input); + $linesAdded = 0; + $count = \count($lines) - 1; + foreach ($lines as $i => $lineContent) { + // re-add the line break (that has been removed in the above `explode()` for + // - every line that is not the last line + // - if $newline is required, also add it to the last line + if ($i < $count || $newline) { + $lineContent .= \PHP_EOL; + } + + // skip line if there is no text (or newline for that matter) + if ('' === $lineContent) { + continue; + } + + // For the first line, check if the previous line (last entry of `$this->content`) + // needs to be continued (i.e. does not end with a line break). + if (0 === $i + && (false !== $lastLine = end($this->content)) + && !str_ends_with($lastLine, \PHP_EOL) + ) { + // deduct the line count of the previous line + $this->lines -= (int) ceil($this->getDisplayLength($lastLine) / $width) ?: 1; + // concatenate previous and new line + $lineContent = $lastLine.$lineContent; + // replace last entry of `$this->content` with the new expanded line + array_splice($this->content, -1, 1, $lineContent); + } else { + // otherwise just add the new content + $this->content[] = $lineContent; + } + + $linesAdded += (int) ceil($this->getDisplayLength($lineContent) / $width) ?: 1; + } + + $this->lines += $linesAdded; + + return $linesAdded; + } + protected function doWrite(string $message, bool $newline) { if (!$this->isDecorated()) { @@ -98,11 +157,28 @@ class ConsoleSectionOutput extends StreamOutput return; } - $erasedContent = $this->popStreamContentUntilCurrentSection(); + // Check if the previous line (last entry of `$this->content`) needs to be continued + // (i.e. does not end with a line break). In which case, it needs to be erased first. + $linesToClear = $deleteLastLine = ($lastLine = end($this->content) ?: '') && !str_ends_with($lastLine, \PHP_EOL) ? 1 : 0; - $this->addContent($message); + $linesAdded = $this->addContent($message, $newline); - parent::doWrite($message, true); + if ($lineOverflow = $this->maxHeight > 0 && $this->lines > $this->maxHeight) { + // on overflow, clear the whole section and redraw again (to remove the first lines) + $linesToClear = $this->maxHeight; + } + + $erasedContent = $this->popStreamContentUntilCurrentSection($linesToClear); + + if ($lineOverflow) { + // redraw existing lines of the section + $previousLinesOfSection = \array_slice($this->content, $this->lines - $this->maxHeight, $this->maxHeight - $linesAdded); + parent::doWrite(implode('', $previousLinesOfSection), false); + } + + // if the last line was removed, re-print its content together with the new content. + // otherwise, just print the new content. + parent::doWrite($deleteLastLine ? $lastLine.$message : $message, true); parent::doWrite($erasedContent, false); } @@ -121,7 +197,12 @@ class ConsoleSectionOutput extends StreamOutput } $numberOfLinesToClear += $section->lines; - $erasedContent[] = $section->getContent(); + if ('' !== $sectionContent = $section->getVisibleContent()) { + if (!str_ends_with($sectionContent, \PHP_EOL)) { + $sectionContent .= \PHP_EOL; + } + $erasedContent[] = $sectionContent; + } } if ($numberOfLinesToClear > 0) { diff --git a/vendor/symfony/console/Output/NullOutput.php b/vendor/symfony/console/Output/NullOutput.php index 87214ec..4884cba 100644 --- a/vendor/symfony/console/Output/NullOutput.php +++ b/vendor/symfony/console/Output/NullOutput.php @@ -24,100 +24,64 @@ use Symfony\Component\Console\Formatter\OutputFormatterInterface; */ class NullOutput implements OutputInterface { - private $formatter; + private NullOutputFormatter $formatter; - /** - * {@inheritdoc} - */ public function setFormatter(OutputFormatterInterface $formatter) { // do nothing } - /** - * {@inheritdoc} - */ public function getFormatter(): OutputFormatterInterface { // to comply with the interface we must return a OutputFormatterInterface return $this->formatter ??= new NullOutputFormatter(); } - /** - * {@inheritdoc} - */ public function setDecorated(bool $decorated) { // do nothing } - /** - * {@inheritdoc} - */ public function isDecorated(): bool { return false; } - /** - * {@inheritdoc} - */ public function setVerbosity(int $level) { // do nothing } - /** - * {@inheritdoc} - */ public function getVerbosity(): int { return self::VERBOSITY_QUIET; } - /** - * {@inheritdoc} - */ public function isQuiet(): bool { return true; } - /** - * {@inheritdoc} - */ public function isVerbose(): bool { return false; } - /** - * {@inheritdoc} - */ public function isVeryVerbose(): bool { return false; } - /** - * {@inheritdoc} - */ public function isDebug(): bool { return false; } - /** - * {@inheritdoc} - */ public function writeln(string|iterable $messages, int $options = self::OUTPUT_NORMAL) { // do nothing } - /** - * {@inheritdoc} - */ public function write(string|iterable $messages, bool $newline = false, int $options = self::OUTPUT_NORMAL) { // do nothing diff --git a/vendor/symfony/console/Output/Output.php b/vendor/symfony/console/Output/Output.php index 58c1837..4cb71ac 100644 --- a/vendor/symfony/console/Output/Output.php +++ b/vendor/symfony/console/Output/Output.php @@ -30,7 +30,7 @@ use Symfony\Component\Console\Formatter\OutputFormatterInterface; abstract class Output implements OutputInterface { private int $verbosity; - private $formatter; + private OutputFormatterInterface $formatter; /** * @param int|null $verbosity The verbosity level (one of the VERBOSITY constants in OutputInterface) @@ -44,97 +44,61 @@ abstract class Output implements OutputInterface $this->formatter->setDecorated($decorated); } - /** - * {@inheritdoc} - */ public function setFormatter(OutputFormatterInterface $formatter) { $this->formatter = $formatter; } - /** - * {@inheritdoc} - */ public function getFormatter(): OutputFormatterInterface { return $this->formatter; } - /** - * {@inheritdoc} - */ public function setDecorated(bool $decorated) { $this->formatter->setDecorated($decorated); } - /** - * {@inheritdoc} - */ public function isDecorated(): bool { return $this->formatter->isDecorated(); } - /** - * {@inheritdoc} - */ public function setVerbosity(int $level) { $this->verbosity = $level; } - /** - * {@inheritdoc} - */ public function getVerbosity(): int { return $this->verbosity; } - /** - * {@inheritdoc} - */ public function isQuiet(): bool { return self::VERBOSITY_QUIET === $this->verbosity; } - /** - * {@inheritdoc} - */ public function isVerbose(): bool { return self::VERBOSITY_VERBOSE <= $this->verbosity; } - /** - * {@inheritdoc} - */ public function isVeryVerbose(): bool { return self::VERBOSITY_VERY_VERBOSE <= $this->verbosity; } - /** - * {@inheritdoc} - */ public function isDebug(): bool { return self::VERBOSITY_DEBUG <= $this->verbosity; } - /** - * {@inheritdoc} - */ public function writeln(string|iterable $messages, int $options = self::OUTPUT_NORMAL) { $this->write($messages, true, $options); } - /** - * {@inheritdoc} - */ public function write(string|iterable $messages, bool $newline = false, int $options = self::OUTPUT_NORMAL) { if (!is_iterable($messages)) { diff --git a/vendor/symfony/console/Output/OutputInterface.php b/vendor/symfony/console/Output/OutputInterface.php index beb9218..bc927c5 100644 --- a/vendor/symfony/console/Output/OutputInterface.php +++ b/vendor/symfony/console/Output/OutputInterface.php @@ -33,15 +33,17 @@ interface OutputInterface /** * Writes a message to the output. * - * @param $newline Whether to add a newline - * @param $options A bitmask of options (one of the OUTPUT or VERBOSITY constants), 0 is considered the same as self::OUTPUT_NORMAL | self::VERBOSITY_NORMAL + * @param bool $newline Whether to add a newline + * @param int $options A bitmask of options (one of the OUTPUT or VERBOSITY constants), + * 0 is considered the same as self::OUTPUT_NORMAL | self::VERBOSITY_NORMAL */ public function write(string|iterable $messages, bool $newline = false, int $options = 0); /** * Writes a message to the output and adds a newline at the end. * - * @param $options A bitmask of options (one of the OUTPUT or VERBOSITY constants), 0 is considered the same as self::OUTPUT_NORMAL | self::VERBOSITY_NORMAL + * @param int $options A bitmask of options (one of the OUTPUT or VERBOSITY constants), + * 0 is considered the same as self::OUTPUT_NORMAL | self::VERBOSITY_NORMAL */ public function writeln(string|iterable $messages, int $options = 0); diff --git a/vendor/symfony/console/Output/StreamOutput.php b/vendor/symfony/console/Output/StreamOutput.php index ac58e41..9ec524e 100644 --- a/vendor/symfony/console/Output/StreamOutput.php +++ b/vendor/symfony/console/Output/StreamOutput.php @@ -47,9 +47,7 @@ class StreamOutput extends Output $this->stream = $stream; - if (null === $decorated) { - $decorated = $this->hasColorSupport(); - } + $decorated ??= $this->hasColorSupport(); parent::__construct($verbosity, $decorated, $formatter); } @@ -64,9 +62,6 @@ class StreamOutput extends Output return $this->stream; } - /** - * {@inheritdoc} - */ protected function doWrite(string $message, bool $newline) { if ($newline) { diff --git a/vendor/symfony/console/Output/TrimmedBufferOutput.php b/vendor/symfony/console/Output/TrimmedBufferOutput.php index 0d375e0..1ca5a13 100644 --- a/vendor/symfony/console/Output/TrimmedBufferOutput.php +++ b/vendor/symfony/console/Output/TrimmedBufferOutput.php @@ -45,9 +45,6 @@ class TrimmedBufferOutput extends Output return $content; } - /** - * {@inheritdoc} - */ protected function doWrite(string $message, bool $newline) { $this->buffer .= $message; diff --git a/vendor/symfony/console/Question/Question.php b/vendor/symfony/console/Question/Question.php index f99e685..b06db94 100644 --- a/vendor/symfony/console/Question/Question.php +++ b/vendor/symfony/console/Question/Question.php @@ -152,7 +152,7 @@ class Question } elseif ($values instanceof \Traversable) { $valueCache = null; $callback = static function () use ($values, &$valueCache) { - return $valueCache ?? $valueCache = iterator_to_array($values, false); + return $valueCache ??= iterator_to_array($values, false); }; } else { $callback = null; @@ -178,11 +178,14 @@ class Question */ public function setAutocompleterCallback(callable $callback = null): static { + if (1 > \func_num_args()) { + trigger_deprecation('symfony/console', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__); + } if ($this->hidden && null !== $callback) { throw new LogicException('A hidden question cannot use the autocompleter.'); } - $this->autocompleterCallback = null === $callback || $callback instanceof \Closure ? $callback : \Closure::fromCallable($callback); + $this->autocompleterCallback = null === $callback ? null : $callback(...); return $this; } @@ -194,7 +197,10 @@ class Question */ public function setValidator(callable $validator = null): static { - $this->validator = null === $validator || $validator instanceof \Closure ? $validator : \Closure::fromCallable($validator); + if (1 > \func_num_args()) { + trigger_deprecation('symfony/console', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__); + } + $this->validator = null === $validator ? null : $validator(...); return $this; } @@ -246,7 +252,7 @@ class Question */ public function setNormalizer(callable $normalizer): static { - $this->normalizer = $normalizer instanceof \Closure ? $normalizer : \Closure::fromCallable($normalizer); + $this->normalizer = $normalizer(...); return $this; } diff --git a/vendor/symfony/console/README.md b/vendor/symfony/console/README.md index c4c1299..c89b4a1 100644 --- a/vendor/symfony/console/README.md +++ b/vendor/symfony/console/README.md @@ -4,18 +4,6 @@ Console Component The Console component eases the creation of beautiful and testable command line interfaces. -Sponsor -------- - -The Console component for Symfony 5.4/6.0 is [backed][1] by [Les-Tilleuls.coop][2]. - -Les-Tilleuls.coop is a team of 50+ Symfony experts who can help you design, develop and -fix your projects. We provide a wide range of professional services including development, -consulting, coaching, training and audits. We also are highly skilled in JS, Go and DevOps. -We are a worker cooperative! - -Help Symfony by [sponsoring][3] its development! - Resources --------- @@ -30,7 +18,3 @@ Credits `Resources/bin/hiddeninput.exe` is a third party binary provided within this component. Find sources and license at https://github.com/Seldaek/hidden-input. - -[1]: https://symfony.com/backers -[2]: https://les-tilleuls.coop -[3]: https://symfony.com/sponsor diff --git a/vendor/symfony/console/Resources/completion.bash b/vendor/symfony/console/Resources/completion.bash index c5e89c3..ad69eab 100644 --- a/vendor/symfony/console/Resources/completion.bash +++ b/vendor/symfony/console/Resources/completion.bash @@ -11,18 +11,21 @@ _sf_{{ COMMAND_NAME }}() { local sf_cmd="${COMP_WORDS[0]}" # for an alias, get the real script behind it - if [[ $(type -t $sf_cmd) == "alias" ]]; then + sf_cmd_type=$(type -t $sf_cmd) + if [[ $sf_cmd_type == "alias" ]]; then sf_cmd=$(alias $sf_cmd | sed -E "s/alias $sf_cmd='(.*)'/\1/") + elif [[ $sf_cmd_type == "file" ]]; then + sf_cmd=$(type -p $sf_cmd) fi - if [ ! -f "$sf_cmd" ]; then + if [[ $sf_cmd_type != "function" && ! -x $sf_cmd ]]; then return 1 fi local cur prev words cword _get_comp_words_by_ref -n := cur prev words cword - local completecmd=("$sf_cmd" "_complete" "-sbash" "-c$cword" "-S{{ VERSION }}") + local completecmd=("$sf_cmd" "_complete" "--no-interaction" "-sbash" "-c$cword" "-a{{ VERSION }}") for w in ${words[@]}; do w=$(printf -- '%b' "$w") # remove quotes from typed values diff --git a/vendor/symfony/console/Resources/completion.fish b/vendor/symfony/console/Resources/completion.fish new file mode 100644 index 0000000..1c34292 --- /dev/null +++ b/vendor/symfony/console/Resources/completion.fish @@ -0,0 +1,29 @@ +# This file is part of the Symfony package. +# +# (c) Fabien Potencier +# +# For the full copyright and license information, please view +# https://symfony.com/doc/current/contributing/code/license.html + +function _sf_{{ COMMAND_NAME }} + set sf_cmd (commandline -o) + set c (count (commandline -oc)) + + set completecmd "$sf_cmd[1]" "_complete" "--no-interaction" "-sfish" "-a{{ VERSION }}" + + for i in $sf_cmd + if [ $i != "" ] + set completecmd $completecmd "-i$i" + end + end + + set completecmd $completecmd "-c$c" + + set sfcomplete ($completecmd) + + for i in $sfcomplete + echo $i + end +end + +complete -c '{{ COMMAND_NAME }}' -a '(_sf_{{ COMMAND_NAME }})' -f diff --git a/vendor/symfony/console/Resources/completion.zsh b/vendor/symfony/console/Resources/completion.zsh new file mode 100644 index 0000000..97a9e88 --- /dev/null +++ b/vendor/symfony/console/Resources/completion.zsh @@ -0,0 +1,80 @@ +# This file is part of the Symfony package. +# +# (c) Fabien Potencier +# +# For the full copyright and license information, please view +# https://symfony.com/doc/current/contributing/code/license.html + +# +# zsh completions for {{ COMMAND_NAME }} +# +# References: +# - https://github.com/spf13/cobra/blob/master/zsh_completions.go +# - https://github.com/symfony/symfony/blob/5.4/src/Symfony/Component/Console/Resources/completion.bash +# +_sf_{{ COMMAND_NAME }}() { + local lastParam flagPrefix requestComp out comp + local -a completions + + # The user could have moved the cursor backwards on the command-line. + # We need to trigger completion from the $CURRENT location, so we need + # to truncate the command-line ($words) up to the $CURRENT location. + # (We cannot use $CURSOR as its value does not work when a command is an alias.) + words=("${=words[1,CURRENT]}") lastParam=${words[-1]} + + # For zsh, when completing a flag with an = (e.g., {{ COMMAND_NAME }} -n=) + # completions must be prefixed with the flag + setopt local_options BASH_REMATCH + if [[ "${lastParam}" =~ '-.*=' ]]; then + # We are dealing with a flag with an = + flagPrefix="-P ${BASH_REMATCH}" + fi + + # Prepare the command to obtain completions + requestComp="${words[0]} ${words[1]} _complete --no-interaction -szsh -a{{ VERSION }} -c$((CURRENT-1))" i="" + for w in ${words[@]}; do + w=$(printf -- '%b' "$w") + # remove quotes from typed values + quote="${w:0:1}" + if [ "$quote" = \' ]; then + w="${w%\'}" + w="${w#\'}" + elif [ "$quote" = \" ]; then + w="${w%\"}" + w="${w#\"}" + fi + # empty values are ignored + if [ ! -z "$w" ]; then + i="${i}-i${w} " + fi + done + + # Ensure at least 1 input + if [ "${i}" = "" ]; then + requestComp="${requestComp} -i\" \"" + else + requestComp="${requestComp} ${i}" + fi + + # Use eval to handle any environment variables and such + out=$(eval ${requestComp} 2>/dev/null) + + while IFS='\n' read -r comp; do + if [ -n "$comp" ]; then + # If requested, completions are returned with a description. + # The description is preceded by a TAB character. + # For zsh's _describe, we need to use a : instead of a TAB. + # We first need to escape any : as part of the completion itself. + comp=${comp//:/\\:} + local tab=$(printf '\t') + comp=${comp//$tab/:} + completions+=${comp} + fi + done < <(printf "%s\n" "${out[@]}") + + # Let inbuilt _describe handle completions + eval _describe "completions" completions $flagPrefix + return $? +} + +compdef _sf_{{ COMMAND_NAME }} {{ COMMAND_NAME }} diff --git a/vendor/symfony/console/SignalRegistry/SignalRegistry.php b/vendor/symfony/console/SignalRegistry/SignalRegistry.php index 15978fe..ef2e5f0 100644 --- a/vendor/symfony/console/SignalRegistry/SignalRegistry.php +++ b/vendor/symfony/console/SignalRegistry/SignalRegistry.php @@ -34,20 +34,12 @@ final class SignalRegistry $this->signalHandlers[$signal][] = $signalHandler; - pcntl_signal($signal, [$this, 'handle']); + pcntl_signal($signal, $this->handle(...)); } public static function isSupported(): bool { - if (!\function_exists('pcntl_signal')) { - return false; - } - - if (\in_array('pcntl_signal', explode(',', ini_get('disable_functions')))) { - return false; - } - - return true; + return \function_exists('pcntl_signal'); } /** diff --git a/vendor/symfony/console/Style/OutputStyle.php b/vendor/symfony/console/Style/OutputStyle.php index 0b2ded3..b694bb5 100644 --- a/vendor/symfony/console/Style/OutputStyle.php +++ b/vendor/symfony/console/Style/OutputStyle.php @@ -23,16 +23,13 @@ use Symfony\Component\Console\Output\OutputInterface; */ abstract class OutputStyle implements OutputInterface, StyleInterface { - private $output; + private OutputInterface $output; public function __construct(OutputInterface $output) { $this->output = $output; } - /** - * {@inheritdoc} - */ public function newLine(int $count = 1) { $this->output->write(str_repeat(\PHP_EOL, $count)); @@ -43,97 +40,61 @@ abstract class OutputStyle implements OutputInterface, StyleInterface return new ProgressBar($this->output, $max); } - /** - * {@inheritdoc} - */ public function write(string|iterable $messages, bool $newline = false, int $type = self::OUTPUT_NORMAL) { $this->output->write($messages, $newline, $type); } - /** - * {@inheritdoc} - */ public function writeln(string|iterable $messages, int $type = self::OUTPUT_NORMAL) { $this->output->writeln($messages, $type); } - /** - * {@inheritdoc} - */ public function setVerbosity(int $level) { $this->output->setVerbosity($level); } - /** - * {@inheritdoc} - */ public function getVerbosity(): int { return $this->output->getVerbosity(); } - /** - * {@inheritdoc} - */ public function setDecorated(bool $decorated) { $this->output->setDecorated($decorated); } - /** - * {@inheritdoc} - */ public function isDecorated(): bool { return $this->output->isDecorated(); } - /** - * {@inheritdoc} - */ public function setFormatter(OutputFormatterInterface $formatter) { $this->output->setFormatter($formatter); } - /** - * {@inheritdoc} - */ public function getFormatter(): OutputFormatterInterface { return $this->output->getFormatter(); } - /** - * {@inheritdoc} - */ public function isQuiet(): bool { return $this->output->isQuiet(); } - /** - * {@inheritdoc} - */ public function isVerbose(): bool { return $this->output->isVerbose(); } - /** - * {@inheritdoc} - */ public function isVeryVerbose(): bool { return $this->output->isVeryVerbose(); } - /** - * {@inheritdoc} - */ public function isDebug(): bool { return $this->output->isDebug(); diff --git a/vendor/symfony/console/Style/SymfonyStyle.php b/vendor/symfony/console/Style/SymfonyStyle.php index 56ad30a..997f862 100644 --- a/vendor/symfony/console/Style/SymfonyStyle.php +++ b/vendor/symfony/console/Style/SymfonyStyle.php @@ -15,6 +15,7 @@ use Symfony\Component\Console\Exception\InvalidArgumentException; use Symfony\Component\Console\Exception\RuntimeException; use Symfony\Component\Console\Formatter\OutputFormatter; use Symfony\Component\Console\Helper\Helper; +use Symfony\Component\Console\Helper\OutputWrapper; use Symfony\Component\Console\Helper\ProgressBar; use Symfony\Component\Console\Helper\SymfonyQuestionHelper; use Symfony\Component\Console\Helper\Table; @@ -38,12 +39,12 @@ class SymfonyStyle extends OutputStyle { public const MAX_LINE_LENGTH = 120; - private $input; - private $output; - private $questionHelper; - private $progressBar; + private InputInterface $input; + private OutputInterface $output; + private SymfonyQuestionHelper $questionHelper; + private ProgressBar $progressBar; private int $lineLength; - private $bufferedOutput; + private TrimmedBufferOutput $bufferedOutput; public function __construct(InputInterface $input, OutputInterface $output) { @@ -68,9 +69,6 @@ class SymfonyStyle extends OutputStyle $this->newLine(); } - /** - * {@inheritdoc} - */ public function title(string $message) { $this->autoPrependBlock(); @@ -81,9 +79,6 @@ class SymfonyStyle extends OutputStyle $this->newLine(); } - /** - * {@inheritdoc} - */ public function section(string $message) { $this->autoPrependBlock(); @@ -94,9 +89,6 @@ class SymfonyStyle extends OutputStyle $this->newLine(); } - /** - * {@inheritdoc} - */ public function listing(array $elements) { $this->autoPrependText(); @@ -108,9 +100,6 @@ class SymfonyStyle extends OutputStyle $this->newLine(); } - /** - * {@inheritdoc} - */ public function text(string|array $message) { $this->autoPrependText(); @@ -129,33 +118,21 @@ class SymfonyStyle extends OutputStyle $this->block($message, null, null, ' // ', false, false); } - /** - * {@inheritdoc} - */ public function success(string|array $message) { $this->block($message, 'OK', 'fg=black;bg=green', ' ', true); } - /** - * {@inheritdoc} - */ public function error(string|array $message) { $this->block($message, 'ERROR', 'fg=white;bg=red', ' ', true); } - /** - * {@inheritdoc} - */ public function warning(string|array $message) { $this->block($message, 'WARNING', 'fg=black;bg=yellow', ' ', true); } - /** - * {@inheritdoc} - */ public function note(string|array $message) { $this->block($message, 'NOTE', 'fg=yellow', ' ! '); @@ -169,17 +146,11 @@ class SymfonyStyle extends OutputStyle $this->block($message, 'INFO', 'fg=green', ' ', true); } - /** - * {@inheritdoc} - */ public function caution(string|array $message) { $this->block($message, 'CAUTION', 'fg=white;bg=red', ' ! ', true); } - /** - * {@inheritdoc} - */ public function table(array $headers, array $rows) { $this->createTable() @@ -239,9 +210,6 @@ class SymfonyStyle extends OutputStyle $this->horizontalTable($headers, [$row]); } - /** - * {@inheritdoc} - */ public function ask(string $question, string $default = null, callable $validator = null): mixed { $question = new Question($question, $default); @@ -250,9 +218,6 @@ class SymfonyStyle extends OutputStyle return $this->askQuestion($question); } - /** - * {@inheritdoc} - */ public function askHidden(string $question, callable $validator = null): mixed { $question = new Question($question); @@ -263,47 +228,35 @@ class SymfonyStyle extends OutputStyle return $this->askQuestion($question); } - /** - * {@inheritdoc} - */ public function confirm(string $question, bool $default = true): bool { return $this->askQuestion(new ConfirmationQuestion($question, $default)); } - /** - * {@inheritdoc} - */ - public function choice(string $question, array $choices, mixed $default = null): mixed + public function choice(string $question, array $choices, mixed $default = null, bool $multiSelect = false): mixed { if (null !== $default) { $values = array_flip($choices); $default = $values[$default] ?? $default; } - return $this->askQuestion(new ChoiceQuestion($question, $choices, $default)); + $questionChoice = new ChoiceQuestion($question, $choices, $default); + $questionChoice->setMultiselect($multiSelect); + + return $this->askQuestion($questionChoice); } - /** - * {@inheritdoc} - */ public function progressStart(int $max = 0) { $this->progressBar = $this->createProgressBar($max); $this->progressBar->start(); } - /** - * {@inheritdoc} - */ public function progressAdvance(int $step = 1) { $this->getProgressBar()->advance($step); } - /** - * {@inheritdoc} - */ public function progressFinish() { $this->getProgressBar()->finish(); @@ -311,9 +264,6 @@ class SymfonyStyle extends OutputStyle unset($this->progressBar); } - /** - * {@inheritdoc} - */ public function createProgressBar(int $max = 0): ProgressBar { $progressBar = parent::createProgressBar($max); @@ -355,9 +305,6 @@ class SymfonyStyle extends OutputStyle return $answer; } - /** - * {@inheritdoc} - */ public function writeln(string|iterable $messages, int $type = self::OUTPUT_NORMAL) { if (!is_iterable($messages)) { @@ -370,9 +317,6 @@ class SymfonyStyle extends OutputStyle } } - /** - * {@inheritdoc} - */ public function write(string|iterable $messages, bool $newline = false, int $type = self::OUTPUT_NORMAL) { if (!is_iterable($messages)) { @@ -385,9 +329,6 @@ class SymfonyStyle extends OutputStyle } } - /** - * {@inheritdoc} - */ public function newLine(int $count = 1) { parent::newLine($count); @@ -422,18 +363,18 @@ class SymfonyStyle extends OutputStyle $chars = substr(str_replace(\PHP_EOL, "\n", $this->bufferedOutput->fetch()), -2); if (!isset($chars[0])) { - $this->newLine(); //empty history, so we should start with a new line. + $this->newLine(); // empty history, so we should start with a new line. return; } - //Prepend new line for each non LF chars (This means no blank line was output before) + // Prepend new line for each non LF chars (This means no blank line was output before) $this->newLine(2 - substr_count($chars, "\n")); } private function autoPrependText(): void { $fetched = $this->bufferedOutput->fetch(); - //Prepend new line if last char isn't EOL: + // Prepend new line if last char isn't EOL: if (!str_ends_with($fetched, "\n")) { $this->newLine(); } @@ -453,22 +394,25 @@ class SymfonyStyle extends OutputStyle if (null !== $type) { $type = sprintf('[%s] ', $type); - $indentLength = \strlen($type); + $indentLength = Helper::width($type); $lineIndentation = str_repeat(' ', $indentLength); } // wrap and add newlines for each element + $outputWrapper = new OutputWrapper(); foreach ($messages as $key => $message) { if ($escape) { $message = OutputFormatter::escape($message); } - $decorationLength = Helper::width($message) - Helper::width(Helper::removeDecoration($this->getFormatter(), $message)); - $messageLineLength = min($this->lineLength - $prefixLength - $indentLength + $decorationLength, $this->lineLength); - $messageLines = explode(\PHP_EOL, wordwrap($message, $messageLineLength, \PHP_EOL, true)); - foreach ($messageLines as $messageLine) { - $lines[] = $messageLine; - } + $lines = array_merge( + $lines, + explode(\PHP_EOL, $outputWrapper->wrap( + $message, + $this->lineLength - $prefixLength - $indentLength, + \PHP_EOL + )) + ); if (\count($messages) > 1 && $key < \count($messages) - 1) { $lines[] = ''; diff --git a/vendor/symfony/console/Terminal.php b/vendor/symfony/console/Terminal.php index 80020c9..216c609 100644 --- a/vendor/symfony/console/Terminal.php +++ b/vendor/symfony/console/Terminal.php @@ -11,12 +11,75 @@ namespace Symfony\Component\Console; +use Symfony\Component\Console\Output\AnsiColorMode; + class Terminal { + public const DEFAULT_COLOR_MODE = AnsiColorMode::Ansi4; + + private static ?AnsiColorMode $colorMode = null; private static ?int $width = null; private static ?int $height = null; private static ?bool $stty = null; + /** + * About Ansi color types: https://en.wikipedia.org/wiki/ANSI_escape_code#Colors + * For more information about true color support with terminals https://github.com/termstandard/colors/. + */ + public static function getColorMode(): AnsiColorMode + { + // Use Cache from previous run (or user forced mode) + if (null !== self::$colorMode) { + return self::$colorMode; + } + + // Try with $COLORTERM first + if (\is_string($colorterm = getenv('COLORTERM'))) { + $colorterm = strtolower($colorterm); + + if (str_contains($colorterm, 'truecolor')) { + self::setColorMode(AnsiColorMode::Ansi24); + + return self::$colorMode; + } + + if (str_contains($colorterm, '256color')) { + self::setColorMode(AnsiColorMode::Ansi8); + + return self::$colorMode; + } + } + + // Try with $TERM + if (\is_string($term = getenv('TERM'))) { + $term = strtolower($term); + + if (str_contains($term, 'truecolor')) { + self::setColorMode(AnsiColorMode::Ansi24); + + return self::$colorMode; + } + + if (str_contains($term, '256color')) { + self::setColorMode(AnsiColorMode::Ansi8); + + return self::$colorMode; + } + } + + self::setColorMode(self::DEFAULT_COLOR_MODE); + + return self::$colorMode; + } + + /** + * Force a terminal color mode rendering. + */ + public static function setColorMode(?AnsiColorMode $colorMode): void + { + self::$colorMode = $colorMode; + } + /** * Gets the terminal width. */ @@ -106,11 +169,11 @@ class Terminal private static function initDimensionsUsingStty() { if ($sttyString = self::getSttyColumns()) { - if (preg_match('/rows.(\d+);.columns.(\d+);/i', $sttyString, $matches)) { + if (preg_match('/rows.(\d+);.columns.(\d+);/is', $sttyString, $matches)) { // extract [w, h] from "rows h; columns w;" self::$width = (int) $matches[2]; self::$height = (int) $matches[1]; - } elseif (preg_match('/;.(\d+).rows;.(\d+).columns/i', $sttyString, $matches)) { + } elseif (preg_match('/;.(\d+).rows;.(\d+).columns/is', $sttyString, $matches)) { // extract [w, h] from "; h rows; w columns" self::$width = (int) $matches[2]; self::$height = (int) $matches[1]; @@ -139,10 +202,10 @@ class Terminal */ private static function getSttyColumns(): ?string { - return self::readFromProcess('stty -a | grep columns'); + return self::readFromProcess(['stty', '-a']); } - private static function readFromProcess(string $command): ?string + private static function readFromProcess(string|array $command): ?string { if (!\function_exists('proc_open')) { return null; diff --git a/vendor/symfony/console/Tester/ApplicationTester.php b/vendor/symfony/console/Tester/ApplicationTester.php index 0404020..58aee54 100644 --- a/vendor/symfony/console/Tester/ApplicationTester.php +++ b/vendor/symfony/console/Tester/ApplicationTester.php @@ -28,7 +28,7 @@ class ApplicationTester { use TesterTrait; - private $application; + private Application $application; public function __construct(Application $application) { @@ -49,17 +49,37 @@ class ApplicationTester */ public function run(array $input, array $options = []): int { - $this->input = new ArrayInput($input); - if (isset($options['interactive'])) { - $this->input->setInteractive($options['interactive']); + $prevShellVerbosity = getenv('SHELL_VERBOSITY'); + + try { + $this->input = new ArrayInput($input); + if (isset($options['interactive'])) { + $this->input->setInteractive($options['interactive']); + } + + if ($this->inputs) { + $this->input->setStream(self::createStream($this->inputs)); + } + + $this->initOutput($options); + + return $this->statusCode = $this->application->run($this->input, $this->output); + } finally { + // SHELL_VERBOSITY is set by Application::configureIO so we need to unset/reset it + // to its previous value to avoid one test's verbosity to spread to the following tests + if (false === $prevShellVerbosity) { + if (\function_exists('putenv')) { + @putenv('SHELL_VERBOSITY'); + } + unset($_ENV['SHELL_VERBOSITY']); + unset($_SERVER['SHELL_VERBOSITY']); + } else { + if (\function_exists('putenv')) { + @putenv('SHELL_VERBOSITY='.$prevShellVerbosity); + } + $_ENV['SHELL_VERBOSITY'] = $prevShellVerbosity; + $_SERVER['SHELL_VERBOSITY'] = $prevShellVerbosity; + } } - - if ($this->inputs) { - $this->input->setStream(self::createStream($this->inputs)); - } - - $this->initOutput($options); - - return $this->statusCode = $this->application->run($this->input, $this->output); } } diff --git a/vendor/symfony/console/Tester/CommandTester.php b/vendor/symfony/console/Tester/CommandTester.php index f6ee4b7..2ff813b 100644 --- a/vendor/symfony/console/Tester/CommandTester.php +++ b/vendor/symfony/console/Tester/CommandTester.php @@ -24,7 +24,7 @@ class CommandTester { use TesterTrait; - private $command; + private Command $command; public function __construct(Command $command) { diff --git a/vendor/symfony/console/Tester/Constraint/CommandIsSuccessful.php b/vendor/symfony/console/Tester/Constraint/CommandIsSuccessful.php index a473242..09c6194 100644 --- a/vendor/symfony/console/Tester/Constraint/CommandIsSuccessful.php +++ b/vendor/symfony/console/Tester/Constraint/CommandIsSuccessful.php @@ -16,33 +16,21 @@ use Symfony\Component\Console\Command\Command; final class CommandIsSuccessful extends Constraint { - /** - * {@inheritdoc} - */ public function toString(): string { return 'is successful'; } - /** - * {@inheritdoc} - */ protected function matches($other): bool { return Command::SUCCESS === $other; } - /** - * {@inheritdoc} - */ protected function failureDescription($other): string { return 'the command '.$this->toString(); } - /** - * {@inheritdoc} - */ protected function additionalFailureDescription($other): string { $mapping = [ diff --git a/vendor/symfony/console/Tester/TesterTrait.php b/vendor/symfony/console/Tester/TesterTrait.php index b238f95..9670a49 100644 --- a/vendor/symfony/console/Tester/TesterTrait.php +++ b/vendor/symfony/console/Tester/TesterTrait.php @@ -23,10 +23,10 @@ use Symfony\Component\Console\Tester\Constraint\CommandIsSuccessful; */ trait TesterTrait { - private $output; + private StreamOutput $output; private array $inputs = []; private bool $captureStreamsIndependently = false; - private $input; + private InputInterface $input; private int $statusCode; /** @@ -152,12 +152,10 @@ trait TesterTrait $reflectedOutput = new \ReflectionObject($this->output); $strErrProperty = $reflectedOutput->getProperty('stderr'); - $strErrProperty->setAccessible(true); $strErrProperty->setValue($this->output, $errorOutput); $reflectedParent = $reflectedOutput->getParentClass(); $streamProperty = $reflectedParent->getProperty('stream'); - $streamProperty->setAccessible(true); $streamProperty->setValue($this->output, fopen('php://memory', 'w', false)); } } diff --git a/vendor/symfony/console/composer.json b/vendor/symfony/console/composer.json index 7d3947f..bafe5d1 100644 --- a/vendor/symfony/console/composer.json +++ b/vendor/symfony/console/composer.json @@ -16,7 +16,8 @@ } ], "require": { - "php": ">=8.0.2", + "php": ">=8.1", + "symfony/deprecation-contracts": "^2.1|^3", "symfony/polyfill-mbstring": "~1.0", "symfony/service-contracts": "^1.1|^2|^3", "symfony/string": "^5.4|^6.0" diff --git a/vendor/symfony/deprecation-contracts/CHANGELOG.md b/vendor/symfony/deprecation-contracts/CHANGELOG.md new file mode 100644 index 0000000..7932e26 --- /dev/null +++ b/vendor/symfony/deprecation-contracts/CHANGELOG.md @@ -0,0 +1,5 @@ +CHANGELOG +========= + +The changelog is maintained for all Symfony contracts at the following URL: +https://github.com/symfony/contracts/blob/main/CHANGELOG.md diff --git a/vendor/symfony/deprecation-contracts/LICENSE b/vendor/symfony/deprecation-contracts/LICENSE new file mode 100644 index 0000000..406242f --- /dev/null +++ b/vendor/symfony/deprecation-contracts/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2020-2022 Fabien Potencier + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/vendor/symfony/deprecation-contracts/README.md b/vendor/symfony/deprecation-contracts/README.md new file mode 100644 index 0000000..4957933 --- /dev/null +++ b/vendor/symfony/deprecation-contracts/README.md @@ -0,0 +1,26 @@ +Symfony Deprecation Contracts +============================= + +A generic function and convention to trigger deprecation notices. + +This package provides a single global function named `trigger_deprecation()` that triggers silenced deprecation notices. + +By using a custom PHP error handler such as the one provided by the Symfony ErrorHandler component, +the triggered deprecations can be caught and logged for later discovery, both on dev and prod environments. + +The function requires at least 3 arguments: + - the name of the Composer package that is triggering the deprecation + - the version of the package that introduced the deprecation + - the message of the deprecation + - more arguments can be provided: they will be inserted in the message using `printf()` formatting + +Example: +```php +trigger_deprecation('symfony/blockchain', '8.9', 'Using "%s" is deprecated, use "%s" instead.', 'bitcoin', 'fabcoin'); +``` + +This will generate the following message: +`Since symfony/blockchain 8.9: Using "bitcoin" is deprecated, use "fabcoin" instead.` + +While not necessarily recommended, the deprecation notices can be completely ignored by declaring an empty +`function trigger_deprecation() {}` in your application. diff --git a/vendor/symfony/deprecation-contracts/composer.json b/vendor/symfony/deprecation-contracts/composer.json new file mode 100644 index 0000000..774200f --- /dev/null +++ b/vendor/symfony/deprecation-contracts/composer.json @@ -0,0 +1,35 @@ +{ + "name": "symfony/deprecation-contracts", + "type": "library", + "description": "A generic function and convention to trigger deprecation notices", + "homepage": "https://symfony.com", + "license": "MIT", + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "require": { + "php": ">=8.1" + }, + "autoload": { + "files": [ + "function.php" + ] + }, + "minimum-stability": "dev", + "extra": { + "branch-alias": { + "dev-main": "3.3-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + } +} diff --git a/vendor/symfony/deprecation-contracts/function.php b/vendor/symfony/deprecation-contracts/function.php new file mode 100644 index 0000000..2d56512 --- /dev/null +++ b/vendor/symfony/deprecation-contracts/function.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +if (!function_exists('trigger_deprecation')) { + /** + * Triggers a silenced deprecation notice. + * + * @param string $package The name of the Composer package that is triggering the deprecation + * @param string $version The version of the package that introduced the deprecation + * @param string $message The message of the deprecation + * @param mixed ...$args Values to insert in the message using printf() formatting + * + * @author Nicolas Grekas + */ + function trigger_deprecation(string $package, string $version, string $message, mixed ...$args): void + { + @trigger_error(($package || $version ? "Since $package $version: " : '').($args ? vsprintf($message, $args) : $message), \E_USER_DEPRECATED); + } +} diff --git a/vendor/symfony/polyfill-ctype/README.md b/vendor/symfony/polyfill-ctype/README.md index 8add1ab..b144d03 100644 --- a/vendor/symfony/polyfill-ctype/README.md +++ b/vendor/symfony/polyfill-ctype/README.md @@ -4,7 +4,7 @@ Symfony Polyfill / Ctype This component provides `ctype_*` functions to users who run php versions without the ctype extension. More information can be found in the -[main Polyfill README](https://github.com/symfony/polyfill/blob/master/README.md). +[main Polyfill README](https://github.com/symfony/polyfill/blob/main/README.md). License ======= diff --git a/vendor/symfony/polyfill-ctype/composer.json b/vendor/symfony/polyfill-ctype/composer.json index ccb8e57..1b3efff 100644 --- a/vendor/symfony/polyfill-ctype/composer.json +++ b/vendor/symfony/polyfill-ctype/composer.json @@ -31,7 +31,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-main": "1.23-dev" + "dev-main": "1.27-dev" }, "thanks": { "name": "symfony/polyfill", diff --git a/vendor/symfony/polyfill-intl-grapheme/Grapheme.php b/vendor/symfony/polyfill-intl-grapheme/Grapheme.php index 6f7c0c7..5373f16 100644 --- a/vendor/symfony/polyfill-intl-grapheme/Grapheme.php +++ b/vendor/symfony/polyfill-intl-grapheme/Grapheme.php @@ -48,7 +48,7 @@ final class Grapheme $start = \strlen($s) + $start; } - if (!is_scalar($s)) { + if (!\is_scalar($s)) { $hasError = false; set_error_handler(function () use (&$hasError) { $hasError = true; }); $next = substr($s, $start); diff --git a/vendor/symfony/polyfill-intl-grapheme/README.md b/vendor/symfony/polyfill-intl-grapheme/README.md index 77523ea..f55d92c 100644 --- a/vendor/symfony/polyfill-intl-grapheme/README.md +++ b/vendor/symfony/polyfill-intl-grapheme/README.md @@ -23,7 +23,7 @@ This component provides a partial, native PHP implementation of the - [`grapheme_substr`](https://php.net/grapheme_substr): Return part of a string More information can be found in the -[main Polyfill README](https://github.com/symfony/polyfill/blob/master/README.md). +[main Polyfill README](https://github.com/symfony/polyfill/blob/main/README.md). License ======= diff --git a/vendor/symfony/polyfill-intl-grapheme/composer.json b/vendor/symfony/polyfill-intl-grapheme/composer.json index 02c98ee..fde5537 100644 --- a/vendor/symfony/polyfill-intl-grapheme/composer.json +++ b/vendor/symfony/polyfill-intl-grapheme/composer.json @@ -28,7 +28,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-main": "1.23-dev" + "dev-main": "1.27-dev" }, "thanks": { "name": "symfony/polyfill", diff --git a/vendor/symfony/polyfill-intl-normalizer/Normalizer.php b/vendor/symfony/polyfill-intl-normalizer/Normalizer.php index 4443c23..81704ab 100644 --- a/vendor/symfony/polyfill-intl-normalizer/Normalizer.php +++ b/vendor/symfony/polyfill-intl-normalizer/Normalizer.php @@ -90,7 +90,7 @@ class Normalizer self::$cC = self::getData('combiningClass'); } - if (null !== $mbEncoding = (2 /* MB_OVERLOAD_STRING */ & (int) ini_get('mbstring.func_overload')) ? mb_internal_encoding() : null) { + if (null !== $mbEncoding = (2 /* MB_OVERLOAD_STRING */ & (int) \ini_get('mbstring.func_overload')) ? mb_internal_encoding() : null) { mb_internal_encoding('8bit'); } diff --git a/vendor/symfony/polyfill-intl-normalizer/README.md b/vendor/symfony/polyfill-intl-normalizer/README.md index 15060c5..b9b762e 100644 --- a/vendor/symfony/polyfill-intl-normalizer/README.md +++ b/vendor/symfony/polyfill-intl-normalizer/README.md @@ -6,7 +6,7 @@ This component provides a fallback implementation for the by the [Intl](https://php.net/intl) extension. More information can be found in the -[main Polyfill README](https://github.com/symfony/polyfill/blob/master/README.md). +[main Polyfill README](https://github.com/symfony/polyfill/blob/main/README.md). License ======= diff --git a/vendor/symfony/polyfill-intl-normalizer/composer.json b/vendor/symfony/polyfill-intl-normalizer/composer.json index 393edf7..65f72d6 100644 --- a/vendor/symfony/polyfill-intl-normalizer/composer.json +++ b/vendor/symfony/polyfill-intl-normalizer/composer.json @@ -29,7 +29,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-main": "1.23-dev" + "dev-main": "1.27-dev" }, "thanks": { "name": "symfony/polyfill", diff --git a/vendor/symfony/polyfill-mbstring/Mbstring.php b/vendor/symfony/polyfill-mbstring/Mbstring.php index b65c54a..bce5c4a 100644 --- a/vendor/symfony/polyfill-mbstring/Mbstring.php +++ b/vendor/symfony/polyfill-mbstring/Mbstring.php @@ -80,7 +80,7 @@ final class Mbstring public static function mb_convert_encoding($s, $toEncoding, $fromEncoding = null) { - if (\is_array($fromEncoding) || ($fromEncoding !== null && false !== strpos($fromEncoding, ','))) { + if (\is_array($fromEncoding) || (null !== $fromEncoding && false !== strpos($fromEncoding, ','))) { $fromEncoding = self::mb_detect_encoding($s, $fromEncoding); } else { $fromEncoding = self::getEncoding($fromEncoding); @@ -102,7 +102,7 @@ final class Mbstring $fromEncoding = 'Windows-1252'; } if ('UTF-8' !== $fromEncoding) { - $s = \iconv($fromEncoding, 'UTF-8//IGNORE', $s); + $s = iconv($fromEncoding, 'UTF-8//IGNORE', $s); } return preg_replace_callback('/[\x80-\xFF]+/', [__CLASS__, 'html_encoding_callback'], $s); @@ -113,7 +113,7 @@ final class Mbstring $fromEncoding = 'UTF-8'; } - return \iconv($fromEncoding, $toEncoding.'//IGNORE', $s); + return iconv($fromEncoding, $toEncoding.'//IGNORE', $s); } public static function mb_convert_variables($toEncoding, $fromEncoding, &...$vars) @@ -130,7 +130,7 @@ final class Mbstring public static function mb_decode_mimeheader($s) { - return \iconv_mime_decode($s, 2, self::$internalEncoding); + return iconv_mime_decode($s, 2, self::$internalEncoding); } public static function mb_encode_mimeheader($s, $charset = null, $transferEncoding = null, $linefeed = null, $indent = null) @@ -140,7 +140,7 @@ final class Mbstring public static function mb_decode_numericentity($s, $convmap, $encoding = null) { - if (null !== $s && !is_scalar($s) && !(\is_object($s) && method_exists($s, '__toString'))) { + if (null !== $s && !\is_scalar($s) && !(\is_object($s) && method_exists($s, '__toString'))) { trigger_error('mb_decode_numericentity() expects parameter 1 to be string, '.\gettype($s).' given', \E_USER_WARNING); return null; @@ -150,7 +150,7 @@ final class Mbstring return false; } - if (null !== $encoding && !is_scalar($encoding)) { + if (null !== $encoding && !\is_scalar($encoding)) { trigger_error('mb_decode_numericentity() expects parameter 3 to be string, '.\gettype($s).' given', \E_USER_WARNING); return ''; // Instead of null (cf. mb_encode_numericentity). @@ -166,10 +166,10 @@ final class Mbstring if ('UTF-8' === $encoding) { $encoding = null; if (!preg_match('//u', $s)) { - $s = @\iconv('UTF-8', 'UTF-8//IGNORE', $s); + $s = @iconv('UTF-8', 'UTF-8//IGNORE', $s); } } else { - $s = \iconv($encoding, 'UTF-8//IGNORE', $s); + $s = iconv($encoding, 'UTF-8//IGNORE', $s); } $cnt = floor(\count($convmap) / 4) * 4; @@ -195,12 +195,12 @@ final class Mbstring return $s; } - return \iconv('UTF-8', $encoding.'//IGNORE', $s); + return iconv('UTF-8', $encoding.'//IGNORE', $s); } public static function mb_encode_numericentity($s, $convmap, $encoding = null, $is_hex = false) { - if (null !== $s && !is_scalar($s) && !(\is_object($s) && method_exists($s, '__toString'))) { + if (null !== $s && !\is_scalar($s) && !(\is_object($s) && method_exists($s, '__toString'))) { trigger_error('mb_encode_numericentity() expects parameter 1 to be string, '.\gettype($s).' given', \E_USER_WARNING); return null; @@ -210,13 +210,13 @@ final class Mbstring return false; } - if (null !== $encoding && !is_scalar($encoding)) { + if (null !== $encoding && !\is_scalar($encoding)) { trigger_error('mb_encode_numericentity() expects parameter 3 to be string, '.\gettype($s).' given', \E_USER_WARNING); return null; // Instead of '' (cf. mb_decode_numericentity). } - if (null !== $is_hex && !is_scalar($is_hex)) { + if (null !== $is_hex && !\is_scalar($is_hex)) { trigger_error('mb_encode_numericentity() expects parameter 4 to be boolean, '.\gettype($s).' given', \E_USER_WARNING); return null; @@ -232,10 +232,10 @@ final class Mbstring if ('UTF-8' === $encoding) { $encoding = null; if (!preg_match('//u', $s)) { - $s = @\iconv('UTF-8', 'UTF-8//IGNORE', $s); + $s = @iconv('UTF-8', 'UTF-8//IGNORE', $s); } } else { - $s = \iconv($encoding, 'UTF-8//IGNORE', $s); + $s = iconv($encoding, 'UTF-8//IGNORE', $s); } static $ulenMask = ["\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4]; @@ -265,7 +265,7 @@ final class Mbstring return $result; } - return \iconv('UTF-8', $encoding.'//IGNORE', $result); + return iconv('UTF-8', $encoding.'//IGNORE', $result); } public static function mb_convert_case($s, $mode, $encoding = null) @@ -280,10 +280,10 @@ final class Mbstring if ('UTF-8' === $encoding) { $encoding = null; if (!preg_match('//u', $s)) { - $s = @\iconv('UTF-8', 'UTF-8//IGNORE', $s); + $s = @iconv('UTF-8', 'UTF-8//IGNORE', $s); } } else { - $s = \iconv($encoding, 'UTF-8//IGNORE', $s); + $s = iconv($encoding, 'UTF-8//IGNORE', $s); } if (\MB_CASE_TITLE == $mode) { @@ -343,7 +343,7 @@ final class Mbstring return $s; } - return \iconv('UTF-8', $encoding.'//IGNORE', $s); + return iconv('UTF-8', $encoding.'//IGNORE', $s); } public static function mb_internal_encoding($encoding = null) @@ -354,7 +354,7 @@ final class Mbstring $normalizedEncoding = self::getEncoding($encoding); - if ('UTF-8' === $normalizedEncoding || false !== @\iconv($normalizedEncoding, $normalizedEncoding, ' ')) { + if ('UTF-8' === $normalizedEncoding || false !== @iconv($normalizedEncoding, $normalizedEncoding, ' ')) { self::$internalEncoding = $normalizedEncoding; return true; @@ -413,7 +413,7 @@ final class Mbstring $encoding = self::$internalEncoding; } - return self::mb_detect_encoding($var, [$encoding]) || false !== @\iconv($encoding, $encoding, $var); + return self::mb_detect_encoding($var, [$encoding]) || false !== @iconv($encoding, $encoding, $var); } public static function mb_detect_encoding($str, $encodingList = null, $strict = false) @@ -488,7 +488,7 @@ final class Mbstring return \strlen($s); } - return @\iconv_strlen($s, $encoding); + return @iconv_strlen($s, $encoding); } public static function mb_strpos($haystack, $needle, $offset = 0, $encoding = null) @@ -509,7 +509,7 @@ final class Mbstring return 0; } - return \iconv_strpos($haystack, $needle, $offset, $encoding); + return iconv_strpos($haystack, $needle, $offset, $encoding); } public static function mb_strrpos($haystack, $needle, $offset = 0, $encoding = null) @@ -533,7 +533,7 @@ final class Mbstring } $pos = '' !== $needle || 80000 > \PHP_VERSION_ID - ? \iconv_strrpos($haystack, $needle, $encoding) + ? iconv_strrpos($haystack, $needle, $encoding) : self::mb_strlen($haystack, $encoding); return false !== $pos ? $offset + $pos : false; @@ -541,7 +541,7 @@ final class Mbstring public static function mb_str_split($string, $split_length = 1, $encoding = null) { - if (null !== $string && !is_scalar($string) && !(\is_object($string) && method_exists($string, '__toString'))) { + if (null !== $string && !\is_scalar($string) && !(\is_object($string) && method_exists($string, '__toString'))) { trigger_error('mb_str_split() expects parameter 1 to be string, '.\gettype($string).' given', \E_USER_WARNING); return null; @@ -550,6 +550,7 @@ final class Mbstring if (1 > $split_length = (int) $split_length) { if (80000 > \PHP_VERSION_ID) { trigger_error('The length of each segment must be greater than zero', \E_USER_WARNING); + return false; } @@ -568,7 +569,7 @@ final class Mbstring } $rx .= '.{'.$split_length.'})/us'; - return preg_split($rx, $string, null, \PREG_SPLIT_DELIM_CAPTURE | \PREG_SPLIT_NO_EMPTY); + return preg_split($rx, $string, -1, \PREG_SPLIT_DELIM_CAPTURE | \PREG_SPLIT_NO_EMPTY); } $result = []; @@ -617,7 +618,7 @@ final class Mbstring } if ($start < 0) { - $start = \iconv_strlen($s, $encoding) + $start; + $start = iconv_strlen($s, $encoding) + $start; if ($start < 0) { $start = 0; } @@ -626,13 +627,13 @@ final class Mbstring if (null === $length) { $length = 2147483647; } elseif ($length < 0) { - $length = \iconv_strlen($s, $encoding) + $length - $start; + $length = iconv_strlen($s, $encoding) + $length - $start; if ($length < 0) { return ''; } } - return (string) \iconv_substr($s, $start, $length, $encoding); + return (string) iconv_substr($s, $start, $length, $encoding); } public static function mb_stripos($haystack, $needle, $offset = 0, $encoding = null) @@ -657,7 +658,7 @@ final class Mbstring $pos = strrpos($haystack, $needle); } else { $needle = self::mb_substr($needle, 0, 1, $encoding); - $pos = \iconv_strrpos($haystack, $needle, $encoding); + $pos = iconv_strrpos($haystack, $needle, $encoding); } return self::getSubpart($pos, $part, $haystack, $encoding); @@ -736,12 +737,12 @@ final class Mbstring $encoding = self::getEncoding($encoding); if ('UTF-8' !== $encoding) { - $s = \iconv($encoding, 'UTF-8//IGNORE', $s); + $s = iconv($encoding, 'UTF-8//IGNORE', $s); } $s = preg_replace('/[\x{1100}-\x{115F}\x{2329}\x{232A}\x{2E80}-\x{303E}\x{3040}-\x{A4CF}\x{AC00}-\x{D7A3}\x{F900}-\x{FAFF}\x{FE10}-\x{FE19}\x{FE30}-\x{FE6F}\x{FF00}-\x{FF60}\x{FFE0}-\x{FFE6}\x{20000}-\x{2FFFD}\x{30000}-\x{3FFFD}]/u', '', $s, -1, $wide); - return ($wide << 1) + \iconv_strlen($s, 'UTF-8'); + return ($wide << 1) + iconv_strlen($s, 'UTF-8'); } public static function mb_substr_count($haystack, $needle, $encoding = null) diff --git a/vendor/symfony/polyfill-mbstring/README.md b/vendor/symfony/polyfill-mbstring/README.md index 4efb599..478b40d 100644 --- a/vendor/symfony/polyfill-mbstring/README.md +++ b/vendor/symfony/polyfill-mbstring/README.md @@ -5,7 +5,7 @@ This component provides a partial, native PHP implementation for the [Mbstring](https://php.net/mbstring) extension. More information can be found in the -[main Polyfill README](https://github.com/symfony/polyfill/blob/master/README.md). +[main Polyfill README](https://github.com/symfony/polyfill/blob/main/README.md). License ======= diff --git a/vendor/symfony/polyfill-mbstring/composer.json b/vendor/symfony/polyfill-mbstring/composer.json index 1fa21ca..4489553 100644 --- a/vendor/symfony/polyfill-mbstring/composer.json +++ b/vendor/symfony/polyfill-mbstring/composer.json @@ -31,7 +31,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-main": "1.23-dev" + "dev-main": "1.27-dev" }, "thanks": { "name": "symfony/polyfill", diff --git a/vendor/symfony/polyfill-php80/README.md b/vendor/symfony/polyfill-php80/README.md index 10b8ee4..3816c55 100644 --- a/vendor/symfony/polyfill-php80/README.md +++ b/vendor/symfony/polyfill-php80/README.md @@ -3,12 +3,13 @@ Symfony Polyfill / Php80 This component provides features added to PHP 8.0 core: -- `Stringable` interface +- [`Stringable`](https://php.net/stringable) interface - [`fdiv`](https://php.net/fdiv) -- `ValueError` class -- `UnhandledMatchError` class +- [`ValueError`](https://php.net/valueerror) class +- [`UnhandledMatchError`](https://php.net/unhandledmatcherror) class - `FILTER_VALIDATE_BOOL` constant - [`get_debug_type`](https://php.net/get_debug_type) +- [`PhpToken`](https://php.net/phptoken) class - [`preg_last_error_msg`](https://php.net/preg_last_error_msg) - [`str_contains`](https://php.net/str_contains) - [`str_starts_with`](https://php.net/str_starts_with) diff --git a/vendor/symfony/polyfill-php80/Resources/stubs/Attribute.php b/vendor/symfony/polyfill-php80/Resources/stubs/Attribute.php index 7ea6d27..2b95542 100644 --- a/vendor/symfony/polyfill-php80/Resources/stubs/Attribute.php +++ b/vendor/symfony/polyfill-php80/Resources/stubs/Attribute.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + #[Attribute(Attribute::TARGET_CLASS)] final class Attribute { diff --git a/vendor/symfony/polyfill-php80/Resources/stubs/PhpToken.php b/vendor/symfony/polyfill-php80/Resources/stubs/PhpToken.php index 72f1081..bd1212f 100644 --- a/vendor/symfony/polyfill-php80/Resources/stubs/PhpToken.php +++ b/vendor/symfony/polyfill-php80/Resources/stubs/PhpToken.php @@ -1,6 +1,15 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +if (\PHP_VERSION_ID < 80000 && extension_loaded('tokenizer')) { class PhpToken extends Symfony\Polyfill\Php80\PhpToken { } diff --git a/vendor/symfony/polyfill-php80/Resources/stubs/Stringable.php b/vendor/symfony/polyfill-php80/Resources/stubs/Stringable.php index 77e037c..7c62d75 100644 --- a/vendor/symfony/polyfill-php80/Resources/stubs/Stringable.php +++ b/vendor/symfony/polyfill-php80/Resources/stubs/Stringable.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + if (\PHP_VERSION_ID < 80000) { interface Stringable { diff --git a/vendor/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.php b/vendor/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.php index 37937cb..01c6c6c 100644 --- a/vendor/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.php +++ b/vendor/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + if (\PHP_VERSION_ID < 80000) { class UnhandledMatchError extends Error { diff --git a/vendor/symfony/polyfill-php80/Resources/stubs/ValueError.php b/vendor/symfony/polyfill-php80/Resources/stubs/ValueError.php index a3a9b88..783dbc2 100644 --- a/vendor/symfony/polyfill-php80/Resources/stubs/ValueError.php +++ b/vendor/symfony/polyfill-php80/Resources/stubs/ValueError.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + if (\PHP_VERSION_ID < 80000) { class ValueError extends Error { diff --git a/vendor/symfony/polyfill-php80/composer.json b/vendor/symfony/polyfill-php80/composer.json index 5fe679d..bd9a326 100644 --- a/vendor/symfony/polyfill-php80/composer.json +++ b/vendor/symfony/polyfill-php80/composer.json @@ -30,7 +30,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-main": "1.23-dev" + "dev-main": "1.27-dev" }, "thanks": { "name": "symfony/polyfill", diff --git a/vendor/symfony/service-contracts/.gitignore b/vendor/symfony/service-contracts/.gitignore deleted file mode 100644 index c49a5d8..0000000 --- a/vendor/symfony/service-contracts/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -vendor/ -composer.lock -phpunit.xml diff --git a/vendor/symfony/service-contracts/Attribute/SubscribedService.php b/vendor/symfony/service-contracts/Attribute/SubscribedService.php index 10d1bc3..d98e1df 100644 --- a/vendor/symfony/service-contracts/Attribute/SubscribedService.php +++ b/vendor/symfony/service-contracts/Attribute/SubscribedService.php @@ -11,9 +11,14 @@ namespace Symfony\Contracts\Service\Attribute; +use Symfony\Contracts\Service\ServiceSubscriberInterface; use Symfony\Contracts\Service\ServiceSubscriberTrait; /** + * For use as the return value for {@see ServiceSubscriberInterface}. + * + * @example new SubscribedService('http_client', HttpClientInterface::class, false, new Target('githubApi')) + * * Use with {@see ServiceSubscriberTrait} to mark a method's return type * as a subscribed service. * @@ -22,12 +27,21 @@ use Symfony\Contracts\Service\ServiceSubscriberTrait; #[\Attribute(\Attribute::TARGET_METHOD)] final class SubscribedService { + /** @var object[] */ + public array $attributes; + /** - * @param string|null $key The key to use for the service - * If null, use "ClassName::methodName" + * @param string|null $key The key to use for the service + * @param class-string|null $type The service class + * @param bool $nullable Whether the service is optional + * @param object|object[] $attributes One or more dependency injection attributes to use */ public function __construct( - public ?string $key = null + public ?string $key = null, + public ?string $type = null, + public bool $nullable = false, + array|object $attributes = [], ) { + $this->attributes = \is_array($attributes) ? $attributes : [$attributes]; } } diff --git a/vendor/symfony/service-contracts/LICENSE b/vendor/symfony/service-contracts/LICENSE index 2358414..74cdc2d 100644 --- a/vendor/symfony/service-contracts/LICENSE +++ b/vendor/symfony/service-contracts/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2018-2021 Fabien Potencier +Copyright (c) 2018-2022 Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/vendor/symfony/service-contracts/ServiceLocatorTrait.php b/vendor/symfony/service-contracts/ServiceLocatorTrait.php index 19d3e80..45c8d91 100644 --- a/vendor/symfony/service-contracts/ServiceLocatorTrait.php +++ b/vendor/symfony/service-contracts/ServiceLocatorTrait.php @@ -38,17 +38,11 @@ trait ServiceLocatorTrait $this->factories = $factories; } - /** - * {@inheritdoc} - */ public function has(string $id): bool { return isset($this->factories[$id]); } - /** - * {@inheritdoc} - */ public function get(string $id): mixed { if (!isset($this->factories[$id])) { @@ -71,9 +65,6 @@ trait ServiceLocatorTrait } } - /** - * {@inheritdoc} - */ public function getProvidedServices(): array { if (!isset($this->providedTypes)) { diff --git a/vendor/symfony/service-contracts/ServiceProviderInterface.php b/vendor/symfony/service-contracts/ServiceProviderInterface.php index c60ad0b..a28fd82 100644 --- a/vendor/symfony/service-contracts/ServiceProviderInterface.php +++ b/vendor/symfony/service-contracts/ServiceProviderInterface.php @@ -18,9 +18,18 @@ use Psr\Container\ContainerInterface; * * @author Nicolas Grekas * @author Mateusz Sip + * + * @template T of mixed */ interface ServiceProviderInterface extends ContainerInterface { + /** + * @return T + */ + public function get(string $id): mixed; + + public function has(string $id): bool; + /** * Returns an associative array of service types keyed by the identifiers provided by the current container. * diff --git a/vendor/symfony/service-contracts/ServiceSubscriberInterface.php b/vendor/symfony/service-contracts/ServiceSubscriberInterface.php index 881ab97..3da1916 100644 --- a/vendor/symfony/service-contracts/ServiceSubscriberInterface.php +++ b/vendor/symfony/service-contracts/ServiceSubscriberInterface.php @@ -11,6 +11,8 @@ namespace Symfony\Contracts\Service; +use Symfony\Contracts\Service\Attribute\SubscribedService; + /** * A ServiceSubscriber exposes its dependencies via the static {@link getSubscribedServices} method. * @@ -29,7 +31,8 @@ namespace Symfony\Contracts\Service; interface ServiceSubscriberInterface { /** - * Returns an array of service types required by such instances, optionally keyed by the service names used internally. + * Returns an array of service types (or {@see SubscribedService} objects) required + * by such instances, optionally keyed by the service names used internally. * * For mandatory dependencies: * @@ -47,7 +50,13 @@ interface ServiceSubscriberInterface * * ['?Psr\Log\LoggerInterface'] is a shortcut for * * ['Psr\Log\LoggerInterface' => '?Psr\Log\LoggerInterface'] * - * @return string[] The required service types, optionally keyed by service names + * additionally, an array of {@see SubscribedService}'s can be returned: + * + * * [new SubscribedService('logger', Psr\Log\LoggerInterface::class)] + * * [new SubscribedService(type: Psr\Log\LoggerInterface::class, nullable: true)] + * * [new SubscribedService('http_client', HttpClientInterface::class, attributes: new Target('githubApi'))] + * + * @return string[]|SubscribedService[] The required service types, optionally keyed by service names */ public static function getSubscribedServices(): array; } diff --git a/vendor/symfony/service-contracts/ServiceSubscriberTrait.php b/vendor/symfony/service-contracts/ServiceSubscriberTrait.php index f7db036..f7cd3a9 100644 --- a/vendor/symfony/service-contracts/ServiceSubscriberTrait.php +++ b/vendor/symfony/service-contracts/ServiceSubscriberTrait.php @@ -12,6 +12,7 @@ namespace Symfony\Contracts\Service; use Psr\Container\ContainerInterface; +use Symfony\Contracts\Service\Attribute\Required; use Symfony\Contracts\Service\Attribute\SubscribedService; /** @@ -25,18 +26,9 @@ trait ServiceSubscriberTrait /** @var ContainerInterface */ protected $container; - /** - * {@inheritdoc} - */ public static function getSubscribedServices(): array { - static $services; - - if (null !== $services) { - return $services; - } - - $services = \is_callable(['parent', __FUNCTION__]) ? parent::getSubscribedServices() : []; + $services = method_exists(get_parent_class(self::class) ?: '', __FUNCTION__) ? parent::getSubscribedServices() : []; foreach ((new \ReflectionClass(self::class))->getMethods() as $method) { if (self::class !== $method->getDeclaringClass()->name) { @@ -55,26 +47,28 @@ trait ServiceSubscriberTrait throw new \LogicException(sprintf('Cannot use "%s" on methods without a return type in "%s::%s()".', SubscribedService::class, $method->name, self::class)); } - $serviceId = $returnType instanceof \ReflectionNamedType ? $returnType->getName() : (string) $returnType; + /* @var SubscribedService $attribute */ + $attribute = $attribute->newInstance(); + $attribute->key ??= self::class.'::'.$method->name; + $attribute->type ??= $returnType instanceof \ReflectionNamedType ? $returnType->getName() : (string) $returnType; + $attribute->nullable = $returnType->allowsNull(); - if ($returnType->allowsNull()) { - $serviceId = '?'.$serviceId; + if ($attribute->attributes) { + $services[] = $attribute; + } else { + $services[$attribute->key] = ($attribute->nullable ? '?' : '').$attribute->type; } - - $services[$attribute->newInstance()->key ?? self::class.'::'.$method->name] = $serviceId; } return $services; } - /** - * @required - */ + #[Required] public function setContainer(ContainerInterface $container): ?ContainerInterface { $this->container = $container; - if (\is_callable(['parent', __FUNCTION__])) { + if (method_exists(get_parent_class(self::class) ?: '', __FUNCTION__)) { return parent::setContainer($container); } diff --git a/vendor/symfony/service-contracts/composer.json b/vendor/symfony/service-contracts/composer.json index d3b047f..36b0d95 100644 --- a/vendor/symfony/service-contracts/composer.json +++ b/vendor/symfony/service-contracts/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": ">=8.0.2", + "php": ">=8.1", "psr/container": "^2.0" }, "conflict": { @@ -26,12 +26,15 @@ "symfony/service-implementation": "" }, "autoload": { - "psr-4": { "Symfony\\Contracts\\Service\\": "" } + "psr-4": { "Symfony\\Contracts\\Service\\": "" }, + "exclude-from-classmap": [ + "/Test/" + ] }, "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-main": "3.0-dev" + "dev-main": "3.3-dev" }, "thanks": { "name": "symfony/contracts", diff --git a/vendor/symfony/string/AbstractString.php b/vendor/symfony/string/AbstractString.php index 8564430..bf491f8 100644 --- a/vendor/symfony/string/AbstractString.php +++ b/vendor/symfony/string/AbstractString.php @@ -74,7 +74,7 @@ abstract class AbstractString implements \Stringable, \JsonSerializable foreach ($values as $k => $v) { if (\is_string($k) && '' !== $k && $k !== $j = (string) new static($k)) { - $keys = $keys ?? array_keys($values); + $keys ??= array_keys($values); $keys[$i] = $j; } @@ -244,7 +244,7 @@ abstract class AbstractString implements \Stringable, \JsonSerializable public function collapseWhitespace(): static { $str = clone $this; - $str->string = trim(preg_replace('/(?:\s{2,}+|[^\S ])/', ' ', $str->string)); + $str->string = trim(preg_replace("/(?:[ \n\r\t\x0C]{2,}+|[\n\r\t\x0C])/", ' ', $str->string), " \n\r\t\x0C"); return $str; } @@ -452,15 +452,7 @@ abstract class AbstractString implements \Stringable, \JsonSerializable try { if (false === $chunks = preg_split($delimiter, $this->string, $limit, $flags)) { - $lastError = preg_last_error(); - - foreach (get_defined_constants(true)['pcre'] as $k => $v) { - if ($lastError === $v && '_ERROR' === substr($k, -6)) { - throw new RuntimeException('Splitting failed with '.$k.'.'); - } - } - - throw new RuntimeException('Splitting failed with unknown error code.'); + throw new RuntimeException('Splitting failed with error: '.preg_last_error_msg()); } } finally { restore_error_handler(); @@ -558,7 +550,7 @@ abstract class AbstractString implements \Stringable, \JsonSerializable */ public function trimPrefix($prefix): static { - if (\is_array($prefix) || $prefix instanceof \Traversable) { + if (\is_array($prefix) || $prefix instanceof \Traversable) { // don't use is_iterable(), it's slow foreach ($prefix as $s) { $t = $this->trimPrefix($s); @@ -592,7 +584,7 @@ abstract class AbstractString implements \Stringable, \JsonSerializable */ public function trimSuffix($suffix): static { - if (\is_array($suffix) || $suffix instanceof \Traversable) { + if (\is_array($suffix) || $suffix instanceof \Traversable) { // don't use is_iterable(), it's slow foreach ($suffix as $s) { $t = $this->trimSuffix($s); diff --git a/vendor/symfony/string/AbstractUnicodeString.php b/vendor/symfony/string/AbstractUnicodeString.php index 2d4abab..5291227 100644 --- a/vendor/symfony/string/AbstractUnicodeString.php +++ b/vendor/symfony/string/AbstractUnicodeString.php @@ -121,10 +121,10 @@ abstract class AbstractUnicodeString extends AbstractString $s = preg_replace("/([AUO])\u{0308}(?=\p{Ll})/u", '$1e', $s); $s = str_replace(["a\u{0308}", "o\u{0308}", "u\u{0308}", "A\u{0308}", "O\u{0308}", "U\u{0308}"], ['ae', 'oe', 'ue', 'AE', 'OE', 'UE'], $s); } elseif (\function_exists('transliterator_transliterate')) { - if (null === $transliterator = self::$transliterators[$rule] ?? self::$transliterators[$rule] = \Transliterator::create($rule)) { + if (null === $transliterator = self::$transliterators[$rule] ??= \Transliterator::create($rule)) { if ('any-latin/bgn' === $rule) { $rule = 'any-latin'; - $transliterator = self::$transliterators[$rule] ?? self::$transliterators[$rule] = \Transliterator::create($rule); + $transliterator = self::$transliterators[$rule] ??= \Transliterator::create($rule); } if (null === $transliterator) { @@ -159,7 +159,7 @@ abstract class AbstractUnicodeString extends AbstractString public function camel(): static { $str = clone $this; - $str->string = str_replace(' ', '', preg_replace_callback('/\b./u', static function ($m) use (&$i) { + $str->string = str_replace(' ', '', preg_replace_callback('/\b.(?![A-Z]{2,})/u', static function ($m) use (&$i) { return 1 === ++$i ? ('İ' === $m[0] ? 'i̇' : mb_strtolower($m[0], 'UTF-8')) : mb_convert_case($m[0], \MB_CASE_TITLE, 'UTF-8'); }, preg_replace('/[^\pL0-9]++/u', ' ', $this->string))); @@ -234,15 +234,7 @@ abstract class AbstractUnicodeString extends AbstractString try { if (false === $match($regexp.'u', $this->string, $matches, $flags | \PREG_UNMATCHED_AS_NULL, $offset)) { - $lastError = preg_last_error(); - - foreach (get_defined_constants(true)['pcre'] as $k => $v) { - if ($lastError === $v && '_ERROR' === substr($k, -6)) { - throw new RuntimeException('Matching failed with '.$k.'.'); - } - } - - throw new RuntimeException('Matching failed with unknown error code.'); + throw new RuntimeException('Matching failed with error: '.preg_last_error_msg()); } } finally { restore_error_handler(); @@ -329,7 +321,7 @@ abstract class AbstractUnicodeString extends AbstractString $lastError = preg_last_error(); foreach (get_defined_constants(true)['pcre'] as $k => $v) { - if ($lastError === $v && '_ERROR' === substr($k, -6)) { + if ($lastError === $v && str_ends_with($k, '_ERROR')) { throw new RuntimeException('Matching failed with '.$k.'.'); } } @@ -356,7 +348,7 @@ abstract class AbstractUnicodeString extends AbstractString public function snake(): static { - $str = $this->camel()->title(); + $str = $this->camel(); $str->string = mb_strtolower(preg_replace(['/(\p{Lu}+)(\p{Lu}\p{Ll})/u', '/([\p{Ll}0-9])(\p{Lu})/u'], '\1_\2', $str->string), 'UTF-8'); return $str; @@ -467,7 +459,7 @@ abstract class AbstractUnicodeString extends AbstractString $width = 0; $s = str_replace(["\x00", "\x05", "\x07"], '', $this->string); - if (false !== strpos($s, "\r")) { + if (str_contains($s, "\r")) { $s = str_replace(["\r\n", "\r"], "\n", $s); } @@ -478,14 +470,17 @@ abstract class AbstractUnicodeString extends AbstractString foreach (explode("\n", $s) as $s) { if ($ignoreAnsiDecoration) { $s = preg_replace('/(?:\x1B(?: - \[ [\x30-\x3F]*+ [\x20-\x2F]*+ [0x40-\x7E] + \[ [\x30-\x3F]*+ [\x20-\x2F]*+ [\x40-\x7E] | [P\]X^_] .*? \x1B\\\\ | [\x41-\x7E] )|[\p{Cc}\x7F]++)/xu', '', $s); } - // Non printable characters have been dropped, so wcswidth cannot logically return -1. - $width += $this->wcswidth($s); + $lineWidth = $this->wcswidth($s); + + if ($lineWidth > $width) { + $width = $lineWidth; + } } return $width; @@ -555,9 +550,7 @@ abstract class AbstractUnicodeString extends AbstractString return -1; } - if (null === self::$tableZero) { - self::$tableZero = require __DIR__.'/Resources/data/wcswidth_table_zero.php'; - } + self::$tableZero ??= require __DIR__.'/Resources/data/wcswidth_table_zero.php'; if ($codePoint >= self::$tableZero[0][0] && $codePoint <= self::$tableZero[$ubound = \count(self::$tableZero) - 1][1]) { $lbound = 0; @@ -574,9 +567,7 @@ abstract class AbstractUnicodeString extends AbstractString } } - if (null === self::$tableWide) { - self::$tableWide = require __DIR__.'/Resources/data/wcswidth_table_wide.php'; - } + self::$tableWide ??= require __DIR__.'/Resources/data/wcswidth_table_wide.php'; if ($codePoint >= self::$tableWide[0][0] && $codePoint <= self::$tableWide[$ubound = \count(self::$tableWide) - 1][1]) { $lbound = 0; diff --git a/vendor/symfony/string/ByteString.php b/vendor/symfony/string/ByteString.php index b3649b6..212290f 100644 --- a/vendor/symfony/string/ByteString.php +++ b/vendor/symfony/string/ByteString.php @@ -48,7 +48,7 @@ class ByteString extends AbstractString throw new InvalidArgumentException(sprintf('A strictly positive length is expected, "%d" given.', $length)); } - $alphabet = $alphabet ?? self::ALPHABET_ALPHANUMERIC; + $alphabet ??= self::ALPHABET_ALPHANUMERIC; $alphabetSize = \strlen($alphabet); $bits = (int) ceil(log($alphabetSize, 2.0)); if ($bits <= 0 || $bits > 56) { @@ -103,7 +103,10 @@ class ByteString extends AbstractString public function camel(): static { $str = clone $this; - $str->string = lcfirst(str_replace(' ', '', ucwords(preg_replace('/[^a-zA-Z0-9\x7f-\xff]++/', ' ', $this->string)))); + + $parts = explode(' ', trim(ucwords(preg_replace('/[^a-zA-Z0-9\x7f-\xff]++/', ' ', $this->string)))); + $parts[0] = 1 !== \strlen($parts[0]) && ctype_upper($parts[0]) ? $parts[0] : lcfirst($parts[0]); + $str->string = implode('', $parts); return $str; } @@ -237,15 +240,7 @@ class ByteString extends AbstractString try { if (false === $match($regexp, $this->string, $matches, $flags | \PREG_UNMATCHED_AS_NULL, $offset)) { - $lastError = preg_last_error(); - - foreach (get_defined_constants(true)['pcre'] as $k => $v) { - if ($lastError === $v && '_ERROR' === substr($k, -6)) { - throw new RuntimeException('Matching failed with '.$k.'.'); - } - } - - throw new RuntimeException('Matching failed with unknown error code.'); + throw new RuntimeException('Matching failed with error: '.preg_last_error_msg()); } } finally { restore_error_handler(); @@ -312,7 +307,7 @@ class ByteString extends AbstractString $lastError = preg_last_error(); foreach (get_defined_constants(true)['pcre'] as $k => $v) { - if ($lastError === $v && '_ERROR' === substr($k, -6)) { + if ($lastError === $v && str_ends_with($k, '_ERROR')) { throw new RuntimeException('Matching failed with '.$k.'.'); } } @@ -347,7 +342,7 @@ class ByteString extends AbstractString public function snake(): static { - $str = $this->camel()->title(); + $str = $this->camel(); $str->string = strtolower(preg_replace(['/([A-Z]+)([A-Z][a-z])/', '/([a-z\d])([A-Z])/'], '\1_\2', $str->string)); return $str; @@ -363,7 +358,7 @@ class ByteString extends AbstractString public function split(string $delimiter, int $limit = null, int $flags = null): array { - if (1 > $limit = $limit ?? \PHP_INT_MAX) { + if (1 > $limit ??= \PHP_INT_MAX) { throw new InvalidArgumentException('Split limit must be a positive integer.'); } diff --git a/vendor/symfony/string/CHANGELOG.md b/vendor/symfony/string/CHANGELOG.md index 53af364..31a3b54 100644 --- a/vendor/symfony/string/CHANGELOG.md +++ b/vendor/symfony/string/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +6.2 +--- + + * Add support for emoji in `AsciiSlugger` + 5.4 --- diff --git a/vendor/symfony/string/CodePointString.php b/vendor/symfony/string/CodePointString.php index 926ff79..f5c900f 100644 --- a/vendor/symfony/string/CodePointString.php +++ b/vendor/symfony/string/CodePointString.php @@ -210,7 +210,7 @@ class CodePointString extends AbstractUnicodeString public function split(string $delimiter, int $limit = null, int $flags = null): array { - if (1 > $limit = $limit ?? \PHP_INT_MAX) { + if (1 > $limit ??= \PHP_INT_MAX) { throw new InvalidArgumentException('Split limit must be a positive integer.'); } diff --git a/vendor/symfony/string/Inflector/EnglishInflector.php b/vendor/symfony/string/Inflector/EnglishInflector.php index 9f2fac6..4474736 100644 --- a/vendor/symfony/string/Inflector/EnglishInflector.php +++ b/vendor/symfony/string/Inflector/EnglishInflector.php @@ -350,9 +350,6 @@ final class EnglishInflector implements InflectorInterface 'seiceps', ]; - /** - * {@inheritdoc} - */ public function singularize(string $plural): array { $pluralRev = strrev($plural); @@ -384,7 +381,7 @@ final class EnglishInflector implements InflectorInterface if ($j === $suffixLength) { // Is there any character preceding the suffix in the plural string? if ($j < $pluralLength) { - $nextIsVocal = false !== strpos('aeiou', $lowerPluralRev[$j]); + $nextIsVocal = str_contains('aeiou', $lowerPluralRev[$j]); if (!$map[2] && $nextIsVocal) { // suffix may not succeed a vocal but next char is one @@ -429,9 +426,6 @@ final class EnglishInflector implements InflectorInterface return [$plural]; } - /** - * {@inheritdoc} - */ public function pluralize(string $singular): array { $singularRev = strrev($singular); @@ -464,7 +458,7 @@ final class EnglishInflector implements InflectorInterface if ($j === $suffixLength) { // Is there any character preceding the suffix in the plural string? if ($j < $singularLength) { - $nextIsVocal = false !== strpos('aeiou', $lowerSingularRev[$j]); + $nextIsVocal = str_contains('aeiou', $lowerSingularRev[$j]); if (!$map[2] && $nextIsVocal) { // suffix may not succeed a vocal but next char is one diff --git a/vendor/symfony/string/Inflector/FrenchInflector.php b/vendor/symfony/string/Inflector/FrenchInflector.php index 42f6125..955abbf 100644 --- a/vendor/symfony/string/Inflector/FrenchInflector.php +++ b/vendor/symfony/string/Inflector/FrenchInflector.php @@ -100,7 +100,7 @@ final class FrenchInflector implements InflectorInterface ['/^mes(sieur|seigneur)s$/', 'mon\1'], ['/^Mes(sieur|seigneur)s$/', 'Mon\1'], - //Default rule + // Default rule ['/s$/i', ''], ]; @@ -108,11 +108,8 @@ final class FrenchInflector implements InflectorInterface * A list of words which should not be inflected. * This list is only used by singularize. */ - private const UNINFLECTED = '/^(abcès|accès|abus|albatros|anchois|anglais|autobus|bois|brebis|carquois|cas|chas|colis|concours|corps|cours|cyprès|décès|devis|discours|dos|embarras|engrais|entrelacs|excès|fils|fois|gâchis|gars|glas|héros|intrus|jars|jus|kermès|lacis|legs|lilas|marais|mars|matelas|mépris|mets|mois|mors|obus|os|palais|paradis|parcours|pardessus|pays|plusieurs|poids|pois|pouls|printemps|processus|progrès|puits|pus|rabais|radis|recors|recours|refus|relais|remords|remous|rictus|rhinocéros|repas|rubis|sas|secours|sens|souris|succès|talus|tapis|tas|taudis|temps|tiers|univers|velours|verglas|vernis|virus)$/i'; + private const UNINFLECTED = '/^(abcès|accès|abus|albatros|anchois|anglais|autobus|bois|brebis|carquois|cas|chas|colis|concours|corps|cours|cyprès|décès|devis|discours|dos|embarras|engrais|entrelacs|excès|fils|fois|gâchis|gars|glas|héros|intrus|jars|jus|kermès|lacis|legs|lilas|marais|mars|matelas|mépris|mets|mois|mors|obus|os|palais|paradis|parcours|pardessus|pays|plusieurs|poids|pois|pouls|printemps|processus|progrès|puits|pus|rabais|radis|recors|recours|refus|relais|remords|remous|rictus|rhinocéros|repas|rubis|sans|sas|secours|sens|souris|succès|talus|tapis|tas|taudis|temps|tiers|univers|velours|verglas|vernis|virus)$/i'; - /** - * {@inheritdoc} - */ public function singularize(string $plural): array { if ($this->isInflectedWord($plural)) { @@ -130,9 +127,6 @@ final class FrenchInflector implements InflectorInterface return [$plural]; } - /** - * {@inheritdoc} - */ public function pluralize(string $singular): array { if ($this->isInflectedWord($singular)) { diff --git a/vendor/symfony/string/LICENSE b/vendor/symfony/string/LICENSE index 9c907a4..5c7ba05 100644 --- a/vendor/symfony/string/LICENSE +++ b/vendor/symfony/string/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2019-2022 Fabien Potencier +Copyright (c) 2019-2023 Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/vendor/symfony/string/LazyString.php b/vendor/symfony/string/LazyString.php index 15b8d72..9523b8c 100644 --- a/vendor/symfony/string/LazyString.php +++ b/vendor/symfony/string/LazyString.php @@ -34,7 +34,7 @@ class LazyString implements \Stringable, \JsonSerializable if (null !== $arguments) { if (!\is_callable($callback)) { $callback[0] = $callback[0](); - $callback[1] = $callback[1] ?? '__invoke'; + $callback[1] ??= '__invoke'; } $value = $callback(...$arguments); $callback = self::getPrettyName($callback); @@ -50,7 +50,7 @@ class LazyString implements \Stringable, \JsonSerializable public static function fromStringable(string|int|float|bool|\Stringable $value): static { if (\is_object($value)) { - return static::fromCallable([$value, '__toString']); + return static::fromCallable($value->__toString(...)); } $lazyString = new static(); @@ -64,7 +64,7 @@ class LazyString implements \Stringable, \JsonSerializable */ final public static function isStringable(mixed $value): bool { - return \is_string($value) || $value instanceof \Stringable || is_scalar($value); + return \is_string($value) || $value instanceof \Stringable || \is_scalar($value); } /** @@ -86,7 +86,7 @@ class LazyString implements \Stringable, \JsonSerializable try { return $this->value = ($this->value)(); } catch (\Throwable $e) { - if (\TypeError::class === \get_class($e) && __FILE__ === $e->getFile()) { + if (\TypeError::class === $e::class && __FILE__ === $e->getFile()) { $type = explode(', ', $e->getMessage()); $type = substr(array_pop($type), 0, -\strlen(' returned')); $r = new \ReflectionFunction($this->value); @@ -127,7 +127,7 @@ class LazyString implements \Stringable, \JsonSerializable } elseif ($callback instanceof \Closure) { $r = new \ReflectionFunction($callback); - if (false !== strpos($r->name, '{closure}') || !$class = $r->getClosureScopeClass()) { + if (str_contains($r->name, '{closure}') || !$class = \PHP_VERSION_ID >= 80111 ? $r->getClosureCalledClass() : $r->getClosureScopeClass()) { return $r->name; } diff --git a/vendor/symfony/string/Resources/data/wcswidth_table_wide.php b/vendor/symfony/string/Resources/data/wcswidth_table_wide.php index 43c802d..5a647e6 100644 --- a/vendor/symfony/string/Resources/data/wcswidth_table_wide.php +++ b/vendor/symfony/string/Resources/data/wcswidth_table_wide.php @@ -3,8 +3,8 @@ /* * This file has been auto-generated by the Symfony String Component for internal use. * - * Unicode version: 14.0.0 - * Date: 2021-09-17T09:20:30+02:00 + * Unicode version: 15.0.0 + * Date: 2022-10-05T17:16:36+02:00 */ return [ @@ -856,10 +856,18 @@ return [ 110848, 110882, ], + [ + 110898, + 110898, + ], [ 110928, 110930, ], + [ + 110933, + 110933, + ], [ 110948, 110951, @@ -1005,7 +1013,7 @@ return [ 128727, ], [ - 128733, + 128732, 128735, ], [ @@ -1038,39 +1046,31 @@ return [ ], [ 129648, - 129652, - ], - [ - 129656, 129660, ], [ 129664, - 129670, + 129672, ], [ 129680, - 129708, + 129725, ], [ - 129712, - 129722, - ], - [ - 129728, + 129727, 129733, ], [ - 129744, - 129753, + 129742, + 129755, ], [ 129760, - 129767, + 129768, ], [ 129776, - 129782, + 129784, ], [ 131072, @@ -1082,10 +1082,10 @@ return [ ], [ 173824, - 177976, + 177977, ], [ - 177977, + 177978, 177983, ], [ @@ -1130,6 +1130,14 @@ return [ ], [ 201547, + 201551, + ], + [ + 201552, + 205743, + ], + [ + 205744, 262141, ], ]; diff --git a/vendor/symfony/string/Resources/data/wcswidth_table_zero.php b/vendor/symfony/string/Resources/data/wcswidth_table_zero.php index 63b0824..9ae7330 100644 --- a/vendor/symfony/string/Resources/data/wcswidth_table_zero.php +++ b/vendor/symfony/string/Resources/data/wcswidth_table_zero.php @@ -3,8 +3,8 @@ /* * This file has been auto-generated by the Symfony String Component for internal use. * - * Unicode version: 14.0.0 - * Date: 2021-09-17T09:20:30+02:00 + * Unicode version: 15.0.0 + * Date: 2022-10-05T17:16:37+02:00 */ return [ @@ -382,7 +382,7 @@ return [ ], [ 3784, - 3789, + 3790, ], [ 3864, @@ -920,6 +920,10 @@ return [ 69291, 69292, ], + [ + 69373, + 69375, + ], [ 69446, 69456, @@ -1008,6 +1012,10 @@ return [ 70206, 70206, ], + [ + 70209, + 70209, + ], [ 70367, 70367, @@ -1252,6 +1260,30 @@ return [ 73459, 73460, ], + [ + 73472, + 73473, + ], + [ + 73526, + 73530, + ], + [ + 73536, + 73536, + ], + [ + 73538, + 73538, + ], + [ + 78912, + 78912, + ], + [ + 78919, + 78933, + ], [ 92912, 92916, @@ -1348,6 +1380,10 @@ return [ 122918, 122922, ], + [ + 123023, + 123023, + ], [ 123184, 123190, @@ -1360,6 +1396,10 @@ return [ 123628, 123631, ], + [ + 124140, + 124143, + ], [ 125136, 125142, diff --git a/vendor/symfony/string/Resources/functions.php b/vendor/symfony/string/Resources/functions.php index c950894..7a97040 100644 --- a/vendor/symfony/string/Resources/functions.php +++ b/vendor/symfony/string/Resources/functions.php @@ -31,7 +31,7 @@ if (!\function_exists(s::class)) { */ function s(?string $string = ''): AbstractString { - $string = $string ?? ''; + $string ??= ''; return preg_match('//u', $string) ? new UnicodeString($string) : new ByteString($string); } diff --git a/vendor/symfony/string/Slugger/AsciiSlugger.php b/vendor/symfony/string/Slugger/AsciiSlugger.php index 548a6b9..826d07c 100644 --- a/vendor/symfony/string/Slugger/AsciiSlugger.php +++ b/vendor/symfony/string/Slugger/AsciiSlugger.php @@ -11,6 +11,7 @@ namespace Symfony\Component\String\Slugger; +use Symfony\Component\Intl\Transliterator\EmojiTransliterator; use Symfony\Component\String\AbstractUnicodeString; use Symfony\Component\String\UnicodeString; use Symfony\Contracts\Translation\LocaleAwareInterface; @@ -58,6 +59,7 @@ class AsciiSlugger implements SluggerInterface, LocaleAwareInterface private \Closure|array $symbolsMap = [ 'en' => ['@' => 'at', '&' => 'and'], ]; + private bool|string $emoji = false; /** * Cache of transliterators per locale. @@ -72,37 +74,49 @@ class AsciiSlugger implements SluggerInterface, LocaleAwareInterface $this->symbolsMap = $symbolsMap ?? $this->symbolsMap; } - /** - * {@inheritdoc} - */ public function setLocale(string $locale) { $this->defaultLocale = $locale; } - /** - * {@inheritdoc} - */ public function getLocale(): string { return $this->defaultLocale; } /** - * {@inheritdoc} + * @param bool|string $emoji true will use the same locale, + * false will disable emoji, + * and a string to use a specific locale */ + public function withEmoji(bool|string $emoji = true): static + { + if (false !== $emoji && !class_exists(EmojiTransliterator::class)) { + throw new \LogicException(sprintf('You cannot use the "%s()" method as the "symfony/intl" package is not installed. Try running "composer require symfony/intl".', __METHOD__)); + } + + $new = clone $this; + $new->emoji = $emoji; + + return $new; + } + public function slug(string $string, string $separator = '-', string $locale = null): AbstractUnicodeString { - $locale = $locale ?? $this->defaultLocale; + $locale ??= $this->defaultLocale; $transliterator = []; - if ($locale && ('de' === $locale || 0 === strpos($locale, 'de_'))) { + if ($locale && ('de' === $locale || str_starts_with($locale, 'de_'))) { // Use the shortcut for German in UnicodeString::ascii() if possible (faster and no requirement on intl) $transliterator = ['de-ASCII']; } elseif (\function_exists('transliterator_transliterate') && $locale) { $transliterator = (array) $this->createTransliterator($locale); } + if ($emojiTransliterator = $this->createEmojiTransliterator($locale)) { + $transliterator[] = $emojiTransliterator; + } + if ($this->symbolsMap instanceof \Closure) { // If the symbols map is passed as a closure, there is no need to fallback to the parent locale // as the closure can just provide substitutions for all locales of interest. @@ -161,6 +175,25 @@ class AsciiSlugger implements SluggerInterface, LocaleAwareInterface return $this->transliterators[$locale] = $this->transliterators[$parent] = $transliterator ?? null; } + private function createEmojiTransliterator(?string $locale): ?EmojiTransliterator + { + if (\is_string($this->emoji)) { + $locale = $this->emoji; + } elseif (!$this->emoji) { + return null; + } + + while (null !== $locale) { + try { + return EmojiTransliterator::create("emoji-$locale"); + } catch (\IntlException) { + $locale = self::getParentLocale($locale); + } + } + + return null; + } + private static function getParentLocale(?string $locale): ?string { if (!$locale) { diff --git a/vendor/symfony/string/UnicodeString.php b/vendor/symfony/string/UnicodeString.php index 70cf4c5..a64c6a9 100644 --- a/vendor/symfony/string/UnicodeString.php +++ b/vendor/symfony/string/UnicodeString.php @@ -139,7 +139,7 @@ class UnicodeString extends AbstractUnicodeString try { $i = $this->ignoreCase ? grapheme_stripos($this->string, $needle, $offset) : grapheme_strpos($this->string, $needle, $offset); - } catch (\ValueError $e) { + } catch (\ValueError) { return null; } @@ -280,7 +280,7 @@ class UnicodeString extends AbstractUnicodeString public function split(string $delimiter, int $limit = null, int $flags = null): array { - if (1 > $limit = $limit ?? 2147483647) { + if (1 > $limit ??= 2147483647) { throw new InvalidArgumentException('Split limit must be a positive integer.'); } diff --git a/vendor/symfony/string/composer.json b/vendor/symfony/string/composer.json index 187323f..44a809d 100644 --- a/vendor/symfony/string/composer.json +++ b/vendor/symfony/string/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": ">=8.0.2", + "php": ">=8.1", "symfony/polyfill-ctype": "~1.8", "symfony/polyfill-intl-grapheme": "~1.0", "symfony/polyfill-intl-normalizer": "~1.0", @@ -24,6 +24,7 @@ }, "require-dev": { "symfony/error-handler": "^5.4|^6.0", + "symfony/intl": "^6.2", "symfony/http-client": "^5.4|^6.0", "symfony/translation-contracts": "^2.0|^3.0", "symfony/var-exporter": "^5.4|^6.0" diff --git a/vendor/symfony/translation-contracts/.gitignore b/vendor/symfony/translation-contracts/.gitignore deleted file mode 100644 index c49a5d8..0000000 --- a/vendor/symfony/translation-contracts/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -vendor/ -composer.lock -phpunit.xml diff --git a/vendor/symfony/translation-contracts/LICENSE b/vendor/symfony/translation-contracts/LICENSE index 2358414..74cdc2d 100644 --- a/vendor/symfony/translation-contracts/LICENSE +++ b/vendor/symfony/translation-contracts/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2018-2021 Fabien Potencier +Copyright (c) 2018-2022 Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/vendor/symfony/translation-contracts/Test/TranslatorTest.php b/vendor/symfony/translation-contracts/Test/TranslatorTest.php index c2c30a9..fbfa161 100644 --- a/vendor/symfony/translation-contracts/Test/TranslatorTest.php +++ b/vendor/symfony/translation-contracts/Test/TranslatorTest.php @@ -271,7 +271,7 @@ class TranslatorTest extends TestCase ['This is a text with a\nnew-line in it. Selector = 0.', '{0}This is a text with a\nnew-line in it. Selector = 0.|{1}This is a text with a\nnew-line in it. Selector = 1.|[1,Inf]This is a text with a\nnew-line in it. Selector > 1.', 0], // with double-quotes and id split accros lines ["This is a text with a\nnew-line in it. Selector = 1.", "{0}This is a text with a\nnew-line in it. Selector = 0.|{1}This is a text with a\nnew-line in it. Selector = 1.|[1,Inf]This is a text with a\nnew-line in it. Selector > 1.", 1], - // esacape pipe + // escape pipe ['This is a text with | in it. Selector = 0.', '{0}This is a text with || in it. Selector = 0.|{1}This is a text with || in it. Selector = 1.', 0], // Empty plural set (2 plural forms) from a .PO file ['', '|', 1], @@ -356,7 +356,7 @@ class TranslatorTest extends TestCase foreach ($matrix as $langCode => $data) { $indexes = array_flip($data); if ($expectSuccess) { - $this->assertEquals($nplural, \count($indexes), "Langcode '$langCode' has '$nplural' plural forms."); + $this->assertCount($nplural, $indexes, "Langcode '$langCode' has '$nplural' plural forms."); } else { $this->assertNotEquals((int) $nplural, \count($indexes), "Langcode '$langCode' has '$nplural' plural forms."); } diff --git a/vendor/symfony/translation-contracts/TranslatorTrait.php b/vendor/symfony/translation-contracts/TranslatorTrait.php index 9c264bd..46e9170 100644 --- a/vendor/symfony/translation-contracts/TranslatorTrait.php +++ b/vendor/symfony/translation-contracts/TranslatorTrait.php @@ -22,25 +22,16 @@ trait TranslatorTrait { private ?string $locale = null; - /** - * {@inheritdoc} - */ public function setLocale(string $locale) { $this->locale = $locale; } - /** - * {@inheritdoc} - */ public function getLocale(): string { return $this->locale ?: (class_exists(\Locale::class) ? \Locale::getDefault() : 'en'); } - /** - * {@inheritdoc} - */ public function trans(?string $id, array $parameters = [], string $domain = null, string $locale = null): string { if (null === $id || '' === $id) { @@ -140,121 +131,92 @@ EOF; { $number = abs($number); - switch ('pt_BR' !== $locale && 'en_US_POSIX' !== $locale && \strlen($locale) > 3 ? substr($locale, 0, strrpos($locale, '_')) : $locale) { - case 'af': - case 'bn': - case 'bg': - case 'ca': - case 'da': - case 'de': - case 'el': - case 'en': - case 'en_US_POSIX': - case 'eo': - case 'es': - case 'et': - case 'eu': - case 'fa': - case 'fi': - case 'fo': - case 'fur': - case 'fy': - case 'gl': - case 'gu': - case 'ha': - case 'he': - case 'hu': - case 'is': - case 'it': - case 'ku': - case 'lb': - case 'ml': - case 'mn': - case 'mr': - case 'nah': - case 'nb': - case 'ne': - case 'nl': - case 'nn': - case 'no': - case 'oc': - case 'om': - case 'or': - case 'pa': - case 'pap': - case 'ps': - case 'pt': - case 'so': - case 'sq': - case 'sv': - case 'sw': - case 'ta': - case 'te': - case 'tk': - case 'ur': - case 'zu': - return (1 == $number) ? 0 : 1; - - case 'am': - case 'bh': - case 'fil': - case 'fr': - case 'gun': - case 'hi': - case 'hy': - case 'ln': - case 'mg': - case 'nso': - case 'pt_BR': - case 'ti': - case 'wa': - return ($number < 2) ? 0 : 1; - - case 'be': - case 'bs': - case 'hr': - case 'ru': - case 'sh': - case 'sr': - case 'uk': - return ((1 == $number % 10) && (11 != $number % 100)) ? 0 : ((($number % 10 >= 2) && ($number % 10 <= 4) && (($number % 100 < 10) || ($number % 100 >= 20))) ? 1 : 2); - - case 'cs': - case 'sk': - return (1 == $number) ? 0 : ((($number >= 2) && ($number <= 4)) ? 1 : 2); - - case 'ga': - return (1 == $number) ? 0 : ((2 == $number) ? 1 : 2); - - case 'lt': - return ((1 == $number % 10) && (11 != $number % 100)) ? 0 : ((($number % 10 >= 2) && (($number % 100 < 10) || ($number % 100 >= 20))) ? 1 : 2); - - case 'sl': - return (1 == $number % 100) ? 0 : ((2 == $number % 100) ? 1 : (((3 == $number % 100) || (4 == $number % 100)) ? 2 : 3)); - - case 'mk': - return (1 == $number % 10) ? 0 : 1; - - case 'mt': - return (1 == $number) ? 0 : (((0 == $number) || (($number % 100 > 1) && ($number % 100 < 11))) ? 1 : ((($number % 100 > 10) && ($number % 100 < 20)) ? 2 : 3)); - - case 'lv': - return (0 == $number) ? 0 : (((1 == $number % 10) && (11 != $number % 100)) ? 1 : 2); - - case 'pl': - return (1 == $number) ? 0 : ((($number % 10 >= 2) && ($number % 10 <= 4) && (($number % 100 < 12) || ($number % 100 > 14))) ? 1 : 2); - - case 'cy': - return (1 == $number) ? 0 : ((2 == $number) ? 1 : (((8 == $number) || (11 == $number)) ? 2 : 3)); - - case 'ro': - return (1 == $number) ? 0 : (((0 == $number) || (($number % 100 > 0) && ($number % 100 < 20))) ? 1 : 2); - - case 'ar': - return (0 == $number) ? 0 : ((1 == $number) ? 1 : ((2 == $number) ? 2 : ((($number % 100 >= 3) && ($number % 100 <= 10)) ? 3 : ((($number % 100 >= 11) && ($number % 100 <= 99)) ? 4 : 5)))); - - default: - return 0; - } + return match ('pt_BR' !== $locale && 'en_US_POSIX' !== $locale && \strlen($locale) > 3 ? substr($locale, 0, strrpos($locale, '_')) : $locale) { + 'af', + 'bn', + 'bg', + 'ca', + 'da', + 'de', + 'el', + 'en', + 'en_US_POSIX', + 'eo', + 'es', + 'et', + 'eu', + 'fa', + 'fi', + 'fo', + 'fur', + 'fy', + 'gl', + 'gu', + 'ha', + 'he', + 'hu', + 'is', + 'it', + 'ku', + 'lb', + 'ml', + 'mn', + 'mr', + 'nah', + 'nb', + 'ne', + 'nl', + 'nn', + 'no', + 'oc', + 'om', + 'or', + 'pa', + 'pap', + 'ps', + 'pt', + 'so', + 'sq', + 'sv', + 'sw', + 'ta', + 'te', + 'tk', + 'ur', + 'zu' => (1 == $number) ? 0 : 1, + 'am', + 'bh', + 'fil', + 'fr', + 'gun', + 'hi', + 'hy', + 'ln', + 'mg', + 'nso', + 'pt_BR', + 'ti', + 'wa' => ($number < 2) ? 0 : 1, + 'be', + 'bs', + 'hr', + 'ru', + 'sh', + 'sr', + 'uk' => ((1 == $number % 10) && (11 != $number % 100)) ? 0 : ((($number % 10 >= 2) && ($number % 10 <= 4) && (($number % 100 < 10) || ($number % 100 >= 20))) ? 1 : 2), + 'cs', + 'sk' => (1 == $number) ? 0 : ((($number >= 2) && ($number <= 4)) ? 1 : 2), + 'ga' => (1 == $number) ? 0 : ((2 == $number) ? 1 : 2), + 'lt' => ((1 == $number % 10) && (11 != $number % 100)) ? 0 : ((($number % 10 >= 2) && (($number % 100 < 10) || ($number % 100 >= 20))) ? 1 : 2), + 'sl' => (1 == $number % 100) ? 0 : ((2 == $number % 100) ? 1 : (((3 == $number % 100) || (4 == $number % 100)) ? 2 : 3)), + 'mk' => (1 == $number % 10) ? 0 : 1, + 'mt' => (1 == $number) ? 0 : (((0 == $number) || (($number % 100 > 1) && ($number % 100 < 11))) ? 1 : ((($number % 100 > 10) && ($number % 100 < 20)) ? 2 : 3)), + 'lv' => (0 == $number) ? 0 : (((1 == $number % 10) && (11 != $number % 100)) ? 1 : 2), + 'pl' => (1 == $number) ? 0 : ((($number % 10 >= 2) && ($number % 10 <= 4) && (($number % 100 < 12) || ($number % 100 > 14))) ? 1 : 2), + 'cy' => (1 == $number) ? 0 : ((2 == $number) ? 1 : (((8 == $number) || (11 == $number)) ? 2 : 3)), + 'ro' => (1 == $number) ? 0 : (((0 == $number) || (($number % 100 > 0) && ($number % 100 < 20))) ? 1 : 2), + 'ar' => (0 == $number) ? 0 : ((1 == $number) ? 1 : ((2 == $number) ? 2 : ((($number % 100 >= 3) && ($number % 100 <= 10)) ? 3 : ((($number % 100 >= 11) && ($number % 100 <= 99)) ? 4 : 5)))), + default => 0, + }; } } diff --git a/vendor/symfony/translation-contracts/composer.json b/vendor/symfony/translation-contracts/composer.json index 875242f..3454800 100644 --- a/vendor/symfony/translation-contracts/composer.json +++ b/vendor/symfony/translation-contracts/composer.json @@ -16,18 +16,21 @@ } ], "require": { - "php": ">=8.0.2" + "php": ">=8.1" }, "suggest": { "symfony/translation-implementation": "" }, "autoload": { - "psr-4": { "Symfony\\Contracts\\Translation\\": "" } + "psr-4": { "Symfony\\Contracts\\Translation\\": "" }, + "exclude-from-classmap": [ + "/Test/" + ] }, "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-main": "3.0-dev" + "dev-main": "3.3-dev" }, "thanks": { "name": "symfony/contracts", diff --git a/vendor/symfony/translation/CHANGELOG.md b/vendor/symfony/translation/CHANGELOG.md index 160b5e6..b755fec 100644 --- a/vendor/symfony/translation/CHANGELOG.md +++ b/vendor/symfony/translation/CHANGELOG.md @@ -1,6 +1,19 @@ CHANGELOG ========= +6.2 +--- + + * Deprecate `PhpStringTokenParser` + * Deprecate `PhpExtractor` in favor of `PhpAstExtractor` + * Add `PhpAstExtractor` (requires [nikic/php-parser](https://github.com/nikic/php-parser) to be installed) + +6.1 +--- + + * Parameters implementing `TranslatableInterface` are processed + * Add the file extension to the `XliffFileDumper` constructor + 5.4 --- diff --git a/vendor/symfony/translation/Catalogue/AbstractOperation.php b/vendor/symfony/translation/Catalogue/AbstractOperation.php index 43a52fa..419ba95 100644 --- a/vendor/symfony/translation/Catalogue/AbstractOperation.php +++ b/vendor/symfony/translation/Catalogue/AbstractOperation.php @@ -77,9 +77,6 @@ abstract class AbstractOperation implements OperationInterface $this->messages = []; } - /** - * {@inheritdoc} - */ public function getDomains(): array { if (null === $this->domains) { @@ -100,9 +97,6 @@ abstract class AbstractOperation implements OperationInterface return $this->domains; } - /** - * {@inheritdoc} - */ public function getMessages(string $domain): array { if (!\in_array($domain, $this->getDomains())) { @@ -116,9 +110,6 @@ abstract class AbstractOperation implements OperationInterface return $this->messages[$domain][self::ALL_BATCH]; } - /** - * {@inheritdoc} - */ public function getNewMessages(string $domain): array { if (!\in_array($domain, $this->getDomains())) { @@ -132,9 +123,6 @@ abstract class AbstractOperation implements OperationInterface return $this->messages[$domain][self::NEW_BATCH]; } - /** - * {@inheritdoc} - */ public function getObsoleteMessages(string $domain): array { if (!\in_array($domain, $this->getDomains())) { @@ -148,9 +136,6 @@ abstract class AbstractOperation implements OperationInterface return $this->messages[$domain][self::OBSOLETE_BATCH]; } - /** - * {@inheritdoc} - */ public function getResult(): MessageCatalogueInterface { foreach ($this->getDomains() as $domain) { @@ -174,12 +159,12 @@ abstract class AbstractOperation implements OperationInterface foreach ($this->getDomains() as $domain) { $intlDomain = $domain.MessageCatalogueInterface::INTL_DOMAIN_SUFFIX; - switch ($batch) { - case self::OBSOLETE_BATCH: $messages = $this->getObsoleteMessages($domain); break; - case self::NEW_BATCH: $messages = $this->getNewMessages($domain); break; - case self::ALL_BATCH: $messages = $this->getMessages($domain); break; - default: throw new \InvalidArgumentException(sprintf('$batch argument must be one of ["%s", "%s", "%s"].', self::ALL_BATCH, self::NEW_BATCH, self::OBSOLETE_BATCH)); - } + $messages = match ($batch) { + self::OBSOLETE_BATCH => $this->getObsoleteMessages($domain), + self::NEW_BATCH => $this->getNewMessages($domain), + self::ALL_BATCH => $this->getMessages($domain), + default => throw new \InvalidArgumentException(sprintf('$batch argument must be one of ["%s", "%s", "%s"].', self::ALL_BATCH, self::NEW_BATCH, self::OBSOLETE_BATCH)), + }; if (!$messages || (!$this->source->all($intlDomain) && $this->source->all($domain))) { continue; diff --git a/vendor/symfony/translation/Catalogue/MergeOperation.php b/vendor/symfony/translation/Catalogue/MergeOperation.php index 87db2fb..7a0ce23 100644 --- a/vendor/symfony/translation/Catalogue/MergeOperation.php +++ b/vendor/symfony/translation/Catalogue/MergeOperation.php @@ -24,9 +24,6 @@ use Symfony\Component\Translation\MessageCatalogueInterface; */ class MergeOperation extends AbstractOperation { - /** - * {@inheritdoc} - */ protected function processDomain(string $domain) { $this->messages[$domain] = [ @@ -36,6 +33,18 @@ class MergeOperation extends AbstractOperation ]; $intlDomain = $domain.MessageCatalogueInterface::INTL_DOMAIN_SUFFIX; + foreach ($this->target->getCatalogueMetadata('', $domain) ?? [] as $key => $value) { + if (null === $this->result->getCatalogueMetadata($key, $domain)) { + $this->result->setCatalogueMetadata($key, $value, $domain); + } + } + + foreach ($this->target->getCatalogueMetadata('', $intlDomain) ?? [] as $key => $value) { + if (null === $this->result->getCatalogueMetadata($key, $intlDomain)) { + $this->result->setCatalogueMetadata($key, $value, $intlDomain); + } + } + foreach ($this->source->all($domain) as $id => $message) { $this->messages[$domain]['all'][$id] = $message; $d = $this->source->defines($id, $intlDomain) ? $intlDomain : $domain; diff --git a/vendor/symfony/translation/Catalogue/TargetOperation.php b/vendor/symfony/translation/Catalogue/TargetOperation.php index 682b575..6ab60c3 100644 --- a/vendor/symfony/translation/Catalogue/TargetOperation.php +++ b/vendor/symfony/translation/Catalogue/TargetOperation.php @@ -25,9 +25,6 @@ use Symfony\Component\Translation\MessageCatalogueInterface; */ class TargetOperation extends AbstractOperation { - /** - * {@inheritdoc} - */ protected function processDomain(string $domain) { $this->messages[$domain] = [ @@ -37,6 +34,18 @@ class TargetOperation extends AbstractOperation ]; $intlDomain = $domain.MessageCatalogueInterface::INTL_DOMAIN_SUFFIX; + foreach ($this->target->getCatalogueMetadata('', $domain) ?? [] as $key => $value) { + if (null === $this->result->getCatalogueMetadata($key, $domain)) { + $this->result->setCatalogueMetadata($key, $value, $domain); + } + } + + foreach ($this->target->getCatalogueMetadata('', $intlDomain) ?? [] as $key => $value) { + if (null === $this->result->getCatalogueMetadata($key, $intlDomain)) { + $this->result->setCatalogueMetadata($key, $value, $intlDomain); + } + } + // For 'all' messages, the code can't be simplified as ``$this->messages[$domain]['all'] = $target->all($domain);``, // because doing so will drop messages like {x: x ∈ source ∧ x ∉ target.all ∧ x ∈ target.fallback} // diff --git a/vendor/symfony/translation/CatalogueMetadataAwareInterface.php b/vendor/symfony/translation/CatalogueMetadataAwareInterface.php new file mode 100644 index 0000000..7e76857 --- /dev/null +++ b/vendor/symfony/translation/CatalogueMetadataAwareInterface.php @@ -0,0 +1,44 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Translation; + +/** + * This interface is used to get, set, and delete metadata about the Catalogue. + * + * @author Hugo Alliaume + */ +interface CatalogueMetadataAwareInterface +{ + /** + * Gets catalogue metadata for the given domain and key. + * + * Passing an empty domain will return an array with all catalogue metadata indexed by + * domain and then by key. Passing an empty key will return an array with all + * catalogue metadata for the given domain. + * + * @return mixed The value that was set or an array with the domains/keys or null + */ + public function getCatalogueMetadata(string $key = '', string $domain = 'messages'): mixed; + + /** + * Adds catalogue metadata to a message domain. + */ + public function setCatalogueMetadata(string $key, mixed $value, string $domain = 'messages'); + + /** + * Deletes catalogue metadata for the given key and domain. + * + * Passing an empty domain will delete all catalogue metadata. Passing an empty key will + * delete all metadata for the given domain. + */ + public function deleteCatalogueMetadata(string $key = '', string $domain = 'messages'); +} diff --git a/vendor/symfony/translation/Command/TranslationPullCommand.php b/vendor/symfony/translation/Command/TranslationPullCommand.php index 42513a8..225deba 100644 --- a/vendor/symfony/translation/Command/TranslationPullCommand.php +++ b/vendor/symfony/translation/Command/TranslationPullCommand.php @@ -34,9 +34,9 @@ final class TranslationPullCommand extends Command { use TranslationTrait; - private $providerCollection; - private $writer; - private $reader; + private TranslationProviderCollection $providerCollection; + private TranslationWriterInterface $writer; + private TranslationReaderInterface $reader; private string $defaultLocale; private array $transPaths; private array $enabledLocales; @@ -64,9 +64,8 @@ final class TranslationPullCommand extends Command if ($input->mustSuggestOptionValuesFor('domains')) { $provider = $this->providerCollection->get($input->getArgument('provider')); - if ($provider && method_exists($provider, 'getDomains')) { - $domains = $provider->getDomains(); - $suggestions->suggestValues($domains); + if (method_exists($provider, 'getDomains')) { + $suggestions->suggestValues($provider->getDomains()); } return; @@ -83,9 +82,6 @@ final class TranslationPullCommand extends Command } } - /** - * {@inheritdoc} - */ protected function configure() { $keys = $this->providerCollection->keys(); @@ -120,9 +116,6 @@ EOF ; } - /** - * {@inheritdoc} - */ protected function execute(InputInterface $input, OutputInterface $output): int { $io = new SymfonyStyle($input, $output); @@ -141,7 +134,7 @@ EOF switch ($format) { case 'xlf20': $xliffVersion = '2.0'; - // no break + // no break case 'xlf12': $format = 'xlf'; } @@ -159,7 +152,7 @@ EOF if ($force) { foreach ($providerTranslations->getCatalogues() as $catalogue) { - $operation = new TargetOperation((new MessageCatalogue($catalogue->getLocale())), $catalogue); + $operation = new TargetOperation(new MessageCatalogue($catalogue->getLocale()), $catalogue); if ($intlIcu) { $operation->moveMessagesToIntlDomainsIfPossible(); } diff --git a/vendor/symfony/translation/Command/TranslationPushCommand.php b/vendor/symfony/translation/Command/TranslationPushCommand.php index dba2164..42799e0 100644 --- a/vendor/symfony/translation/Command/TranslationPushCommand.php +++ b/vendor/symfony/translation/Command/TranslationPushCommand.php @@ -21,6 +21,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; +use Symfony\Component\Translation\Provider\FilteringProvider; use Symfony\Component\Translation\Provider\TranslationProviderCollection; use Symfony\Component\Translation\Reader\TranslationReaderInterface; use Symfony\Component\Translation\TranslatorBag; @@ -33,8 +34,8 @@ final class TranslationPushCommand extends Command { use TranslationTrait; - private $providers; - private $reader; + private TranslationProviderCollection $providers; + private TranslationReaderInterface $reader; private array $transPaths; private array $enabledLocales; @@ -72,9 +73,6 @@ final class TranslationPushCommand extends Command } } - /** - * {@inheritdoc} - */ protected function configure() { $keys = $this->providers->keys(); @@ -112,9 +110,6 @@ EOF ; } - /** - * {@inheritdoc} - */ protected function execute(InputInterface $input, OutputInterface $output): int { $provider = $this->providers->get($input->getArgument('provider')); @@ -129,6 +124,12 @@ EOF $force = $input->getOption('force'); $deleteMissing = $input->getOption('delete-missing'); + if (!$domains && $provider instanceof FilteringProvider) { + $domains = $provider->getDomains(); + } + + // Reading local translations must be done after retrieving the domains from the provider + // in order to manage only translations from configured domains $localTranslations = $this->readLocalTranslations($locales, $domains, $this->transPaths); if (!$domains) { diff --git a/vendor/symfony/translation/Command/XliffLintCommand.php b/vendor/symfony/translation/Command/XliffLintCommand.php index f062fb7..1e5f26c 100644 --- a/vendor/symfony/translation/Command/XliffLintCommand.php +++ b/vendor/symfony/translation/Command/XliffLintCommand.php @@ -45,14 +45,11 @@ class XliffLintCommand extends Command { parent::__construct($name); - $this->directoryIteratorProvider = null === $directoryIteratorProvider || $directoryIteratorProvider instanceof \Closure ? $directoryIteratorProvider : \Closure::fromCallable($directoryIteratorProvider); - $this->isReadableProvider = null === $isReadableProvider || $isReadableProvider instanceof \Closure ? $isReadableProvider : \Closure::fromCallable($isReadableProvider); + $this->directoryIteratorProvider = null === $directoryIteratorProvider ? null : $directoryIteratorProvider(...); + $this->isReadableProvider = null === $isReadableProvider ? null : $isReadableProvider(...); $this->requireStrictFileNames = $requireStrictFileNames; } - /** - * {@inheritdoc} - */ protected function configure() { $this @@ -156,16 +153,12 @@ EOF private function display(SymfonyStyle $io, array $files) { - switch ($this->format) { - case 'txt': - return $this->displayTxt($io, $files); - case 'json': - return $this->displayJson($io, $files); - case 'github': - return $this->displayTxt($io, $files, true); - default: - throw new InvalidArgumentException(sprintf('The format "%s" is not supported.', $this->format)); - } + return match ($this->format) { + 'txt' => $this->displayTxt($io, $files), + 'json' => $this->displayJson($io, $files), + 'github' => $this->displayTxt($io, $files, true), + default => throw new InvalidArgumentException(sprintf('The format "%s" is not supported.', $this->format)), + }; } private function displayTxt(SymfonyStyle $io, array $filesInfo, bool $errorAsGithubAnnotations = false) @@ -184,9 +177,7 @@ EOF // general document errors have a '-1' line number $line = -1 === $error['line'] ? null : $error['line']; - if ($githubReporter) { - $githubReporter->error($error['message'], $info['file'], $line, null !== $line ? $error['column'] : null); - } + $githubReporter?->error($error['message'], $info['file'], $line, null !== $line ? $error['column'] : null); return null === $line ? $error['message'] : sprintf('Line %d, Column %d: %s', $line, $error['column'], $error['message']); }, $info['messages'])); diff --git a/vendor/symfony/translation/DataCollector/TranslationDataCollector.php b/vendor/symfony/translation/DataCollector/TranslationDataCollector.php index 0f7901d..064140a 100644 --- a/vendor/symfony/translation/DataCollector/TranslationDataCollector.php +++ b/vendor/symfony/translation/DataCollector/TranslationDataCollector.php @@ -25,16 +25,13 @@ use Symfony\Component\VarDumper\Cloner\Data; */ class TranslationDataCollector extends DataCollector implements LateDataCollectorInterface { - private $translator; + private DataCollectorTranslator $translator; public function __construct(DataCollectorTranslator $translator) { $this->translator = $translator; } - /** - * {@inheritdoc} - */ public function lateCollect() { $messages = $this->sanitizeCollectedMessages($this->translator->getCollectedMessages()); @@ -45,18 +42,12 @@ class TranslationDataCollector extends DataCollector implements LateDataCollecto $this->data = $this->cloneVar($this->data); } - /** - * {@inheritdoc} - */ public function collect(Request $request, Response $response, \Throwable $exception = null) { $this->data['locale'] = $this->translator->getLocale(); $this->data['fallback_locales'] = $this->translator->getFallbackLocales(); } - /** - * {@inheritdoc} - */ public function reset() { $this->data = []; @@ -95,9 +86,6 @@ class TranslationDataCollector extends DataCollector implements LateDataCollecto return (isset($this->data['fallback_locales']) && \count($this->data['fallback_locales']) > 0) ? $this->data['fallback_locales'] : []; } - /** - * {@inheritdoc} - */ public function getName(): string { return 'translation'; diff --git a/vendor/symfony/translation/DataCollectorTranslator.php b/vendor/symfony/translation/DataCollectorTranslator.php index 2a08b09..c360c9e 100644 --- a/vendor/symfony/translation/DataCollectorTranslator.php +++ b/vendor/symfony/translation/DataCollectorTranslator.php @@ -25,7 +25,7 @@ class DataCollectorTranslator implements TranslatorInterface, TranslatorBagInter public const MESSAGE_MISSING = 1; public const MESSAGE_EQUALS_FALLBACK = 2; - private $translator; + private TranslatorInterface $translator; private array $messages = []; /** @@ -40,9 +40,6 @@ class DataCollectorTranslator implements TranslatorInterface, TranslatorBagInter $this->translator = $translator; } - /** - * {@inheritdoc} - */ public function trans(?string $id, array $parameters = [], string $domain = null, string $locale = null): string { $trans = $this->translator->trans($id = (string) $id, $parameters, $domain, $locale); @@ -51,41 +48,27 @@ class DataCollectorTranslator implements TranslatorInterface, TranslatorBagInter return $trans; } - /** - * {@inheritdoc} - */ public function setLocale(string $locale) { $this->translator->setLocale($locale); } - /** - * {@inheritdoc} - */ public function getLocale(): string { return $this->translator->getLocale(); } - /** - * {@inheritdoc} - */ public function getCatalogue(string $locale = null): MessageCatalogueInterface { return $this->translator->getCatalogue($locale); } - /** - * {@inheritdoc} - */ public function getCatalogues(): array { return $this->translator->getCatalogues(); } /** - * {@inheritdoc} - * * @return string[] */ public function warmUp(string $cacheDir): array @@ -124,9 +107,7 @@ class DataCollectorTranslator implements TranslatorInterface, TranslatorBagInter private function collectMessage(?string $locale, ?string $domain, string $id, string $translation, ?array $parameters = []) { - if (null === $domain) { - $domain = 'messages'; - } + $domain ??= 'messages'; $catalogue = $this->translator->getCatalogue($locale); $locale = $catalogue->getLocale(); diff --git a/vendor/symfony/translation/DependencyInjection/TranslatorPass.php b/vendor/symfony/translation/DependencyInjection/TranslatorPass.php index be79cda..b060171 100644 --- a/vendor/symfony/translation/DependencyInjection/TranslatorPass.php +++ b/vendor/symfony/translation/DependencyInjection/TranslatorPass.php @@ -49,6 +49,21 @@ class TranslatorPass implements CompilerPassInterface ->replaceArgument(3, $loaders) ; + if ($container->hasDefinition('validator') && $container->hasDefinition('translation.extractor.visitor.constraint')) { + $constraintVisitorDefinition = $container->getDefinition('translation.extractor.visitor.constraint'); + $constraintClassNames = []; + + foreach ($container->findTaggedServiceIds('validator.constraint_validator', true) as $id => $attributes) { + $serviceDefinition = $container->getDefinition($id); + // Resolve constraint validator FQCN even if defined as %foo.validator.class% parameter + $className = $container->getParameterBag()->resolveValue($serviceDefinition->getClass()); + // Extraction of the constraint class name from the Constraint Validator FQCN + $constraintClassNames[] = str_replace('Validator', '', substr(strrchr($className, '\\'), 1)); + } + + $constraintVisitorDefinition->setArgument(0, $constraintClassNames); + } + if (!$container->hasParameter('twig.default_path')) { return; } diff --git a/vendor/symfony/translation/Dumper/CsvFileDumper.php b/vendor/symfony/translation/Dumper/CsvFileDumper.php index 0bd3f5e..df2c2a8 100644 --- a/vendor/symfony/translation/Dumper/CsvFileDumper.php +++ b/vendor/symfony/translation/Dumper/CsvFileDumper.php @@ -23,9 +23,6 @@ class CsvFileDumper extends FileDumper private string $delimiter = ';'; private string $enclosure = '"'; - /** - * {@inheritdoc} - */ public function formatCatalogue(MessageCatalogue $messages, string $domain, array $options = []): string { $handle = fopen('php://memory', 'r+'); @@ -50,9 +47,6 @@ class CsvFileDumper extends FileDumper $this->enclosure = $enclosure; } - /** - * {@inheritdoc} - */ protected function getExtension(): string { return 'csv'; diff --git a/vendor/symfony/translation/Dumper/FileDumper.php b/vendor/symfony/translation/Dumper/FileDumper.php index 6bad4ff..b2db0f3 100644 --- a/vendor/symfony/translation/Dumper/FileDumper.php +++ b/vendor/symfony/translation/Dumper/FileDumper.php @@ -42,9 +42,6 @@ abstract class FileDumper implements DumperInterface $this->relativePathTemplate = $relativePathTemplate; } - /** - * {@inheritdoc} - */ public function dump(MessageCatalogue $messages, array $options = []) { if (!\array_key_exists('path', $options)) { diff --git a/vendor/symfony/translation/Dumper/IcuResFileDumper.php b/vendor/symfony/translation/Dumper/IcuResFileDumper.php index b62ea15..50ef82d 100644 --- a/vendor/symfony/translation/Dumper/IcuResFileDumper.php +++ b/vendor/symfony/translation/Dumper/IcuResFileDumper.php @@ -20,14 +20,8 @@ use Symfony\Component\Translation\MessageCatalogue; */ class IcuResFileDumper extends FileDumper { - /** - * {@inheritdoc} - */ protected $relativePathTemplate = '%domain%/%locale%.%extension%'; - /** - * {@inheritdoc} - */ public function formatCatalogue(MessageCatalogue $messages, string $domain, array $options = []): string { $data = $indexes = $resources = ''; @@ -47,7 +41,7 @@ class IcuResFileDumper extends FileDumper $data .= pack('V', \strlen($target)) .mb_convert_encoding($target."\0", 'UTF-16LE', 'UTF-8') .$this->writePadding($data) - ; + ; } $resOffset = $this->getPosition($data); @@ -56,7 +50,7 @@ class IcuResFileDumper extends FileDumper .$indexes .$this->writePadding($data) .$resources - ; + ; $bundleTop = $this->getPosition($data); @@ -94,9 +88,6 @@ class IcuResFileDumper extends FileDumper return (\strlen($data) + 28) / 4; } - /** - * {@inheritdoc} - */ protected function getExtension(): string { return 'res'; diff --git a/vendor/symfony/translation/Dumper/IniFileDumper.php b/vendor/symfony/translation/Dumper/IniFileDumper.php index 75032be..6cbdef6 100644 --- a/vendor/symfony/translation/Dumper/IniFileDumper.php +++ b/vendor/symfony/translation/Dumper/IniFileDumper.php @@ -20,9 +20,6 @@ use Symfony\Component\Translation\MessageCatalogue; */ class IniFileDumper extends FileDumper { - /** - * {@inheritdoc} - */ public function formatCatalogue(MessageCatalogue $messages, string $domain, array $options = []): string { $output = ''; @@ -35,9 +32,6 @@ class IniFileDumper extends FileDumper return $output; } - /** - * {@inheritdoc} - */ protected function getExtension(): string { return 'ini'; diff --git a/vendor/symfony/translation/Dumper/JsonFileDumper.php b/vendor/symfony/translation/Dumper/JsonFileDumper.php index 1102730..e503539 100644 --- a/vendor/symfony/translation/Dumper/JsonFileDumper.php +++ b/vendor/symfony/translation/Dumper/JsonFileDumper.php @@ -20,9 +20,6 @@ use Symfony\Component\Translation\MessageCatalogue; */ class JsonFileDumper extends FileDumper { - /** - * {@inheritdoc} - */ public function formatCatalogue(MessageCatalogue $messages, string $domain, array $options = []): string { $flags = $options['json_encoding'] ?? \JSON_PRETTY_PRINT; @@ -30,9 +27,6 @@ class JsonFileDumper extends FileDumper return json_encode($messages->all($domain), $flags); } - /** - * {@inheritdoc} - */ protected function getExtension(): string { return 'json'; diff --git a/vendor/symfony/translation/Dumper/MoFileDumper.php b/vendor/symfony/translation/Dumper/MoFileDumper.php index 08c8f89..9ded5f4 100644 --- a/vendor/symfony/translation/Dumper/MoFileDumper.php +++ b/vendor/symfony/translation/Dumper/MoFileDumper.php @@ -21,9 +21,6 @@ use Symfony\Component\Translation\MessageCatalogue; */ class MoFileDumper extends FileDumper { - /** - * {@inheritdoc} - */ public function formatCatalogue(MessageCatalogue $messages, string $domain, array $options = []): string { $sources = $targets = $sourceOffsets = $targetOffsets = ''; @@ -57,19 +54,16 @@ class MoFileDumper extends FileDumper .$this->writeLong($offset[2] + $sourcesStart + $sourcesSize); } - $output = implode('', array_map([$this, 'writeLong'], $header)) + $output = implode('', array_map($this->writeLong(...), $header)) .$sourceOffsets .$targetOffsets .$sources .$targets - ; + ; return $output; } - /** - * {@inheritdoc} - */ protected function getExtension(): string { return 'mo'; diff --git a/vendor/symfony/translation/Dumper/PhpFileDumper.php b/vendor/symfony/translation/Dumper/PhpFileDumper.php index 565d893..51e9066 100644 --- a/vendor/symfony/translation/Dumper/PhpFileDumper.php +++ b/vendor/symfony/translation/Dumper/PhpFileDumper.php @@ -20,17 +20,11 @@ use Symfony\Component\Translation\MessageCatalogue; */ class PhpFileDumper extends FileDumper { - /** - * {@inheritdoc} - */ public function formatCatalogue(MessageCatalogue $messages, string $domain, array $options = []): string { return "all($domain), true).";\n"; } - /** - * {@inheritdoc} - */ protected function getExtension(): string { return 'php'; diff --git a/vendor/symfony/translation/Dumper/PoFileDumper.php b/vendor/symfony/translation/Dumper/PoFileDumper.php index 313e504..c026672 100644 --- a/vendor/symfony/translation/Dumper/PoFileDumper.php +++ b/vendor/symfony/translation/Dumper/PoFileDumper.php @@ -20,9 +20,6 @@ use Symfony\Component\Translation\MessageCatalogue; */ class PoFileDumper extends FileDumper { - /** - * {@inheritdoc} - */ public function formatCatalogue(MessageCatalogue $messages, string $domain, array $options = []): string { $output = 'msgid ""'."\n"; @@ -111,9 +108,6 @@ EOF; return $standardRules; } - /** - * {@inheritdoc} - */ protected function getExtension(): string { return 'po'; diff --git a/vendor/symfony/translation/Dumper/QtFileDumper.php b/vendor/symfony/translation/Dumper/QtFileDumper.php index 819409f..0373e9c 100644 --- a/vendor/symfony/translation/Dumper/QtFileDumper.php +++ b/vendor/symfony/translation/Dumper/QtFileDumper.php @@ -20,9 +20,6 @@ use Symfony\Component\Translation\MessageCatalogue; */ class QtFileDumper extends FileDumper { - /** - * {@inheritdoc} - */ public function formatCatalogue(MessageCatalogue $messages, string $domain, array $options = []): string { $dom = new \DOMDocument('1.0', 'utf-8'); @@ -51,9 +48,6 @@ class QtFileDumper extends FileDumper return $dom->saveXML(); } - /** - * {@inheritdoc} - */ protected function getExtension(): string { return 'ts'; diff --git a/vendor/symfony/translation/Dumper/XliffFileDumper.php b/vendor/symfony/translation/Dumper/XliffFileDumper.php index b8a109a..5384719 100644 --- a/vendor/symfony/translation/Dumper/XliffFileDumper.php +++ b/vendor/symfony/translation/Dumper/XliffFileDumper.php @@ -21,9 +21,11 @@ use Symfony\Component\Translation\MessageCatalogue; */ class XliffFileDumper extends FileDumper { - /** - * {@inheritdoc} - */ + public function __construct( + private string $extension = 'xlf', + ) { + } + public function formatCatalogue(MessageCatalogue $messages, string $domain, array $options = []): string { $xliffVersion = '1.2'; @@ -47,12 +49,9 @@ class XliffFileDumper extends FileDumper throw new InvalidArgumentException(sprintf('No support implemented for dumping XLIFF version "%s".', $xliffVersion)); } - /** - * {@inheritdoc} - */ protected function getExtension(): string { - return 'xlf'; + return $this->extension; } private function dumpXliff1(string $defaultLocale, MessageCatalogue $messages, ?string $domain, array $options = []) @@ -81,6 +80,15 @@ class XliffFileDumper extends FileDumper $xliffTool->setAttribute($id, $value); } + if ($catalogueMetadata = $messages->getCatalogueMetadata('', $domain) ?? []) { + $xliffPropGroup = $xliffHead->appendChild($dom->createElement('prop-group')); + foreach ($catalogueMetadata as $key => $value) { + $xliffProp = $xliffPropGroup->appendChild($dom->createElement('prop')); + $xliffProp->setAttribute('prop-type', $key); + $xliffProp->appendChild($dom->createTextNode($value)); + } + } + $xliffBody = $xliffFile->appendChild($dom->createElement('body')); foreach ($messages->all($domain) as $source => $target) { $translation = $dom->createElement('trans-unit'); @@ -147,6 +155,16 @@ class XliffFileDumper extends FileDumper $xliffFile->setAttribute('id', $domain.'.'.$messages->getLocale()); } + if ($catalogueMetadata = $messages->getCatalogueMetadata('', $domain) ?? []) { + $xliff->setAttribute('xmlns:m', 'urn:oasis:names:tc:xliff:metadata:2.0'); + $xliffMetadata = $xliffFile->appendChild($dom->createElement('m:metadata')); + foreach ($catalogueMetadata as $key => $value) { + $xliffMeta = $xliffMetadata->appendChild($dom->createElement('prop')); + $xliffMeta->setAttribute('type', $key); + $xliffMeta->appendChild($dom->createTextNode($value)); + } + } + foreach ($messages->all($domain) as $source => $target) { $translation = $dom->createElement('unit'); $translation->setAttribute('id', strtr(substr(base64_encode(hash('sha256', $source, true)), 0, 7), '/+', '._')); diff --git a/vendor/symfony/translation/Dumper/YamlFileDumper.php b/vendor/symfony/translation/Dumper/YamlFileDumper.php index d0cfbef..d267033 100644 --- a/vendor/symfony/translation/Dumper/YamlFileDumper.php +++ b/vendor/symfony/translation/Dumper/YamlFileDumper.php @@ -30,9 +30,6 @@ class YamlFileDumper extends FileDumper $this->extension = $extension; } - /** - * {@inheritdoc} - */ public function formatCatalogue(MessageCatalogue $messages, string $domain, array $options = []): string { if (!class_exists(Yaml::class)) { @@ -52,9 +49,6 @@ class YamlFileDumper extends FileDumper return Yaml::dump($data); } - /** - * {@inheritdoc} - */ protected function getExtension(): string { return $this->extension; diff --git a/vendor/symfony/translation/Exception/ProviderException.php b/vendor/symfony/translation/Exception/ProviderException.php index 331ff75..65883f8 100644 --- a/vendor/symfony/translation/Exception/ProviderException.php +++ b/vendor/symfony/translation/Exception/ProviderException.php @@ -18,7 +18,7 @@ use Symfony\Contracts\HttpClient\ResponseInterface; */ class ProviderException extends RuntimeException implements ProviderExceptionInterface { - private $response; + private ResponseInterface $response; private string $debug; public function __construct(string $message, ResponseInterface $response, int $code = 0, \Exception $previous = null) diff --git a/vendor/symfony/translation/Extractor/ChainExtractor.php b/vendor/symfony/translation/Extractor/ChainExtractor.php index e58e82f..0d2132f 100644 --- a/vendor/symfony/translation/Extractor/ChainExtractor.php +++ b/vendor/symfony/translation/Extractor/ChainExtractor.php @@ -35,9 +35,6 @@ class ChainExtractor implements ExtractorInterface $this->extractors[$format] = $extractor; } - /** - * {@inheritdoc} - */ public function setPrefix(string $prefix) { foreach ($this->extractors as $extractor) { @@ -45,9 +42,6 @@ class ChainExtractor implements ExtractorInterface } } - /** - * {@inheritdoc} - */ public function extract(string|iterable $directory, MessageCatalogue $catalogue) { foreach ($this->extractors as $extractor) { diff --git a/vendor/symfony/translation/Extractor/PhpAstExtractor.php b/vendor/symfony/translation/Extractor/PhpAstExtractor.php new file mode 100644 index 0000000..d0bbf0e --- /dev/null +++ b/vendor/symfony/translation/Extractor/PhpAstExtractor.php @@ -0,0 +1,78 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Translation\Extractor; + +use PhpParser\NodeTraverser; +use PhpParser\NodeVisitor; +use PhpParser\Parser; +use PhpParser\ParserFactory; +use Symfony\Component\Finder\Finder; +use Symfony\Component\Translation\Extractor\Visitor\AbstractVisitor; +use Symfony\Component\Translation\MessageCatalogue; + +/** + * PhpAstExtractor extracts translation messages from a PHP AST. + * + * @author Mathieu Santostefano + */ +final class PhpAstExtractor extends AbstractFileExtractor implements ExtractorInterface +{ + private Parser $parser; + + public function __construct( + /** + * @param iterable $visitors + */ + private readonly iterable $visitors, + private string $prefix = '', + ) { + if (!class_exists(ParserFactory::class)) { + throw new \LogicException(sprintf('You cannot use "%s" as the "nikic/php-parser" package is not installed. Try running "composer require nikic/php-parser".', static::class)); + } + + $this->parser = (new ParserFactory())->create(ParserFactory::PREFER_PHP7); + } + + public function extract(iterable|string $resource, MessageCatalogue $catalogue): void + { + foreach ($this->extractFiles($resource) as $file) { + $traverser = new NodeTraverser(); + /** @var AbstractVisitor&NodeVisitor $visitor */ + foreach ($this->visitors as $visitor) { + $visitor->initialize($catalogue, $file, $this->prefix); + $traverser->addVisitor($visitor); + } + + $nodes = $this->parser->parse(file_get_contents($file)); + $traverser->traverse($nodes); + } + } + + public function setPrefix(string $prefix): void + { + $this->prefix = $prefix; + } + + protected function canBeExtracted(string $file): bool + { + return 'php' === pathinfo($file, \PATHINFO_EXTENSION) && $this->isFile($file); + } + + protected function extractFromDirectory(array|string $resource): iterable|Finder + { + if (!class_exists(Finder::class)) { + throw new \LogicException(sprintf('You cannot use "%s" as the "symfony/finder" package is not installed. Try running "composer require symfony/finder".', static::class)); + } + + return (new Finder())->files()->name('*.php')->in($resource); + } +} diff --git a/vendor/symfony/translation/Extractor/PhpExtractor.php b/vendor/symfony/translation/Extractor/PhpExtractor.php index 1b86cc5..329d619 100644 --- a/vendor/symfony/translation/Extractor/PhpExtractor.php +++ b/vendor/symfony/translation/Extractor/PhpExtractor.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Translation\Extractor; +trigger_deprecation('symfony/translation', '6.2', '"%s" is deprecated, use "%s" instead.', PhpExtractor::class, PhpAstExtractor::class); + use Symfony\Component\Finder\Finder; use Symfony\Component\Translation\MessageCatalogue; @@ -18,6 +20,8 @@ use Symfony\Component\Translation\MessageCatalogue; * PhpExtractor extracts translation messages from a PHP template. * * @author Michel Salib + * + * @deprecated since Symfony 6.2, use the PhpAstExtractor instead */ class PhpExtractor extends AbstractFileExtractor implements ExtractorInterface { @@ -128,9 +132,6 @@ class PhpExtractor extends AbstractFileExtractor implements ExtractorInterface ], ]; - /** - * {@inheritdoc} - */ public function extract(string|iterable $resource, MessageCatalogue $catalog) { $files = $this->extractFiles($resource); @@ -141,9 +142,6 @@ class PhpExtractor extends AbstractFileExtractor implements ExtractorInterface } } - /** - * {@inheritdoc} - */ public function setPrefix(string $prefix) { $this->prefix = $prefix; @@ -314,9 +312,6 @@ class PhpExtractor extends AbstractFileExtractor implements ExtractorInterface return $this->isFile($file) && 'php' === pathinfo($file, \PATHINFO_EXTENSION); } - /** - * {@inheritdoc} - */ protected function extractFromDirectory(string|array $directory): iterable { if (!class_exists(Finder::class)) { diff --git a/vendor/symfony/translation/Extractor/PhpStringTokenParser.php b/vendor/symfony/translation/Extractor/PhpStringTokenParser.php index 7fbd37c..3b854ce 100644 --- a/vendor/symfony/translation/Extractor/PhpStringTokenParser.php +++ b/vendor/symfony/translation/Extractor/PhpStringTokenParser.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Translation\Extractor; +trigger_deprecation('symfony/translation', '6.2', '"%s" is deprecated.', PhpStringTokenParser::class); + /* * The following is derived from code at http://github.com/nikic/PHP-Parser * @@ -47,6 +49,9 @@ namespace Symfony\Component\Translation\Extractor; * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +/** + * @deprecated since Symfony 6.2 + */ class PhpStringTokenParser { protected static $replacements = [ diff --git a/vendor/symfony/translation/Extractor/Visitor/AbstractVisitor.php b/vendor/symfony/translation/Extractor/Visitor/AbstractVisitor.php new file mode 100644 index 0000000..c341056 --- /dev/null +++ b/vendor/symfony/translation/Extractor/Visitor/AbstractVisitor.php @@ -0,0 +1,124 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Translation\Extractor\Visitor; + +use PhpParser\Node; +use Symfony\Component\Translation\MessageCatalogue; + +/** + * @author Mathieu Santostefano + */ +abstract class AbstractVisitor +{ + private MessageCatalogue $catalogue; + private \SplFileInfo $file; + private string $messagePrefix; + + public function initialize(MessageCatalogue $catalogue, \SplFileInfo $file, string $messagePrefix): void + { + $this->catalogue = $catalogue; + $this->file = $file; + $this->messagePrefix = $messagePrefix; + } + + protected function addMessageToCatalogue(string $message, ?string $domain, int $line): void + { + $domain ??= 'messages'; + $this->catalogue->set($message, $this->messagePrefix.$message, $domain); + $metadata = $this->catalogue->getMetadata($message, $domain) ?? []; + $normalizedFilename = preg_replace('{[\\\\/]+}', '/', $this->file); + $metadata['sources'][] = $normalizedFilename.':'.$line; + $this->catalogue->setMetadata($message, $metadata, $domain); + } + + protected function getStringArguments(Node\Expr\CallLike|Node\Attribute|Node\Expr\New_ $node, int|string $index, bool $indexIsRegex = false): array + { + if (\is_string($index)) { + return $this->getStringNamedArguments($node, $index, $indexIsRegex); + } + + $args = $node instanceof Node\Expr\CallLike ? $node->getRawArgs() : $node->args; + + if (!($arg = $args[$index] ?? null) instanceof Node\Arg) { + return []; + } + + return (array) $this->getStringValue($arg->value); + } + + protected function hasNodeNamedArguments(Node\Expr\CallLike|Node\Attribute|Node\Expr\New_ $node): bool + { + $args = $node instanceof Node\Expr\CallLike ? $node->getRawArgs() : $node->args; + + foreach ($args as $arg) { + if ($arg instanceof Node\Arg && null !== $arg->name) { + return true; + } + } + + return false; + } + + protected function nodeFirstNamedArgumentIndex(Node\Expr\CallLike|Node\Attribute|Node\Expr\New_ $node): int + { + $args = $node instanceof Node\Expr\CallLike ? $node->getRawArgs() : $node->args; + + foreach ($args as $i => $arg) { + if ($arg instanceof Node\Arg && null !== $arg->name) { + return $i; + } + } + + return \PHP_INT_MAX; + } + + private function getStringNamedArguments(Node\Expr\CallLike|Node\Attribute $node, string $argumentName = null, bool $isArgumentNamePattern = false): array + { + $args = $node instanceof Node\Expr\CallLike ? $node->getArgs() : $node->args; + $argumentValues = []; + + foreach ($args as $arg) { + if (!$isArgumentNamePattern && $arg->name?->toString() === $argumentName) { + $argumentValues[] = $this->getStringValue($arg->value); + } elseif ($isArgumentNamePattern && preg_match($argumentName, $arg->name?->toString() ?? '') > 0) { + $argumentValues[] = $this->getStringValue($arg->value); + } + } + + return array_filter($argumentValues); + } + + private function getStringValue(Node $node): ?string + { + if ($node instanceof Node\Scalar\String_) { + return $node->value; + } + + if ($node instanceof Node\Expr\BinaryOp\Concat) { + if (null === $left = $this->getStringValue($node->left)) { + return null; + } + + if (null === $right = $this->getStringValue($node->right)) { + return null; + } + + return $left.$right; + } + + if ($node instanceof Node\Expr\Assign && $node->expr instanceof Node\Scalar\String_) { + return $node->expr->value; + } + + return null; + } +} diff --git a/vendor/symfony/translation/Extractor/Visitor/ConstraintVisitor.php b/vendor/symfony/translation/Extractor/Visitor/ConstraintVisitor.php new file mode 100644 index 0000000..3c64584 --- /dev/null +++ b/vendor/symfony/translation/Extractor/Visitor/ConstraintVisitor.php @@ -0,0 +1,114 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Translation\Extractor\Visitor; + +use PhpParser\Node; +use PhpParser\NodeVisitor; + +/** + * @author Mathieu Santostefano + * + * Code mostly comes from https://github.com/php-translation/extractor/blob/master/src/Visitor/Php/Symfony/Constraint.php + */ +final class ConstraintVisitor extends AbstractVisitor implements NodeVisitor +{ + private const CONSTRAINT_VALIDATION_MESSAGE_PATTERN = '/[a-zA-Z]*message/i'; + + public function __construct( + private readonly array $constraintClassNames = [] + ) { + } + + public function beforeTraverse(array $nodes): ?Node + { + return null; + } + + public function enterNode(Node $node): ?Node + { + if (!$node instanceof Node\Expr\New_ && !$node instanceof Node\Attribute) { + return null; + } + + $className = $node instanceof Node\Attribute ? $node->name : $node->class; + if (!$className instanceof Node\Name) { + return null; + } + + $parts = $className->parts; + $isConstraintClass = false; + + foreach ($parts as $part) { + if (\in_array($part, $this->constraintClassNames, true)) { + $isConstraintClass = true; + + break; + } + } + + if (!$isConstraintClass) { + return null; + } + + $arg = $node->args[0] ?? null; + if (!$arg instanceof Node\Arg) { + return null; + } + + if ($this->hasNodeNamedArguments($node)) { + $messages = $this->getStringArguments($node, self::CONSTRAINT_VALIDATION_MESSAGE_PATTERN, true); + } else { + if (!$arg->value instanceof Node\Expr\Array_) { + // There is no way to guess which argument is a message to be translated. + return null; + } + + $messages = []; + $options = $arg->value; + + /** @var Node\Expr\ArrayItem $item */ + foreach ($options->items as $item) { + if (!$item->key instanceof Node\Scalar\String_) { + continue; + } + + if (!preg_match(self::CONSTRAINT_VALIDATION_MESSAGE_PATTERN, $item->key->value ?? '')) { + continue; + } + + if (!$item->value instanceof Node\Scalar\String_) { + continue; + } + + $messages[] = $item->value->value; + + break; + } + } + + foreach ($messages as $message) { + $this->addMessageToCatalogue($message, 'validators', $node->getStartLine()); + } + + return null; + } + + public function leaveNode(Node $node): ?Node + { + return null; + } + + public function afterTraverse(array $nodes): ?Node + { + return null; + } +} diff --git a/vendor/symfony/translation/Extractor/Visitor/TransMethodVisitor.php b/vendor/symfony/translation/Extractor/Visitor/TransMethodVisitor.php new file mode 100644 index 0000000..0b537ba --- /dev/null +++ b/vendor/symfony/translation/Extractor/Visitor/TransMethodVisitor.php @@ -0,0 +1,65 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Translation\Extractor\Visitor; + +use PhpParser\Node; +use PhpParser\NodeVisitor; + +/** + * @author Mathieu Santostefano + */ +final class TransMethodVisitor extends AbstractVisitor implements NodeVisitor +{ + public function beforeTraverse(array $nodes): ?Node + { + return null; + } + + public function enterNode(Node $node): ?Node + { + if (!$node instanceof Node\Expr\MethodCall && !$node instanceof Node\Expr\FuncCall) { + return null; + } + + if (!\is_string($node->name) && !$node->name instanceof Node\Identifier && !$node->name instanceof Node\Name) { + return null; + } + + $name = (string) $node->name; + + if ('trans' === $name || 't' === $name) { + $firstNamedArgumentIndex = $this->nodeFirstNamedArgumentIndex($node); + + if (!$messages = $this->getStringArguments($node, 0 < $firstNamedArgumentIndex ? 0 : 'message')) { + return null; + } + + $domain = $this->getStringArguments($node, 2 < $firstNamedArgumentIndex ? 2 : 'domain')[0] ?? null; + + foreach ($messages as $message) { + $this->addMessageToCatalogue($message, $domain, $node->getStartLine()); + } + } + + return null; + } + + public function leaveNode(Node $node): ?Node + { + return null; + } + + public function afterTraverse(array $nodes): ?Node + { + return null; + } +} diff --git a/vendor/symfony/translation/Extractor/Visitor/TranslatableMessageVisitor.php b/vendor/symfony/translation/Extractor/Visitor/TranslatableMessageVisitor.php new file mode 100644 index 0000000..c1505a1 --- /dev/null +++ b/vendor/symfony/translation/Extractor/Visitor/TranslatableMessageVisitor.php @@ -0,0 +1,65 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Translation\Extractor\Visitor; + +use PhpParser\Node; +use PhpParser\NodeVisitor; + +/** + * @author Mathieu Santostefano + */ +final class TranslatableMessageVisitor extends AbstractVisitor implements NodeVisitor +{ + public function beforeTraverse(array $nodes): ?Node + { + return null; + } + + public function enterNode(Node $node): ?Node + { + if (!$node instanceof Node\Expr\New_) { + return null; + } + + if (!($className = $node->class) instanceof Node\Name) { + return null; + } + + if (!\in_array('TranslatableMessage', $className->parts, true)) { + return null; + } + + $firstNamedArgumentIndex = $this->nodeFirstNamedArgumentIndex($node); + + if (!$messages = $this->getStringArguments($node, 0 < $firstNamedArgumentIndex ? 0 : 'message')) { + return null; + } + + $domain = $this->getStringArguments($node, 2 < $firstNamedArgumentIndex ? 2 : 'domain')[0] ?? null; + + foreach ($messages as $message) { + $this->addMessageToCatalogue($message, $domain, $node->getStartLine()); + } + + return null; + } + + public function leaveNode(Node $node): ?Node + { + return null; + } + + public function afterTraverse(array $nodes): ?Node + { + return null; + } +} diff --git a/vendor/symfony/translation/Formatter/IntlFormatter.php b/vendor/symfony/translation/Formatter/IntlFormatter.php index f7f1c36..30873cc 100644 --- a/vendor/symfony/translation/Formatter/IntlFormatter.php +++ b/vendor/symfony/translation/Formatter/IntlFormatter.php @@ -23,9 +23,6 @@ class IntlFormatter implements IntlFormatterInterface private $hasMessageFormatter; private $cache = []; - /** - * {@inheritdoc} - */ public function formatIntl(string $message, string $locale, array $parameters = []): string { // MessageFormatter constructor throws an exception if the message is empty @@ -34,7 +31,7 @@ class IntlFormatter implements IntlFormatterInterface } if (!$formatter = $this->cache[$locale][$message] ?? null) { - if (!($this->hasMessageFormatter ?? $this->hasMessageFormatter = class_exists(\MessageFormatter::class))) { + if (!$this->hasMessageFormatter ??= class_exists(\MessageFormatter::class)) { throw new LogicException('Cannot parse message translation: please install the "intl" PHP extension or the "symfony/polyfill-intl-messageformatter" package.'); } try { diff --git a/vendor/symfony/translation/Formatter/MessageFormatter.php b/vendor/symfony/translation/Formatter/MessageFormatter.php index 68821b1..29ad574 100644 --- a/vendor/symfony/translation/Formatter/MessageFormatter.php +++ b/vendor/symfony/translation/Formatter/MessageFormatter.php @@ -22,8 +22,8 @@ class_exists(IntlFormatter::class); */ class MessageFormatter implements MessageFormatterInterface, IntlFormatterInterface { - private $translator; - private $intlFormatter; + private TranslatorInterface $translator; + private IntlFormatterInterface $intlFormatter; /** * @param TranslatorInterface|null $translator An identity translator to use as selector for pluralization @@ -34,9 +34,6 @@ class MessageFormatter implements MessageFormatterInterface, IntlFormatterInterf $this->intlFormatter = $intlFormatter ?? new IntlFormatter(); } - /** - * {@inheritdoc} - */ public function format(string $message, string $locale, array $parameters = []): string { if ($this->translator instanceof TranslatorInterface) { @@ -46,9 +43,6 @@ class MessageFormatter implements MessageFormatterInterface, IntlFormatterInterf return strtr($message, $parameters); } - /** - * {@inheritdoc} - */ public function formatIntl(string $message, string $locale, array $parameters = []): string { return $this->intlFormatter->formatIntl($message, $locale, $parameters); diff --git a/vendor/symfony/translation/LICENSE b/vendor/symfony/translation/LICENSE index 88bf75b..0083704 100644 --- a/vendor/symfony/translation/LICENSE +++ b/vendor/symfony/translation/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2022 Fabien Potencier +Copyright (c) 2004-2023 Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/vendor/symfony/translation/Loader/ArrayLoader.php b/vendor/symfony/translation/Loader/ArrayLoader.php index 35de9ef..e240493 100644 --- a/vendor/symfony/translation/Loader/ArrayLoader.php +++ b/vendor/symfony/translation/Loader/ArrayLoader.php @@ -20,9 +20,6 @@ use Symfony\Component\Translation\MessageCatalogue; */ class ArrayLoader implements LoaderInterface { - /** - * {@inheritdoc} - */ public function load(mixed $resource, string $locale, string $domain = 'messages'): MessageCatalogue { $resource = $this->flatten($resource); diff --git a/vendor/symfony/translation/Loader/CsvFileLoader.php b/vendor/symfony/translation/Loader/CsvFileLoader.php index 76b00b1..7620b72 100644 --- a/vendor/symfony/translation/Loader/CsvFileLoader.php +++ b/vendor/symfony/translation/Loader/CsvFileLoader.php @@ -24,9 +24,6 @@ class CsvFileLoader extends FileLoader private string $enclosure = '"'; private string $escape = '\\'; - /** - * {@inheritdoc} - */ protected function loadResource(string $resource): array { $messages = []; @@ -45,7 +42,7 @@ class CsvFileLoader extends FileLoader continue; } - if ('#' !== substr($data[0], 0, 1) && isset($data[1]) && 2 === \count($data)) { + if (!str_starts_with($data[0], '#') && isset($data[1]) && 2 === \count($data)) { $messages[$data[0]] = $data[1]; } } diff --git a/vendor/symfony/translation/Loader/FileLoader.php b/vendor/symfony/translation/Loader/FileLoader.php index e170d76..877c3bb 100644 --- a/vendor/symfony/translation/Loader/FileLoader.php +++ b/vendor/symfony/translation/Loader/FileLoader.php @@ -21,9 +21,6 @@ use Symfony\Component\Translation\MessageCatalogue; */ abstract class FileLoader extends ArrayLoader { - /** - * {@inheritdoc} - */ public function load(mixed $resource, string $locale, string $domain = 'messages'): MessageCatalogue { if (!stream_is_local($resource)) { @@ -37,9 +34,7 @@ abstract class FileLoader extends ArrayLoader $messages = $this->loadResource($resource); // empty resource - if (null === $messages) { - $messages = []; - } + $messages ??= []; // not an array if (!\is_array($messages)) { diff --git a/vendor/symfony/translation/Loader/IcuDatFileLoader.php b/vendor/symfony/translation/Loader/IcuDatFileLoader.php index c3ca5fd..76e4e7f 100644 --- a/vendor/symfony/translation/Loader/IcuDatFileLoader.php +++ b/vendor/symfony/translation/Loader/IcuDatFileLoader.php @@ -23,9 +23,6 @@ use Symfony\Component\Translation\MessageCatalogue; */ class IcuDatFileLoader extends IcuResFileLoader { - /** - * {@inheritdoc} - */ public function load(mixed $resource, string $locale, string $domain = 'messages'): MessageCatalogue { if (!stream_is_local($resource.'.dat')) { @@ -38,7 +35,7 @@ class IcuDatFileLoader extends IcuResFileLoader try { $rb = new \ResourceBundle($locale, $resource); - } catch (\Exception $e) { + } catch (\Exception) { $rb = null; } diff --git a/vendor/symfony/translation/Loader/IcuResFileLoader.php b/vendor/symfony/translation/Loader/IcuResFileLoader.php index 54c48f8..a5fa4fb 100644 --- a/vendor/symfony/translation/Loader/IcuResFileLoader.php +++ b/vendor/symfony/translation/Loader/IcuResFileLoader.php @@ -23,9 +23,6 @@ use Symfony\Component\Translation\MessageCatalogue; */ class IcuResFileLoader implements LoaderInterface { - /** - * {@inheritdoc} - */ public function load(mixed $resource, string $locale, string $domain = 'messages'): MessageCatalogue { if (!stream_is_local($resource)) { @@ -38,7 +35,7 @@ class IcuResFileLoader implements LoaderInterface try { $rb = new \ResourceBundle($locale, $resource); - } catch (\Exception $e) { + } catch (\Exception) { $rb = null; } diff --git a/vendor/symfony/translation/Loader/IniFileLoader.php b/vendor/symfony/translation/Loader/IniFileLoader.php index 04e294d..3126896 100644 --- a/vendor/symfony/translation/Loader/IniFileLoader.php +++ b/vendor/symfony/translation/Loader/IniFileLoader.php @@ -18,9 +18,6 @@ namespace Symfony\Component\Translation\Loader; */ class IniFileLoader extends FileLoader { - /** - * {@inheritdoc} - */ protected function loadResource(string $resource): array { return parse_ini_file($resource, true); diff --git a/vendor/symfony/translation/Loader/JsonFileLoader.php b/vendor/symfony/translation/Loader/JsonFileLoader.php index 67a8d58..385553e 100644 --- a/vendor/symfony/translation/Loader/JsonFileLoader.php +++ b/vendor/symfony/translation/Loader/JsonFileLoader.php @@ -20,9 +20,6 @@ use Symfony\Component\Translation\Exception\InvalidResourceException; */ class JsonFileLoader extends FileLoader { - /** - * {@inheritdoc} - */ protected function loadResource(string $resource): array { $messages = []; @@ -42,19 +39,13 @@ class JsonFileLoader extends FileLoader */ private function getJSONErrorMessage(int $errorCode): string { - switch ($errorCode) { - case \JSON_ERROR_DEPTH: - return 'Maximum stack depth exceeded'; - case \JSON_ERROR_STATE_MISMATCH: - return 'Underflow or the modes mismatch'; - case \JSON_ERROR_CTRL_CHAR: - return 'Unexpected control character found'; - case \JSON_ERROR_SYNTAX: - return 'Syntax error, malformed JSON'; - case \JSON_ERROR_UTF8: - return 'Malformed UTF-8 characters, possibly incorrectly encoded'; - default: - return 'Unknown error'; - } + return match ($errorCode) { + \JSON_ERROR_DEPTH => 'Maximum stack depth exceeded', + \JSON_ERROR_STATE_MISMATCH => 'Underflow or the modes mismatch', + \JSON_ERROR_CTRL_CHAR => 'Unexpected control character found', + \JSON_ERROR_SYNTAX => 'Syntax error, malformed JSON', + \JSON_ERROR_UTF8 => 'Malformed UTF-8 characters, possibly incorrectly encoded', + default => 'Unknown error', + }; } } diff --git a/vendor/symfony/translation/Loader/MoFileLoader.php b/vendor/symfony/translation/Loader/MoFileLoader.php index b0c8913..8427c39 100644 --- a/vendor/symfony/translation/Loader/MoFileLoader.php +++ b/vendor/symfony/translation/Loader/MoFileLoader.php @@ -38,8 +38,6 @@ class MoFileLoader extends FileLoader /** * Parses machine object (MO) format, independent of the machine's endian it * was created on. Both 32bit and 64bit systems are supported. - * - * {@inheritdoc} */ protected function loadResource(string $resource): array { diff --git a/vendor/symfony/translation/Loader/PhpFileLoader.php b/vendor/symfony/translation/Loader/PhpFileLoader.php index 6bc2a05..93f23cd 100644 --- a/vendor/symfony/translation/Loader/PhpFileLoader.php +++ b/vendor/symfony/translation/Loader/PhpFileLoader.php @@ -20,12 +20,9 @@ class PhpFileLoader extends FileLoader { private static ?array $cache = []; - /** - * {@inheritdoc} - */ protected function loadResource(string $resource): array { - if ([] === self::$cache && \function_exists('opcache_invalidate') && filter_var(ini_get('opcache.enable'), \FILTER_VALIDATE_BOOLEAN) && (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) || filter_var(ini_get('opcache.enable_cli'), \FILTER_VALIDATE_BOOLEAN))) { + if ([] === self::$cache && \function_exists('opcache_invalidate') && filter_var(\ini_get('opcache.enable'), \FILTER_VALIDATE_BOOL) && (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) || filter_var(\ini_get('opcache.enable_cli'), \FILTER_VALIDATE_BOOL))) { self::$cache = null; } @@ -33,10 +30,6 @@ class PhpFileLoader extends FileLoader return require $resource; } - if (isset(self::$cache[$resource])) { - return self::$cache[$resource]; - } - - return self::$cache[$resource] = require $resource; + return self::$cache[$resource] ??= require $resource; } } diff --git a/vendor/symfony/translation/Loader/PoFileLoader.php b/vendor/symfony/translation/Loader/PoFileLoader.php index 6df1614..9f7f125 100644 --- a/vendor/symfony/translation/Loader/PoFileLoader.php +++ b/vendor/symfony/translation/Loader/PoFileLoader.php @@ -57,8 +57,6 @@ class PoFileLoader extends FileLoader * - Message IDs are allowed to have other encodings as just US-ASCII. * * Items with an empty id are ignored. - * - * {@inheritdoc} */ protected function loadResource(string $resource): array { @@ -83,15 +81,15 @@ class PoFileLoader extends FileLoader } $item = $defaults; $flags = []; - } elseif ('#,' === substr($line, 0, 2)) { + } elseif (str_starts_with($line, '#,')) { $flags = array_map('trim', explode(',', substr($line, 2))); - } elseif ('msgid "' === substr($line, 0, 7)) { + } elseif (str_starts_with($line, 'msgid "')) { // We start a new msg so save previous // TODO: this fails when comments or contexts are added $this->addMessage($messages, $item); $item = $defaults; $item['ids']['singular'] = substr($line, 7, -1); - } elseif ('msgstr "' === substr($line, 0, 8)) { + } elseif (str_starts_with($line, 'msgstr "')) { $item['translated'] = substr($line, 8, -1); } elseif ('"' === $line[0]) { $continues = isset($item['translated']) ? 'translated' : 'ids'; @@ -102,9 +100,9 @@ class PoFileLoader extends FileLoader } else { $item[$continues] .= substr($line, 1, -1); } - } elseif ('msgid_plural "' === substr($line, 0, 14)) { + } elseif (str_starts_with($line, 'msgid_plural "')) { $item['ids']['plural'] = substr($line, 14, -1); - } elseif ('msgstr[' === substr($line, 0, 7)) { + } elseif (str_starts_with($line, 'msgstr[')) { $size = strpos($line, ']'); $item['translated'][(int) substr($line, 7, 1)] = substr($line, $size + 3, -1); } diff --git a/vendor/symfony/translation/Loader/QtFileLoader.php b/vendor/symfony/translation/Loader/QtFileLoader.php index 6d5582d..d91e0a1 100644 --- a/vendor/symfony/translation/Loader/QtFileLoader.php +++ b/vendor/symfony/translation/Loader/QtFileLoader.php @@ -25,9 +25,6 @@ use Symfony\Component\Translation\MessageCatalogue; */ class QtFileLoader implements LoaderInterface { - /** - * {@inheritdoc} - */ public function load(mixed $resource, string $locale, string $domain = 'messages'): MessageCatalogue { if (!class_exists(XmlUtils::class)) { diff --git a/vendor/symfony/translation/Loader/XliffFileLoader.php b/vendor/symfony/translation/Loader/XliffFileLoader.php index 670e199..0ce3af5 100644 --- a/vendor/symfony/translation/Loader/XliffFileLoader.php +++ b/vendor/symfony/translation/Loader/XliffFileLoader.php @@ -28,9 +28,6 @@ use Symfony\Component\Translation\Util\XliffUtils; */ class XliffFileLoader implements LoaderInterface { - /** - * {@inheritdoc} - */ public function load(mixed $resource, string $locale, string $domain = 'messages'): MessageCatalogue { if (!class_exists(XmlUtils::class)) { @@ -104,6 +101,10 @@ class XliffFileLoader implements LoaderInterface $file->registerXPathNamespace('xliff', $namespace); + foreach ($file->xpath('.//xliff:prop') as $prop) { + $catalogue->setCatalogueMetadata($prop->attributes()['prop-type'], (string) $prop, $domain); + } + foreach ($file->xpath('.//xliff:trans-unit') as $translation) { $attributes = $translation->attributes(); @@ -227,6 +228,6 @@ class XliffFileLoader implements LoaderInterface private function isXmlString(string $resource): bool { - return 0 === strpos($resource, 'yamlParser) { diff --git a/vendor/symfony/translation/LocaleSwitcher.php b/vendor/symfony/translation/LocaleSwitcher.php new file mode 100644 index 0000000..0fc56e3 --- /dev/null +++ b/vendor/symfony/translation/LocaleSwitcher.php @@ -0,0 +1,75 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Translation; + +use Symfony\Component\Routing\RequestContext; +use Symfony\Contracts\Translation\LocaleAwareInterface; + +/** + * @author Kevin Bond + */ +class LocaleSwitcher implements LocaleAwareInterface +{ + private string $defaultLocale; + + /** + * @param LocaleAwareInterface[] $localeAwareServices + */ + public function __construct( + private string $locale, + private iterable $localeAwareServices, + private ?RequestContext $requestContext = null, + ) { + $this->defaultLocale = $locale; + } + + public function setLocale(string $locale): void + { + \Locale::setDefault($this->locale = $locale); + $this->requestContext?->setParameter('_locale', $locale); + + foreach ($this->localeAwareServices as $service) { + $service->setLocale($locale); + } + } + + public function getLocale(): string + { + return $this->locale; + } + + /** + * Switch to a new locale, execute a callback, then switch back to the original. + * + * @template T + * + * @param callable():T $callback + * + * @return T + */ + public function runWithLocale(string $locale, callable $callback): mixed + { + $original = $this->getLocale(); + $this->setLocale($locale); + + try { + return $callback(); + } finally { + $this->setLocale($original); + } + } + + public function reset(): void + { + $this->setLocale($this->defaultLocale); + } +} diff --git a/vendor/symfony/translation/LoggingTranslator.php b/vendor/symfony/translation/LoggingTranslator.php index 8c8441c..8a81e1f 100644 --- a/vendor/symfony/translation/LoggingTranslator.php +++ b/vendor/symfony/translation/LoggingTranslator.php @@ -21,8 +21,8 @@ use Symfony\Contracts\Translation\TranslatorInterface; */ class LoggingTranslator implements TranslatorInterface, TranslatorBagInterface, LocaleAwareInterface { - private $translator; - private $logger; + private TranslatorInterface $translator; + private LoggerInterface $logger; /** * @param TranslatorInterface&TranslatorBagInterface&LocaleAwareInterface $translator The translator must implement TranslatorBagInterface @@ -37,9 +37,6 @@ class LoggingTranslator implements TranslatorInterface, TranslatorBagInterface, $this->logger = $logger; } - /** - * {@inheritdoc} - */ public function trans(?string $id, array $parameters = [], string $domain = null, string $locale = null): string { $trans = $this->translator->trans($id = (string) $id, $parameters, $domain, $locale); @@ -48,9 +45,6 @@ class LoggingTranslator implements TranslatorInterface, TranslatorBagInterface, return $trans; } - /** - * {@inheritdoc} - */ public function setLocale(string $locale) { $prev = $this->translator->getLocale(); @@ -62,25 +56,16 @@ class LoggingTranslator implements TranslatorInterface, TranslatorBagInterface, $this->logger->debug(sprintf('The locale of the translator has changed from "%s" to "%s".', $prev, $locale)); } - /** - * {@inheritdoc} - */ public function getLocale(): string { return $this->translator->getLocale(); } - /** - * {@inheritdoc} - */ public function getCatalogue(string $locale = null): MessageCatalogueInterface { return $this->translator->getCatalogue($locale); } - /** - * {@inheritdoc} - */ public function getCatalogues(): array { return $this->translator->getCatalogues(); @@ -111,9 +96,7 @@ class LoggingTranslator implements TranslatorInterface, TranslatorBagInterface, */ private function log(string $id, ?string $domain, ?string $locale) { - if (null === $domain) { - $domain = 'messages'; - } + $domain ??= 'messages'; $catalogue = $this->translator->getCatalogue($locale); if ($catalogue->defines($id, $domain)) { diff --git a/vendor/symfony/translation/MessageCatalogue.php b/vendor/symfony/translation/MessageCatalogue.php index 7aa27ef..605f281 100644 --- a/vendor/symfony/translation/MessageCatalogue.php +++ b/vendor/symfony/translation/MessageCatalogue.php @@ -17,13 +17,14 @@ use Symfony\Component\Translation\Exception\LogicException; /** * @author Fabien Potencier */ -class MessageCatalogue implements MessageCatalogueInterface, MetadataAwareInterface +class MessageCatalogue implements MessageCatalogueInterface, MetadataAwareInterface, CatalogueMetadataAwareInterface { private array $messages = []; private array $metadata = []; + private array $catalogueMetadata = []; private array $resources = []; private string $locale; - private $fallbackCatalogue = null; + private ?MessageCatalogueInterface $fallbackCatalogue = null; private ?self $parent = null; /** @@ -35,17 +36,11 @@ class MessageCatalogue implements MessageCatalogueInterface, MetadataAwareInterf $this->messages = $messages; } - /** - * {@inheritdoc} - */ public function getLocale(): string { return $this->locale; } - /** - * {@inheritdoc} - */ public function getDomains(): array { $domains = []; @@ -60,9 +55,6 @@ class MessageCatalogue implements MessageCatalogueInterface, MetadataAwareInterf return array_values($domains); } - /** - * {@inheritdoc} - */ public function all(string $domain = null): array { if (null !== $domain) { @@ -88,17 +80,11 @@ class MessageCatalogue implements MessageCatalogueInterface, MetadataAwareInterf return $allMessages; } - /** - * {@inheritdoc} - */ public function set(string $id, string $translation, string $domain = 'messages') { $this->add([$id => $translation], $domain); } - /** - * {@inheritdoc} - */ public function has(string $id, string $domain = 'messages'): bool { if (isset($this->messages[$domain][$id]) || isset($this->messages[$domain.self::INTL_DOMAIN_SUFFIX][$id])) { @@ -112,17 +98,11 @@ class MessageCatalogue implements MessageCatalogueInterface, MetadataAwareInterf return false; } - /** - * {@inheritdoc} - */ public function defines(string $id, string $domain = 'messages'): bool { return isset($this->messages[$domain][$id]) || isset($this->messages[$domain.self::INTL_DOMAIN_SUFFIX][$id]); } - /** - * {@inheritdoc} - */ public function get(string $id, string $domain = 'messages'): string { if (isset($this->messages[$domain.self::INTL_DOMAIN_SUFFIX][$id])) { @@ -140,9 +120,6 @@ class MessageCatalogue implements MessageCatalogueInterface, MetadataAwareInterf return $id; } - /** - * {@inheritdoc} - */ public function replace(array $messages, string $domain = 'messages') { unset($this->messages[$domain], $this->messages[$domain.self::INTL_DOMAIN_SUFFIX]); @@ -150,30 +127,19 @@ class MessageCatalogue implements MessageCatalogueInterface, MetadataAwareInterf $this->add($messages, $domain); } - /** - * {@inheritdoc} - */ public function add(array $messages, string $domain = 'messages') { - if (!isset($this->messages[$domain])) { - $this->messages[$domain] = []; - } - $intlDomain = $domain; - if (!str_ends_with($domain, self::INTL_DOMAIN_SUFFIX)) { - $intlDomain .= self::INTL_DOMAIN_SUFFIX; - } + $altDomain = str_ends_with($domain, self::INTL_DOMAIN_SUFFIX) ? substr($domain, 0, -\strlen(self::INTL_DOMAIN_SUFFIX)) : $domain.self::INTL_DOMAIN_SUFFIX; foreach ($messages as $id => $message) { - if (isset($this->messages[$intlDomain]) && \array_key_exists($id, $this->messages[$intlDomain])) { - $this->messages[$intlDomain][$id] = $message; - } else { - $this->messages[$domain][$id] = $message; - } + unset($this->messages[$altDomain][$id]); + $this->messages[$domain][$id] = $message; + } + + if ([] === ($this->messages[$altDomain] ?? null)) { + unset($this->messages[$altDomain]); } } - /** - * {@inheritdoc} - */ public function addCatalogue(MessageCatalogueInterface $catalogue) { if ($catalogue->getLocale() !== $this->locale) { @@ -196,11 +162,13 @@ class MessageCatalogue implements MessageCatalogueInterface, MetadataAwareInterf $metadata = $catalogue->getMetadata('', ''); $this->addMetadata($metadata); } + + if ($catalogue instanceof CatalogueMetadataAwareInterface) { + $catalogueMetadata = $catalogue->getCatalogueMetadata('', ''); + $this->addCatalogueMetadata($catalogueMetadata); + } } - /** - * {@inheritdoc} - */ public function addFallbackCatalogue(MessageCatalogueInterface $catalogue) { // detect circular references @@ -230,33 +198,21 @@ class MessageCatalogue implements MessageCatalogueInterface, MetadataAwareInterf } } - /** - * {@inheritdoc} - */ public function getFallbackCatalogue(): ?MessageCatalogueInterface { return $this->fallbackCatalogue; } - /** - * {@inheritdoc} - */ public function getResources(): array { return array_values($this->resources); } - /** - * {@inheritdoc} - */ public function addResource(ResourceInterface $resource) { $this->resources[$resource->__toString()] = $resource; } - /** - * {@inheritdoc} - */ public function getMetadata(string $key = '', string $domain = 'messages'): mixed { if ('' == $domain) { @@ -276,17 +232,11 @@ class MessageCatalogue implements MessageCatalogueInterface, MetadataAwareInterf return null; } - /** - * {@inheritdoc} - */ public function setMetadata(string $key, mixed $value, string $domain = 'messages') { $this->metadata[$domain][$key] = $value; } - /** - * {@inheritdoc} - */ public function deleteMetadata(string $key = '', string $domain = 'messages') { if ('' == $domain) { @@ -298,6 +248,41 @@ class MessageCatalogue implements MessageCatalogueInterface, MetadataAwareInterf } } + public function getCatalogueMetadata(string $key = '', string $domain = 'messages'): mixed + { + if (!$domain) { + return $this->catalogueMetadata; + } + + if (isset($this->catalogueMetadata[$domain])) { + if (!$key) { + return $this->catalogueMetadata[$domain]; + } + + if (isset($this->catalogueMetadata[$domain][$key])) { + return $this->catalogueMetadata[$domain][$key]; + } + } + + return null; + } + + public function setCatalogueMetadata(string $key, mixed $value, string $domain = 'messages') + { + $this->catalogueMetadata[$domain][$key] = $value; + } + + public function deleteCatalogueMetadata(string $key = '', string $domain = 'messages') + { + if (!$domain) { + $this->catalogueMetadata = []; + } elseif (!$key) { + unset($this->catalogueMetadata[$domain]); + } else { + unset($this->catalogueMetadata[$domain][$key]); + } + } + /** * Adds current values with the new values. * @@ -311,4 +296,13 @@ class MessageCatalogue implements MessageCatalogueInterface, MetadataAwareInterf } } } + + private function addCatalogueMetadata(array $values) + { + foreach ($values as $domain => $keys) { + foreach ($keys as $key => $value) { + $this->setCatalogueMetadata($key, $value, $domain); + } + } + } } diff --git a/vendor/symfony/translation/MetadataAwareInterface.php b/vendor/symfony/translation/MetadataAwareInterface.php index 2eaaceb..5753b81 100644 --- a/vendor/symfony/translation/MetadataAwareInterface.php +++ b/vendor/symfony/translation/MetadataAwareInterface.php @@ -12,7 +12,7 @@ namespace Symfony\Component\Translation; /** - * MetadataAwareInterface. + * This interface is used to get, set, and delete metadata about the translation messages. * * @author Fabien Potencier */ diff --git a/vendor/symfony/translation/Provider/FilteringProvider.php b/vendor/symfony/translation/Provider/FilteringProvider.php index a43fedc..d4465b9 100644 --- a/vendor/symfony/translation/Provider/FilteringProvider.php +++ b/vendor/symfony/translation/Provider/FilteringProvider.php @@ -21,7 +21,7 @@ use Symfony\Component\Translation\TranslatorBagInterface; */ class FilteringProvider implements ProviderInterface { - private $provider; + private ProviderInterface $provider; private array $locales; private array $domains; @@ -37,9 +37,6 @@ class FilteringProvider implements ProviderInterface return (string) $this->provider; } - /** - * {@inheritdoc} - */ public function write(TranslatorBagInterface $translatorBag): void { $this->provider->write($translatorBag); diff --git a/vendor/symfony/translation/PseudoLocalizationTranslator.php b/vendor/symfony/translation/PseudoLocalizationTranslator.php index 848dc1d..0207e99 100644 --- a/vendor/symfony/translation/PseudoLocalizationTranslator.php +++ b/vendor/symfony/translation/PseudoLocalizationTranslator.php @@ -20,7 +20,7 @@ final class PseudoLocalizationTranslator implements TranslatorInterface { private const EXPANSION_CHARACTER = '~'; - private $translator; + private TranslatorInterface $translator; private bool $accents; private float $expansionFactor; private bool $brackets; @@ -83,9 +83,6 @@ final class PseudoLocalizationTranslator implements TranslatorInterface $this->localizableHTMLAttributes = $options['localizable_html_attributes'] ?? []; } - /** - * {@inheritdoc} - */ public function trans(string $id, array $parameters = [], string $domain = null, string $locale = null): string { $trans = ''; @@ -283,7 +280,7 @@ final class PseudoLocalizationTranslator implements TranslatorInterface } $visibleLength = $this->strlen($visibleText); - $missingLength = (int) (ceil($visibleLength * $this->expansionFactor)) - $visibleLength; + $missingLength = (int) ceil($visibleLength * $this->expansionFactor) - $visibleLength; if ($this->brackets) { $missingLength -= 2; } diff --git a/vendor/symfony/translation/README.md b/vendor/symfony/translation/README.md index adda9a5..4fedd6a 100644 --- a/vendor/symfony/translation/README.md +++ b/vendor/symfony/translation/README.md @@ -26,12 +26,11 @@ echo $translator->trans('Hello World!'); // outputs « Bonjour ! » Sponsor ------- -The Translation component for Symfony 5.4/6.0 is [backed][1] by: +The Translation component for Symfony 6.1 is [backed][1] by: * [Crowdin][2], a cloud-based localization management software helping teams to go global and stay agile. - * [Lokalise][3], a continuous localization and translation management platform that integrates into your development workflow so you can ship localized products, faster. -Help Symfony by [sponsoring][4] its development! +Help Symfony by [sponsoring][3] its development! Resources --------- @@ -44,5 +43,4 @@ Resources [1]: https://symfony.com/backers [2]: https://crowdin.com -[3]: https://lokalise.com -[4]: https://symfony.com/sponsor +[3]: https://symfony.com/sponsor diff --git a/vendor/symfony/translation/Reader/TranslationReader.php b/vendor/symfony/translation/Reader/TranslationReader.php index bbc687e..fd2ee66 100644 --- a/vendor/symfony/translation/Reader/TranslationReader.php +++ b/vendor/symfony/translation/Reader/TranslationReader.php @@ -39,9 +39,6 @@ class TranslationReader implements TranslationReaderInterface $this->loaders[$format] = $loader; } - /** - * {@inheritdoc} - */ public function read(string $directory, MessageCatalogue $catalogue) { if (!is_dir($directory)) { diff --git a/vendor/symfony/translation/Resources/bin/translation-status.php b/vendor/symfony/translation/Resources/bin/translation-status.php index a769164..4fe814c 100644 --- a/vendor/symfony/translation/Resources/bin/translation-status.php +++ b/vendor/symfony/translation/Resources/bin/translation-status.php @@ -9,6 +9,10 @@ * file that was distributed with this source code. */ +if ('cli' !== \PHP_SAPI) { + throw new Exception('This script must be run from the command line.'); +} + $usageInstructions = << - - + - + @@ -1672,14 +1672,16 @@ Jan-10-2006 + + - + @@ -1739,10 +1741,11 @@ Jan-10-2006 + - + @@ -1791,6 +1794,7 @@ Jan-10-2006 + @@ -1838,16 +1842,34 @@ Jan-10-2006 + + + + + + + + + + + + + + + + + + - + - + @@ -1865,8 +1887,9 @@ Jan-10-2006 + - + @@ -1877,6 +1900,7 @@ Jan-10-2006 + @@ -1901,7 +1925,7 @@ Jan-10-2006 - + @@ -1913,10 +1937,11 @@ Jan-10-2006 + - + @@ -1924,6 +1949,7 @@ Jan-10-2006 + @@ -1947,7 +1973,7 @@ Jan-10-2006 - + @@ -1962,7 +1988,8 @@ Jan-10-2006 - + + @@ -1985,7 +2012,8 @@ Jan-10-2006 - + + @@ -2011,6 +2039,8 @@ Jan-10-2006 + + @@ -2018,7 +2048,7 @@ Jan-10-2006 - + @@ -2042,18 +2072,21 @@ Jan-10-2006 - + + - + + + @@ -2070,7 +2103,7 @@ Jan-10-2006 - + @@ -2089,20 +2122,22 @@ Jan-10-2006 + - + + - + @@ -2111,7 +2146,8 @@ Jan-10-2006 - + + @@ -2121,12 +2157,13 @@ Jan-10-2006 + - + @@ -2217,7 +2254,8 @@ Jan-10-2006 - + + diff --git a/vendor/symfony/translation/Test/ProviderFactoryTestCase.php b/vendor/symfony/translation/Test/ProviderFactoryTestCase.php index d6510e0..d1259c7 100644 --- a/vendor/symfony/translation/Test/ProviderFactoryTestCase.php +++ b/vendor/symfony/translation/Test/ProviderFactoryTestCase.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Translation\Test; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Psr\Log\LoggerInterface; use Symfony\Component\HttpClient\MockHttpClient; @@ -20,6 +21,7 @@ use Symfony\Component\Translation\Exception\UnsupportedSchemeException; use Symfony\Component\Translation\Loader\LoaderInterface; use Symfony\Component\Translation\Provider\Dsn; use Symfony\Component\Translation\Provider\ProviderFactoryInterface; +use Symfony\Component\Translation\TranslatorBagInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; /** @@ -31,11 +33,12 @@ use Symfony\Contracts\HttpClient\HttpClientInterface; */ abstract class ProviderFactoryTestCase extends TestCase { - protected $client; - protected $logger; + protected HttpClientInterface $client; + protected LoggerInterface|MockObject $logger; protected string $defaultLocale; - protected $loader; - protected $xliffFileDumper; + protected LoaderInterface|MockObject $loader; + protected XliffFileDumper|MockObject $xliffFileDumper; + protected TranslatorBagInterface|MockObject $translatorBag; abstract public function createFactory(): ProviderFactoryInterface; @@ -144,4 +147,9 @@ abstract class ProviderFactoryTestCase extends TestCase { return $this->xliffFileDumper ??= $this->createMock(XliffFileDumper::class); } + + protected function getTranslatorBag(): TranslatorBagInterface + { + return $this->translatorBag ??= $this->createMock(TranslatorBagInterface::class); + } } diff --git a/vendor/symfony/translation/Test/ProviderTestCase.php b/vendor/symfony/translation/Test/ProviderTestCase.php index 5ae2682..6de24ac 100644 --- a/vendor/symfony/translation/Test/ProviderTestCase.php +++ b/vendor/symfony/translation/Test/ProviderTestCase.php @@ -11,12 +11,14 @@ namespace Symfony\Component\Translation\Test; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Psr\Log\LoggerInterface; use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\Translation\Dumper\XliffFileDumper; use Symfony\Component\Translation\Loader\LoaderInterface; use Symfony\Component\Translation\Provider\ProviderInterface; +use Symfony\Component\Translation\TranslatorBagInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; /** @@ -28,11 +30,12 @@ use Symfony\Contracts\HttpClient\HttpClientInterface; */ abstract class ProviderTestCase extends TestCase { - protected $client; - protected $logger; + protected HttpClientInterface $client; + protected LoggerInterface|MockObject $logger; protected string $defaultLocale; - protected $loader; - protected $xliffFileDumper; + protected LoaderInterface|MockObject $loader; + protected XliffFileDumper|MockObject $xliffFileDumper; + protected TranslatorBagInterface|MockObject $translatorBag; abstract public function createProvider(HttpClientInterface $client, LoaderInterface $loader, LoggerInterface $logger, string $defaultLocale, string $endpoint): ProviderInterface; @@ -73,4 +76,9 @@ abstract class ProviderTestCase extends TestCase { return $this->xliffFileDumper ??= $this->createMock(XliffFileDumper::class); } + + protected function getTranslatorBag(): TranslatorBagInterface + { + return $this->translatorBag ??= $this->createMock(TranslatorBagInterface::class); + } } diff --git a/vendor/symfony/translation/Translator.php b/vendor/symfony/translation/Translator.php index 05e84d0..a9344dd 100644 --- a/vendor/symfony/translation/Translator.php +++ b/vendor/symfony/translation/Translator.php @@ -22,6 +22,7 @@ use Symfony\Component\Translation\Formatter\MessageFormatter; use Symfony\Component\Translation\Formatter\MessageFormatterInterface; use Symfony\Component\Translation\Loader\LoaderInterface; use Symfony\Contracts\Translation\LocaleAwareInterface; +use Symfony\Contracts\Translation\TranslatableInterface; use Symfony\Contracts\Translation\TranslatorInterface; // Help opcache.preload discover always-needed symbols @@ -51,7 +52,7 @@ class Translator implements TranslatorInterface, TranslatorBagInterface, LocaleA private array $resources = []; - private $formatter; + private MessageFormatterInterface $formatter; private ?string $cacheDir; @@ -59,7 +60,7 @@ class Translator implements TranslatorInterface, TranslatorBagInterface, LocaleA private array $cacheVary; - private $configCacheFactory; + private ?ConfigCacheFactoryInterface $configCacheFactory; private array $parentLocales; @@ -72,11 +73,7 @@ class Translator implements TranslatorInterface, TranslatorBagInterface, LocaleA { $this->setLocale($locale); - if (null === $formatter) { - $formatter = new MessageFormatter(); - } - - $this->formatter = $formatter; + $this->formatter = $formatter ??= new MessageFormatter(); $this->cacheDir = $cacheDir; $this->debug = $debug; $this->cacheVary = $cacheVary; @@ -108,9 +105,7 @@ class Translator implements TranslatorInterface, TranslatorBagInterface, LocaleA */ public function addResource(string $format, mixed $resource, string $locale, string $domain = null) { - if (null === $domain) { - $domain = 'messages'; - } + $domain ??= 'messages'; $this->assertValidLocale($locale); $locale ?: $locale = class_exists(\Locale::class) ? \Locale::getDefault() : 'en'; @@ -124,18 +119,12 @@ class Translator implements TranslatorInterface, TranslatorBagInterface, LocaleA } } - /** - * {@inheritdoc} - */ public function setLocale(string $locale) { $this->assertValidLocale($locale); $this->locale = $locale; } - /** - * {@inheritdoc} - */ public function getLocale(): string { return $this->locale ?: (class_exists(\Locale::class) ? \Locale::getDefault() : 'en'); @@ -170,18 +159,13 @@ class Translator implements TranslatorInterface, TranslatorBagInterface, LocaleA return $this->fallbackLocales; } - /** - * {@inheritdoc} - */ public function trans(?string $id, array $parameters = [], string $domain = null, string $locale = null): string { if (null === $id || '' === $id) { return ''; } - if (null === $domain) { - $domain = 'messages'; - } + $domain ??= 'messages'; $catalogue = $this->getCatalogue($locale); $locale = $catalogue->getLocale(); @@ -194,6 +178,10 @@ class Translator implements TranslatorInterface, TranslatorBagInterface, LocaleA } } + $parameters = array_map(function ($parameter) use ($locale) { + return $parameter instanceof TranslatableInterface ? $parameter->trans($this, $locale) : $parameter; + }, $parameters); + $len = \strlen(MessageCatalogue::INTL_DOMAIN_SUFFIX); if ($this->hasIntlFormatter && ($catalogue->defines($id, $domain.MessageCatalogue::INTL_DOMAIN_SUFFIX) @@ -205,9 +193,6 @@ class Translator implements TranslatorInterface, TranslatorBagInterface, LocaleA return $this->formatter->format($catalogue->get($id, $domain), $locale, $parameters); } - /** - * {@inheritdoc} - */ public function getCatalogue(string $locale = null): MessageCatalogueInterface { if (!$locale) { @@ -223,9 +208,6 @@ class Translator implements TranslatorInterface, TranslatorBagInterface, LocaleA return $this->catalogues[$locale]; } - /** - * {@inheritdoc} - */ public function getCatalogues(): array { return array_values($this->catalogues); diff --git a/vendor/symfony/translation/TranslatorBag.php b/vendor/symfony/translation/TranslatorBag.php index ffd109f..fb8ede8 100644 --- a/vendor/symfony/translation/TranslatorBag.php +++ b/vendor/symfony/translation/TranslatorBag.php @@ -35,9 +35,6 @@ final class TranslatorBag implements TranslatorBagInterface } } - /** - * {@inheritdoc} - */ public function getCatalogue(string $locale = null): MessageCatalogueInterface { if (null === $locale || !isset($this->catalogues[$locale])) { @@ -47,9 +44,6 @@ final class TranslatorBag implements TranslatorBagInterface return $this->catalogues[$locale]; } - /** - * {@inheritdoc} - */ public function getCatalogues(): array { return array_values($this->catalogues); @@ -94,7 +88,10 @@ final class TranslatorBag implements TranslatorBagInterface $obsoleteCatalogue = new MessageCatalogue($locale); foreach ($operation->getDomains() as $domain) { - $obsoleteCatalogue->add($operation->getObsoleteMessages($domain), $domain); + $obsoleteCatalogue->add( + array_diff($operation->getMessages($domain), $operation->getNewMessages($domain)), + $domain + ); } $diff->addCatalogue($obsoleteCatalogue); diff --git a/vendor/symfony/translation/Util/XliffUtils.php b/vendor/symfony/translation/Util/XliffUtils.php index 85ecc85..335c34b 100644 --- a/vendor/symfony/translation/Util/XliffUtils.php +++ b/vendor/symfony/translation/Util/XliffUtils.php @@ -129,7 +129,7 @@ class XliffUtils private static function getSchema(string $xliffVersion): string { if ('1.2' === $xliffVersion) { - $schemaSource = file_get_contents(__DIR__.'/../Resources/schemas/xliff-core-1.2-strict.xsd'); + $schemaSource = file_get_contents(__DIR__.'/../Resources/schemas/xliff-core-1.2-transitional.xsd'); $xmlUri = 'http://www.w3.org/2001/xml.xsd'; } elseif ('2.0' === $xliffVersion) { $schemaSource = file_get_contents(__DIR__.'/../Resources/schemas/xliff-core-2.0.xsd'); diff --git a/vendor/symfony/translation/composer.json b/vendor/symfony/translation/composer.json index abe8b97..d75df65 100644 --- a/vendor/symfony/translation/composer.json +++ b/vendor/symfony/translation/composer.json @@ -16,11 +16,12 @@ } ], "require": { - "php": ">=8.0.2", + "php": ">=8.1", "symfony/polyfill-mbstring": "~1.0", "symfony/translation-contracts": "^2.3|^3.0" }, "require-dev": { + "nikic/php-parser": "^4.13", "symfony/config": "^5.4|^6.0", "symfony/console": "^5.4|^6.0", "symfony/dependency-injection": "^5.4|^6.0", @@ -28,6 +29,7 @@ "symfony/http-kernel": "^5.4|^6.0", "symfony/intl": "^5.4|^6.0", "symfony/polyfill-intl-icu": "^1.21", + "symfony/routing": "^5.4|^6.0", "symfony/service-contracts": "^1.1.2|^2|^3", "symfony/yaml": "^5.4|^6.0", "symfony/finder": "^5.4|^6.0", @@ -45,6 +47,7 @@ "symfony/translation-implementation": "2.3|3.0" }, "suggest": { + "nikic/php-parser": "To use PhpAstExtractor", "symfony/config": "", "symfony/yaml": "", "psr/log-implementation": "To use logging capability in translator"