Skip to content

Move test files to tests dir - #173

Merged
php-pulls merged 1 commit into
php:PHP-5.3from
reeze:fix-tests-dir
Aug 21, 2012
Merged

php-pulls merged 1 commit into
php:PHP-5.3from
reeze:fix-tests-dir

Conversation

@reeze

@reeze reeze commented Aug 21, 2012

Copy link
Copy Markdown
Contributor

These test files are not in ext/intl/tests but ext/intl this moves these file to the right place.

There are 7 files duplicated, so these files was deleted but not moved.

There are 7 files duplicated, so those files was deleted
@travisbot

Copy link
Copy Markdown

This pull request fails (merged 0cdc1f5 into b9a0501).

@laruence

Copy link
Copy Markdown
Member

@ab please be careful about this, thanks :)

@php-pulls
php-pulls merged commit 0cdc1f5 into php:PHP-5.3 Aug 21, 2012
heyJordanParker added a commit to heyJordanParker/php-sharp that referenced this pull request Oct 13, 2026
…and every help's fix compiles

Problem

php#173's first review found five gaps.

1. `empty is bool`, `default is int` and `flag ? print(1) : 0` failed to
   parse. `read_php_construct` read any expression start after a PHP-only word
   as PHP's construct.
2. A class named `Print`, `Match`, `Return` or `Event` was refused. The lexer
   matched PHP# keywords case-insensitively, so `new Match()` was a parse error,
   and semantics refused PHP's reserved words as class names.
3. A member named `is`, `match` or `default` was refused, though a member name
   is only written after `.` or where it is declared.
4. `sealed` and `foreign` were missing from `SHARP_KEYWORDS`.
5. Four helps quoted a fix that did not compile. The `Inherits` help left out
   imports, types and defaults. `new Self.of()` in a subclass named the
   subclass. `if (x);` suggested `{ ; }`. `declare(strict_types=1);` got two
   errors that named PHP. A reserved catch or pattern variable got no keyword
   message, a file-level `unset(x)` fired twice, and a lone `;` at file level
   compiled.

Solution

PHP# keywords are case-sensitive, as C#'s are. The lexer keeps a keyword
token only for its exact spelling, and only a lowercase PHP word reads as
PHP's construct. `Self` stays the one capitalized keyword.

A PHP-only word reads as its construct only where the construct can follow:
an operand that is not a PHP# infix word, or parentheses followed by `{`,
`=>` or `=`. Parentheses followed by `:` or a name read as a construct only
after `fn`, `function`, and `foreach`, `switch` or `elseif` at a statement's
start. Anywhere else they are a call.

A class takes any capitalized word except the type names the engine refuses.
A member takes any word. Locals, parameters, catch variables and pattern
variables keep the keyword refusal.

The `Inherits` help writes each parameter's type, the literal defaults it can
write, and the imports the types need. It writes `[:]` for an empty map
default. `new Self.of()` in a class that inherits `of` names the declaring
class. `declare(…)` gets one PHP# error. A lone `;` at file level is refused,
and file-level `unset` and `isset` fire once.

crates/
├── syntax/src/
│   ├── token/mod.rs                        sealed, foreign; is_sharp_keyword, exact spelling
│   ├── lexer/mod.rs                        keeps a keyword token through is_sharp_keyword
│   └── parser/
│       ├── stream.rs                       peek_after_parentheses returns the token
│       └── internal/
│           ├── common.rs                   read_php_keyword: the construct only where it follows
│           ├── expression.rs               infix operators through php_keyword
│           ├── statement.rs, control_flow/if.rs   read_php_statement
│           ├── function_like/arrow_function.rs     peek_after_parentheses
│           ├── variable.rs, try.rs, pattern.rs     a reserved catch or pattern variable parses
│           └── class_like/property.rs              any word names a field
├── semantics/src/internal/
│   ├── mod.rs                              events and declare in PHP#
│   └── checker/
│       ├── sharp.rs                        class names, declare, file-level code, `{ }`, new Self.of in its own class
│       ├── statement.rs                    no strict_types position error in PHP#
│       └── class_like/{mod,inheritance}.rs PHP's reserved words only in .php
├── analyzer/src/
│   ├── statement/class_like/method.rs      the Inherits help: types, defaults, imports
│   └── expression/instantiation.rs         new Self.of in a subclass names the declaring class
├── syntax/tests/sharp.rs                   every PHP-only word in each position
├── semantics/tests/sharp.rs                file-level kinds, declare, `{ }`, reserved catch and pattern, class names
├── analyzer/tests/sharp.rs                 the Inherits fix and new Self.sized fix compile
└── sharp-bridge/tests/lower.rs             all 43 PHP-only words; any word names a member; Print and Return name classes
heyJordanParker added a commit to heyJordanParker/php-sharp that referenced this pull request Oct 13, 2026
fix: PHP#'s rulings on braces, keyword names, constructors and file-level code
heyJordanParker added a commit to heyJordanParker/php-sharp that referenced this pull request Oct 13, 2026
…s and structs keep apart

Problem: php#170 added `MetadataFlags::EVENT` at `1 << 48`, the bit this branch's `STRUCT` held, so after a plain
merge every struct read as an event and every event as a struct, with no conflict to say so. This branch also writes
a struct's `init` property at its read visibility, public, which php#170's interface check reads as settable, so a class
that gives an interface's `set` property with `init` stopped being refused.

Solution: keep master's `EVENT` at `1 << 48`, move `STRUCT` to `1 << 49` and `REQUIRED` to `1 << 50`, so every flag
holds its own bit. A struct emitted is refused as no event, and `==` on an event is refused as on any class, so each
row fails if the two flags ever share a bit again. php#170's interface check treats an `init` property as set only while
its object is created. The other conflicts keep both sides: master's `emit`, `on`, miscased keywords and its
`list`/`function` local rule, beside the struct parser, which runs before a miscased type keyword is read, as an event
does.

crates/
├── codex/src/metadata/flags.rs               EVENT 1<<48 (master), STRUCT 1<<49, REQUIRED 1<<50
├── codex/src/scanner/function_like.rs        both sides' imports
├── analyzer/src/statement/mod.rs             master's imports, minus TObject this branch no longer uses
├── analyzer/src/statement/class_like/mod.rs  report_unfit_interface_property: an `init` property is not settable
├── analyzer/tests/sharp.rs                   emit_takes_an_event: `emit spot;` row
│                                             a_struct_compares_by_value: `==` on two `Moved` events row
├── hir/src/lower/error/mod.rs                both parse errors
└── syntax/src/
    ├── error.rs                              StructHeaderTypeInSharp beside MiscasedKeywordInSharp
    ├── cst/node.rs, walker/mod.rs            both sides' imports
    └── parser/internal/
        ├── statement.rs                      struct arm, master's emit arm and local-declaration kinds
        ├── class_like/mod.rs                 is_at_struct before read_php_type_declaration
        └── class_like/method.rs              refuse_required beside parse_optional_on
heyJordanParker added a commit to heyJordanParker/php-sharp that referenced this pull request Oct 13, 2026
Problem: after the merge with php#170 and php#173, nightly CI's `a_property_default_of_100_000_terms_is_inferred_on_a_small_stack`
overflowed its 128 KiB thread. The parser grows the stack only at a guard, when less than the 100 KiB red zone is
left, and the frames from `parse_statement`'s guard to `parse_expression_with_precedence`'s, through a class and its
property, came to about 93 KiB in an unoptimized macOS build, with `parse_statement_inner` alone at 48 KiB. Master's
`emit` arm and this branch's struct arms each passed alone; together, on CI's larger frames, the chain passed the
space the first guard leaves. With a 80 KiB red zone on a 90 KiB thread, the same test overflows locally.

Solution: `parse_classlike_member` runs through `ensure_sufficient_stack`, as `parse_statement` does. A member is a
recursive entry point, since its body holds statements and an anonymous class's members, so the chain splits in two,
about 57 and 38 KiB. The 80 KiB red zone test passes with it. Parsing is unchanged.

crates/syntax/src/parser/internal/class_like/
└── member.rs   parse_classlike_member guards parse_classlike_member_inner, the member's former body
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants